# Deployment Guide: Hugging Face Spaces This guide will help you deploy your **Prism** application to Hugging Face Spaces using Docker. ## Prerequisites 1. A [Hugging Face account](https://huggingface.co/join). 2. Git installed on your computer. ## Step 1: Create a New Space 1. Go to [huggingface.co/new-space](https://huggingface.co/new-space). 2. **Space Name**: Enter a name (e.g., `prism-classifier`). 3. **License**: Choose a license (e.g., MIT) or leave blank. 4. **SDK**: Select **Docker**. 5. **Space Hardware**: Select **CPU Basic (Free)** (or upgrade if you need more power for AI models). 6. **Visibility**: Public or Private. 7. Click **Create Space**. ## Step 2: Setup Git for Deployment You need to link your local project to the Hugging Face Space. 1. Open your terminal in the project root (`d:\My Stuff\Coding Projects\Prism`). 2. Initialize Git (if not already done): ```bash git init ``` 3. Add the Hugging Face remote (replace `YOUR_USERNAME` and `SPACE_NAME`): ```bash git remote add space https://huggingface.co/spaces/YOUR_USERNAME/SPACE_NAME ``` ## Step 3: Prepare Files (Already Done!) I have already configured the necessary files for you: * **`Dockerfile`**: Builds the React frontend and sets up the Python backend. * **`app.py`**: Configured to run on port 7860 (required by HF Spaces). * **`requirements.txt`**: Lists all Python dependencies. ## Step 4: Deploy To deploy, simply commit your changes and push to the `space` remote. 1. **Add files**: ```bash git add . ``` 2. **Commit**: ```bash git commit -m "Initial deploy to Hugging Face" ``` 3. **Push**: ```bash git push space master:main ``` *(Note: HF Spaces usually use `main` branch. If your local branch is `master`, use `master:main`. If local is `main`, just `git push space main`)*. > **IMPORTANT: Authentication** > When asked for your **Username**, enter your Hugging Face username. > When asked for your **Password**, you MUST enter an **Access Token**, not your account password. > > **How to get a Token:** > 1. Go to [huggingface.co/settings/tokens](https://huggingface.co/settings/tokens). > 2. Click **Create new token**. > 3. Type: **Write**. Name: "Deploy". > 4. Copy the token (starts with `hf_...`). > 5. Paste this token when the terminal asks for your password. > > **Troubleshooting: "Updates were rejected"** > If you see an error saying "Updates were rejected", it means your Space already has a `README.md` that you don't have locally. > For the **first push only**, you can force overwrite it: > ```bash > git push --force space master:main > ``` > > **Troubleshooting: "File larger than 10MB"** > If you see an error about `static/background.mp3` being too large, you need **Git LFS**: > ```bash > git lfs install > git lfs track "static/background.mp3" > git add .gitattributes > git commit --amend --no-edit > git push --force space master:main > ``` ## Step 5: Future Updates To reflect future changes on the live site: 1. Make your changes in the code. 2. Run: ```bash git add . git commit -m "Update description" git push space master:main ``` The Space will automatically rebuild and update! ## Troubleshooting * **Build Failures**: Check the "Logs" tab in your Hugging Face Space to see why the build failed. * **Large Files**: If you have large model files (>10MB), you might need to use `git lfs`. However, your models seem to be downloaded at runtime, so this shouldn't be an issue.