makeitfr commited on
Commit
b42de2f
Β·
verified Β·
1 Parent(s): 3f3908a

Upload HF_SPACES_DEPLOYMENT.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. HF_SPACES_DEPLOYMENT.md +123 -0
HF_SPACES_DEPLOYMENT.md ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Deploy to Hugging Face Spaces
2
+
3
+ ## Why Your Current Deploy is Stuck
4
+
5
+ Common causes:
6
+ 1. ❌ **No proper app entry point** - HF Spaces doesn't know what to run
7
+ 2. ❌ **Model loading timeout** - Takes >60s to initialize models
8
+ 3. ❌ **Wrong port** - Must use port 7860
9
+ 4. ❌ **Heavy dependencies** - Build fails with missing packages
10
+ 5. ❌ **Stuck on first model download** - PaddleOCR/YOLO loading hangs
11
+
12
+ ## Solution: Use the New HF Spaces Setup βœ…
13
+
14
+ I've created everything needed:
15
+ - `app_hf_spaces.py` - Gradio UI with proper startup
16
+ - `Dockerfile` - Optimized for HF Spaces
17
+ - `.dockerignore` - Reduces build size
18
+
19
+ ## Step-by-Step Deployment
20
+
21
+ ### 1. **Delete Old Space** (if it exists)
22
+ Go to https://huggingface.co/spaces and delete the stuck Space.
23
+
24
+ ### 2. **Create New Space**
25
+ - Go to https://huggingface.co/new-space
26
+ - **Owner:** Your username
27
+ - **Space name:** `omoi-ui-detector` (or your choice)
28
+ - **License:** OpenRAIL-M (or your choice)
29
+ - **Space SDK:** Docker
30
+ - Click **Create Space**
31
+
32
+ ### 3. **Push Code to Space**
33
+ ```bash
34
+ cd /workspaces/omoi-v2
35
+
36
+ # Add your HF token
37
+ huggingface-cli login
38
+
39
+ # Add Space remote
40
+ git remote add space https://huggingface.co/spaces/YOUR_USERNAME/omoi-ui-detector
41
+
42
+ # Push to trigger build
43
+ git push space main
44
+ ```
45
+
46
+ ### 4. **Wait for Build** (5-10 minutes first time)
47
+ - Watch progress at: https://huggingface.co/spaces/YOUR_USERNAME/omoi-ui-detector
48
+ - Look for "Building..." β†’ "Running"
49
+ - First build is slow (downloads ~2GB models)
50
+
51
+ ### 5. **Test** βœ…
52
+ Once running, upload a UI screenshot and click "Analyze"
53
+
54
+ ---
55
+
56
+ ## Files Used in Deployment
57
+
58
+ | File | Purpose |
59
+ |------|---------|
60
+ | `Dockerfile` | Build configuration |
61
+ | `app_hf_spaces.py` | Main Gradio app (entry point) |
62
+ | `config.py` | Path configuration |
63
+ | `ui_element_analyzer.py` | Core analysis logic |
64
+ | `.dockerignore` | Reduce build size |
65
+
66
+ ## Troubleshooting
67
+
68
+ ### Still stuck on "Starting"?
69
+
70
+ 1. **Check build logs:**
71
+ - Click your Space
72
+ - Click "Logs" button (top right)
73
+ - Look for error messages
74
+
75
+ 2. **Common errors:**
76
+ - `ModuleNotFoundError: No module named 'paddleocr'`
77
+ β†’ Install might have failed, retry Space build
78
+
79
+ - `torch not found`
80
+ β†’ PyTorch install needs more time/space
81
+
82
+ - `Dockerfile not found`
83
+ β†’ Ensure files are in repo root and pushed to space
84
+
85
+ 3. **Force rebuild:**
86
+ - Go to Space settings
87
+ - Click "Restart" or delete & recreate
88
+
89
+ ### Startup too slow?
90
+
91
+ - First launch takes 2-3 minutes (model download)
92
+ - Subsequent launches are instant
93
+ - HF Spaces has free tier limits (CPU-based)
94
+
95
+ ---
96
+
97
+ ## API-Only Alternative (Faster)
98
+
99
+ If you want just the API (no Gradio UI), I can create:
100
+ - Lightweight FastAPI container
101
+ - Raw inference endpoints
102
+ - No model download on first request
103
+
104
+ Request this if Gradio is too slow!
105
+
106
+ ---
107
+
108
+ ## Space Settings Optimization
109
+
110
+ Once deployed, go to Space **Settings** and:
111
+ 1. Set **Persistent Storage**: 10GB (for model cache)
112
+ 2. Set **SDK**: Docker βœ“
113
+ 3. Enable **Community Features** (optional)
114
+
115
+ ---
116
+
117
+ ## Next Steps
118
+
119
+ 1. Update `YOUR_USERNAME` in git push command
120
+ 2. Run the deployment commands above
121
+ 3. Share Space URL when ready!
122
+
123
+ Any issues? Check the Space logs or let me know the error!