infy / QUICK_SETUP.md
shourya
Update app docs, setup scripts, and utils
62a67da

A newer version of the Gradio SDK is available: 6.13.0

Upgrade

⚑ 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+C to 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, .safetensors tracked 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)

  1. Go to your Spaces URL (check Spaces dashboard)
  2. Wait for rebuild (usually 1-2 min)
  3. Click "Analyze Sentiment"
  4. βœ… 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! ✨