π¬ AI Video Generator - Hailuo Clone
A powerful AI video generation platform with multiple backend options. Generate stunning videos from text prompts using state-of-the-art AI models!
β¨ Features
- π₯ Multiple AI Models - CogVideoX, Hailuo Video-01, HunyuanVideo
- π 3 Backend Options - Replicate API, Local Generation, or HF Spaces
- π¨ Advanced Controls - Camera movements, visual effects, styles (Hailuo-inspired)
- π» Beautiful UI - Modern, responsive web interface
- π Privacy Options - Run completely locally or use cloud APIs
- β‘ Fast Generation - 30-60 seconds with Replicate, or run locally
π― Quick Start (3 Options)
Option 1: Replicate API (Recommended - Most Reliable)
Best for: Fast, reliable video generation with minimal setup
Get Replicate API Token
# Sign up at https://replicate.com # Get token from https://replicate.com/account/api-tokensSetup
# Clone the repo git clone <your-repo-url> cd hailuo-clone # Create .env file echo "REPLICATE_API_TOKEN=your_token_here" > .env # Install dependencies pip install -r requirements.txt pip install replicate # Run backend python backend_replicate.pyOpen UI
- Open
index.htmlin your browser - Enter a prompt and generate!
- Open
Cost: ~$0.05-0.10 per video
Option 2: Local Generation (Free & Private)
Best for: Complete privacy, offline use, no API costs
Install PyTorch
# For GPU (NVIDIA) pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 # For CPU only pip install torch torchvision torchaudioInstall Dependencies
pip install -r requirements_local.txtRun
# Start backend python backend_local.py # Open index_local.html in browser
Requirements:
- GPU: RTX 3060+ (30-120s per video)
- CPU: 16GB RAM (5-10 min per video)
- Storage: 10GB for model
Option 3: Hugging Face Spaces (Free but Unreliable)
Best for: Testing, no setup required
Install Dependencies
pip install -r requirements.txtRun
python backend_enhanced.py # Open index_enhanced.html
Note: HF Spaces may be sleeping/overloaded. Use Demo Mode for testing.
π Project Structure
hailuo-clone/
βββ Backend Options
β βββ backend_replicate.py # Replicate API (recommended)
β βββ backend_local.py # Local generation
β βββ backend_enhanced.py # HF Spaces (multiple models)
β βββ backend_simple.py # Demo mode
β
βββ Frontend
β βββ index.html # Simple UI (works with all backends)
β βββ index_enhanced.html # Advanced UI with camera controls
β βββ index_local.html # Local generation UI
β
βββ Configuration
β βββ models_config.py # Model configurations
β βββ requirements.txt # Basic dependencies
β βββ requirements_local.txt # Local generation dependencies
β βββ .env.example # Environment variables template
β
βββ Documentation
βββ README.md # This file
βββ SOLUTION_GUIDE.md # Troubleshooting guide
βββ README_LOCAL.md # Local setup guide
π¨ Available Models
Replicate API
- Hailuo Video-01 (MiniMax) - The real Hailuo model! π₯
- CogVideoX-5B - High quality text-to-video
Local Generation
- CogVideoX-2B - Runs on your computer
Hugging Face Spaces
- CogVideoX-5B - High quality (when available)
- CogVideoX-2B - Faster version
- HunyuanVideo - Tencent's SOTA model
- Stable Video Diffusion - Image-to-video
π¬ Usage Examples
Basic Text-to-Video
# Using any backend on localhost:5000
import requests
response = requests.post('http://localhost:5000/generate-video', json={
'prompt': 'A golden retriever running through a field of flowers at sunset'
})
video_url = response.json()['video_url']
With Replicate (Specific Model)
response = requests.post('http://localhost:5000/generate-video', json={
'prompt': 'A cat playing with yarn',
'model': 'hailuo' # or 'cogvideox'
})
Advanced (Camera Controls)
response = requests.post('http://localhost:5000/generate-video', json={
'prompt': 'Ocean waves at sunset',
'camera_movement': '[Zoom in]',
'visual_effect': 'cinematic lighting, film grain',
'style': 'photorealistic, 4k, high detail'
})
π§ Configuration
Environment Variables (.env)
# Replicate API
REPLICATE_API_TOKEN=your_token_here
# Flask Configuration
FLASK_PORT=5000
FLASK_DEBUG=False
# Model Selection
DEFAULT_MODEL=cogvideox-5b
Model Configuration (models_config.py)
- Camera movements (zoom, pan, tilt, etc.)
- Visual effects (cinematic, dramatic, slow-motion)
- Video styles (realistic, anime, 3D render)
- Example prompts by category
π Performance Comparison
| Backend | Setup Time | Speed | Quality | Cost | Reliability |
|---|---|---|---|---|---|
| Replicate | 5 min | 30-60s | βββββ | $0.05-0.10 | βββββ |
| Local (GPU) | 30 min | 30-120s | ββββ | Free | βββββ |
| Local (CPU) | 30 min | 5-10 min | ββββ | Free | βββββ |
| HF Spaces | Instant | 30-60s | ββββ | Free | ββ |
π Deployment
Local Development
python backend_replicate.py
# Open http://localhost:5000
Production (with Gunicorn)
pip install gunicorn
gunicorn -w 4 -b 0.0.0.0:5000 backend_replicate:app
Docker (Optional)
FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "backend_replicate.py"]
π Troubleshooting
"Model provider unreachable"
- Solution: Use Replicate API (
backend_replicate.py) instead of HF Spaces - HF Spaces are often sleeping/overloaded
"Out of memory" (Local)
- Solution: Use CPU mode or reduce batch size
- Close other GPU applications
"Too slow" (Local CPU)
- Expected: CPU generation takes 5-10 minutes
- Solution: Use Replicate API or get a GPU
Port 5000 already in use
- Solution: Kill the process or change port in backend file
See SOLUTION_GUIDE.md for detailed troubleshooting.
π Documentation
- SOLUTION_GUIDE.md - Complete troubleshooting guide
- README_LOCAL.md - Local generation setup
- REPLICATE_SETUP.md - Replicate API setup
- QUICKSTART_LOCAL.md - Quick local setup
π€ Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments
- CogVideoX by Tsinghua University
- Hailuo Video-01 by MiniMax
- Replicate for API infrastructure
- Hugging Face for model hosting
π Star History
If you find this project useful, please consider giving it a star! β
π Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: your-email@example.com
Made with β€οΈ for the AI video generation community