A collection of production-ready, multi-GPU inference pipelines for video generation, image-to-video conversion, and depth estimation using Hugging Face models.
opensora/
βββ text_to_video/ # Text-to-video generation
β βββ simple_inference.py
β βββ multi_gpu_inference.py
β βββ batch_inference.py
β βββ compare_models.py
β βββ README.md
β
βββ image_to_video/ # Image-to-video conversion
β βββ simple_image_to_video.py
β βββ image_to_video_multi_gpu.py
β βββ batch_image_to_video.py
β βββ README.md
β
βββ depth_estimation/ # Depth estimation
βββ simple_depth_estimation.py
βββ multi_gpu_depth_estimation.py
βββ batch_depth_estimation.py
βββ compare_models.py
βββ README.md
# Clone or download the project
cd opensora
# Install dependencies for all pipelines
pip install torch>=2.0.0 transformers>=4.35.0 diffusers>=0.25.0 accelerate>=0.24.0 \
pillow>=10.0.0 matplotlib>=3.7.0 "numpy<2.0.0" opencv-python>=4.8.0
# Text-to-video only
pip install -r text_to_video/requirements.txt
# Image-to-video only
pip install -r image_to_video/requirements.txt
# Depth estimation only
pip install -r depth_estimation/requirements.txt
!pip install -q torch transformers diffusers accelerate pillow matplotlib "numpy<2.0.0"
from text_to_video.simple_inference import simple_text_to_video
# Generate video from text
simple_text_to_video(
prompt="A cat playing piano",
output_path="cat_piano.mp4"
)
from image_to_video.simple_image_to_video import simple_image_to_video
# Convert image to video
simple_image_to_video(
image_path="photo.jpg",
output_path="animated.mp4"
)
from depth_estimation.simple_depth_estimation import simple_depth_estimation
# Estimate depth from image
simple_depth_estimation(
image_path="scene.jpg",
output_path="depth_map.png"
)
All pipelines support multi-GPU automatically:
# Text-to-video with multi-GPU
from text_to_video.multi_gpu_inference import generate_video_multi_gpu
generate_video_multi_gpu(
prompt="Astronaut riding a horse",
use_multi_gpu=True # Automatically distributes across GPUs
)
# Image-to-video with multi-GPU
from image_to_video.image_to_video_multi_gpu import image_to_video_multi_gpu
image_to_video_multi_gpu(
image_path="input.jpg",
use_multi_gpu=True
)
# Depth estimation with multi-GPU
from depth_estimation.multi_gpu_depth_estimation import estimate_depth_multi_gpu
estimate_depth_multi_gpu(
image_path="input.jpg",
use_multi_gpu=True
)
Tested on 2x Tesla T4 GPUs (14.7GB each):
| Pipeline | Task | Single GPU | Multi-GPU (2x) | Speedup |
|---|---|---|---|---|
| Text-to-Video | 25 frames | 45s | 28s | 1.6x |
| Image-to-Video | 14 frames | 180s | 110s | 1.6x |
| Depth Estimation | 1024x1024 | 3.5s | 2.1s | 1.7x |
Each pipeline has comprehensive documentation:
import os
import torch
import gc
# Set memory optimization
os.environ['PYTORCH_CUDA_ALLOC_CONF'] = 'expandable_segments:True'
# Clear GPU cache
torch.cuda.empty_cache()
gc.collect()
# Use only GPU 0 and 1
export CUDA_VISIBLE_DEVICES=0,1
# Or in Python
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0,1'
# Test with small model first
model_id="depth-anything-small"
max_image_size=512
# Much faster than processing individually
python batch_depth_estimation.py --input-dir ./images
import torch
# Check GPU memory
for i in range(torch.cuda.device_count()):
print(f"GPU {i}: {torch.cuda.memory_allocated(i)/1e9:.2f}GB")
torch.cuda.empty_cache()
import gc; gc.collect()
CUDA Out of Memory:
Slow Performance:
torch.cuda.is_available()Model Download Fails:
export HF_HOME=/path/to/cacheSee individual TROUBLESHOOTING.md files for detailed solutions.
Test each pipeline:
# Test text-to-video
python text_to_video/test_installation.py
# Test image-to-video
python image_to_video/simple_image_to_video.py --help
# Test depth estimation
python depth_estimation/test_installation.py
Contributions welcome! Each pipeline is self-contained and follows the same structure for easy extension.
Individual models have their own licenses. Check model cards on Hugging Face.
For issues:
nvidia-smiSee the examples.py file in each pipeline directory for 10+ ready-to-run examples covering:
Ready to start? Choose a pipeline and check its QUICKSTART.md file!
# Text-to-video
cd text_to_video && cat QUICKSTART.md
# Image-to-video
cd image_to_video && cat QUICKSTART.md
# Depth estimation
cd depth_estimation && cat QUICKSTART.md
1 commits
Python
99.4%
A collection of production-ready, multi-GPU inference pipelines for video generation, image-to-video conversion, and depth estimation using Hugging Face models.
opensora/
βββ text_to_video/ # Text-to-video generation
β βββ simple_inference.py
β βββ multi_gpu_inference.py
β βββ batch_inference.py
β βββ compare_models.py
β βββ README.md
β
βββ image_to_video/ # Image-to-video conversion
β βββ simple_image_to_video.py
β βββ image_to_video_multi_gpu.py
β βββ batch_image_to_video.py
β βββ README.md
β
βββ depth_estimation/ # Depth estimation
βββ simple_depth_estimation.py
βββ multi_gpu_depth_estimation.py
βββ batch_depth_estimation.py
βββ compare_models.py
βββ README.md
# Clone or download the project
cd opensora
# Install dependencies for all pipelines
pip install torch>=2.0.0 transformers>=4.35.0 diffusers>=0.25.0 accelerate>=0.24.0 \
pillow>=10.0.0 matplotlib>=3.7.0 "numpy<2.0.0" opencv-python>=4.8.0
# Text-to-video only
pip install -r text_to_video/requirements.txt
# Image-to-video only
pip install -r image_to_video/requirements.txt
# Depth estimation only
pip install -r depth_estimation/requirements.txt
!pip install -q torch transformers diffusers accelerate pillow matplotlib "numpy<2.0.0"
from text_to_video.simple_inference import simple_text_to_video
# Generate video from text
simple_text_to_video(
prompt="A cat playing piano",
output_path="cat_piano.mp4"
)
from image_to_video.simple_image_to_video import simple_image_to_video
# Convert image to video
simple_image_to_video(
image_path="photo.jpg",
output_path="animated.mp4"
)
from depth_estimation.simple_depth_estimation import simple_depth_estimation
# Estimate depth from image
simple_depth_estimation(
image_path="scene.jpg",
output_path="depth_map.png"
)
All pipelines support multi-GPU automatically:
# Text-to-video with multi-GPU
from text_to_video.multi_gpu_inference import generate_video_multi_gpu
generate_video_multi_gpu(
prompt="Astronaut riding a horse",
use_multi_gpu=True # Automatically distributes across GPUs
)
# Image-to-video with multi-GPU
from image_to_video.image_to_video_multi_gpu import image_to_video_multi_gpu
image_to_video_multi_gpu(
image_path="input.jpg",
use_multi_gpu=True
)
# Depth estimation with multi-GPU
from depth_estimation.multi_gpu_depth_estimation import estimate_depth_multi_gpu
estimate_depth_multi_gpu(
image_path="input.jpg",
use_multi_gpu=True
)
Tested on 2x Tesla T4 GPUs (14.7GB each):
| Pipeline | Task | Single GPU | Multi-GPU (2x) | Speedup |
|---|---|---|---|---|
| Text-to-Video | 25 frames | 45s | 28s | 1.6x |
| Image-to-Video | 14 frames | 180s | 110s | 1.6x |
| Depth Estimation | 1024x1024 | 3.5s | 2.1s | 1.7x |
Each pipeline has comprehensive documentation:
import os
import torch
import gc
# Set memory optimization
os.environ['PYTORCH_CUDA_ALLOC_CONF'] = 'expandable_segments:True'
# Clear GPU cache
torch.cuda.empty_cache()
gc.collect()
# Use only GPU 0 and 1
export CUDA_VISIBLE_DEVICES=0,1
# Or in Python
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0,1'
# Test with small model first
model_id="depth-anything-small"
max_image_size=512
# Much faster than processing individually
python batch_depth_estimation.py --input-dir ./images
import torch
# Check GPU memory
for i in range(torch.cuda.device_count()):
print(f"GPU {i}: {torch.cuda.memory_allocated(i)/1e9:.2f}GB")
torch.cuda.empty_cache()
import gc; gc.collect()
CUDA Out of Memory:
Slow Performance:
torch.cuda.is_available()Model Download Fails:
export HF_HOME=/path/to/cacheSee individual TROUBLESHOOTING.md files for detailed solutions.
Test each pipeline:
# Test text-to-video
python text_to_video/test_installation.py
# Test image-to-video
python image_to_video/simple_image_to_video.py --help
# Test depth estimation
python depth_estimation/test_installation.py
Contributions welcome! Each pipeline is self-contained and follows the same structure for easy extension.
Individual models have their own licenses. Check model cards on Hugging Face.
For issues:
nvidia-smiSee the examples.py file in each pipeline directory for 10+ ready-to-run examples covering:
Ready to start? Choose a pipeline and check its QUICKSTART.md file!
# Text-to-video
cd text_to_video && cat QUICKSTART.md
# Image-to-video
cd image_to_video && cat QUICKSTART.md
# Depth estimation
cd depth_estimation && cat QUICKSTART.md
1 commits
Python
99.4%