|
# 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/) |