File size: 7,900 Bytes
63495ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
# πŸš€ HuggingFace Spaces Deployment Guide

## Quick Deployment Steps

### Option 1: Using HuggingFace Web Interface (Easiest)

1. **Go to HuggingFace Spaces**
   - Visit: https://huggingface.co/spaces
   - Click "Create new Space"

2. **Configure Your Space**
   - **Space name**: `ppt-script-generator` (or your choice)
   - **License**: MIT
   - **SDK**: Gradio
   - **Visibility**: Public (or Private)
   - Click "Create Space"

3. **Upload Files**
   - Click "Files" tab
   - Upload these files:
     - `app.py`
     - `requirements_hf.txt` (rename to `requirements.txt` when uploading)
     - `README_HF.md` (rename to `README.md` when uploading)

4. **Wait for Build**
   - HuggingFace will automatically build your Space
   - Takes 1-2 minutes
   - Status shown at top of page

5. **Access Your App**
   - Once built, click "App" tab
   - Your app is live at: `https://huggingface.co/spaces/YOUR_USERNAME/ppt-script-generator`
   - Share this URL with anyone!

---

### Option 2: Using Git (For Developers)

1. **Create Space on HuggingFace**
   - Visit: https://huggingface.co/new-space
   - Fill in details as above

2. **Clone Repository**
   ```bash
   git clone https://huggingface.co/spaces/YOUR_USERNAME/ppt-script-generator
   cd ppt-script-generator
   ```

3. **Add Files**
   ```bash
   cp path/to/app.py .
   cp path/to/requirements_hf.txt requirements.txt
   cp path/to/README_HF.md README.md
   ```

4. **Commit and Push**
   ```bash
   git add .
   git commit -m "Initial commit: PPT Script Generator"
   git push
   ```

5. **Check Deployment**
   - Visit your Space URL
   - Check build logs if needed

---

## πŸ“‚ Required Files

Your Space needs exactly 3 files:

### 1. `app.py` (Main Application)
- Contains the complete Gradio interface
- Uses HuggingFace Inference API
- No local model download needed

### 2. `requirements.txt` (Dependencies)
```
gradio
huggingface_hub
```

### 3. `README.md` (Space Description)
- Shown on your Space's landing page
- Must have YAML frontmatter at top
- Describes your app

---

## βš™οΈ Configuration Options

### In README.md Frontmatter

```yaml
---
title: PowerPoint Script Generator    # Your app name
emoji: 🎀                              # Icon for your Space
colorFrom: purple                      # Gradient start color
colorTo: blue                          # Gradient end color
sdk: gradio                            # Always 'gradio'
sdk_version: 4.44.0                    # Gradio version
app_file: app.py                       # Main file name
pinned: false                          # Pin to your profile?
license: mit                           # License type
---
```

### Visibility Options

- **Public**: Anyone can view and use
- **Private**: Only you (and collaborators) can access

---

## πŸ” Testing Your Deployment

### Before Deploying

Test locally first:
```bash
python app.py
```

Should show:
```
Running on local URL:  http://127.0.0.1:7860
```

### After Deploying

1. **Check Build Status**
   - Look for green checkmark
   - If red X, check logs

2. **Test the App**
   - Try example topics
   - Test with custom topic
   - Verify output quality

3. **Common Issues**
   - **Build fails**: Check requirements.txt
   - **App crashes**: Check app.py for errors
   - **Slow generation**: Normal for free tier
   - **API errors**: Wait and retry (rate limits)

---

## πŸ“Š Usage Limits (Free Tier)

HuggingFace Spaces free tier has:
- **Compute**: Limited CPU/RAM
- **API calls**: Rate limited
- **Uptime**: May sleep after inactivity
- **Build time**: A few minutes

**For production use**, consider upgrading to a paid tier.

---

## 🎨 Customization After Deployment

### Update Your Space

1. **Via Web Interface**
   - Go to "Files" tab
   - Click file to edit
   - Make changes
   - Click "Commit changes"
   - Space rebuilds automatically

2. **Via Git**
   ```bash
   # Make changes to files
   git add .
   git commit -m "Updated generation prompt"
   git push
   ```

### Common Customizations

**Change Model:**
```python
self.client = InferenceClient(
    model="different-model-name",
    token=os.getenv("HF_TOKEN")
)
```

**Adjust Defaults:**
```python
num_slides = gr.Slider(
    minimum=3,
    maximum=15,  # Changed from 10
    value=7,     # Changed from 5
    ...
)
```

**Add More Examples:**
```python
gr.Examples(
    examples=[
        ["Your new topic", 5, "Students", "Educational"],
        # Add more here
    ],
    ...
)
```

---

## πŸ› Troubleshooting

### Build Errors

**Error: "No module named 'gradio'"**
- Fix: Check `requirements.txt` has `gradio`

**Error: "Cannot find app.py"**
- Fix: Ensure `app_file: app.py` in README.md frontmatter

### Runtime Errors

**Error: "API rate limit exceeded"**
- Wait 60 seconds and try again
- Consider upgrading Space tier

**Error: "Model timeout"**
- Normal for long generations
- Reduce number of slides
- Reduce max_tokens

**App shows "Sleeping"**
- Free tier sleeps after inactivity
- Click to wake it up (takes 10-20 seconds)

---

## πŸ“ˆ Monitoring Your Space

### Check Analytics

- Visit your Space page
- Click "Analytics" tab
- See:
  - Number of users
  - Usage patterns
  - Popular features

### View Logs

- Click "Logs" tab
- See real-time app output
- Debug errors
- Monitor performance

---

## πŸ”’ Security Best Practices

### API Tokens

- Never hardcode tokens in code
- Use `os.getenv("HF_TOKEN")`
- HF Spaces provides this automatically

### Rate Limiting

- Implement client-side delays
- Show loading messages
- Handle API errors gracefully

### Input Validation

Already implemented in `app.py`:
```python
if not topic.strip():
    return "⚠️ Please enter a presentation topic."
```

---

## 🌟 Making Your Space Popular

### 1. Good Description
- Clear README.md
- Screenshots/GIFs
- Use cases

### 2. Example Content
- Provide good examples
- Show various use cases
- Make it easy to try

### 3. Share It
- Social media
- GitHub repos
- Blog posts
- Communities

### 4. Maintain It
- Fix bugs quickly
- Update dependencies
- Improve based on feedback

---

## πŸ“± Embedding Your Space

### In a Website

```html
<gradio-app src="https://huggingface.co/spaces/YOUR_USERNAME/ppt-script-generator"></gradio-app>
<script type="module" src="https://gradio.s3-us-west-2.amazonaws.com/4.44.0/gradio.js"></script>
```

### In a Blog Post

Use the embed code from your Space settings.

---

## πŸš€ Next Steps After Deployment

1. **Test thoroughly**
   - Try various topics
   - Different audiences
   - Edge cases

2. **Gather feedback**
   - Share with users
   - Collect suggestions
   - Iterate and improve

3. **Add features**
   - Export to PDF
   - Save templates
   - Multi-language support

4. **Optimize performance**
   - Cache common requests
   - Optimize prompts
   - Reduce token usage

---

## πŸ“ž Getting Help

### Resources

- **HuggingFace Docs**: https://huggingface.co/docs/hub/spaces
- **Gradio Docs**: https://gradio.app/docs
- **Community Forum**: https://discuss.huggingface.co

### Common Questions

**Q: How long does deployment take?**
A: Usually 1-2 minutes for first build

**Q: Can I use private models?**
A: Yes, with HF Pro subscription

**Q: What's the API rate limit?**
A: Varies by tier; free tier is limited

**Q: Can I upgrade my Space?**
A: Yes, upgrade to PRO or Enterprise

---

## βœ… Pre-Deployment Checklist

Before you deploy, ensure:

- [ ] `app.py` runs locally without errors
- [ ] `requirements.txt` has all dependencies
- [ ] `README.md` has correct YAML frontmatter
- [ ] Example topics work correctly
- [ ] Error handling is in place
- [ ] Loading messages are shown
- [ ] Output is properly formatted
- [ ] All features work as expected

---

## πŸŽ‰ You're Ready!

Your Space will be live at:
```
https://huggingface.co/spaces/YOUR_USERNAME/ppt-script-generator
```

**Share it with the world!** 🌍

---

*Last Updated: January 2026*