JayAtriahf-7 commited on
Commit
ed832e7
Β·
verified Β·
1 Parent(s): 433ba7c

Upload DEPLOYMENT_GUIDE.md

Browse files
Files changed (1) hide show
  1. DEPLOYMENT_GUIDE.md +414 -0
DEPLOYMENT_GUIDE.md ADDED
@@ -0,0 +1,414 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # πŸš€ Deploy to Hugging Face Spaces - Complete Guide
2
+
3
+ ## What is Hugging Face Spaces?
4
+
5
+ Hugging Face Spaces is a **FREE platform** to host ML demos and applications. It provides:
6
+ - βœ… **Free hosting** for public Spaces
7
+ - βœ… **Automatic deployment** from Git
8
+ - βœ… **Gradio/Streamlit support** for interactive UIs
9
+ - βœ… **GPU support** (free tier available)
10
+ - βœ… **Easy sharing** via web URL
11
+
12
+ ---
13
+
14
+ ## 🎯 What We're Deploying
15
+
16
+ Your Moon Crater Navigation project as an **interactive web application** with:
17
+ 1. **Crater Detection Tab**: Upload images, detect craters
18
+ 2. **Path Planning Tab**: Plan navigation routes on lunar terrain
19
+ 3. **About Tab**: Project information and documentation
20
+
21
+ ---
22
+
23
+ ## πŸ“‹ Prerequisites (Same as Before)
24
+
25
+ 1. βœ… Hugging Face account: https://huggingface.co/join
26
+ 2. βœ… Access token with **Write** permission
27
+ 3. βœ… Logged in via CLI: `huggingface-cli login`
28
+
29
+ ---
30
+
31
+ ## πŸš€ Deployment Methods
32
+
33
+ ### METHOD 1: Web Interface (Easiest - Recommended)
34
+
35
+ #### Step 1: Create a New Space
36
+
37
+ 1. Go to: https://huggingface.co/new-space
38
+ 2. Fill in the form:
39
+ - **Owner**: Your username
40
+ - **Space name**: `moon-crater-navigation` (or your choice)
41
+ - **License**: MIT
42
+ - **SDK**: Select **Gradio**
43
+ - **Visibility**: Public (for free hosting)
44
+ 3. Click **Create Space**
45
+
46
+ #### Step 2: Upload Files via Web Interface
47
+
48
+ You'll see a Git repository interface. Upload these files:
49
+
50
+ **Required Files:**
51
+ 1. `app.py` - Main application file
52
+ 2. `requirements_space.txt` - Rename to `requirements.txt` when uploading
53
+ 3. `README_SPACE.md` - Rename to `README.md` when uploading
54
+
55
+ **Optional but Recommended:**
56
+ 4. `src/` folder - Your source code
57
+ 5. `weights/best.pt` - Your trained model (if available)
58
+ 6. `examples/` folder - Sample images for demos
59
+
60
+ **How to Upload:**
61
+ - Click "Files" tab
62
+ - Click "Add file" β†’ "Upload files"
63
+ - Drag and drop or browse files
64
+ - Click "Commit to main"
65
+
66
+ #### Step 3: Wait for Build
67
+
68
+ - Hugging Face will automatically:
69
+ 1. Install dependencies from `requirements.txt`
70
+ 2. Run your `app.py`
71
+ 3. Deploy the Gradio interface
72
+ - Build time: ~2-5 minutes
73
+ - Watch the "Logs" tab for progress
74
+
75
+ #### Step 4: Test Your App
76
+
77
+ - Once built, your app will be live at:
78
+ `https://huggingface.co/spaces/YOUR_USERNAME/moon-crater-navigation`
79
+ - Test both tabs:
80
+ - Crater Detection
81
+ - Path Planning
82
+
83
+ ---
84
+
85
+ ### METHOD 2: Git Push (For Developers)
86
+
87
+ #### Step 1: Clone Your Space Repository
88
+
89
+ ```cmd
90
+ git clone https://huggingface.co/spaces/YOUR_USERNAME/moon-crater-navigation
91
+ cd moon-crater-navigation
92
+ ```
93
+
94
+ #### Step 2: Copy Files
95
+
96
+ ```cmd
97
+ # Copy main app file
98
+ copy e:\project\major_project\app.py app.py
99
+
100
+ # Copy requirements (rename)
101
+ copy e:\project\major_project\requirements_space.txt requirements.txt
102
+
103
+ # Copy README (rename)
104
+ copy e:\project\major_project\README_SPACE.md README.md
105
+
106
+ # Copy source code
107
+ xcopy /E /I e:\project\major_project\src src
108
+
109
+ # Copy model weights (if available)
110
+ mkdir weights
111
+ copy e:\project\major_project\data\yolov8_training_runs\*\weights\best.pt weights\best.pt
112
+ ```
113
+
114
+ #### Step 3: Commit and Push
115
+
116
+ ```cmd
117
+ git add .
118
+ git commit -m "Initial deployment of Moon Crater Navigation"
119
+ git push
120
+ ```
121
+
122
+ #### Step 4: Monitor Deployment
123
+
124
+ Visit your Space URL and watch it build automatically.
125
+
126
+ ---
127
+
128
+ ### METHOD 3: Python Script (Automated)
129
+
130
+ I'll create a script for this:
131
+
132
+ ---
133
+
134
+ ## πŸ“ Required File Structure for Space
135
+
136
+ ```
137
+ moon-crater-navigation/ (Your Space repository)
138
+ β”œβ”€β”€ app.py # Main Gradio app
139
+ β”œβ”€β”€ requirements.txt # Python dependencies
140
+ β”œβ”€β”€ README.md # Space description (shows on page)
141
+ β”œβ”€β”€ src/ # Your source code
142
+ β”‚ β”œβ”€β”€ terrain.py
143
+ β”‚ β”œβ”€β”€ pathfinding.py
144
+ β”‚ β”œβ”€β”€ visualizer.py
145
+ β”‚ └── ...
146
+ β”œβ”€β”€ weights/ # Model weights
147
+ β”‚ └── best.pt # Your trained YOLOv8 model
148
+ └── examples/ # Sample images (optional)
149
+ β”œβ”€β”€ lunar_surface_1.jpg
150
+ └── terrain_1.jpg
151
+ ```
152
+
153
+ ---
154
+
155
+ ## βš™οΈ Important Configuration
156
+
157
+ ### Hardware Selection
158
+
159
+ **Free Options:**
160
+ - **CPU Basic**: Free, sufficient for demos (Default)
161
+ - **CPU Upgrade**: Free, 2x faster
162
+
163
+ **Paid Options** (if you need more power):
164
+ - **GPU**: For faster inference (~$0.60/hour)
165
+ - **Persistent storage**: For large files
166
+
167
+ For this project, **CPU Basic (Free)** is enough!
168
+
169
+ ### Settings to Configure
170
+
171
+ 1. **Visibility**: Public (for free hosting)
172
+ 2. **Sleep time**: Space sleeps after 48h of inactivity (wakes on visit)
173
+ 3. **Secrets**: If you need API keys (not needed for this project)
174
+
175
+ ---
176
+
177
+ ## 🎨 Customization Tips
178
+
179
+ ### Before Deploying
180
+
181
+ Edit `app.py` to customize:
182
+
183
+ 1. **Title and Description**:
184
+ ```python
185
+ title="πŸŒ™ Your Custom Title"
186
+ ```
187
+
188
+ 2. **Theme**:
189
+ ```python
190
+ theme=gr.themes.Soft() # or Base(), Monochrome(), Glass()
191
+ ```
192
+
193
+ 3. **Example Images**:
194
+ - Create `examples/` folder
195
+ - Add sample lunar images
196
+ - Update examples in app.py
197
+
198
+ 4. **Your Info**:
199
+ - Update "About" tab
200
+ - Add your GitHub/LinkedIn
201
+ - Add your model details
202
+
203
+ ---
204
+
205
+ ## πŸ“€ Uploading Large Files (Model Weights)
206
+
207
+ ### If Your Model is > 10MB
208
+
209
+ Use Git LFS (Large File Storage):
210
+
211
+ ```cmd
212
+ # Install Git LFS
213
+ git lfs install
214
+
215
+ # Track large files
216
+ git lfs track "*.pt"
217
+ git lfs track "weights/*"
218
+
219
+ # Add .gitattributes
220
+ git add .gitattributes
221
+
222
+ # Now add and commit normally
223
+ git add weights/best.pt
224
+ git commit -m "Add model weights"
225
+ git push
226
+ ```
227
+
228
+ ### Alternative: Hugging Face Hub
229
+
230
+ Upload large files separately:
231
+
232
+ ```python
233
+ from huggingface_hub import HfApi
234
+
235
+ api = HfApi()
236
+ api.upload_file(
237
+ path_or_fileobj="weights/best.pt",
238
+ path_in_repo="weights/best.pt",
239
+ repo_id="YOUR_USERNAME/moon-crater-navigation",
240
+ repo_type="space"
241
+ )
242
+ ```
243
+
244
+ ---
245
+
246
+ ## πŸ› Troubleshooting
247
+
248
+ ### Common Issues
249
+
250
+ | Issue | Solution |
251
+ |-------|----------|
252
+ | **App won't build** | Check logs tab for errors |
253
+ | **Dependencies fail** | Verify requirements.txt syntax |
254
+ | **Module not found** | Add missing package to requirements.txt |
255
+ | **App crashes on load** | Check for missing files (src/, weights/) |
256
+ | **Slow loading** | Optimize model size or use smaller model |
257
+ | **Out of memory** | Reduce batch size or image size in code |
258
+
259
+ ### Debug Tips
260
+
261
+ 1. **Check Build Logs**:
262
+ - Go to your Space β†’ "Logs" tab
263
+ - Look for red error messages
264
+
265
+ 2. **Test Locally First**:
266
+ ```cmd
267
+ cd e:\project\major_project
268
+ python app.py
269
+ ```
270
+ - Visit http://127.0.0.1:7860
271
+ - Fix any errors before deploying
272
+
273
+ 3. **Verify Requirements**:
274
+ ```cmd
275
+ pip install -r requirements_space.txt
276
+ ```
277
+
278
+ ---
279
+
280
+ ## βœ… Deployment Checklist
281
+
282
+ Before deploying, ensure:
283
+
284
+ - [ ] `app.py` runs locally without errors
285
+ - [ ] `requirements_space.txt` has all dependencies
286
+ - [ ] `README_SPACE.md` describes your project
287
+ - [ ] Model weights available (or app has demo mode)
288
+ - [ ] Source code (`src/`) is included
289
+ - [ ] Example images added (optional but nice)
290
+ - [ ] Customized branding (title, description, about)
291
+ - [ ] Tested both tabs (crater detection, path planning)
292
+
293
+ ---
294
+
295
+ ## 🎯 Step-by-Step Quick Start
296
+
297
+ ### Absolute Fastest Way (5 minutes):
298
+
299
+ 1. **Create Space**: https://huggingface.co/new-space
300
+ - Name: `moon-crater-navigation`
301
+ - SDK: Gradio
302
+ - Public
303
+
304
+ 2. **Upload 3 Files**:
305
+ - Upload `app.py` as is
306
+ - Upload `requirements_space.txt` β†’ rename to `requirements.txt`
307
+ - Upload `README_SPACE.md` β†’ rename to `README.md`
308
+
309
+ 3. **Wait 2-3 minutes** for build
310
+
311
+ 4. **Visit your Space** and test!
312
+
313
+ That's it! πŸŽ‰
314
+
315
+ ### To Add Full Functionality Later:
316
+
317
+ 5. Upload `src/` folder
318
+ 6. Upload model weights to `weights/best.pt`
319
+ 7. Add example images to `examples/`
320
+
321
+ ---
322
+
323
+ ## 🌟 After Deployment
324
+
325
+ ### Promote Your Space
326
+
327
+ 1. **Share the Link**:
328
+ - Twitter, LinkedIn, Reddit
329
+ - Tag @huggingface
330
+ - Use hashtags: #MachineLearning #Space #AI
331
+
332
+ 2. **Add to Papers**:
333
+ - Include Space link in research papers
334
+ - Use as interactive supplement
335
+
336
+ 3. **Embed in Websites**:
337
+ ```html
338
+ <gradio-app src="https://YOUR_USERNAME-moon-crater-navigation.hf.space"></gradio-app>
339
+ ```
340
+
341
+ 4. **Update Model Card**:
342
+ - Link Space in your model repository README
343
+ - Add demo GIF/screenshots
344
+
345
+ ### Monitor Usage
346
+
347
+ - Check "Analytics" tab for:
348
+ - Number of visitors
349
+ - API calls
350
+ - Popular features
351
+
352
+ ---
353
+
354
+ ## πŸ’° Cost Analysis
355
+
356
+ ### FREE Tier Includes:
357
+ - βœ… Unlimited public Spaces
358
+ - βœ… CPU hosting
359
+ - βœ… Automatic SSL/HTTPS
360
+ - βœ… Custom subdomain
361
+ - βœ… Automatic sleeping (wakes on visit)
362
+ - βœ… Community support
363
+
364
+ ### What Costs Money:
365
+ - ❌ GPU hardware (~$0.60/hour, optional)
366
+ - ❌ Persistent storage (>50GB, optional)
367
+ - ❌ Private Spaces with always-on (optional)
368
+
369
+ **For this project: 100% FREE! πŸŽ‰**
370
+
371
+ ---
372
+
373
+ ## πŸ“š Additional Resources
374
+
375
+ - **Spaces Documentation**: https://huggingface.co/docs/hub/spaces
376
+ - **Gradio Documentation**: https://gradio.app/docs
377
+ - **Example Spaces**: https://huggingface.co/spaces
378
+ - **Community Forum**: https://discuss.huggingface.co/
379
+
380
+ ---
381
+
382
+ ## πŸŽ“ Learning Path
383
+
384
+ 1. **Deploy basic version** (app.py only) - 5 min
385
+ 2. **Add source code** (src/ folder) - 5 min
386
+ 3. **Add model weights** (weights/best.pt) - 5 min
387
+ 4. **Add examples** (sample images) - 5 min
388
+ 5. **Customize UI** (themes, branding) - 10 min
389
+ 6. **Optimize performance** (if needed) - 30 min
390
+
391
+ **Total time: ~1 hour for full deployment**
392
+
393
+ ---
394
+
395
+ ## πŸŽ‰ Success Criteria
396
+
397
+ Your deployment is successful when:
398
+ - βœ… Space builds without errors
399
+ - βœ… App loads in browser
400
+ - βœ… Crater detection works (even in demo mode)
401
+ - βœ… Path planning works with uploaded images
402
+ - βœ… UI is responsive and user-friendly
403
+ - βœ… Public can access and use it
404
+
405
+ ---
406
+
407
+ ## πŸš€ Ready to Deploy?
408
+
409
+ Choose your method:
410
+ - **Beginner**: Use Web Interface (Method 1)
411
+ - **Developer**: Use Git Push (Method 2)
412
+ - **Automated**: Use Python Script (Method 3, script below)
413
+
414
+ Good luck! Your lunar navigation app will be live soon! πŸŒ™βœ¨