Spaces:
No application file
No application file
π Deployment Guide for Hugging Face Spaces
Files Created for Deployment
- app.py - Main Gradio application
- README.md - Space configuration and documentation
- requirements.txt - Python dependencies
- packages.txt - System dependencies for Manim
- .gitignore - Files to exclude from git
- test_deployment.py - Local testing script
Step-by-Step Deployment Instructions
1. Create a New Hugging Face Space
- Go to Hugging Face Spaces
- Click "Create new Space"
- Choose:
- Space name:
ai-video-generator(or your preferred name) - License: MIT
- SDK: Gradio
- Hardware: CPU Basic (free tier) or GPU if you have Pro subscription
- Space name:
2. Upload Files
Upload all the files from your video_generator folder:
app.pyREADME.mdrequirements.txtpackages.txt.gitignore
DO NOT upload:
.envfile (contains your API key)video_generator.py(original file, not needed)
3. Set Environment Variables
- Go to your Space settings
- Click on "Variables and secrets"
- Add a new secret:
- Name:
GEMINI_API_KEY - Value: Your actual Gemini API key (from your .env file)
- Name:
4. Wait for Build
- The space will automatically build and install dependencies
- This may take 5-15 minutes due to Manim installation
- Check the build logs for any errors
5. Test the Application
- Once built, test with a simple topic like "Introduction to Python"
- Check if videos generate correctly
- Verify the interface works smoothly
Troubleshooting
Common Issues and Solutions
Build Timeout
- Manim installation can be slow
- Try using a smaller requirements.txt with fewer versions specified
Memory Issues
- Use shorter video durations (1 minute)
- Consider upgrading to GPU hardware
API Key Issues
- Double-check the secret name is exactly
GEMINI_API_KEY - Verify the API key is valid and has quota
- Double-check the secret name is exactly
Video Generation Fails
- Check the generation logs in the interface
- Manim syntax might need adjustment for the cloud environment
Alternative Deployment (GitHub β HF Spaces)
If you prefer using Git:
- Create a GitHub repository
- Push all files (except .env)
- Connect the repository to Hugging Face Spaces
- Set the API key in Spaces secrets
Performance Tips
- Use shorter durations (1-2 minutes max)
- Simple topics work better than complex ones
- Monitor usage to stay within API limits
- Consider caching for frequently requested topics
Security Notes
- Never commit API keys to public repositories
- Use Hugging Face Spaces secrets for sensitive data
- The .gitignore file excludes sensitive files
Support
If you encounter issues:
- Check the Space logs
- Verify all dependencies in requirements.txt
- Test locally first with test_deployment.py
- Consider the Hugging Face Spaces documentation