description: Deploy to Hugging Face Spaces
Deploying to Hugging Face Spaces
This guide explains how to deploy the Samsung Prism Prototype to a Hugging Face Space and keep it synced with your local changes.
Prerequisites
- A Hugging Face account.
- Git installed on your machine.
Step 1: Create a New Space
- Go to huggingface.co/spaces.
- Click "Create new Space".
- Name:
samsung-prism-prototype(or similar). - License: MIT (optional).
- SDK: Select Docker (Recommended for custom dependencies like OpenCV/EasyOCR) or Gradio (if you were using Gradio, but we are using Flask, so Docker is best).
- Note: Since we are using Flask, Docker is the most flexible option. Select Docker -> Blank.
- Click "Create Space".
Step 2: Prepare Your Project for Docker
Ensure you have a Dockerfile in the root of your project.
(I will verify/create this for you in the next steps).
Step 3: Connect Local Repo to Hugging Face
- Initialize git if you haven't already:
git init - Add the Hugging Face remote (replace
YOUR_USERNAMEandSPACE_NAME):git remote add space https://huggingface.co/spaces/YOUR_USERNAME/SPACE_NAME - Pull the initial files (like README.md) from the Space:
git pull space main --allow-unrelated-histories
Step 4: Push Changes
Whenever you make changes locally, run these commands to update the Space:
# Add all changes
git add .
# Commit changes
git commit -m "Update prototype"
# Push to Hugging Face
git push space main
Step 5: Handling Large Files (Models)
IMPORTANT: Hugging Face Spaces have a hard limit on file sizes for Git (LFS).
Since your Models/ directory is large, you should NOT push it to Git directly if the files are huge.
Instead, rely on the model_handler.py logic to download models from the Hugging Face Hub at runtime, or use git lfs if you must upload custom weights.
Since we updated model_handler.py to download from HF Hub if local files are missing, you can simply exclude the Models/ directory from git.
Create/Update .gitignore:
Models/
__pycache__/
.venv/
.env