File size: 2,520 Bytes
42e7ec7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# 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](https://huggingface.co/join)
2. A [Hugging Face API token](https://huggingface.co/settings/tokens) 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:
   ```bash
   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](https://huggingface.co/spaces)
   - Choose "Gradio" as the SDK
   - Set a name for your Space

2. Initialize git in your project directory (if not already done):
   ```bash
   git init
   ```

3. Configure git:
   ```bash
   git config --local user.name "YOUR_USERNAME"
   git config --local user.email "YOUR_EMAIL"
   ```

4. Add Hugging Face as a remote:
   ```bash
   git remote add space https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
   ```

5. Add, commit, and push your files:
   ```bash
   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

- [Hugging Face Spaces Documentation](https://huggingface.co/docs/hub/spaces)
- [Gradio Documentation](https://www.gradio.app/docs/)