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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# π HuggingFace Spaces Deployment Guide
|
| 2 |
+
|
| 3 |
+
## Quick Deployment Steps
|
| 4 |
+
|
| 5 |
+
### Option 1: Using HuggingFace Web Interface (Easiest)
|
| 6 |
+
|
| 7 |
+
1. **Go to HuggingFace Spaces**
|
| 8 |
+
- Visit: https://huggingface.co/spaces
|
| 9 |
+
- Click "Create new Space"
|
| 10 |
+
|
| 11 |
+
2. **Configure Your Space**
|
| 12 |
+
- **Space name**: `ppt-script-generator` (or your choice)
|
| 13 |
+
- **License**: MIT
|
| 14 |
+
- **SDK**: Gradio
|
| 15 |
+
- **Visibility**: Public (or Private)
|
| 16 |
+
- Click "Create Space"
|
| 17 |
+
|
| 18 |
+
3. **Upload Files**
|
| 19 |
+
- Click "Files" tab
|
| 20 |
+
- Upload these files:
|
| 21 |
+
- `app.py`
|
| 22 |
+
- `requirements_hf.txt` (rename to `requirements.txt` when uploading)
|
| 23 |
+
- `README_HF.md` (rename to `README.md` when uploading)
|
| 24 |
+
|
| 25 |
+
4. **Wait for Build**
|
| 26 |
+
- HuggingFace will automatically build your Space
|
| 27 |
+
- Takes 1-2 minutes
|
| 28 |
+
- Status shown at top of page
|
| 29 |
+
|
| 30 |
+
5. **Access Your App**
|
| 31 |
+
- Once built, click "App" tab
|
| 32 |
+
- Your app is live at: `https://huggingface.co/spaces/YOUR_USERNAME/ppt-script-generator`
|
| 33 |
+
- Share this URL with anyone!
|
| 34 |
+
|
| 35 |
+
---
|
| 36 |
+
|
| 37 |
+
### Option 2: Using Git (For Developers)
|
| 38 |
+
|
| 39 |
+
1. **Create Space on HuggingFace**
|
| 40 |
+
- Visit: https://huggingface.co/new-space
|
| 41 |
+
- Fill in details as above
|
| 42 |
+
|
| 43 |
+
2. **Clone Repository**
|
| 44 |
+
```bash
|
| 45 |
+
git clone https://huggingface.co/spaces/YOUR_USERNAME/ppt-script-generator
|
| 46 |
+
cd ppt-script-generator
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
3. **Add Files**
|
| 50 |
+
```bash
|
| 51 |
+
cp path/to/app.py .
|
| 52 |
+
cp path/to/requirements_hf.txt requirements.txt
|
| 53 |
+
cp path/to/README_HF.md README.md
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
4. **Commit and Push**
|
| 57 |
+
```bash
|
| 58 |
+
git add .
|
| 59 |
+
git commit -m "Initial commit: PPT Script Generator"
|
| 60 |
+
git push
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
5. **Check Deployment**
|
| 64 |
+
- Visit your Space URL
|
| 65 |
+
- Check build logs if needed
|
| 66 |
+
|
| 67 |
+
---
|
| 68 |
+
|
| 69 |
+
## π Required Files
|
| 70 |
+
|
| 71 |
+
Your Space needs exactly 3 files:
|
| 72 |
+
|
| 73 |
+
### 1. `app.py` (Main Application)
|
| 74 |
+
- Contains the complete Gradio interface
|
| 75 |
+
- Uses HuggingFace Inference API
|
| 76 |
+
- No local model download needed
|
| 77 |
+
|
| 78 |
+
### 2. `requirements.txt` (Dependencies)
|
| 79 |
+
```
|
| 80 |
+
gradio
|
| 81 |
+
huggingface_hub
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
### 3. `README.md` (Space Description)
|
| 85 |
+
- Shown on your Space's landing page
|
| 86 |
+
- Must have YAML frontmatter at top
|
| 87 |
+
- Describes your app
|
| 88 |
+
|
| 89 |
+
---
|
| 90 |
+
|
| 91 |
+
## βοΈ Configuration Options
|
| 92 |
+
|
| 93 |
+
### In README.md Frontmatter
|
| 94 |
+
|
| 95 |
+
```yaml
|
| 96 |
+
---
|
| 97 |
+
title: PowerPoint Script Generator # Your app name
|
| 98 |
+
emoji: π€ # Icon for your Space
|
| 99 |
+
colorFrom: purple # Gradient start color
|
| 100 |
+
colorTo: blue # Gradient end color
|
| 101 |
+
sdk: gradio # Always 'gradio'
|
| 102 |
+
sdk_version: 4.44.0 # Gradio version
|
| 103 |
+
app_file: app.py # Main file name
|
| 104 |
+
pinned: false # Pin to your profile?
|
| 105 |
+
license: mit # License type
|
| 106 |
+
---
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
### Visibility Options
|
| 110 |
+
|
| 111 |
+
- **Public**: Anyone can view and use
|
| 112 |
+
- **Private**: Only you (and collaborators) can access
|
| 113 |
+
|
| 114 |
+
---
|
| 115 |
+
|
| 116 |
+
## π Testing Your Deployment
|
| 117 |
+
|
| 118 |
+
### Before Deploying
|
| 119 |
+
|
| 120 |
+
Test locally first:
|
| 121 |
+
```bash
|
| 122 |
+
python app.py
|
| 123 |
+
```
|
| 124 |
+
|
| 125 |
+
Should show:
|
| 126 |
+
```
|
| 127 |
+
Running on local URL: http://127.0.0.1:7860
|
| 128 |
+
```
|
| 129 |
+
|
| 130 |
+
### After Deploying
|
| 131 |
+
|
| 132 |
+
1. **Check Build Status**
|
| 133 |
+
- Look for green checkmark
|
| 134 |
+
- If red X, check logs
|
| 135 |
+
|
| 136 |
+
2. **Test the App**
|
| 137 |
+
- Try example topics
|
| 138 |
+
- Test with custom topic
|
| 139 |
+
- Verify output quality
|
| 140 |
+
|
| 141 |
+
3. **Common Issues**
|
| 142 |
+
- **Build fails**: Check requirements.txt
|
| 143 |
+
- **App crashes**: Check app.py for errors
|
| 144 |
+
- **Slow generation**: Normal for free tier
|
| 145 |
+
- **API errors**: Wait and retry (rate limits)
|
| 146 |
+
|
| 147 |
+
---
|
| 148 |
+
|
| 149 |
+
## π Usage Limits (Free Tier)
|
| 150 |
+
|
| 151 |
+
HuggingFace Spaces free tier has:
|
| 152 |
+
- **Compute**: Limited CPU/RAM
|
| 153 |
+
- **API calls**: Rate limited
|
| 154 |
+
- **Uptime**: May sleep after inactivity
|
| 155 |
+
- **Build time**: A few minutes
|
| 156 |
+
|
| 157 |
+
**For production use**, consider upgrading to a paid tier.
|
| 158 |
+
|
| 159 |
+
---
|
| 160 |
+
|
| 161 |
+
## π¨ Customization After Deployment
|
| 162 |
+
|
| 163 |
+
### Update Your Space
|
| 164 |
+
|
| 165 |
+
1. **Via Web Interface**
|
| 166 |
+
- Go to "Files" tab
|
| 167 |
+
- Click file to edit
|
| 168 |
+
- Make changes
|
| 169 |
+
- Click "Commit changes"
|
| 170 |
+
- Space rebuilds automatically
|
| 171 |
+
|
| 172 |
+
2. **Via Git**
|
| 173 |
+
```bash
|
| 174 |
+
# Make changes to files
|
| 175 |
+
git add .
|
| 176 |
+
git commit -m "Updated generation prompt"
|
| 177 |
+
git push
|
| 178 |
+
```
|
| 179 |
+
|
| 180 |
+
### Common Customizations
|
| 181 |
+
|
| 182 |
+
**Change Model:**
|
| 183 |
+
```python
|
| 184 |
+
self.client = InferenceClient(
|
| 185 |
+
model="different-model-name",
|
| 186 |
+
token=os.getenv("HF_TOKEN")
|
| 187 |
+
)
|
| 188 |
+
```
|
| 189 |
+
|
| 190 |
+
**Adjust Defaults:**
|
| 191 |
+
```python
|
| 192 |
+
num_slides = gr.Slider(
|
| 193 |
+
minimum=3,
|
| 194 |
+
maximum=15, # Changed from 10
|
| 195 |
+
value=7, # Changed from 5
|
| 196 |
+
...
|
| 197 |
+
)
|
| 198 |
+
```
|
| 199 |
+
|
| 200 |
+
**Add More Examples:**
|
| 201 |
+
```python
|
| 202 |
+
gr.Examples(
|
| 203 |
+
examples=[
|
| 204 |
+
["Your new topic", 5, "Students", "Educational"],
|
| 205 |
+
# Add more here
|
| 206 |
+
],
|
| 207 |
+
...
|
| 208 |
+
)
|
| 209 |
+
```
|
| 210 |
+
|
| 211 |
+
---
|
| 212 |
+
|
| 213 |
+
## π Troubleshooting
|
| 214 |
+
|
| 215 |
+
### Build Errors
|
| 216 |
+
|
| 217 |
+
**Error: "No module named 'gradio'"**
|
| 218 |
+
- Fix: Check `requirements.txt` has `gradio`
|
| 219 |
+
|
| 220 |
+
**Error: "Cannot find app.py"**
|
| 221 |
+
- Fix: Ensure `app_file: app.py` in README.md frontmatter
|
| 222 |
+
|
| 223 |
+
### Runtime Errors
|
| 224 |
+
|
| 225 |
+
**Error: "API rate limit exceeded"**
|
| 226 |
+
- Wait 60 seconds and try again
|
| 227 |
+
- Consider upgrading Space tier
|
| 228 |
+
|
| 229 |
+
**Error: "Model timeout"**
|
| 230 |
+
- Normal for long generations
|
| 231 |
+
- Reduce number of slides
|
| 232 |
+
- Reduce max_tokens
|
| 233 |
+
|
| 234 |
+
**App shows "Sleeping"**
|
| 235 |
+
- Free tier sleeps after inactivity
|
| 236 |
+
- Click to wake it up (takes 10-20 seconds)
|
| 237 |
+
|
| 238 |
+
---
|
| 239 |
+
|
| 240 |
+
## π Monitoring Your Space
|
| 241 |
+
|
| 242 |
+
### Check Analytics
|
| 243 |
+
|
| 244 |
+
- Visit your Space page
|
| 245 |
+
- Click "Analytics" tab
|
| 246 |
+
- See:
|
| 247 |
+
- Number of users
|
| 248 |
+
- Usage patterns
|
| 249 |
+
- Popular features
|
| 250 |
+
|
| 251 |
+
### View Logs
|
| 252 |
+
|
| 253 |
+
- Click "Logs" tab
|
| 254 |
+
- See real-time app output
|
| 255 |
+
- Debug errors
|
| 256 |
+
- Monitor performance
|
| 257 |
+
|
| 258 |
+
---
|
| 259 |
+
|
| 260 |
+
## π Security Best Practices
|
| 261 |
+
|
| 262 |
+
### API Tokens
|
| 263 |
+
|
| 264 |
+
- Never hardcode tokens in code
|
| 265 |
+
- Use `os.getenv("HF_TOKEN")`
|
| 266 |
+
- HF Spaces provides this automatically
|
| 267 |
+
|
| 268 |
+
### Rate Limiting
|
| 269 |
+
|
| 270 |
+
- Implement client-side delays
|
| 271 |
+
- Show loading messages
|
| 272 |
+
- Handle API errors gracefully
|
| 273 |
+
|
| 274 |
+
### Input Validation
|
| 275 |
+
|
| 276 |
+
Already implemented in `app.py`:
|
| 277 |
+
```python
|
| 278 |
+
if not topic.strip():
|
| 279 |
+
return "β οΈ Please enter a presentation topic."
|
| 280 |
+
```
|
| 281 |
+
|
| 282 |
+
---
|
| 283 |
+
|
| 284 |
+
## π Making Your Space Popular
|
| 285 |
+
|
| 286 |
+
### 1. Good Description
|
| 287 |
+
- Clear README.md
|
| 288 |
+
- Screenshots/GIFs
|
| 289 |
+
- Use cases
|
| 290 |
+
|
| 291 |
+
### 2. Example Content
|
| 292 |
+
- Provide good examples
|
| 293 |
+
- Show various use cases
|
| 294 |
+
- Make it easy to try
|
| 295 |
+
|
| 296 |
+
### 3. Share It
|
| 297 |
+
- Social media
|
| 298 |
+
- GitHub repos
|
| 299 |
+
- Blog posts
|
| 300 |
+
- Communities
|
| 301 |
+
|
| 302 |
+
### 4. Maintain It
|
| 303 |
+
- Fix bugs quickly
|
| 304 |
+
- Update dependencies
|
| 305 |
+
- Improve based on feedback
|
| 306 |
+
|
| 307 |
+
---
|
| 308 |
+
|
| 309 |
+
## π± Embedding Your Space
|
| 310 |
+
|
| 311 |
+
### In a Website
|
| 312 |
+
|
| 313 |
+
```html
|
| 314 |
+
<gradio-app src="https://huggingface.co/spaces/YOUR_USERNAME/ppt-script-generator"></gradio-app>
|
| 315 |
+
<script type="module" src="https://gradio.s3-us-west-2.amazonaws.com/4.44.0/gradio.js"></script>
|
| 316 |
+
```
|
| 317 |
+
|
| 318 |
+
### In a Blog Post
|
| 319 |
+
|
| 320 |
+
Use the embed code from your Space settings.
|
| 321 |
+
|
| 322 |
+
---
|
| 323 |
+
|
| 324 |
+
## π Next Steps After Deployment
|
| 325 |
+
|
| 326 |
+
1. **Test thoroughly**
|
| 327 |
+
- Try various topics
|
| 328 |
+
- Different audiences
|
| 329 |
+
- Edge cases
|
| 330 |
+
|
| 331 |
+
2. **Gather feedback**
|
| 332 |
+
- Share with users
|
| 333 |
+
- Collect suggestions
|
| 334 |
+
- Iterate and improve
|
| 335 |
+
|
| 336 |
+
3. **Add features**
|
| 337 |
+
- Export to PDF
|
| 338 |
+
- Save templates
|
| 339 |
+
- Multi-language support
|
| 340 |
+
|
| 341 |
+
4. **Optimize performance**
|
| 342 |
+
- Cache common requests
|
| 343 |
+
- Optimize prompts
|
| 344 |
+
- Reduce token usage
|
| 345 |
+
|
| 346 |
+
---
|
| 347 |
+
|
| 348 |
+
## π Getting Help
|
| 349 |
+
|
| 350 |
+
### Resources
|
| 351 |
+
|
| 352 |
+
- **HuggingFace Docs**: https://huggingface.co/docs/hub/spaces
|
| 353 |
+
- **Gradio Docs**: https://gradio.app/docs
|
| 354 |
+
- **Community Forum**: https://discuss.huggingface.co
|
| 355 |
+
|
| 356 |
+
### Common Questions
|
| 357 |
+
|
| 358 |
+
**Q: How long does deployment take?**
|
| 359 |
+
A: Usually 1-2 minutes for first build
|
| 360 |
+
|
| 361 |
+
**Q: Can I use private models?**
|
| 362 |
+
A: Yes, with HF Pro subscription
|
| 363 |
+
|
| 364 |
+
**Q: What's the API rate limit?**
|
| 365 |
+
A: Varies by tier; free tier is limited
|
| 366 |
+
|
| 367 |
+
**Q: Can I upgrade my Space?**
|
| 368 |
+
A: Yes, upgrade to PRO or Enterprise
|
| 369 |
+
|
| 370 |
+
---
|
| 371 |
+
|
| 372 |
+
## β
Pre-Deployment Checklist
|
| 373 |
+
|
| 374 |
+
Before you deploy, ensure:
|
| 375 |
+
|
| 376 |
+
- [ ] `app.py` runs locally without errors
|
| 377 |
+
- [ ] `requirements.txt` has all dependencies
|
| 378 |
+
- [ ] `README.md` has correct YAML frontmatter
|
| 379 |
+
- [ ] Example topics work correctly
|
| 380 |
+
- [ ] Error handling is in place
|
| 381 |
+
- [ ] Loading messages are shown
|
| 382 |
+
- [ ] Output is properly formatted
|
| 383 |
+
- [ ] All features work as expected
|
| 384 |
+
|
| 385 |
+
---
|
| 386 |
+
|
| 387 |
+
## π You're Ready!
|
| 388 |
+
|
| 389 |
+
Your Space will be live at:
|
| 390 |
+
```
|
| 391 |
+
https://huggingface.co/spaces/YOUR_USERNAME/ppt-script-generator
|
| 392 |
+
```
|
| 393 |
+
|
| 394 |
+
**Share it with the world!** π
|
| 395 |
+
|
| 396 |
+
---
|
| 397 |
+
|
| 398 |
+
*Last Updated: January 2026*
|
HUGGINGFACE_DEPLOYMENT_SUMMARY.md
ADDED
|
@@ -0,0 +1,484 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# π HuggingFace Spaces Deployment Package - Complete
|
| 2 |
+
|
| 3 |
+
## π― What You Have
|
| 4 |
+
|
| 5 |
+
A **production-ready PowerPoint Script Generator** that runs on **HuggingFace Spaces** using the **Falcon3-1B-Instruct** model via cloud API.
|
| 6 |
+
|
| 7 |
+
**Key Advantages:**
|
| 8 |
+
- β
No local installation required
|
| 9 |
+
- β
No model download needed (~0MB vs 700MB+)
|
| 10 |
+
- β
Works on any device with internet
|
| 11 |
+
- β
Free to deploy and use
|
| 12 |
+
- β
Shareable URL for anyone
|
| 13 |
+
- β
Automatic scaling and hosting
|
| 14 |
+
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
## π¦ Files for HuggingFace Spaces Deployment
|
| 18 |
+
|
| 19 |
+
### π§ Required Files (3 Total)
|
| 20 |
+
|
| 21 |
+
Upload these **exact 3 files** to your HuggingFace Space:
|
| 22 |
+
|
| 23 |
+
1. **`app.py`** (Main Application)
|
| 24 |
+
- Complete Gradio web interface
|
| 25 |
+
- Uses HuggingFace Inference API
|
| 26 |
+
- No local model needed
|
| 27 |
+
- ~250 lines of production code
|
| 28 |
+
|
| 29 |
+
2. **`requirements.txt`** (Dependencies)
|
| 30 |
+
- Upload: `requirements_hf.txt`
|
| 31 |
+
- **Rename to**: `requirements.txt` when uploading
|
| 32 |
+
- Contents:
|
| 33 |
+
```
|
| 34 |
+
gradio
|
| 35 |
+
huggingface_hub
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
3. **`README.md`** (Space Description)
|
| 39 |
+
- Upload: `README_HF.md`
|
| 40 |
+
- **Rename to**: `README.md` when uploading
|
| 41 |
+
- Has YAML frontmatter for Space configuration
|
| 42 |
+
|
| 43 |
+
### π Documentation Files (3 Total)
|
| 44 |
+
|
| 45 |
+
For your reference (don't upload these to HuggingFace):
|
| 46 |
+
|
| 47 |
+
4. **`QUICKSTART_HF.md`** - 5-minute deployment guide
|
| 48 |
+
5. **`DEPLOYMENT_GUIDE.md`** - Comprehensive deployment instructions
|
| 49 |
+
6. **`test_hf_app.py`** - Local testing script
|
| 50 |
+
|
| 51 |
+
---
|
| 52 |
+
|
| 53 |
+
## π Deployment Steps (Ultra Quick)
|
| 54 |
+
|
| 55 |
+
### 5-Minute Deployment:
|
| 56 |
+
|
| 57 |
+
```bash
|
| 58 |
+
1. Go to: https://huggingface.co/new-space
|
| 59 |
+
2. Create Space:
|
| 60 |
+
- Name: ppt-script-generator
|
| 61 |
+
- SDK: Gradio
|
| 62 |
+
- Hardware: CPU basic (free)
|
| 63 |
+
3. Upload 3 files:
|
| 64 |
+
- app.py (as is)
|
| 65 |
+
- requirements_hf.txt β rename to requirements.txt
|
| 66 |
+
- README_HF.md β rename to README.md
|
| 67 |
+
4. Click "Commit changes"
|
| 68 |
+
5. Wait 1-2 minutes for build
|
| 69 |
+
6. Done! Your app is live!
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
**Your URL will be:**
|
| 73 |
+
```
|
| 74 |
+
https://huggingface.co/spaces/YOUR_USERNAME/ppt-script-generator
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
---
|
| 78 |
+
|
| 79 |
+
## β¨ Key Features of Your App
|
| 80 |
+
|
| 81 |
+
### User Features:
|
| 82 |
+
- π Enter any presentation topic
|
| 83 |
+
- π Choose 3-10 slides
|
| 84 |
+
- π₯ 8 audience types (students, executives, technical, etc.)
|
| 85 |
+
- π¨ 6 tone options (professional, casual, inspirational, etc.)
|
| 86 |
+
- βοΈ Advanced controls (temperature, max tokens)
|
| 87 |
+
- π‘ 5 pre-loaded example topics
|
| 88 |
+
- π One-click copy of generated scripts
|
| 89 |
+
|
| 90 |
+
### Technical Features:
|
| 91 |
+
- π€ Uses Falcon3-1B-Instruct via HuggingFace API
|
| 92 |
+
- π¨ Beautiful Gradio interface
|
| 93 |
+
- βοΈ 100% cloud-based (no local setup)
|
| 94 |
+
- π No API key management (HF handles it)
|
| 95 |
+
- β‘ Fast generation (10-30 seconds)
|
| 96 |
+
- π± Mobile-friendly responsive design
|
| 97 |
+
|
| 98 |
+
---
|
| 99 |
+
|
| 100 |
+
## π What Each Slide Script Includes
|
| 101 |
+
|
| 102 |
+
```yaml
|
| 103 |
+
For Each Slide:
|
| 104 |
+
- Title: Clear, descriptive heading
|
| 105 |
+
- Speaker Script: 2-4 complete sentences
|
| 106 |
+
- Key Points: 3-4 bullet points
|
| 107 |
+
- Timing: Suggested duration (seconds)
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
**Example Output:**
|
| 111 |
+
|
| 112 |
+
```
|
| 113 |
+
---
|
| 114 |
+
Slide 1: Introduction to Cloud Computing
|
| 115 |
+
|
| 116 |
+
Speaker Script:
|
| 117 |
+
Welcome everyone. Today we'll explore cloud computing, a
|
| 118 |
+
technology that's revolutionizing how businesses operate.
|
| 119 |
+
Cloud computing allows companies to access computing resources
|
| 120 |
+
over the internet, eliminating the need for expensive on-premises
|
| 121 |
+
infrastructure.
|
| 122 |
+
|
| 123 |
+
Key Points:
|
| 124 |
+
- Access computing resources via internet
|
| 125 |
+
- No need for physical infrastructure
|
| 126 |
+
- Pay-as-you-go pricing model
|
| 127 |
+
- Scalable and flexible
|
| 128 |
+
|
| 129 |
+
Timing: 50 seconds
|
| 130 |
+
|
| 131 |
+
---
|
| 132 |
+
```
|
| 133 |
+
|
| 134 |
+
---
|
| 135 |
+
|
| 136 |
+
## π Comparison: Local vs HuggingFace Versions
|
| 137 |
+
|
| 138 |
+
| Feature | Local Version | HuggingFace Spaces |
|
| 139 |
+
|---------|---------------|-------------------|
|
| 140 |
+
| **Model Storage** | 700MB local download | 0MB (cloud API) |
|
| 141 |
+
| **Setup Time** | 5-10 minutes | 2-3 minutes |
|
| 142 |
+
| **Requirements** | Python, packages, model | Just upload 3 files |
|
| 143 |
+
| **Access** | Local only | Anywhere with internet |
|
| 144 |
+
| **Sharing** | Complex | Just share URL |
|
| 145 |
+
| **Hardware** | Your computer | HF servers |
|
| 146 |
+
| **Cost** | Free (uses your resources) | Free (HF tier) |
|
| 147 |
+
| **Speed** | Depends on your CPU | Depends on API load |
|
| 148 |
+
| **Maintenance** | You manage | HF manages |
|
| 149 |
+
| **Best For** | Learning, offline use | Production, sharing |
|
| 150 |
+
|
| 151 |
+
**Recommendation**: Use **HuggingFace Spaces** for:
|
| 152 |
+
- Portfolio projects
|
| 153 |
+
- Sharing with others
|
| 154 |
+
- Production demos
|
| 155 |
+
- No-installation required scenarios
|
| 156 |
+
|
| 157 |
+
Use **Local version** for:
|
| 158 |
+
- Learning prompt engineering
|
| 159 |
+
- Offline development
|
| 160 |
+
- Custom model experimentation
|
| 161 |
+
- Full control over resources
|
| 162 |
+
|
| 163 |
+
---
|
| 164 |
+
|
| 165 |
+
## π― Use Cases
|
| 166 |
+
|
| 167 |
+
### Perfect For:
|
| 168 |
+
|
| 169 |
+
1. **Business Presentations**
|
| 170 |
+
- Sales pitches
|
| 171 |
+
- Quarterly reviews
|
| 172 |
+
- Strategy sessions
|
| 173 |
+
- Board meetings
|
| 174 |
+
|
| 175 |
+
2. **Educational Content**
|
| 176 |
+
- Lectures
|
| 177 |
+
- Training materials
|
| 178 |
+
- Workshops
|
| 179 |
+
- Tutorials
|
| 180 |
+
|
| 181 |
+
3. **Technical Talks**
|
| 182 |
+
- Conference presentations
|
| 183 |
+
- Technical deep-dives
|
| 184 |
+
- Architecture reviews
|
| 185 |
+
- Product demos
|
| 186 |
+
|
| 187 |
+
4. **Investor Pitches**
|
| 188 |
+
- Fundraising presentations
|
| 189 |
+
- Startup pitches
|
| 190 |
+
- Business plans
|
| 191 |
+
- Growth strategies
|
| 192 |
+
|
| 193 |
+
5. **Training Sessions**
|
| 194 |
+
- Employee onboarding
|
| 195 |
+
- Skill development
|
| 196 |
+
- Compliance training
|
| 197 |
+
- Product training
|
| 198 |
+
|
| 199 |
+
---
|
| 200 |
+
|
| 201 |
+
## π‘ Example Scenarios
|
| 202 |
+
|
| 203 |
+
### Scenario 1: Business Executive
|
| 204 |
+
|
| 205 |
+
**Input:**
|
| 206 |
+
- Topic: "Q1 2025 Sales Performance and Q2 Strategy"
|
| 207 |
+
- Slides: 6
|
| 208 |
+
- Audience: Business executives
|
| 209 |
+
- Tone: Professional
|
| 210 |
+
|
| 211 |
+
**Gets:**
|
| 212 |
+
- Executive-focused scripts
|
| 213 |
+
- Metrics and KPIs highlighted
|
| 214 |
+
- Strategic language
|
| 215 |
+
- Action-oriented content
|
| 216 |
+
|
| 217 |
+
---
|
| 218 |
+
|
| 219 |
+
### Scenario 2: Teacher
|
| 220 |
+
|
| 221 |
+
**Input:**
|
| 222 |
+
- Topic: "Introduction to Photosynthesis"
|
| 223 |
+
- Slides: 5
|
| 224 |
+
- Audience: Students
|
| 225 |
+
- Tone: Educational
|
| 226 |
+
|
| 227 |
+
**Gets:**
|
| 228 |
+
- Simple, clear explanations
|
| 229 |
+
- Step-by-step progression
|
| 230 |
+
- Relatable examples
|
| 231 |
+
- Engaging content
|
| 232 |
+
|
| 233 |
+
---
|
| 234 |
+
|
| 235 |
+
### Scenario 3: Developer
|
| 236 |
+
|
| 237 |
+
**Input:**
|
| 238 |
+
- Topic: "Microservices Architecture Best Practices"
|
| 239 |
+
- Slides: 8
|
| 240 |
+
- Audience: Technical professionals
|
| 241 |
+
- Tone: Technical and detailed
|
| 242 |
+
|
| 243 |
+
**Gets:**
|
| 244 |
+
- Technical depth
|
| 245 |
+
- Implementation details
|
| 246 |
+
- Best practices
|
| 247 |
+
- Code examples mentioned
|
| 248 |
+
|
| 249 |
+
---
|
| 250 |
+
|
| 251 |
+
## π§ͺ Testing Before Deployment
|
| 252 |
+
|
| 253 |
+
Run the test script locally:
|
| 254 |
+
|
| 255 |
+
```bash
|
| 256 |
+
python test_hf_app.py
|
| 257 |
+
```
|
| 258 |
+
|
| 259 |
+
**Expected Output:**
|
| 260 |
+
```
|
| 261 |
+
π HUGGINGFACE SPACES APP - PRE-DEPLOYMENT TEST
|
| 262 |
+
================================================================================
|
| 263 |
+
|
| 264 |
+
Testing Package Imports...
|
| 265 |
+
β
Gradio UI Framework: INSTALLED
|
| 266 |
+
β
HuggingFace Hub Client: INSTALLED
|
| 267 |
+
|
| 268 |
+
Testing app.py File...
|
| 269 |
+
β
app.py file exists
|
| 270 |
+
β
app.py is valid Python code
|
| 271 |
+
β
PPTScriptGenerator class found
|
| 272 |
+
β
create_gradio_interface function found
|
| 273 |
+
β
InferenceClient usage found
|
| 274 |
+
|
| 275 |
+
[... more tests ...]
|
| 276 |
+
|
| 277 |
+
π All tests passed! Your app is ready to deploy to HuggingFace Spaces!
|
| 278 |
+
```
|
| 279 |
+
|
| 280 |
+
---
|
| 281 |
+
|
| 282 |
+
## π Troubleshooting
|
| 283 |
+
|
| 284 |
+
### Common Issues:
|
| 285 |
+
|
| 286 |
+
**"Build Failed"**
|
| 287 |
+
- Check file names are exact: `app.py`, `requirements.txt`, `README.md`
|
| 288 |
+
- Verify YAML frontmatter in README.md
|
| 289 |
+
- Check Logs tab for specific error
|
| 290 |
+
|
| 291 |
+
**"API Rate Limit"**
|
| 292 |
+
- Normal for free tier during high load
|
| 293 |
+
- Wait 60 seconds and retry
|
| 294 |
+
- Reduce number of slides
|
| 295 |
+
- Try off-peak hours
|
| 296 |
+
|
| 297 |
+
**"Space Sleeping"**
|
| 298 |
+
- Free tier sleeps after 30 min inactivity
|
| 299 |
+
- Click to wake (10-20 seconds)
|
| 300 |
+
- Upgrade to HF Pro to prevent sleeping
|
| 301 |
+
|
| 302 |
+
**"Slow Generation"**
|
| 303 |
+
- Normal during high API load
|
| 304 |
+
- Reduce max_tokens to 1500
|
| 305 |
+
- Reduce slides to 3-5
|
| 306 |
+
- Try different times of day
|
| 307 |
+
|
| 308 |
+
---
|
| 309 |
+
|
| 310 |
+
## π Educational Value
|
| 311 |
+
|
| 312 |
+
This project demonstrates:
|
| 313 |
+
|
| 314 |
+
### For Your Agentic AI Program:
|
| 315 |
+
|
| 316 |
+
1. **β
LLM Integration**
|
| 317 |
+
- Using cloud-based inference APIs
|
| 318 |
+
- Understanding API vs local models
|
| 319 |
+
- Managing API calls and errors
|
| 320 |
+
|
| 321 |
+
2. **β
Prompt Engineering**
|
| 322 |
+
- Structured prompt design
|
| 323 |
+
- Role-based prompting
|
| 324 |
+
- Output format specification
|
| 325 |
+
- Parameter tuning
|
| 326 |
+
|
| 327 |
+
3. **β
Application Development**
|
| 328 |
+
- Building user-friendly interfaces
|
| 329 |
+
- Error handling and validation
|
| 330 |
+
- User experience design
|
| 331 |
+
- Production deployment
|
| 332 |
+
|
| 333 |
+
4. **β
Cloud Infrastructure**
|
| 334 |
+
- Deploying to cloud platforms
|
| 335 |
+
- Managing dependencies
|
| 336 |
+
- Configuration management
|
| 337 |
+
- Continuous deployment
|
| 338 |
+
|
| 339 |
+
5. **β
Real-World Application**
|
| 340 |
+
- Solving actual business problems
|
| 341 |
+
- User-centered design
|
| 342 |
+
- Practical AI implementation
|
| 343 |
+
- Portfolio-worthy project
|
| 344 |
+
|
| 345 |
+
---
|
| 346 |
+
|
| 347 |
+
## π Next Steps After Deployment
|
| 348 |
+
|
| 349 |
+
### Immediate:
|
| 350 |
+
1. β
Test with various topics
|
| 351 |
+
2. β
Share with colleagues/classmates
|
| 352 |
+
3. β
Add to your portfolio
|
| 353 |
+
4. β
Gather feedback
|
| 354 |
+
|
| 355 |
+
### Short-term:
|
| 356 |
+
1. Customize example topics
|
| 357 |
+
2. Adjust default settings
|
| 358 |
+
3. Monitor usage analytics
|
| 359 |
+
4. Iterate based on feedback
|
| 360 |
+
|
| 361 |
+
### Long-term:
|
| 362 |
+
1. Add export functionality (PDF/DOCX)
|
| 363 |
+
2. Implement template saving
|
| 364 |
+
3. Add multi-language support
|
| 365 |
+
4. Build mobile-optimized version
|
| 366 |
+
|
| 367 |
+
---
|
| 368 |
+
|
| 369 |
+
## π Making It Stand Out
|
| 370 |
+
|
| 371 |
+
### Portfolio Tips:
|
| 372 |
+
|
| 373 |
+
1. **Documentation**
|
| 374 |
+
- Include screenshots in README
|
| 375 |
+
- Add demo GIF
|
| 376 |
+
- Write clear use cases
|
| 377 |
+
|
| 378 |
+
2. **Examples**
|
| 379 |
+
- Show diverse topics
|
| 380 |
+
- Demonstrate different audiences
|
| 381 |
+
- Highlight quality outputs
|
| 382 |
+
|
| 383 |
+
3. **Sharing**
|
| 384 |
+
- Blog post about development
|
| 385 |
+
- LinkedIn post with demo
|
| 386 |
+
- GitHub repo with code
|
| 387 |
+
- Video walkthrough
|
| 388 |
+
|
| 389 |
+
4. **Improvements**
|
| 390 |
+
- Gather user feedback
|
| 391 |
+
- Add requested features
|
| 392 |
+
- Keep dependencies updated
|
| 393 |
+
- Monitor and fix issues
|
| 394 |
+
|
| 395 |
+
---
|
| 396 |
+
|
| 397 |
+
## β
Pre-Deployment Checklist
|
| 398 |
+
|
| 399 |
+
Before deploying, ensure:
|
| 400 |
+
|
| 401 |
+
- [ ] All 3 files ready (app.py, requirements.txt, README.md)
|
| 402 |
+
- [ ] Files named correctly
|
| 403 |
+
- [ ] README has YAML frontmatter
|
| 404 |
+
- [ ] Test script passes locally
|
| 405 |
+
- [ ] Example topics work
|
| 406 |
+
- [ ] Error handling in place
|
| 407 |
+
- [ ] Loading messages shown
|
| 408 |
+
- [ ] HuggingFace account created
|
| 409 |
+
- [ ] Understand how to upload files
|
| 410 |
+
|
| 411 |
+
---
|
| 412 |
+
|
| 413 |
+
## π Summary
|
| 414 |
+
|
| 415 |
+
### What You've Built:
|
| 416 |
+
|
| 417 |
+
A **professional, cloud-deployed AI application** that:
|
| 418 |
+
- Generates PowerPoint scripts instantly
|
| 419 |
+
- Works for any topic
|
| 420 |
+
- Customizes for different audiences
|
| 421 |
+
- Runs entirely in the cloud
|
| 422 |
+
- Costs $0 to deploy and use
|
| 423 |
+
- Can be shared with anyone
|
| 424 |
+
- Requires no installation
|
| 425 |
+
|
| 426 |
+
### Time Investment:
|
| 427 |
+
- **Development**: Already done! β
|
| 428 |
+
- **Deployment**: 5 minutes
|
| 429 |
+
- **Testing**: 2 minutes
|
| 430 |
+
- **Total**: < 10 minutes to go live
|
| 431 |
+
|
| 432 |
+
### Technologies Used:
|
| 433 |
+
- Falcon3-1B-Instruct (TII)
|
| 434 |
+
- HuggingFace Inference API
|
| 435 |
+
- Gradio (UI framework)
|
| 436 |
+
- HuggingFace Spaces (hosting)
|
| 437 |
+
- Python 3.8+
|
| 438 |
+
|
| 439 |
+
---
|
| 440 |
+
|
| 441 |
+
## π Support
|
| 442 |
+
|
| 443 |
+
### If You Need Help:
|
| 444 |
+
|
| 445 |
+
**Documentation:**
|
| 446 |
+
- `QUICKSTART_HF.md` - Fast deployment guide
|
| 447 |
+
- `DEPLOYMENT_GUIDE.md` - Detailed instructions
|
| 448 |
+
- `test_hf_app.py` - Test your setup
|
| 449 |
+
|
| 450 |
+
**External Resources:**
|
| 451 |
+
- HuggingFace Docs: https://huggingface.co/docs/hub/spaces
|
| 452 |
+
- Gradio Guide: https://gradio.app/docs
|
| 453 |
+
- Community: https://discuss.huggingface.co
|
| 454 |
+
|
| 455 |
+
**Test Locally First:**
|
| 456 |
+
```bash
|
| 457 |
+
python test_hf_app.py
|
| 458 |
+
```
|
| 459 |
+
|
| 460 |
+
---
|
| 461 |
+
|
| 462 |
+
## π― Your Deployment URL
|
| 463 |
+
|
| 464 |
+
After deployment, your app will be at:
|
| 465 |
+
|
| 466 |
+
```
|
| 467 |
+
https://huggingface.co/spaces/YOUR_USERNAME/ppt-script-generator
|
| 468 |
+
```
|
| 469 |
+
|
| 470 |
+
**Share it everywhere!** π
|
| 471 |
+
|
| 472 |
+
---
|
| 473 |
+
|
| 474 |
+
**Built for: Johns Hopkins University Agentic AI Certificate Program** π
|
| 475 |
+
**Demonstrates: Caselet 4 from HuggingFace Prompt Engineering Lab** π
|
| 476 |
+
**Status: Production Ready** β
|
| 477 |
+
**Cost: $0** π°
|
| 478 |
+
**Time to Deploy: < 5 minutes** β‘
|
| 479 |
+
|
| 480 |
+
---
|
| 481 |
+
|
| 482 |
+
*Last Updated: January 2026*
|
| 483 |
+
*Version: HuggingFace Spaces Edition*
|
| 484 |
+
*Ready to Deploy!* π
|
QUICKSTART_HF.md
ADDED
|
@@ -0,0 +1,347 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# π Quick Start: Deploy to HuggingFace Spaces in 5 Minutes
|
| 2 |
+
|
| 3 |
+
## What You're Deploying
|
| 4 |
+
|
| 5 |
+
A **PowerPoint Script Generator** that uses AI to create presentation scripts for any topic.
|
| 6 |
+
|
| 7 |
+
**No installation required!** Everything runs in the cloud on HuggingFace Spaces.
|
| 8 |
+
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
## β‘ Super Fast Deployment (3 Steps)
|
| 12 |
+
|
| 13 |
+
### Step 1: Create a HuggingFace Account (if needed)
|
| 14 |
+
|
| 15 |
+
1. Go to https://huggingface.co/join
|
| 16 |
+
2. Sign up (free!)
|
| 17 |
+
3. Verify your email
|
| 18 |
+
|
| 19 |
+
### Step 2: Create a New Space
|
| 20 |
+
|
| 21 |
+
1. Go to https://huggingface.co/new-space
|
| 22 |
+
2. Fill in:
|
| 23 |
+
- **Owner**: Your username
|
| 24 |
+
- **Space name**: `ppt-script-generator`
|
| 25 |
+
- **License**: MIT
|
| 26 |
+
- **Select SDK**: Choose **Gradio**
|
| 27 |
+
- **Space hardware**: CPU basic (free)
|
| 28 |
+
- **Visibility**: Public
|
| 29 |
+
3. Click **"Create Space"**
|
| 30 |
+
|
| 31 |
+
### Step 3: Upload Your Files
|
| 32 |
+
|
| 33 |
+
You need to upload 3 files:
|
| 34 |
+
|
| 35 |
+
1. **Click "Files and versions"** tab
|
| 36 |
+
2. **Click "Add file" β "Upload files"**
|
| 37 |
+
3. **Upload these 3 files:**
|
| 38 |
+
|
| 39 |
+
π **File 1: `app.py`**
|
| 40 |
+
- Upload the `app.py` file from this package
|
| 41 |
+
|
| 42 |
+
π **File 2: `requirements.txt`**
|
| 43 |
+
- Upload `requirements_hf.txt`
|
| 44 |
+
- **IMPORTANT**: Rename it to `requirements.txt` when uploading
|
| 45 |
+
|
| 46 |
+
π **File 3: `README.md`**
|
| 47 |
+
- Upload `README_HF.md`
|
| 48 |
+
- **IMPORTANT**: Rename it to `README.md` when uploading
|
| 49 |
+
|
| 50 |
+
4. **Click "Commit changes to main"**
|
| 51 |
+
|
| 52 |
+
### Step 4: Wait for Build
|
| 53 |
+
|
| 54 |
+
- HuggingFace automatically builds your Space (takes 1-2 minutes)
|
| 55 |
+
- You'll see a progress indicator
|
| 56 |
+
- When complete, you'll see "App" tab become active
|
| 57 |
+
|
| 58 |
+
### Step 5: Use Your App!
|
| 59 |
+
|
| 60 |
+
- Click the **"App"** tab
|
| 61 |
+
- Your app is now live!
|
| 62 |
+
- Share the URL: `https://huggingface.co/spaces/YOUR_USERNAME/ppt-script-generator`
|
| 63 |
+
|
| 64 |
+
---
|
| 65 |
+
|
| 66 |
+
## π― Using Your App
|
| 67 |
+
|
| 68 |
+
### Try It Out
|
| 69 |
+
|
| 70 |
+
1. **Enter a topic**: e.g., "The Future of Renewable Energy"
|
| 71 |
+
2. **Set number of slides**: e.g., 5
|
| 72 |
+
3. **Choose audience**: e.g., "Business executives"
|
| 73 |
+
4. **Select tone**: e.g., "Professional"
|
| 74 |
+
5. **Click "Generate Presentation Script"**
|
| 75 |
+
6. **Wait 10-30 seconds** for AI to generate
|
| 76 |
+
7. **Copy the script** and use it!
|
| 77 |
+
|
| 78 |
+
### Example Input/Output
|
| 79 |
+
|
| 80 |
+
**Input:**
|
| 81 |
+
```
|
| 82 |
+
Topic: Introduction to Artificial Intelligence
|
| 83 |
+
Slides: 5
|
| 84 |
+
Audience: Students
|
| 85 |
+
Tone: Educational
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
**Output:**
|
| 89 |
+
```
|
| 90 |
+
---
|
| 91 |
+
Slide 1: What is Artificial Intelligence?
|
| 92 |
+
|
| 93 |
+
Speaker Script:
|
| 94 |
+
Welcome everyone! Today we're diving into the fascinating world
|
| 95 |
+
of Artificial Intelligence. AI is the science of making computers
|
| 96 |
+
think and learn like humans do. Imagine teaching a computer to
|
| 97 |
+
recognize your voice, recommend movies you'll love, or even drive
|
| 98 |
+
a car - that's all AI!
|
| 99 |
+
|
| 100 |
+
Key Points:
|
| 101 |
+
- AI makes computers intelligent
|
| 102 |
+
- Mimics human thinking and learning
|
| 103 |
+
- Used in everyday technology
|
| 104 |
+
- Growing field with huge potential
|
| 105 |
+
|
| 106 |
+
Timing: 45 seconds
|
| 107 |
+
|
| 108 |
+
---
|
| 109 |
+
|
| 110 |
+
[... 4 more slides ...]
|
| 111 |
+
```
|
| 112 |
+
|
| 113 |
+
---
|
| 114 |
+
|
| 115 |
+
## π File Structure (What You Uploaded)
|
| 116 |
+
|
| 117 |
+
```
|
| 118 |
+
Your HuggingFace Space:
|
| 119 |
+
β
|
| 120 |
+
βββ app.py # Main application
|
| 121 |
+
βββ requirements.txt # Python dependencies (gradio, huggingface_hub)
|
| 122 |
+
βββ README.md # Space description (with YAML frontmatter)
|
| 123 |
+
```
|
| 124 |
+
|
| 125 |
+
---
|
| 126 |
+
|
| 127 |
+
## β
Verification Checklist
|
| 128 |
+
|
| 129 |
+
After deployment, verify:
|
| 130 |
+
|
| 131 |
+
- [ ] Build completed successfully (green checkmark)
|
| 132 |
+
- [ ] "App" tab is accessible
|
| 133 |
+
- [ ] Example topics load correctly
|
| 134 |
+
- [ ] Generate button works
|
| 135 |
+
- [ ] Script output appears after 10-30 seconds
|
| 136 |
+
- [ ] Copy button works
|
| 137 |
+
- [ ] All dropdowns function properly
|
| 138 |
+
|
| 139 |
+
---
|
| 140 |
+
|
| 141 |
+
## π Common Issues & Fixes
|
| 142 |
+
|
| 143 |
+
### Issue 1: Build Failed
|
| 144 |
+
|
| 145 |
+
**Error**: Red X on build status
|
| 146 |
+
|
| 147 |
+
**Fix**:
|
| 148 |
+
1. Check "Logs" tab for error message
|
| 149 |
+
2. Common causes:
|
| 150 |
+
- Wrong file names (must be exact: `app.py`, `requirements.txt`, `README.md`)
|
| 151 |
+
- Missing YAML frontmatter in README.md
|
| 152 |
+
- Syntax error in app.py
|
| 153 |
+
|
| 154 |
+
### Issue 2: "Sleeping" Message
|
| 155 |
+
|
| 156 |
+
**Status**: App shows "This Space is sleeping"
|
| 157 |
+
|
| 158 |
+
**Fix**:
|
| 159 |
+
- Normal for free tier after inactivity
|
| 160 |
+
- Click anywhere to wake it up
|
| 161 |
+
- Takes 10-20 seconds to restart
|
| 162 |
+
|
| 163 |
+
### Issue 3: Generation Fails
|
| 164 |
+
|
| 165 |
+
**Error**: "API rate limit exceeded" or timeout
|
| 166 |
+
|
| 167 |
+
**Fix**:
|
| 168 |
+
- Wait 60 seconds and try again
|
| 169 |
+
- Reduce number of slides (try 3-5)
|
| 170 |
+
- Reduce max tokens (try 1500)
|
| 171 |
+
- This is normal during high server load
|
| 172 |
+
|
| 173 |
+
### Issue 4: Slow Generation
|
| 174 |
+
|
| 175 |
+
**Status**: Takes > 1 minute to generate
|
| 176 |
+
|
| 177 |
+
**Fix**:
|
| 178 |
+
- Normal for free tier
|
| 179 |
+
- HuggingFace API might be busy
|
| 180 |
+
- Try off-peak hours
|
| 181 |
+
- Consider upgrading to HF Pro for faster inference
|
| 182 |
+
|
| 183 |
+
---
|
| 184 |
+
|
| 185 |
+
## π¨ Customization (After Deployment)
|
| 186 |
+
|
| 187 |
+
Want to change something? Easy!
|
| 188 |
+
|
| 189 |
+
### Change App Title
|
| 190 |
+
|
| 191 |
+
1. Click "Files and versions"
|
| 192 |
+
2. Click `README.md`
|
| 193 |
+
3. Edit the `title:` line in YAML frontmatter
|
| 194 |
+
4. Commit changes
|
| 195 |
+
5. Space rebuilds automatically
|
| 196 |
+
|
| 197 |
+
### Change Example Topics
|
| 198 |
+
|
| 199 |
+
1. Click "Files and versions"
|
| 200 |
+
2. Click `app.py`
|
| 201 |
+
3. Find the `gr.Examples` section
|
| 202 |
+
4. Edit the example list
|
| 203 |
+
5. Commit changes
|
| 204 |
+
|
| 205 |
+
### Adjust Defaults
|
| 206 |
+
|
| 207 |
+
In `app.py`, find and modify:
|
| 208 |
+
```python
|
| 209 |
+
num_slides = gr.Slider(
|
| 210 |
+
minimum=3,
|
| 211 |
+
maximum=10,
|
| 212 |
+
value=5, # Change this default
|
| 213 |
+
...
|
| 214 |
+
)
|
| 215 |
+
```
|
| 216 |
+
|
| 217 |
+
---
|
| 218 |
+
|
| 219 |
+
## π Monitor Your Space
|
| 220 |
+
|
| 221 |
+
### View Analytics
|
| 222 |
+
|
| 223 |
+
1. Go to your Space page
|
| 224 |
+
2. Click "Analytics" tab
|
| 225 |
+
3. See:
|
| 226 |
+
- Total users
|
| 227 |
+
- Active users
|
| 228 |
+
- Usage patterns
|
| 229 |
+
|
| 230 |
+
### Check Logs
|
| 231 |
+
|
| 232 |
+
1. Click "Logs" tab
|
| 233 |
+
2. See real-time output
|
| 234 |
+
3. Debug any issues
|
| 235 |
+
|
| 236 |
+
---
|
| 237 |
+
|
| 238 |
+
## π Sharing Your Space
|
| 239 |
+
|
| 240 |
+
Your Space URL:
|
| 241 |
+
```
|
| 242 |
+
https://huggingface.co/spaces/YOUR_USERNAME/ppt-script-generator
|
| 243 |
+
```
|
| 244 |
+
|
| 245 |
+
### Share On:
|
| 246 |
+
- Social media (Twitter, LinkedIn)
|
| 247 |
+
- Your website or blog
|
| 248 |
+
- Email signature
|
| 249 |
+
- Portfolio
|
| 250 |
+
- GitHub README
|
| 251 |
+
|
| 252 |
+
### Embed in Website
|
| 253 |
+
|
| 254 |
+
```html
|
| 255 |
+
<gradio-app
|
| 256 |
+
src="https://huggingface.co/spaces/YOUR_USERNAME/ppt-script-generator">
|
| 257 |
+
</gradio-app>
|
| 258 |
+
<script
|
| 259 |
+
type="module"
|
| 260 |
+
src="https://gradio.s3-us-west-2.amazonaws.com/4.44.0/gradio.js">
|
| 261 |
+
</script>
|
| 262 |
+
```
|
| 263 |
+
|
| 264 |
+
---
|
| 265 |
+
|
| 266 |
+
## π‘ Tips for Success
|
| 267 |
+
|
| 268 |
+
### For Best Results:
|
| 269 |
+
|
| 270 |
+
1. **Be Specific**:
|
| 271 |
+
- β
"The Impact of AI on Healthcare Diagnostics"
|
| 272 |
+
- β "AI stuff"
|
| 273 |
+
|
| 274 |
+
2. **Choose Right Audience**:
|
| 275 |
+
- Match to who will actually listen
|
| 276 |
+
- Affects language complexity
|
| 277 |
+
|
| 278 |
+
3. **Appropriate Tone**:
|
| 279 |
+
- Professional for business
|
| 280 |
+
- Educational for students
|
| 281 |
+
- Technical for engineers
|
| 282 |
+
|
| 283 |
+
4. **Optimal Slides**:
|
| 284 |
+
- 3-7 slides work best
|
| 285 |
+
- More slides = slower generation
|
| 286 |
+
|
| 287 |
+
5. **Review Output**:
|
| 288 |
+
- Always customize to your style
|
| 289 |
+
- Add personal examples
|
| 290 |
+
- Practice timing
|
| 291 |
+
|
| 292 |
+
---
|
| 293 |
+
|
| 294 |
+
## π What This Demonstrates
|
| 295 |
+
|
| 296 |
+
This project shows your understanding of:
|
| 297 |
+
|
| 298 |
+
- β
**LLM Deployment**: Using AI models in production
|
| 299 |
+
- β
**Prompt Engineering**: Crafting effective prompts
|
| 300 |
+
- β
**Cloud Infrastructure**: Deploying to HuggingFace
|
| 301 |
+
- β
**UI/UX Design**: Building user-friendly interfaces
|
| 302 |
+
- β
**API Integration**: Using HuggingFace Inference API
|
| 303 |
+
- β
**Real-world Application**: Solving actual business problems
|
| 304 |
+
|
| 305 |
+
Perfect for your **Johns Hopkins Agentic AI Certificate** portfolio!
|
| 306 |
+
|
| 307 |
+
---
|
| 308 |
+
|
| 309 |
+
## π Need Help?
|
| 310 |
+
|
| 311 |
+
### Resources:
|
| 312 |
+
- **HuggingFace Docs**: https://huggingface.co/docs/hub/spaces
|
| 313 |
+
- **Gradio Guide**: https://gradio.app/docs
|
| 314 |
+
- **Community Forum**: https://discuss.huggingface.co
|
| 315 |
+
|
| 316 |
+
### Files Included:
|
| 317 |
+
- `DEPLOYMENT_GUIDE.md` - Detailed deployment instructions
|
| 318 |
+
- `test_hf_app.py` - Test script for local verification
|
| 319 |
+
- `app.py` - Main application code
|
| 320 |
+
- `README_HF.md` - Space description
|
| 321 |
+
|
| 322 |
+
---
|
| 323 |
+
|
| 324 |
+
## β¨ You're Done!
|
| 325 |
+
|
| 326 |
+
**Congratulations!** π
|
| 327 |
+
|
| 328 |
+
Your AI-powered PowerPoint Script Generator is now live on HuggingFace Spaces!
|
| 329 |
+
|
| 330 |
+
**Next steps:**
|
| 331 |
+
1. Test it with different topics
|
| 332 |
+
2. Share the URL with friends/colleagues
|
| 333 |
+
3. Add to your portfolio
|
| 334 |
+
4. Get feedback and iterate
|
| 335 |
+
|
| 336 |
+
**Your live app:**
|
| 337 |
+
```
|
| 338 |
+
https://huggingface.co/spaces/YOUR_USERNAME/ppt-script-generator
|
| 339 |
+
```
|
| 340 |
+
|
| 341 |
+
---
|
| 342 |
+
|
| 343 |
+
**Time to deploy: < 5 minutes** β‘
|
| 344 |
+
**Cost: $0 (completely free!)** π°
|
| 345 |
+
**Accessibility: Anyone, anywhere** π
|
| 346 |
+
|
| 347 |
+
**Built for: Johns Hopkins Agentic AI Program** π
|
README_HF.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: PowerPoint Script Generator
|
| 3 |
+
emoji: π€
|
| 4 |
+
colorFrom: purple
|
| 5 |
+
colorTo: blue
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: 4.44.0
|
| 8 |
+
app_file: app.py
|
| 9 |
+
pinned: false
|
| 10 |
+
license: mit
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# π€ PowerPoint Script Generator
|
| 14 |
+
|
| 15 |
+
**Generate professional presentation scripts instantly using AI!**
|
| 16 |
+
|
| 17 |
+
This Gradio application uses **Falcon3-1B-Instruct** to automatically create speaker scripts for PowerPoint presentations on any topic.
|
| 18 |
+
|
| 19 |
+
## β¨ Features
|
| 20 |
+
|
| 21 |
+
- π **Topic-based generation** - Enter any presentation topic
|
| 22 |
+
- π **Customizable slides** - Generate scripts for 3-10 slides
|
| 23 |
+
- π₯ **Multiple audiences** - Students, executives, technical professionals, and more
|
| 24 |
+
- π¨ **Tone options** - Professional, casual, technical, inspirational, etc.
|
| 25 |
+
- βοΈ **Advanced controls** - Adjust temperature and max tokens
|
| 26 |
+
- π‘ **Example topics** - Pre-loaded examples to get started
|
| 27 |
+
- β‘ **Cloud-based** - No installation required!
|
| 28 |
+
|
| 29 |
+
## π How to Use
|
| 30 |
+
|
| 31 |
+
1. **Enter your presentation topic** (e.g., "Introduction to Cloud Computing")
|
| 32 |
+
2. **Select number of slides** (3-10 recommended)
|
| 33 |
+
3. **Choose your audience** (who will be listening?)
|
| 34 |
+
4. **Select tone** (how formal should it be?)
|
| 35 |
+
5. **Click Generate** and wait 10-30 seconds
|
| 36 |
+
6. **Copy your script** and use it in your presentation!
|
| 37 |
+
|
| 38 |
+
## π What You Get
|
| 39 |
+
|
| 40 |
+
For each slide, you'll receive:
|
| 41 |
+
- **Slide Title** - Clear, descriptive heading
|
| 42 |
+
- **Speaker Script** - 2-4 sentences of what to say
|
| 43 |
+
- **Key Points** - Bullet points highlighting main ideas
|
| 44 |
+
- **Timing** - Suggested duration for the slide
|
| 45 |
+
|
| 46 |
+
## π‘ Example Topics
|
| 47 |
+
|
| 48 |
+
- "Quarterly Sales Performance Review"
|
| 49 |
+
- "Introduction to Machine Learning"
|
| 50 |
+
- "Cybersecurity Best Practices"
|
| 51 |
+
- "The Future of Renewable Energy"
|
| 52 |
+
- "Building a Strong Company Culture"
|
| 53 |
+
|
| 54 |
+
## π― Use Cases
|
| 55 |
+
|
| 56 |
+
- Business presentations
|
| 57 |
+
- Educational lectures
|
| 58 |
+
- Conference talks
|
| 59 |
+
- Investor pitches
|
| 60 |
+
- Training sessions
|
| 61 |
+
- Sales presentations
|
| 62 |
+
|
| 63 |
+
## π οΈ Technical Details
|
| 64 |
+
|
| 65 |
+
- **Model**: Falcon3-1B-Instruct (via HuggingFace Inference API)
|
| 66 |
+
- **Framework**: Gradio
|
| 67 |
+
- **Deployment**: HuggingFace Spaces
|
| 68 |
+
- **No local setup required!**
|
| 69 |
+
|
| 70 |
+
## π Tips for Best Results
|
| 71 |
+
|
| 72 |
+
1. **Be specific** with your topic description
|
| 73 |
+
2. **Choose appropriate** audience and tone
|
| 74 |
+
3. **Use 3-7 slides** for optimal quality
|
| 75 |
+
4. **Review and customize** the generated script
|
| 76 |
+
5. **Practice** with the suggested timings
|
| 77 |
+
|
| 78 |
+
## π Created For
|
| 79 |
+
|
| 80 |
+
Johns Hopkins University - Agentic AI Certificate Program
|
| 81 |
+
|
| 82 |
+
Demonstrating practical applications of:
|
| 83 |
+
- Large Language Models (LLMs)
|
| 84 |
+
- Prompt Engineering
|
| 85 |
+
- AI-powered content generation
|
| 86 |
+
|
| 87 |
+
## π License
|
| 88 |
+
|
| 89 |
+
MIT License - Free to use for educational and commercial purposes
|
| 90 |
+
|
| 91 |
+
---
|
| 92 |
+
|
| 93 |
+
**Powered by Falcon3-1B-Instruct via HuggingFace Inference API** π€
|
app.py
ADDED
|
@@ -0,0 +1,343 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
PowerPoint Script Generator for HuggingFace Spaces
|
| 3 |
+
Uses HuggingFace Inference API - No local model download required!
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import gradio as gr
|
| 7 |
+
from huggingface_hub import InferenceClient
|
| 8 |
+
import os
|
| 9 |
+
import time
|
| 10 |
+
|
| 11 |
+
# ============================================================================
|
| 12 |
+
# HUGGINGFACE INFERENCE CLIENT SETUP
|
| 13 |
+
# ============================================================================
|
| 14 |
+
|
| 15 |
+
class PPTScriptGenerator:
|
| 16 |
+
"""Handles script generation using HuggingFace Inference API"""
|
| 17 |
+
|
| 18 |
+
def __init__(self):
|
| 19 |
+
"""Initialize the inference client"""
|
| 20 |
+
# Using the Inference API - no local model needed!
|
| 21 |
+
self.client = InferenceClient(
|
| 22 |
+
model="tiiuae/Falcon3-1B-Instruct",
|
| 23 |
+
token=os.getenv("HF_TOKEN") # HF Spaces automatically provides this
|
| 24 |
+
)
|
| 25 |
+
print("β
Inference client initialized")
|
| 26 |
+
|
| 27 |
+
def create_prompt(self, topic, num_slides, audience="General audience", tone="Professional"):
|
| 28 |
+
"""
|
| 29 |
+
Create a structured prompt for PPT script generation
|
| 30 |
+
|
| 31 |
+
Args:
|
| 32 |
+
topic: The presentation topic
|
| 33 |
+
num_slides: Number of slides to generate scripts for
|
| 34 |
+
audience: Target audience
|
| 35 |
+
tone: Presentation tone
|
| 36 |
+
|
| 37 |
+
Returns:
|
| 38 |
+
Formatted prompt string
|
| 39 |
+
"""
|
| 40 |
+
prompt = f"""You are an expert presentation script writer. Your goal is to create engaging, clear, and well-structured speaker notes for a PowerPoint presentation.
|
| 41 |
+
|
| 42 |
+
**Presentation Topic**: {topic}
|
| 43 |
+
**Number of Slides**: {num_slides}
|
| 44 |
+
**Target Audience**: {audience}
|
| 45 |
+
**Tone**: {tone}
|
| 46 |
+
|
| 47 |
+
**Instructions**:
|
| 48 |
+
1. Generate a complete script for each slide in the presentation
|
| 49 |
+
2. Each slide should have:
|
| 50 |
+
- A clear slide title
|
| 51 |
+
- Detailed speaker notes (2-4 sentences)
|
| 52 |
+
- Key talking points (3-4 bullet points)
|
| 53 |
+
- Suggested timing in seconds
|
| 54 |
+
|
| 55 |
+
3. Ensure smooth transitions between slides
|
| 56 |
+
4. Make the content engaging and appropriate for the target audience
|
| 57 |
+
5. Use the specified tone throughout
|
| 58 |
+
|
| 59 |
+
**Output Format**:
|
| 60 |
+
For each slide, provide:
|
| 61 |
+
|
| 62 |
+
---
|
| 63 |
+
**Slide [Number]: [Title]**
|
| 64 |
+
|
| 65 |
+
**Speaker Script**:
|
| 66 |
+
[Detailed script with 2-4 sentences that the presenter should say]
|
| 67 |
+
|
| 68 |
+
**Key Points**:
|
| 69 |
+
- [Point 1]
|
| 70 |
+
- [Point 2]
|
| 71 |
+
- [Point 3]
|
| 72 |
+
|
| 73 |
+
**Timing**: [Suggested time in seconds]
|
| 74 |
+
|
| 75 |
+
---
|
| 76 |
+
|
| 77 |
+
Begin generating the presentation script now:"""
|
| 78 |
+
|
| 79 |
+
return prompt
|
| 80 |
+
|
| 81 |
+
def generate_script(self, topic, num_slides=5, audience="General audience",
|
| 82 |
+
tone="Professional", temperature=0.7, max_tokens=2000):
|
| 83 |
+
"""
|
| 84 |
+
Generate the PPT script using HuggingFace Inference API
|
| 85 |
+
|
| 86 |
+
Args:
|
| 87 |
+
topic: Presentation topic
|
| 88 |
+
num_slides: Number of slides
|
| 89 |
+
audience: Target audience
|
| 90 |
+
tone: Presentation tone
|
| 91 |
+
temperature: Sampling temperature (0.0-1.0)
|
| 92 |
+
max_tokens: Maximum tokens to generate
|
| 93 |
+
|
| 94 |
+
Returns:
|
| 95 |
+
Generated script as string
|
| 96 |
+
"""
|
| 97 |
+
if not topic or not topic.strip():
|
| 98 |
+
return "β οΈ Please enter a presentation topic."
|
| 99 |
+
|
| 100 |
+
try:
|
| 101 |
+
prompt = self.create_prompt(topic, num_slides, audience, tone)
|
| 102 |
+
|
| 103 |
+
# Generate using the Inference API
|
| 104 |
+
response = self.client.text_generation(
|
| 105 |
+
prompt,
|
| 106 |
+
max_new_tokens=max_tokens,
|
| 107 |
+
temperature=temperature,
|
| 108 |
+
top_p=0.9,
|
| 109 |
+
repetition_penalty=1.1,
|
| 110 |
+
do_sample=True,
|
| 111 |
+
return_full_text=False
|
| 112 |
+
)
|
| 113 |
+
|
| 114 |
+
return response.strip()
|
| 115 |
+
|
| 116 |
+
except Exception as e:
|
| 117 |
+
error_msg = f"β Error generating script: {str(e)}\n\n"
|
| 118 |
+
error_msg += "π‘ This might be due to:\n"
|
| 119 |
+
error_msg += "- High server load (try again in a moment)\n"
|
| 120 |
+
error_msg += "- Topic complexity (try a simpler topic)\n"
|
| 121 |
+
error_msg += "- Token limit exceeded (reduce number of slides)\n"
|
| 122 |
+
return error_msg
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
# ============================================================================
|
| 126 |
+
# GRADIO INTERFACE FOR HUGGINGFACE SPACES
|
| 127 |
+
# ============================================================================
|
| 128 |
+
|
| 129 |
+
def create_gradio_interface():
|
| 130 |
+
"""Create the Gradio UI optimized for HuggingFace Spaces"""
|
| 131 |
+
|
| 132 |
+
# Initialize the generator
|
| 133 |
+
generator = PPTScriptGenerator()
|
| 134 |
+
|
| 135 |
+
# Welcome message
|
| 136 |
+
welcome_html = """
|
| 137 |
+
<div style="text-align: center; padding: 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-radius: 10px; margin-bottom: 20px;">
|
| 138 |
+
<h1 style="color: white; margin: 0; font-size: 2.5em;">π€ PowerPoint Script Generator</h1>
|
| 139 |
+
<p style="color: #f0f0f0; font-size: 1.2em; margin-top: 10px;">
|
| 140 |
+
Powered by Falcon3-1B-Instruct
|
| 141 |
+
</p>
|
| 142 |
+
<p style="color: #e0e0e0; font-size: 0.9em; margin-top: 5px;">
|
| 143 |
+
Generate professional presentation scripts in seconds β¨
|
| 144 |
+
</p>
|
| 145 |
+
</div>
|
| 146 |
+
"""
|
| 147 |
+
|
| 148 |
+
# Instructions
|
| 149 |
+
instructions_html = """
|
| 150 |
+
<div style="background: #f8f9fa; padding: 15px; border-radius: 8px; margin-bottom: 20px; border-left: 4px solid #667eea;">
|
| 151 |
+
<h3 style="margin-top: 0; color: #667eea;">π How to Use:</h3>
|
| 152 |
+
<ol style="margin-bottom: 0;">
|
| 153 |
+
<li><strong>Enter your topic</strong> - Be specific about what you want to present</li>
|
| 154 |
+
<li><strong>Choose number of slides</strong> - Select 3-10 slides</li>
|
| 155 |
+
<li><strong>Select audience & tone</strong> - Customize for your needs</li>
|
| 156 |
+
<li><strong>Click Generate</strong> - Wait 10-30 seconds for your script</li>
|
| 157 |
+
</ol>
|
| 158 |
+
</div>
|
| 159 |
+
"""
|
| 160 |
+
|
| 161 |
+
def generate_wrapper(topic, num_slides, audience, tone, temperature, max_tokens):
|
| 162 |
+
"""Wrapper function for Gradio"""
|
| 163 |
+
if not topic.strip():
|
| 164 |
+
return "β οΈ Please enter a presentation topic."
|
| 165 |
+
|
| 166 |
+
# Show generating message
|
| 167 |
+
yield "π Generating your presentation script...\n\nThis may take 10-30 seconds depending on server load.\n\nPlease wait..."
|
| 168 |
+
|
| 169 |
+
# Generate script
|
| 170 |
+
script = generator.generate_script(
|
| 171 |
+
topic=topic,
|
| 172 |
+
num_slides=num_slides,
|
| 173 |
+
audience=audience,
|
| 174 |
+
tone=tone,
|
| 175 |
+
temperature=temperature,
|
| 176 |
+
max_tokens=max_tokens
|
| 177 |
+
)
|
| 178 |
+
|
| 179 |
+
yield script
|
| 180 |
+
|
| 181 |
+
# Create Gradio interface
|
| 182 |
+
with gr.Blocks(theme=gr.themes.Soft(), title="PPT Script Generator") as demo:
|
| 183 |
+
|
| 184 |
+
gr.HTML(welcome_html)
|
| 185 |
+
gr.HTML(instructions_html)
|
| 186 |
+
|
| 187 |
+
with gr.Row():
|
| 188 |
+
with gr.Column(scale=1):
|
| 189 |
+
gr.Markdown("### π Input Configuration")
|
| 190 |
+
|
| 191 |
+
# Main inputs
|
| 192 |
+
topic_input = gr.Textbox(
|
| 193 |
+
label="π Presentation Topic",
|
| 194 |
+
placeholder="e.g., Introduction to Artificial Intelligence in Healthcare",
|
| 195 |
+
lines=3,
|
| 196 |
+
info="Enter the main topic of your presentation"
|
| 197 |
+
)
|
| 198 |
+
|
| 199 |
+
num_slides = gr.Slider(
|
| 200 |
+
minimum=3,
|
| 201 |
+
maximum=10,
|
| 202 |
+
value=5,
|
| 203 |
+
step=1,
|
| 204 |
+
label="π Number of Slides",
|
| 205 |
+
info="How many slides do you need scripts for?"
|
| 206 |
+
)
|
| 207 |
+
|
| 208 |
+
audience = gr.Dropdown(
|
| 209 |
+
choices=[
|
| 210 |
+
"General audience",
|
| 211 |
+
"Business executives",
|
| 212 |
+
"Technical professionals",
|
| 213 |
+
"Students",
|
| 214 |
+
"Healthcare professionals",
|
| 215 |
+
"Marketing professionals",
|
| 216 |
+
"Investors",
|
| 217 |
+
"Academic researchers"
|
| 218 |
+
],
|
| 219 |
+
value="General audience",
|
| 220 |
+
label="π₯ Target Audience",
|
| 221 |
+
info="Who will be listening to this presentation?"
|
| 222 |
+
)
|
| 223 |
+
|
| 224 |
+
tone = gr.Dropdown(
|
| 225 |
+
choices=[
|
| 226 |
+
"Professional",
|
| 227 |
+
"Casual and friendly",
|
| 228 |
+
"Technical and detailed",
|
| 229 |
+
"Inspirational",
|
| 230 |
+
"Educational",
|
| 231 |
+
"Persuasive"
|
| 232 |
+
],
|
| 233 |
+
value="Professional",
|
| 234 |
+
label="π¨ Presentation Tone",
|
| 235 |
+
info="What style should the script have?"
|
| 236 |
+
)
|
| 237 |
+
|
| 238 |
+
# Advanced settings
|
| 239 |
+
with gr.Accordion("βοΈ Advanced Generation Settings", open=False):
|
| 240 |
+
temperature = gr.Slider(
|
| 241 |
+
minimum=0.3,
|
| 242 |
+
maximum=0.9,
|
| 243 |
+
value=0.7,
|
| 244 |
+
step=0.1,
|
| 245 |
+
label="π‘οΈ Temperature",
|
| 246 |
+
info="Higher = more creative, Lower = more focused"
|
| 247 |
+
)
|
| 248 |
+
|
| 249 |
+
max_tokens = gr.Slider(
|
| 250 |
+
minimum=1000,
|
| 251 |
+
maximum=3000,
|
| 252 |
+
value=2000,
|
| 253 |
+
step=100,
|
| 254 |
+
label="π Max Tokens",
|
| 255 |
+
info="Maximum length of generated script"
|
| 256 |
+
)
|
| 257 |
+
|
| 258 |
+
# Generate button
|
| 259 |
+
generate_btn = gr.Button(
|
| 260 |
+
"π Generate Presentation Script",
|
| 261 |
+
variant="primary",
|
| 262 |
+
size="lg"
|
| 263 |
+
)
|
| 264 |
+
|
| 265 |
+
# Example topics
|
| 266 |
+
gr.Markdown("### π‘ Example Topics:")
|
| 267 |
+
gr.Examples(
|
| 268 |
+
examples=[
|
| 269 |
+
["The Future of Renewable Energy", 5, "Business executives", "Professional"],
|
| 270 |
+
["Introduction to Machine Learning", 7, "Students", "Educational"],
|
| 271 |
+
["Quarterly Sales Performance Review", 4, "Business executives", "Professional"],
|
| 272 |
+
["Cybersecurity Best Practices for Small Businesses", 6, "Technical professionals", "Technical and detailed"],
|
| 273 |
+
["Building a Strong Company Culture", 5, "Business executives", "Inspirational"]
|
| 274 |
+
],
|
| 275 |
+
inputs=[topic_input, num_slides, audience, tone],
|
| 276 |
+
label="Click any example to load it"
|
| 277 |
+
)
|
| 278 |
+
|
| 279 |
+
with gr.Column(scale=1):
|
| 280 |
+
gr.Markdown("### π Generated Script")
|
| 281 |
+
|
| 282 |
+
output = gr.Textbox(
|
| 283 |
+
label="Presentation Script",
|
| 284 |
+
lines=30,
|
| 285 |
+
max_lines=35,
|
| 286 |
+
show_copy_button=True,
|
| 287 |
+
placeholder="Your generated presentation script will appear here...\n\nβ±οΈ Generation typically takes 10-30 seconds.",
|
| 288 |
+
info="Copy this script and use it for your presentation!"
|
| 289 |
+
)
|
| 290 |
+
|
| 291 |
+
# Tips section
|
| 292 |
+
with gr.Accordion("π‘ Tips for Best Results", open=False):
|
| 293 |
+
gr.Markdown("""
|
| 294 |
+
**Best Practices:**
|
| 295 |
+
- π Be specific in your topic description
|
| 296 |
+
- π― Choose appropriate audience and tone
|
| 297 |
+
- β±οΈ Use 3-7 slides for best results
|
| 298 |
+
- π Try different temperatures for variety
|
| 299 |
+
- βοΈ Review and customize the output
|
| 300 |
+
- π€ Practice with the suggested timings
|
| 301 |
+
|
| 302 |
+
**If generation fails:**
|
| 303 |
+
- Wait a moment and try again (server might be busy)
|
| 304 |
+
- Simplify your topic
|
| 305 |
+
- Reduce number of slides
|
| 306 |
+
- Lower max tokens to 1500
|
| 307 |
+
""")
|
| 308 |
+
|
| 309 |
+
# Connect the button to the function
|
| 310 |
+
generate_btn.click(
|
| 311 |
+
fn=generate_wrapper,
|
| 312 |
+
inputs=[topic_input, num_slides, audience, tone, temperature, max_tokens],
|
| 313 |
+
outputs=output
|
| 314 |
+
)
|
| 315 |
+
|
| 316 |
+
# Footer
|
| 317 |
+
gr.Markdown("""
|
| 318 |
+
---
|
| 319 |
+
<div style="text-align: center; color: #666; font-size: 0.9em;">
|
| 320 |
+
<p>π€ Powered by <strong>Falcon3-1B-Instruct</strong> via HuggingFace Inference API</p>
|
| 321 |
+
<p>Built with β€οΈ using Gradio | No local model download required!</p>
|
| 322 |
+
</div>
|
| 323 |
+
""")
|
| 324 |
+
|
| 325 |
+
return demo
|
| 326 |
+
|
| 327 |
+
|
| 328 |
+
# ============================================================================
|
| 329 |
+
# MAIN EXECUTION
|
| 330 |
+
# ============================================================================
|
| 331 |
+
|
| 332 |
+
if __name__ == "__main__":
|
| 333 |
+
print("="*80)
|
| 334 |
+
print("π€ PowerPoint Script Generator - HuggingFace Spaces Version")
|
| 335 |
+
print("="*80)
|
| 336 |
+
print("\nπ Launching Gradio interface...")
|
| 337 |
+
print("="*80)
|
| 338 |
+
|
| 339 |
+
# Create and launch the interface
|
| 340 |
+
demo = create_gradio_interface()
|
| 341 |
+
|
| 342 |
+
# Launch - HuggingFace Spaces will handle the hosting
|
| 343 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
huggingface_hub
|
test_hf_app.py
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Local Test Script for HuggingFace Spaces App
|
| 4 |
+
Tests the app.py before deploying to HuggingFace
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
import sys
|
| 8 |
+
import os
|
| 9 |
+
|
| 10 |
+
def test_imports():
|
| 11 |
+
"""Test if required packages are available"""
|
| 12 |
+
print("="*80)
|
| 13 |
+
print("Testing Package Imports...")
|
| 14 |
+
print("="*80)
|
| 15 |
+
|
| 16 |
+
required_packages = {
|
| 17 |
+
'gradio': 'Gradio UI Framework',
|
| 18 |
+
'huggingface_hub': 'HuggingFace Hub Client'
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
all_passed = True
|
| 22 |
+
|
| 23 |
+
for package, description in required_packages.items():
|
| 24 |
+
try:
|
| 25 |
+
__import__(package)
|
| 26 |
+
print(f"β
{description}: INSTALLED")
|
| 27 |
+
except ImportError:
|
| 28 |
+
print(f"β {description}: NOT FOUND")
|
| 29 |
+
print(f" Install with: pip install {package}")
|
| 30 |
+
all_passed = False
|
| 31 |
+
|
| 32 |
+
return all_passed
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def test_app_file():
|
| 36 |
+
"""Test if app.py exists and is valid Python"""
|
| 37 |
+
print("\n" + "="*80)
|
| 38 |
+
print("Testing app.py File...")
|
| 39 |
+
print("="*80)
|
| 40 |
+
|
| 41 |
+
if not os.path.exists('app.py'):
|
| 42 |
+
print("β app.py not found in current directory")
|
| 43 |
+
print(" Make sure you're in the correct folder")
|
| 44 |
+
return False
|
| 45 |
+
|
| 46 |
+
print("β
app.py file exists")
|
| 47 |
+
|
| 48 |
+
# Try to parse it
|
| 49 |
+
try:
|
| 50 |
+
with open('app.py', 'r') as f:
|
| 51 |
+
code = f.read()
|
| 52 |
+
|
| 53 |
+
compile(code, 'app.py', 'exec')
|
| 54 |
+
print("β
app.py is valid Python code")
|
| 55 |
+
|
| 56 |
+
# Check for key components
|
| 57 |
+
if 'PPTScriptGenerator' in code:
|
| 58 |
+
print("β
PPTScriptGenerator class found")
|
| 59 |
+
else:
|
| 60 |
+
print("β οΈ Warning: PPTScriptGenerator class not found")
|
| 61 |
+
|
| 62 |
+
if 'create_gradio_interface' in code:
|
| 63 |
+
print("β
create_gradio_interface function found")
|
| 64 |
+
else:
|
| 65 |
+
print("β οΈ Warning: create_gradio_interface function not found")
|
| 66 |
+
|
| 67 |
+
if 'InferenceClient' in code:
|
| 68 |
+
print("β
InferenceClient usage found")
|
| 69 |
+
else:
|
| 70 |
+
print("β οΈ Warning: InferenceClient not found")
|
| 71 |
+
|
| 72 |
+
return True
|
| 73 |
+
|
| 74 |
+
except SyntaxError as e:
|
| 75 |
+
print(f"β Syntax error in app.py: {e}")
|
| 76 |
+
return False
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
def test_requirements():
|
| 80 |
+
"""Test if requirements file exists"""
|
| 81 |
+
print("\n" + "="*80)
|
| 82 |
+
print("Testing Requirements File...")
|
| 83 |
+
print("="*80)
|
| 84 |
+
|
| 85 |
+
req_files = ['requirements_hf.txt', 'requirements.txt']
|
| 86 |
+
found = False
|
| 87 |
+
|
| 88 |
+
for req_file in req_files:
|
| 89 |
+
if os.path.exists(req_file):
|
| 90 |
+
print(f"β
{req_file} found")
|
| 91 |
+
with open(req_file, 'r') as f:
|
| 92 |
+
content = f.read()
|
| 93 |
+
print(f" Contents:\n{content}")
|
| 94 |
+
found = True
|
| 95 |
+
break
|
| 96 |
+
|
| 97 |
+
if not found:
|
| 98 |
+
print("β No requirements file found")
|
| 99 |
+
print(" Need either requirements_hf.txt or requirements.txt")
|
| 100 |
+
return False
|
| 101 |
+
|
| 102 |
+
return True
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def test_readme():
|
| 106 |
+
"""Test if README exists"""
|
| 107 |
+
print("\n" + "="*80)
|
| 108 |
+
print("Testing README File...")
|
| 109 |
+
print("="*80)
|
| 110 |
+
|
| 111 |
+
readme_files = ['README_HF.md', 'README.md']
|
| 112 |
+
found = False
|
| 113 |
+
|
| 114 |
+
for readme in readme_files:
|
| 115 |
+
if os.path.exists(readme):
|
| 116 |
+
print(f"β
{readme} found")
|
| 117 |
+
with open(readme, 'r') as f:
|
| 118 |
+
first_lines = ''.join(f.readlines()[:10])
|
| 119 |
+
|
| 120 |
+
if '---' in first_lines and 'title:' in first_lines:
|
| 121 |
+
print("β
YAML frontmatter detected")
|
| 122 |
+
else:
|
| 123 |
+
print("β οΈ Warning: YAML frontmatter not found (needed for HF Spaces)")
|
| 124 |
+
|
| 125 |
+
found = True
|
| 126 |
+
break
|
| 127 |
+
|
| 128 |
+
if not found:
|
| 129 |
+
print("β οΈ Warning: README file not found (recommended for HF Spaces)")
|
| 130 |
+
|
| 131 |
+
return True # Not critical
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
def test_app_launch():
|
| 135 |
+
"""Test if app can be imported and launched"""
|
| 136 |
+
print("\n" + "="*80)
|
| 137 |
+
print("Testing App Launch...")
|
| 138 |
+
print("="*80)
|
| 139 |
+
|
| 140 |
+
try:
|
| 141 |
+
# Try importing the app
|
| 142 |
+
import app as app_module
|
| 143 |
+
print("β
app.py imported successfully")
|
| 144 |
+
|
| 145 |
+
# Check if it has the expected components
|
| 146 |
+
if hasattr(app_module, 'PPTScriptGenerator'):
|
| 147 |
+
print("β
PPTScriptGenerator class accessible")
|
| 148 |
+
|
| 149 |
+
# Try instantiating
|
| 150 |
+
try:
|
| 151 |
+
generator = app_module.PPTScriptGenerator()
|
| 152 |
+
print("β
PPTScriptGenerator instantiated")
|
| 153 |
+
except Exception as e:
|
| 154 |
+
print(f"β οΈ Warning: Could not instantiate PPTScriptGenerator: {e}")
|
| 155 |
+
print(" (This might be okay - could need HF_TOKEN)")
|
| 156 |
+
|
| 157 |
+
if hasattr(app_module, 'create_gradio_interface'):
|
| 158 |
+
print("β
create_gradio_interface function accessible")
|
| 159 |
+
|
| 160 |
+
return True
|
| 161 |
+
|
| 162 |
+
except Exception as e:
|
| 163 |
+
print(f"β Error importing app.py: {e}")
|
| 164 |
+
return False
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
def test_gradio_creation():
|
| 168 |
+
"""Test if Gradio interface can be created"""
|
| 169 |
+
print("\n" + "="*80)
|
| 170 |
+
print("Testing Gradio Interface Creation...")
|
| 171 |
+
print("="*80)
|
| 172 |
+
|
| 173 |
+
try:
|
| 174 |
+
import app as app_module
|
| 175 |
+
|
| 176 |
+
demo = app_module.create_gradio_interface()
|
| 177 |
+
print("β
Gradio interface created successfully")
|
| 178 |
+
|
| 179 |
+
print("\nπ‘ You can now launch the app locally with:")
|
| 180 |
+
print(" python app.py")
|
| 181 |
+
print("\n Or test in this session:")
|
| 182 |
+
print(" >>> import app")
|
| 183 |
+
print(" >>> demo = app.create_gradio_interface()")
|
| 184 |
+
print(" >>> demo.launch()")
|
| 185 |
+
|
| 186 |
+
return True
|
| 187 |
+
|
| 188 |
+
except Exception as e:
|
| 189 |
+
print(f"β Error creating Gradio interface: {e}")
|
| 190 |
+
return False
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
def main():
|
| 194 |
+
"""Run all tests"""
|
| 195 |
+
print("\n" + "π HUGGINGFACE SPACES APP - PRE-DEPLOYMENT TEST")
|
| 196 |
+
print("="*80)
|
| 197 |
+
print("")
|
| 198 |
+
|
| 199 |
+
results = {
|
| 200 |
+
'imports': test_imports(),
|
| 201 |
+
'app_file': test_app_file(),
|
| 202 |
+
'requirements': test_requirements(),
|
| 203 |
+
'readme': test_readme(),
|
| 204 |
+
'app_launch': test_app_launch(),
|
| 205 |
+
'gradio_creation': test_gradio_creation()
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
# Summary
|
| 209 |
+
print("\n" + "="*80)
|
| 210 |
+
print("TEST SUMMARY")
|
| 211 |
+
print("="*80)
|
| 212 |
+
|
| 213 |
+
passed = sum(1 for v in results.values() if v)
|
| 214 |
+
total = len(results)
|
| 215 |
+
|
| 216 |
+
for test_name, result in results.items():
|
| 217 |
+
status = "β
PASSED" if result else "β FAILED"
|
| 218 |
+
print(f"{test_name.upper():25s}: {status}")
|
| 219 |
+
|
| 220 |
+
print("="*80)
|
| 221 |
+
print(f"Results: {passed}/{total} tests passed")
|
| 222 |
+
|
| 223 |
+
if passed == total:
|
| 224 |
+
print("\nπ All tests passed! Your app is ready to deploy to HuggingFace Spaces!")
|
| 225 |
+
print("\nπ Next Steps:")
|
| 226 |
+
print(" 1. Go to https://huggingface.co/new-space")
|
| 227 |
+
print(" 2. Create a new Space with SDK: Gradio")
|
| 228 |
+
print(" 3. Upload these files:")
|
| 229 |
+
print(" - app.py")
|
| 230 |
+
print(" - requirements_hf.txt (rename to requirements.txt)")
|
| 231 |
+
print(" - README_HF.md (rename to README.md)")
|
| 232 |
+
print(" 4. Wait for build (1-2 minutes)")
|
| 233 |
+
print(" 5. Your app will be live!")
|
| 234 |
+
print("\n See DEPLOYMENT_GUIDE.md for detailed instructions")
|
| 235 |
+
else:
|
| 236 |
+
print("\nβ οΈ Some tests failed. Please fix the errors above before deploying.")
|
| 237 |
+
print(" Common fixes:")
|
| 238 |
+
print(" - Install missing packages: pip install gradio huggingface_hub")
|
| 239 |
+
print(" - Ensure app.py is in current directory")
|
| 240 |
+
print(" - Check for syntax errors in app.py")
|
| 241 |
+
|
| 242 |
+
print("="*80)
|
| 243 |
+
|
| 244 |
+
return passed == total
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
if __name__ == "__main__":
|
| 248 |
+
success = main()
|
| 249 |
+
sys.exit(0 if success else 1)
|