Hugging Face Deployment Guide
π Pre-Deployment Checklist
Before uploading to Hugging Face Spaces, ensure:
- All code files are plagiarism-free with original implementations
- Student attribution is present in all files
- README.md has HF metadata header
- requirements.txt includes all dependencies
- .gitattributes is configured for Git LFS
- LICENSE file is present
- Error handling is comprehensive
- Sample video is available (optional)
π Deployment Steps
1. Create a New Space on Hugging Face
- Go to Hugging Face Spaces
- Click "Create new Space"
- Fill in the details:
- Space name:
vehicle-speed-estimation(or your choice) - License: MIT
- SDK: Gradio
- Visibility: Public or Private
- Space name:
2. Upload Files
You can upload files via:
Option A: Web Interface
- Navigate to your Space
- Click "Files and versions"
- Upload all files from the project directory:
app.py main.py config.py requirements.txt README.md LICENSE CITATION.cff CONTRIBUTING.md .gitattributes src/ βββ __init__.py βββ annotator.py βββ speed_estimator.py βββ view_transformer.py βββ exceptions.py
Option B: Git Command Line
# Clone your Space repository
git clone https://huggingface.co/spaces/YOUR_USERNAME/vehicle-speed-estimation
cd vehicle-speed-estimation
# Copy all files from the project
cp -r /path/to/Vehicle-Speed-Estimation-and-Counting-YOLO-Supervision/* .
# Add and commit
git add .
git commit -m "Initial commit: Vehicle Speed Estimation System"
# Push to Hugging Face
git push
3. Configure Git LFS for Large Files
If you have model files or sample videos:
# Install Git LFS
git lfs install
# Track large files
git lfs track "*.pt"
git lfs track "*.mp4"
# Add .gitattributes
git add .gitattributes
git commit -m "Configure Git LFS"
git push
4. Wait for Build
- Hugging Face will automatically build your Space
- Check the "Logs" tab for build progress
- Build typically takes 2-5 minutes
5. Test Your Space
Once built:
- Upload a test video
- Verify processing works
- Check output video quality
- Test error handling with invalid inputs
βοΈ Configuration Notes
Model Files
The YOLO model will be downloaded automatically on first run. If you want to include a pre-downloaded model:
- Download the model (e.g.,
yolov8n.pt) - Create a
models/directory - Upload via Git LFS:
git lfs track "models/*.pt" git add models/yolov8n.pt git commit -m "Add YOLO model" git push
Sample Videos
To include example videos:
- Create a
data/directory - Add sample videos (keep under 100MB each)
- Upload via Git LFS:
git lfs track "data/*.mp4" git add data/vehicles.mp4 git commit -m "Add sample video" git push
Environment Variables
If you need to set environment variables:
- Go to Space Settings
- Click "Variables and secrets"
- Add any required variables
π Troubleshooting
Build Fails
Issue: Dependencies fail to install
Solution:
- Check
requirements.txtfor version conflicts - Ensure all packages are available on PyPI
- Try pinning specific versions
Out of Memory
Issue: Space runs out of memory during processing
Solution:
- Upgrade to a better hardware tier (Settings β Hardware)
- Reduce video resolution in preprocessing
- Use smaller YOLO model (yolov8n instead of yolov8l)
Slow Processing
Issue: Video processing is very slow
Solution:
- Upgrade to GPU hardware (Settings β Hardware)
- Use smaller model for faster inference
- Reduce input video resolution
Model Download Fails
Issue: YOLO model fails to download
Solution:
- Pre-download model and include in repository
- Check internet connectivity in Space
- Use alternative model source
π Hardware Recommendations
| Video Resolution | Model Size | Recommended Hardware |
|---|---|---|
| 720p | YOLOv8n | CPU Basic (Free) |
| 1080p | YOLOv8n/s | CPU Upgrade |
| 1080p | YOLOv8m/l | T4 Small (GPU) |
| 4K | YOLOv8l | A10G Small (GPU) |
π Security Notes
- Never commit API keys or secrets to the repository
- Use Hugging Face Secrets for sensitive data
- Validate all user inputs
- Limit file upload sizes
π Monitoring
After deployment:
- Monitor Space usage in Settings
- Check error logs regularly
- Review user feedback
- Update dependencies periodically
π Updating Your Space
To update after deployment:
# Make changes locally
# Test thoroughly
# Commit and push
git add .
git commit -m "Description of changes"
git push
# Space will automatically rebuild
π Post-Deployment
- Test all functionality
- Share Space link with team
- Add Space to your profile
- Consider writing a blog post about the project
- Share on social media
π Academic Use
For academic submissions:
- Ensure all student names are visible in README
- Include enrollment numbers
- Add CITATION.cff for proper attribution
- Document all external libraries used
- Include technical documentation
β Final Verification
Before marking as complete:
- Space builds successfully
- Video upload works
- Processing completes without errors
- Output video is downloadable
- Statistics are displayed correctly
- Error messages are user-friendly
- All student names are visible
- README renders correctly
- License is visible
π Success!
Your Vehicle Speed Estimation System is now live on Hugging Face Spaces!
Share your Space URL:
https://huggingface.co/spaces/YOUR_USERNAME/vehicle-speed-estimation
Developed by:
- Abhay Gupta (0205CC221005)
- Aditi Lakhera (0205CC221011)
- Balraj Patel (0205CC221049)
- Bhumika Patel (0205CC221050)