Spaces:
Building
Building
File size: 4,661 Bytes
08d7c19 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# π Hugging Face Spaces Deployment Guide
This guide will help you deploy your Dubsway Video AI system to Hugging Face Spaces via GitHub.
## π Prerequisites
1. **GitHub Repository**: Your code should be pushed to a GitHub repository
2. **Hugging Face Account**: Create an account at [huggingface.co](https://huggingface.co)
3. **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 configuration
- `Dockerfile` - Container configuration
- `requirements-hf.txt` - Optimized dependencies
- `app/main.py` - FastAPI application
### 2. Set Up Environment Variables
In your Hugging Face Space settings, add these environment variables:
```bash
# 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
1. Go to [huggingface.co/spaces](https://huggingface.co/spaces)
2. Click "Create new Space"
3. 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
1. In your Space settings, go to "Repository" tab
2. Select "Connect to existing repository"
3. Choose your GitHub repository
4. Set the branch (usually `main` or `master`)
### 5. Configure Build Settings
The Space will automatically use:
- `.huggingface.yaml` for configuration
- `Dockerfile` for container build
- `requirements-hf.txt` for dependencies
### 6. Deploy
1. Push your changes to GitHub
2. Hugging Face will automatically build and deploy
3. Monitor the build logs in your Space
## π Verification
Once deployed, you can:
1. **Check the API**: Visit `https://your-username-dubsway-video-ai.hf.space/`
2. **View Documentation**: Visit `https://your-username-dubsway-video-ai.hf.space/docs`
3. **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 info
- `GET /health` - Health check
- `GET /docs` - Interactive API documentation
- `POST /api/auth/register` - User registration
- `POST /api/auth/login` - User login
- `POST /api/upload/video` - Video upload and analysis
- `GET /api/dashboard/videos` - Get user videos
- `POST /api/custom-chatbot/chat` - Chat with video content
## π§ Troubleshooting
### Common Issues
1. **Build Failures**:
- Check the build logs in your Space
- Ensure all dependencies are in `requirements-hf.txt`
- Verify Dockerfile syntax
2. **Environment Variables**:
- Make sure all required env vars are set in Space settings
- Check for typos in variable names
3. **Memory Issues**:
- The Space uses CPU-only PyTorch to save memory
- Consider using smaller models for production
4. **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:
1. Push changes to your repository
2. Hugging Face automatically rebuilds and deploys
3. Monitor deployment status in your Space
## π Performance Optimization
For better performance in Hugging Face Spaces:
1. **Use CPU-only PyTorch**: Already configured in Dockerfile
2. **Optimize model loading**: Models are loaded on first request
3. **Use SQLite**: Lighter than PostgreSQL for Spaces
4. **Cache results**: Implement caching for repeated requests
## π Security Considerations
1. **API Keys**: Store sensitive keys in Space environment variables
2. **CORS**: Configure allowed origins for production
3. **Rate Limiting**: Implement rate limiting for public APIs
4. **Input Validation**: Validate all user inputs
## π Support
If you encounter issues:
1. Check the build logs in your Space
2. Review the troubleshooting section
3. Check Hugging Face Spaces documentation
4. Monitor your application logs
---
**Happy Deploying! π**
Your Dubsway Video AI system will be accessible at:
`https://your-username-dubsway-video-ai.hf.space/` |