File size: 2,273 Bytes
d790e98 |
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 |
---
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
1. A Hugging Face account.
2. Git installed on your machine.
## Step 1: Create a New Space
1. Go to [huggingface.co/spaces](https://huggingface.co/spaces).
2. Click **"Create new Space"**.
3. **Name**: `samsung-prism-prototype` (or similar).
4. **License**: MIT (optional).
5. **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**.
6. 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
1. Initialize git if you haven't already:
```bash
git init
```
2. Add the Hugging Face remote (replace `YOUR_USERNAME` and `SPACE_NAME`):
```bash
git remote add space https://huggingface.co/spaces/YOUR_USERNAME/SPACE_NAME
```
3. Pull the initial files (like README.md) from the Space:
```bash
git pull space main --allow-unrelated-histories
```
## Step 4: Push Changes
Whenever you make changes locally, run these commands to update the Space:
```bash
# 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
```
|