Spaces:
Running
Running
π Hugging Face Spaces Deployment Guide
This guide will help you deploy your Dubsway Video AI system to Hugging Face Spaces via GitHub.
π Prerequisites
- GitHub Repository: Your code should be pushed to a GitHub repository
- Hugging Face Account: Create an account at huggingface.co
- Environment Variables: Set up your API keys and configuration
π§ Step-by-Step Deployment
1. Prepare Your Repository
Your repository should already have the necessary files:
.huggingface.yaml
- Hugging Face Spaces configurationDockerfile
- Container configurationrequirements-hf.txt
- Optimized dependenciesapp/main.py
- FastAPI application
2. Set Up Environment Variables
In your Hugging Face Space settings, add these environment variables:
# Required for Groq LLM
GROQ_API_KEY=your_groq_api_key_here
# Database (use SQLite for simplicity)
DATABASE_URL=sqlite+aiosqlite:///./dubsway_hf.db
# AWS S3 (optional - for file storage)
AWS_ACCESS_KEY_ID=your_aws_access_key
AWS_SECRET_ACCESS_KEY=your_aws_secret_key
AWS_REGION=us-east-1
S3_BUCKET_NAME=your_s3_bucket_name
# Application
SECRET_KEY=your_secret_key_here
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
# Environment
ENVIRONMENT=production
3. Create Hugging Face Space
- Go to huggingface.co/spaces
- Click "Create new Space"
- Choose settings:
- Owner: Your username
- Space name:
dubsway-video-ai
(or your preferred name) - License: MIT
- SDK: Docker
- Visibility: Public or Private
4. Connect GitHub Repository
- In your Space settings, go to "Repository" tab
- Select "Connect to existing repository"
- Choose your GitHub repository
- Set the branch (usually
main
ormaster
)
5. Configure Build Settings
The Space will automatically use:
.huggingface.yaml
for configurationDockerfile
for container buildrequirements-hf.txt
for dependencies
6. Deploy
- Push your changes to GitHub
- Hugging Face will automatically build and deploy
- Monitor the build logs in your Space
π Verification
Once deployed, you can:
- Check the API: Visit
https://your-username-dubsway-video-ai.hf.space/
- View Documentation: Visit
https://your-username-dubsway-video-ai.hf.space/docs
- Health Check: Visit
https://your-username-dubsway-video-ai.hf.space/health
π οΈ API Endpoints
Your deployed API will have these endpoints:
GET /
- Root endpoint with API infoGET /health
- Health checkGET /docs
- Interactive API documentationPOST /api/auth/register
- User registrationPOST /api/auth/login
- User loginPOST /api/upload/video
- Video upload and analysisGET /api/dashboard/videos
- Get user videosPOST /api/custom-chatbot/chat
- Chat with video content
π§ Troubleshooting
Common Issues
Build Failures:
- Check the build logs in your Space
- Ensure all dependencies are in
requirements-hf.txt
- Verify Dockerfile syntax
Environment Variables:
- Make sure all required env vars are set in Space settings
- Check for typos in variable names
Memory Issues:
- The Space uses CPU-only PyTorch to save memory
- Consider using smaller models for production
Database Issues:
- Use SQLite for simplicity in Spaces
- Ensure database directory is writable
Monitoring
- Check Space logs for errors
- Monitor resource usage
- Test API endpoints regularly
π Continuous Deployment
Once connected to GitHub:
- Push changes to your repository
- Hugging Face automatically rebuilds and deploys
- Monitor deployment status in your Space
π Performance Optimization
For better performance in Hugging Face Spaces:
- Use CPU-only PyTorch: Already configured in Dockerfile
- Optimize model loading: Models are loaded on first request
- Use SQLite: Lighter than PostgreSQL for Spaces
- Cache results: Implement caching for repeated requests
π Security Considerations
- API Keys: Store sensitive keys in Space environment variables
- CORS: Configure allowed origins for production
- Rate Limiting: Implement rate limiting for public APIs
- Input Validation: Validate all user inputs
π Support
If you encounter issues:
- Check the build logs in your Space
- Review the troubleshooting section
- Check Hugging Face Spaces documentation
- Monitor your application logs
Happy Deploying! π
Your Dubsway Video AI system will be accessible at:
https://your-username-dubsway-video-ai.hf.space/