gemma / HUGGINGFACE_DEPLOYMENT.md
w1r4
initial
42e7ec7

A newer version of the Gradio SDK is available: 5.35.0

Upgrade

Deploying to Hugging Face Spaces

This guide will help you deploy your Gemma-2 Multimodal Chat application to Hugging Face Spaces.

Prerequisites

  1. A Hugging Face account
  2. A Hugging Face API token with write access
  3. Git installed on your machine

Deployment Options

You have two options for deploying to Hugging Face Spaces:

Option 1: Using the Provided Script (Recommended)

We've created a helper script that automates the deployment process:

  1. Run the script:

    python push_to_huggingface.py
    
  2. Follow the prompts to enter your:

    • Hugging Face username
    • Space name (or accept the default "gemma-chat")
    • Hugging Face API token
    • Email address (for git configuration)
    • Commit message
  3. The script will:

    • Create a new Space if it doesn't exist
    • Initialize git if needed
    • Configure git credentials
    • Add and commit your files
    • Push to Hugging Face Spaces
  4. Once complete, your application will be available at: https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME

Option 2: Manual Deployment

If you prefer to deploy manually:

  1. Create a new Space on Hugging Face Spaces

    • Choose "Gradio" as the SDK
    • Set a name for your Space
  2. Initialize git in your project directory (if not already done):

    git init
    
  3. Configure git:

    git config --local user.name "YOUR_USERNAME"
    git config --local user.email "YOUR_EMAIL"
    
  4. Add Hugging Face as a remote:

    git remote add space https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
    
  5. Add, commit, and push your files:

    git add .
    git commit -m "Initial commit"
    git push --force space main
    

Configuration Files

The following files are used for Hugging Face Spaces configuration:

  • README.space.md: The README displayed on your Space's page
  • app_config.yaml: Configuration for your Space (model, hardware, etc.)
  • .gitignore: Prevents unnecessary files from being uploaded

Troubleshooting

  • Authentication Issues: Make sure your token has write access
  • Push Errors: Check if your Space already exists and you have the correct URL
  • Deployment Failures: Check the Spaces logs for error messages

Resources