infy / scripts /README.md
shourya
Add pre-session setup scripts
2a31b59
# Pre-Session Setup Scripts
These scripts help you prepare for the HuggingFace Enabling Sessions by pre-downloading models, converting slides, and testing the Spaces app.
## Quick Start (All-in-One)
```bash
bash scripts/setup.sh
```
This runs all three scripts in sequence and prepares everything for your session.
---
## Individual Scripts
### 1️⃣ Download Models Locally
**Purpose:** Pre-cache all HuggingFace models on your laptop so demos run instantly
**File:** `scripts/download_models.py`
**Usage:**
```bash
python3 scripts/download_models.py
```
**What it does:**
- Downloads 5 pre-trained models (~2-3 GB total)
- Stores in `~/.cache/huggingface/hub`
- Takes 10-20 minutes depending on internet speed
- Models: Sentiment, NER, QA, Summarization, Semantic Similarity
**Why:** Models only need to download once. After this, they're cached forever.
---
### 2️⃣ Convert Markdown Slides to PowerPoint
**Purpose:** Convert markdown slides to editable PPTX format for your presentation
**File:** `scripts/convert_slides_to_pptx.py`
**Requirements:**
```bash
pip install python-pptx
```
**Usage:**
```bash
python3 scripts/convert_slides_to_pptx.py
```
**What it does:**
- Converts `slides/SESSION1_SLIDES.md` β†’ `slides/SESSION1_SLIDES.pptx`
- Converts `slides/SESSION2_SLIDES.md` β†’ `slides/SESSION2_SLIDES.pptx`
- Applies basic formatting (headers, text, colors)
**Next steps:**
- Open the PPTX files in PowerPoint or LibreOffice
- Customize colors, fonts, add speaker notes
- Add images or animations as desired
**Note:** The conversion is basic. You can enhance the PPTX afterwards in PowerPoint.
---
### 3️⃣ Pre-Warm Spaces App
**Purpose:** Test that the Spaces app is running and cache models on HF servers
**File:** `scripts/prewarm_spaces.py`
**Usage:**
```bash
python3 scripts/prewarm_spaces.py
```
**What it does:**
- Checks if Spaces app is online
- Waits for startup if needed (first-time builds take 2-3 min)
- Provides session readiness checklist
- Shows timing and performance info
**Expected output:**
```
βœ… Spaces app is online
βœ“ Sentiment Analysis cached
βœ“ NER cached
βœ“ QA cached
βœ“ Summarization cached
βœ“ Semantic Similarity cached
```
---
## Setup Timeline
| Task | Time | Notes |
|------|------|-------|
| Model Download | 10-20 min | Run once, cached forever |
| Slide Conversion | 1-2 min | One-time only |
| Spaces Pre-warm | 2-5 min | Depends on app startup |
| **Total** | **15-30 min** | Do this 30 min before session |
---
## Session Day Checklist
- [ ] Run `bash scripts/setup.sh` (30 min before session)
- [ ] Open slides in PowerPoint/LibreOffice
- [ ] Test one demo on Spaces (click "Analyze Sentiment")
- [ ] Share Spaces URL with attendees: `https://huggingface.co/spaces/Shouryahere/infy`
- [ ] Open `SPEAKER_NOTES.md` for timing reference
- [ ] Screen share test (zoom, teams, etc)
- [ ] Audio test
---
## Troubleshooting
### "ModuleNotFoundError: No module named 'python_pptx'"
```bash
pip install python-pptx
```
### Models still downloading during session?
- Run `scripts/download_models.py` earlier (it's idempotent, safe to run multiple times)
- Check internet speed: Large models (BART) can take 5+ min on slow networks
### Spaces URL not responding?
- Check: https://huggingface.co/spaces/Shouryahere/infy
- If showing "Building", wait 2-3 minutes
- If showing red error, check Spaces build logs
### Slide conversion looks poorly formatted?
- This script does basic conversion; use PowerPoint to enhance
- Recommended: Open PPTX and manually adjust formatting to match your company branding
---
## Manual Alternative
If you prefer not to run scripts:
1. **Download models:** `transformers-cli download-model distilbert-base-uncased-finetuned-sst-2-english` (repeat for each model)
2. **Convert slides:** Use CloudConvert, Zamzar, or open markdown in LibreOffice Impress
3. **Pre-warm Spaces:** Just click each button once when you're ready
---
## Advanced Options
### Custom model downloads
Edit `config.py` to change which models are downloaded
### Custom slide formatting
Edit `scripts/convert_slides_to_pptx.py` to adjust colors, fonts, sizes
### Offline demo fallback
Pre-record a video of running the demos locally in case Spaces is slow
---
πŸ“ **Questions?** See SPEAKER_NOTES.md for more context.
πŸš€ **Ready to present!**