Spaces:
Running
Running
A newer version of the Gradio SDK is available: 6.13.0
β‘ Quick Setup Checklist (10 min)
Complete these steps on your laptop to prepare for your Spaces demo.
Step 1: Download Models Locally (~5 min)
cd /Users/shouryaangrish/Documents/Work/HugginFaceInfy/infy
python3 scripts/download_lightweight_models.py
What it does:
- Downloads DistilBERT sentiment model (~260 MB)
- Downloads BERT tokenizer (~440 MB)
- Saves to
models/directory - Takes ~5 minutes depending on your internet
What to expect:
Downloading sentiment model...
β Saved to models/sentiment/
β Model: 260 MB
β Tokenizer: 5 MB
Total: ~265 MB
Downloading tokenizer...
β Saved to models/tokenizer/
β Model: 440 MB
β Tokenizer: 3 MB
Total: ~443 MB
All models ready! β
Step 2: Test Locally (~2 min)
python3 app.py
- App opens at
http://localhost:7860 - Click "Analyze Sentiment" button
- β Should be instant (models load from disk, not downloading)
- Try another demo if you want
- Press
Ctrl+Cto stop
Step 3: Commit Models to Git (~2 min)
git add .gitignore models/
git commit -m "Add pre-cached models for offline demo"
git push origin main
What happens:
- Git LFS automatically handles large files (
.bin,.safetensorstracked in.gitattributes) - Only pointers stored in normal git, actual files in LFS
- Spaces auto-pulls everything on next deploy
- β Models available even without network
Expected output:
[main abc1234] Add pre-cached models for offline demo
2 files changed, 50 insertions(+)
create mode .gitignore
create mode models/sentiment/...
create mode models/tokenizer/...
Step 4: Verify Spaces Updated (~1 min)
- Go to your Spaces URL (check Spaces dashboard)
- Wait for rebuild (usually 1-2 min)
- Click "Analyze Sentiment"
- β Should work instantly (models from local storage)
Result: Fully Offline Demo β
Now your setup:
- β Models available without any network calls
- β Demos are instant (no download wait)
- β Works even if HF is down
- β Attendees clone repo and have models immediately
- β Perfect for company network restrictions
File Sizes Reference
| File | Size |
|---|---|
| DistilBERT model | 260 MB |
| BERT tokenizer | 440 MB |
| Config files | ~10 MB |
| Total size | ~710 MB |
| Git repo (with LFS) | ~1 MB (pointers) + LFS storage |
The actual large files stay in Git LFS, keeping your repo fast for cloning.
Troubleshooting
Q: Download taking too long?
A: This is normal (5-10 min on typical internet). Models are large. Go grab coffee β
Q: "Permission denied" on scripts?
A: Run:
chmod +x scripts/download_lightweight_models.py
python3 scripts/download_lightweight_models.py
Q: Models directory doesn't exist after download?
A: Check for errors in output. Run again:
python3 scripts/download_lightweight_models.py
Q: Git push fails with "too large"?
A: Git LFS handles this automatically. Just:
git push origin main --force-with-lease
Q: Models still download during demo?
A: Models didn't transfer to Spaces. Check:
ls -la models/sentimen*/
ls -la models/tokenizer/
Should show .bin files. If empty, re-run Step 1.
Timeline for Your Session
| When | Action | Time |
|---|---|---|
| Day before | Run Steps 1-4 on laptop | 10 min |
| 30 min before session | Verify Spaces is ready (load app once) | 1 min |
| During session | Run demo (instant loading guaranteed) | β Works! |
| After session | Attendees can clone repo + models included | Automatic |
You're Ready! π
Once you complete Step 4, your demo is set up perfectly:
- No network dependencies β
- Instant model loading β
- Reproducible for attendees β
- Spaces auto-deploys everything β
Questions? Check USING_LOCAL_MODELS.md for full details.
One-Liner (If you want to do it all at once)
cd /Users/shouryaangrish/Documents/Work/HugginFaceInfy/infy && python3 scripts/download_lightweight_models.py && git add .gitignore models/ && git commit -m "Add pre-cached models" && git push origin main && echo "β
All done! Check Spaces in ~2 min"
Done! β¨