Spaces:
Sleeping
Sleeping
Pre-Deployment Checklist β
Complete this checklist before deploying to Hugging Face Spaces.
1. Model Files
-
pytorch_model.pthis inbackend/api/models/ -
model_best.kerasis inbackend/api/models/ - Both models are in HuggingFace LFS format (
.gitattributes) - Models are not corrupted (test locally first)
2. Local Testing
- Cloned repository successfully
- Added trained models
- Built Docker image:
docker build -t intel . - Container starts without errors
- Can access http://localhost:7860
- Classification endpoint works: POST to
/api/classify/ - Frontend loads properly
- API documentation visible at
/swagger/
3. Configuration
- Updated
.envif using custom settings - Verified
ALLOWED_HOSTSincludes HF domains - Checked
CORS_ALLOWED_ORIGINSis correct - Confirmed
DEBUG=Falsefor production - Reviewed
DJANGO_SECRET_KEY(auto-set is fine)
4. Code Quality
- No hardcoded API keys or passwords
- Removed development-only code
- All imports are available in
requirements.txt - No local file paths hardcoded
- Verified .gitignore doesn't exclude needed files
5. Git & Repository
- All changes committed:
git statusis clean -
.envis in.gitignore(no secrets in repo) - Model files tracked with Git LFS if large
- Remote configured:
git remote add hf <HF_SPACE_URL> - Tested:
git push --dry-run hf main
6. Documentation
- README.md updated with your username
- Updated citation with your info
- Added your model training notes if relevant
- Confirmed DEPLOYMENT.md is accurate
- Link to your HF Space is correct
7. Hugging Face Setup
- Created Hugging Face Space
- Set space as "Docker" SDK
- Set visibility (Public/Private)
- Added appropriate description and license
- Configured any secrets needed (if API keys used)
8. Final Tests (Optional)
- Run
docker build .one more time - Test with different image formats (jpg, png, webp)
- Test with both model options (pytorch, tensorflow)
- Verify error handling (invalid image, bad requests)
- Check performance with larger images
9. Deployment
- All above checks passed β
- Ready message:
git push hf main - Monitoring HF Space for build progress
- Verified Space URL is accessible
- Tested deployed Space (give it 5 minutes to start)
10. Post-Deployment
- Space is running without errors
- All endpoints respond correctly
- Frontend loads on live URL
- API returns correct predictions
- No CORS or security errors
- Shared link with team/public
Deployment Command
# Final push to Hugging Face
git push hf main
# View logs (from HF Space interface)
# Monitor at: https://huggingface.co/spaces/USERNAME/Intel_classification/logs
Rollback Plan
If something goes wrong:
# Revert to previous working state
git log --oneline | head -5
git reset --hard <COMMIT_HASH>
git push hf main --force # Force push (use with caution)
# Or fix issues and push again
git add .
git commit -m "Fix: description of fix"
git push hf main
Common Issues & Fixes
| Issue | Solution |
|---|---|
| Build timeout | Reduce image size or optimize dependencies |
| Out of memory | Prune unused Docker images/volumes |
| Models not loading | Verify file names match exactly |
| CORS errors | Check Django CSRF_TRUSTED_ORIGINS |
| Port conflicts | Ensure 7860 is available locally |
| Frontend not showing | Check React build in frontend/build/ |
Success Indicators β¨
Your deployment is successful when:
- β HF Space shows "Running" status
- β Website loads at your HF Space URL
- β Cannot refund with different images
- β Both models are selectable
- β API documentation (/swagger) is accessible
- β Admin panel works (/admin/)
- β No errors in HF Space logs
Need Help?
- Documentation: DEPLOYMENT.md
- Quick Start: QUICK_START.md
- Changes Made: REORGANIZATION.md
- GitHub Issues: Report bugs
- HF Discussions: Ask community
Estimated Total Time: 15-30 minutes (first-time setup)
Good luck! π