A newer version of the Gradio SDK is available:
5.49.1
π Hugging Face Spaces Migration Guide
Complete guide to migrate your Video Transcription Service from Render.com to Hugging Face Spaces with enhanced features and API access.
π― Why Hugging Face Spaces?
Advantages over Render.com:
- β Higher Resource Limits: More memory and CPU
- β Better Performance: Optimized for ML workloads
- β Free GPU Access: Available for intensive tasks
- β Gradio Integration: Beautiful web interface
- β Community Features: Easy sharing and discovery
- β Persistent Storage: Better file handling
- β API + Web Interface: Both available simultaneously
π Pre-Migration Checklist
- Hugging Face account created
- Git installed locally
- Python environment ready
- Test video files prepared
- Current service functionality documented
π οΈ Step 1: Prepare Deployment Files
Run the automated preparation script:
python deploy_to_hf.py
This creates a hf_spaces_deploy/
directory with all necessary files:
app.py
- Gradio + FastAPI hybrid interfacerequirements.txt
- HF Spaces optimized dependenciesREADME.md
- HF Spaces documentationconfig.py
- HF-optimized configuration- All supporting modules
π Step 2: Create Hugging Face Space
Go to Hugging Face Spaces
- Visit: https://huggingface.co/spaces
- Click "Create new Space"
Configure Your Space
- Name:
video-transcription
(or your choice) - SDK: Select "Gradio"
- Hardware: Start with "CPU basic" (free)
- Visibility: Public (for API access) or Private
- Name:
Create Space
- Click "Create Space"
- Note your Space URL:
https://username-spacename.hf.space
π€ Step 3: Deploy to Hugging Face Spaces
Option A: Git Deployment (Recommended)
cd hf_spaces_deploy
git init
git add .
git commit -m "Initial deployment of Video Transcription Service"
git remote add origin https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
git push -u origin main
Option B: Web Upload
- Go to your Space page
- Click "Files" tab
- Upload all files from
hf_spaces_deploy/
- Ensure
app.py
is in the root directory
β³ Step 4: Monitor Deployment
Check Build Logs
- Go to "Logs" tab in your Space
- Monitor the build process (5-10 minutes)
- Look for successful model download
Expected Log Output
π Starting Video Transcription Service on Hugging Face Spaces π€ Loading Whisper model for Hugging Face Spaces... β Model 'base' preloaded in 45.2 seconds π Starting FastAPI service... Running on local URL: http://0.0.0.0:7860
Troubleshoot Issues
- Build failures: Check requirements.txt
- Memory issues: Switch to "CPU upgrade" hardware
- Model loading issues: Try
WHISPER_MODEL=tiny
β Step 5: Test Your Deployment
Test Web Interface
Visit Your Space
- URL:
https://username-spacename.hf.space
- Should see Gradio interface
- URL:
Upload Test Video
- Use "Upload & Transcribe" tab
- Select a small test video (< 50MB)
- Choose language or use auto-detect
- Click "Start Transcription"
Check Results
- Note the transcription ID
- Use "Check Status" tab to monitor progress
- Verify transcription completes successfully
Test API Functionality
Health Check
curl "https://username-spacename.hf.space/api/health"
Upload Video via API
curl -X POST "https://username-spacename.hf.space/api/transcribe" \ -F "file=@test_video.mp4" \ -F "language=en"
Check Status via API
curl "https://username-spacename.hf.space/api/transcribe/1"
Use Python Client
python hf_api_client.py https://username-spacename.hf.space test_video.mp4
π§ Step 6: Optimize Performance
Hardware Upgrades
If you experience performance issues:
- Go to Space Settings
- Hardware β Upgrade
- Options:
- CPU basic (free) - 2 vCPU, 16GB RAM
- CPU upgrade ($0.05/hour) - 8 vCPU, 32GB RAM
- GPU T4 small ($0.60/hour) - For heavy workloads
Model Optimization
Adjust model size based on your needs:
# In Space settings, add environment variable:
WHISPER_MODEL=tiny # Fastest, good quality
WHISPER_MODEL=base # Balanced (default)
WHISPER_MODEL=small # Better quality, slower
π Step 7: Compare Features
Feature | Render.com | Hugging Face Spaces |
---|---|---|
Memory | 512MB | 16GB (basic) / 32GB (upgrade) |
CPU | Shared | 2-8 vCPU dedicated |
Storage | Ephemeral | Persistent |
GPU | None | T4 available |
Interface | API only | Gradio + API |
Community | Limited | Built-in sharing |
Cost | Free tier limited | More generous free tier |
π Step 8: Migration Validation
Functionality Checklist
- β Web interface loads correctly
- β Video upload works (multiple formats)
- β Language detection/selection works
- β Transcription processing completes
- β Results display correctly
- β API endpoints respond correctly
- β Status checking works
- β Error handling functions
- β Automatic cleanup operates
- β Logging provides good visibility
Performance Validation
- β Model loads within 2-3 minutes
- β First transcription completes successfully
- β Subsequent transcriptions are faster
- β Large files (up to 200MB) process correctly
- β Multiple concurrent requests handled
- β Memory usage stays within limits
π Step 9: Update Your Applications
Update API Endpoints
Replace your Render.com URLs:
# Old Render.com URL
OLD_URL = "https://your-service.onrender.com"
# New HF Spaces URL
NEW_URL = "https://username-spacename.hf.space"
# API endpoints remain the same:
# POST /api/transcribe
# GET /api/transcribe/{id}
# GET /api/health
Update Client Code
# Use the new HF API client
from hf_api_client import HFTranscriptionClient
client = HFTranscriptionClient("https://username-spacename.hf.space")
result = client.transcribe_and_wait("video.mp4")
π Step 10: Go Live
Share Your Space
Make Public (if desired)
- Space Settings β Visibility β Public
Add to Profile
- Pin to your HF profile
- Add description and tags
Share URL
- Web interface:
https://username-spacename.hf.space
- API base:
https://username-spacename.hf.space/api
- Web interface:
Monitor Usage
- Check Space analytics
- Monitor resource usage
- Review user feedback
- Update documentation as needed
π§ Troubleshooting
Common Issues
Build Fails
Solution: Check requirements.txt, ensure all dependencies are compatible
Model Loading Timeout
Solution: Upgrade to CPU upgrade hardware or use WHISPER_MODEL=tiny
API Not Accessible
Solution: Ensure Space is Public and FastAPI is running on port 7860
Memory Issues
Solution: Upgrade hardware or reduce MAX_FILE_SIZE in config
π Support Resources
- HF Spaces Documentation: https://huggingface.co/docs/hub/spaces
- Gradio Documentation: https://gradio.app/docs/
- Community Forum: https://discuss.huggingface.co/
- Your Space Logs: Available in Space dashboard
π― Next Steps
After successful migration:
- Decommission Render.com service
- Update documentation with new URLs
- Notify users of the migration
- Monitor performance and optimize as needed
- Consider GPU upgrade for heavy workloads
π Congratulations! Your Video Transcription Service is now running on Hugging Face Spaces with enhanced capabilities and better performance!
Key Benefits Achieved:
- β Higher resource limits
- β Beautiful Gradio web interface
- β Full API compatibility maintained
- β Better community integration
- β More reliable performance
- β Future GPU upgrade path