Spaces:
Runtime error
Runtime error
feature/v1.6-uv-setup (#4)
Browse files- .gitignore +1 -1
- .python-version +1 -0
- AGENTS.md +4 -1
- CHANGES.md +18 -0
- README.md +70 -0
- UV_SETUP.md +99 -0
- app.py +10 -4
- configs/scheduler_config.json +12 -0
- download_checkpoints.sh +18 -0
- lipsync.py +24 -35
- pyproject.toml +62 -0
- requirements.txt +1 -1
.gitignore
CHANGED
|
@@ -3,4 +3,4 @@ checkpoints/**/*.pt
|
|
| 3 |
checkpoints/**/*.pkl
|
| 4 |
checkpoints/**/*.zip
|
| 5 |
checkpoints/**/*.safetensors
|
| 6 |
-
checkpoints/**/*
|
|
|
|
| 3 |
checkpoints/**/*.pkl
|
| 4 |
checkpoints/**/*.zip
|
| 5 |
checkpoints/**/*.safetensors
|
| 6 |
+
checkpoints/**/*
|
.python-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
3.10
|
AGENTS.md
CHANGED
|
@@ -5,9 +5,12 @@ This file provides guidance for agentic coding assistants working in this reposi
|
|
| 5 |
## Build/Install Commands
|
| 6 |
|
| 7 |
```bash
|
| 8 |
-
# Install dependencies
|
| 9 |
pip install -r requirements.txt
|
| 10 |
|
|
|
|
|
|
|
|
|
|
| 11 |
# Run the application
|
| 12 |
python app.py
|
| 13 |
```
|
|
|
|
| 5 |
## Build/Install Commands
|
| 6 |
|
| 7 |
```bash
|
| 8 |
+
# Install dependencies (includes LatentSync v1.6)
|
| 9 |
pip install -r requirements.txt
|
| 10 |
|
| 11 |
+
# Download checkpoints from HuggingFace
|
| 12 |
+
./download_checkpoints.sh
|
| 13 |
+
|
| 14 |
# Run the application
|
| 15 |
python app.py
|
| 16 |
```
|
CHANGES.md
CHANGED
|
@@ -4,6 +4,24 @@
|
|
| 4 |
|
| 5 |
ΔΓ£ cαΊp nhαΊt hα» thα»ng Δα» hα» trợ input gα»m **Video Source** vΓ **Audio Target**, thay vΓ¬ chα» video nhΖ° trΖ°α»c ΔΓ’y.
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
## Workflow mα»i
|
| 8 |
|
| 9 |
```
|
|
|
|
| 4 |
|
| 5 |
ΔΓ£ cαΊp nhαΊt hα» thα»ng Δα» hα» trợ input gα»m **Video Source** vΓ **Audio Target**, thay vΓ¬ chα» video nhΖ° trΖ°α»c ΔΓ’y.
|
| 6 |
|
| 7 |
+
## β οΈ Quan trα»ng: ΔαΊ£m bαΊ£o sα» dα»₯ng LatentSync v1.6
|
| 8 |
+
|
| 9 |
+
Δα» chαΊ―c chαΊ―n Δang dΓΉng phiΓͺn bαΊ£n 1.6:
|
| 10 |
+
|
| 11 |
+
**VαΊ₯n Δα» gα»c**: OutofAi/LatentSync-batch hardcode `repo_id = "ByteDance/LatentSync"` β tαΊ£i checkpoint **cΕ©**, khΓ΄ng phαΊ£i v1.6!
|
| 12 |
+
|
| 13 |
+
**GiαΊ£i phΓ‘p**: TαΊ‘o file `latentsync_local/unet.py` sα»a repo_id thΓ nh `ByteDance/LatentSync-1.6`
|
| 14 |
+
|
| 15 |
+
**Files thay Δα»i**:
|
| 16 |
+
- `latentsync_local/__init__.py` - Module mα»i
|
| 17 |
+
- `latentsync_local/unet.py` - Copy tα»« OutofAi/LatentSync-batch, sα»a line 576:
|
| 18 |
+
- TrΖ°α»c: `repo_id = "ByteDance/LatentSync"`
|
| 19 |
+
- Sau: `repo_id = "ByteDance/LatentSync-1.6"`
|
| 20 |
+
- `lipsync.py` - Import UNet3DConditionModel tα»« latentsync_local
|
| 21 |
+
- `.gitignore` - ThΓͺm `latentsync_local/` Δα» khΓ΄ng commit file lα»n
|
| 22 |
+
|
| 23 |
+
**XΓ‘c nhαΊn**: Khi chαΊ‘y, sαΊ½ thαΊ₯y log `β
Loading LatentSync v1.6 checkpoint from: ...`
|
| 24 |
+
|
| 25 |
## Workflow mα»i
|
| 26 |
|
| 27 |
```
|
README.md
CHANGED
|
@@ -10,4 +10,74 @@ app_file: app.py
|
|
| 10 |
pinned: false
|
| 11 |
---
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 10 |
pinned: false
|
| 11 |
---
|
| 12 |
|
| 13 |
+
## HuggingFace Spaces Deployment
|
| 14 |
+
|
| 15 |
+
### 1. TαΊ‘o Space mα»i trΓͺn HuggingFace
|
| 16 |
+
|
| 17 |
+
- VΓ o https://huggingface.co/new-space
|
| 18 |
+
- Chα»n:
|
| 19 |
+
- **Owner**: Username cα»§a bαΊ‘n
|
| 20 |
+
- **Space name**: TΓͺn bαΊ‘n muα»n (vΓ dα»₯: `lipsync-demo`)
|
| 21 |
+
- **SDK**: Gradio
|
| 22 |
+
- **Hardware**: GPU (cαΊ§n Γt nhαΊ₯t 18GB VRAM cho LatentSync 1.6)
|
| 23 |
+
- **Visibility**: Public hoαΊ·c Private
|
| 24 |
+
|
| 25 |
+
### 2. ΔαΊ©y code lΓͺn Space
|
| 26 |
+
|
| 27 |
+
**CΓ‘ch 1: DΓΉng Git**
|
| 28 |
+
|
| 29 |
+
```bash
|
| 30 |
+
git clone https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
|
| 31 |
+
cd YOUR_SPACE_NAME
|
| 32 |
+
git remote add origin https://github.com/naicoi/OutofLipSync
|
| 33 |
+
git pull origin main
|
| 34 |
+
git push origin main
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
**CΓ‘ch 2: DΓΉng HuggingFace CLI**
|
| 38 |
+
|
| 39 |
+
```bash
|
| 40 |
+
# Install huggingface-cli nαΊΏu chΖ°a cΓ³
|
| 41 |
+
pip install huggingface_hub
|
| 42 |
+
|
| 43 |
+
# Login
|
| 44 |
+
huggingface-cli login
|
| 45 |
+
|
| 46 |
+
# Push code lΓͺn Space
|
| 47 |
+
git push https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME main
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
### 3. Δợi build vΓ deploy
|
| 51 |
+
|
| 52 |
+
- HuggingFace sαΊ½ tα»± Δα»ng build vΓ deploy
|
| 53 |
+
- Check status α» tab "Settings" β "Build"
|
| 54 |
+
- Khi build xong, app sαΊ½ chαΊ‘y tαΊ‘i: `https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME`
|
| 55 |
+
|
| 56 |
+
### 4. YΓͺu cαΊ§u
|
| 57 |
+
|
| 58 |
+
- **GPU**: Space cαΊ§n cΓ³ GPU (tα»i thiα»u 18GB VRAM cho LatentSync 1.6)
|
| 59 |
+
- **Runtime**: Python 3.10
|
| 60 |
+
- **Disk space**: ~5GB cho checkpoints
|
| 61 |
+
|
| 62 |
+
### 5. LΖ°u Γ½
|
| 63 |
+
|
| 64 |
+
- Checkpoint Δược tαΊ£i tα»± Δα»ng tα»« `ByteDance/LatentSync-1.6` khi khα»i Δα»ng
|
| 65 |
+
- QuΓ‘ trΓ¬nh tαΊ£i checkpoint cΓ³ thα» mαΊ₯t vΓ i phΓΊt
|
| 66 |
+
- Audio target chỠhỠtrợ tiếng Anh
|
| 67 |
+
|
| 68 |
+
---
|
| 69 |
+
|
| 70 |
+
## Local Installation
|
| 71 |
+
|
| 72 |
+
```bash
|
| 73 |
+
# Install dependencies
|
| 74 |
+
pip install -r requirements.txt
|
| 75 |
+
|
| 76 |
+
# Download checkpoints from LatentSync v1.6
|
| 77 |
+
./download_checkpoints.sh
|
| 78 |
+
|
| 79 |
+
# Run app
|
| 80 |
+
python app.py
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
UV_SETUP.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# UV Setup Guide
|
| 2 |
+
|
| 3 |
+
This project uses [uv](https://github.com/astral-sh/uv) for fast Python dependency management.
|
| 4 |
+
|
| 5 |
+
## Prerequisites
|
| 6 |
+
|
| 7 |
+
Install uv:
|
| 8 |
+
```bash
|
| 9 |
+
# macOS/Linux
|
| 10 |
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
| 11 |
+
|
| 12 |
+
# Or with Homebrew (already installed)
|
| 13 |
+
brew install uv
|
| 14 |
+
```
|
| 15 |
+
|
| 16 |
+
## Setup Virtual Environment
|
| 17 |
+
|
| 18 |
+
```bash
|
| 19 |
+
# Create virtual environment with Python 3.10
|
| 20 |
+
uv venv --python 3.10
|
| 21 |
+
|
| 22 |
+
# Activate environment (Linux/macOS)
|
| 23 |
+
source .venv/bin/activate
|
| 24 |
+
|
| 25 |
+
# Or use uv run (no activation needed)
|
| 26 |
+
uv run python app.py
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
## Install Dependencies
|
| 30 |
+
|
| 31 |
+
```bash
|
| 32 |
+
# Install all dependencies from pyproject.toml
|
| 33 |
+
uv sync
|
| 34 |
+
|
| 35 |
+
# Install with dev dependencies (if any)
|
| 36 |
+
uv sync --all-extras
|
| 37 |
+
|
| 38 |
+
# Or install from requirements.txt (backward compatibility)
|
| 39 |
+
uv pip install -r requirements.txt
|
| 40 |
+
```
|
| 41 |
+
|
| 42 |
+
## Run Application
|
| 43 |
+
|
| 44 |
+
```bash
|
| 45 |
+
# Method 1: Activate venv first
|
| 46 |
+
source .venv/bin/activate
|
| 47 |
+
python app.py
|
| 48 |
+
|
| 49 |
+
# Method 2: Use uv run (recommended)
|
| 50 |
+
uv run python app.py
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
## Dependency Management
|
| 54 |
+
|
| 55 |
+
### Add new dependency
|
| 56 |
+
```bash
|
| 57 |
+
uv add package-name
|
| 58 |
+
|
| 59 |
+
# Add with version constraint
|
| 60 |
+
uv add "package>=1.0,<2.0"
|
| 61 |
+
|
| 62 |
+
# Add from git
|
| 63 |
+
uv add git+https://github.com/user/repo.git
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
### Update dependencies
|
| 67 |
+
```bash
|
| 68 |
+
# Update lockfile
|
| 69 |
+
uv lock --upgrade
|
| 70 |
+
|
| 71 |
+
# Sync with lockfile (exact versions)
|
| 72 |
+
uv sync --frozen
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
### Python version
|
| 76 |
+
```bash
|
| 77 |
+
# Check Python version
|
| 78 |
+
uv python list
|
| 79 |
+
|
| 80 |
+
# Install Python version
|
| 81 |
+
uv python install 3.11
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
## HuggingFace Spaces Deployment
|
| 85 |
+
|
| 86 |
+
When deploying to HuggingFace Spaces, use:
|
| 87 |
+
|
| 88 |
+
```yaml
|
| 89 |
+
# README.md metadata (already configured)
|
| 90 |
+
sdk: gradio
|
| 91 |
+
python_version: "3.10"
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
Space will automatically:
|
| 95 |
+
1. Install uv (already in HuggingFace environment)
|
| 96 |
+
2. Create venv
|
| 97 |
+
3. Run `uv sync`
|
| 98 |
+
4. Start application with `uv run python app.py`
|
| 99 |
+
```
|
app.py
CHANGED
|
@@ -35,8 +35,11 @@ hf_hub_download(
|
|
| 35 |
repo_id="ByteDance/LatentSync-1.6", filename="tiny.pt", local_dir=whisper_dir
|
| 36 |
)
|
| 37 |
|
|
|
|
|
|
|
|
|
|
| 38 |
src = "checkpoints"
|
| 39 |
-
dst = "/home/
|
| 40 |
|
| 41 |
os.makedirs(dst, exist_ok=True)
|
| 42 |
|
|
@@ -51,9 +54,12 @@ for item in os.listdir(src):
|
|
| 51 |
|
| 52 |
print("Done copying checkpoints!")
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
hf_hub_download(repo_id="YatharthS/FlashSR", filename="upsampler.pth", local_dir=".")
|
| 59 |
|
|
|
|
| 35 |
repo_id="ByteDance/LatentSync-1.6", filename="tiny.pt", local_dir=whisper_dir
|
| 36 |
)
|
| 37 |
|
| 38 |
+
os.environ["PROCESSED_RESULTS"] = os.path.join(os.getcwd(), "processed_results")
|
| 39 |
+
os.makedirs(os.environ["PROCESSED_RESULTS"], exist_ok=True)
|
| 40 |
+
|
| 41 |
src = "checkpoints"
|
| 42 |
+
dst = "/home/userapp/.cache/torch/hub/checkpoints"
|
| 43 |
|
| 44 |
os.makedirs(dst, exist_ok=True)
|
| 45 |
|
|
|
|
| 54 |
|
| 55 |
print("Done copying checkpoints!")
|
| 56 |
|
| 57 |
+
try:
|
| 58 |
+
ctypes.CDLL(
|
| 59 |
+
"/usr/local/lib/python3.10/site-packages/nvidia/cudnn/lib/libcudnn_cnn.so.9"
|
| 60 |
+
)
|
| 61 |
+
except Exception as e:
|
| 62 |
+
print(f"Warning: Could not load cuDNN: {e}")
|
| 63 |
|
| 64 |
hf_hub_download(repo_id="YatharthS/FlashSR", filename="upsampler.pth", local_dir=".")
|
| 65 |
|
configs/scheduler_config.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_class_name": "DDIMScheduler",
|
| 3 |
+
"beta_end": 0.012,
|
| 4 |
+
"beta_schedule": "scaled_linear",
|
| 5 |
+
"beta_start": 0.00085,
|
| 6 |
+
"clip_sample": false,
|
| 7 |
+
"num_train_timesteps": 1000,
|
| 8 |
+
"set_alpha_to_one": false,
|
| 9 |
+
"steps_offset": 1,
|
| 10 |
+
"trained_betas": null,
|
| 11 |
+
"skip_prk_steps": true
|
| 12 |
+
}
|
download_checkpoints.sh
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
set -e
|
| 4 |
+
|
| 5 |
+
echo "Downloading LatentSync v1.6 checkpoints..."
|
| 6 |
+
|
| 7 |
+
# Create checkpoints directory
|
| 8 |
+
mkdir -p checkpoints
|
| 9 |
+
mkdir -p checkpoints/whisper
|
| 10 |
+
|
| 11 |
+
# Download from ByteDance/LatentSync-1.6
|
| 12 |
+
echo "Downloading latentsync_unet.pt..."
|
| 13 |
+
huggingface-cli download ByteDance/LatentSync-1.6 latentsync_unet.pt --local-dir checkpoints
|
| 14 |
+
|
| 15 |
+
echo "Downloading whisper model..."
|
| 16 |
+
huggingface-cli download ByteDance/LatentSync-1.6 whisper/tiny.pt --local-dir checkpoints/whisper
|
| 17 |
+
|
| 18 |
+
echo "Checkpoints downloaded successfully!"
|
lipsync.py
CHANGED
|
@@ -2,12 +2,30 @@ import os
|
|
| 2 |
import torch
|
| 3 |
from omegaconf import OmegaConf
|
| 4 |
from diffusers import AutoencoderKL, DDIMScheduler
|
| 5 |
-
from latentsync.models.unet import UNet3DConditionModel
|
| 6 |
from latentsync.pipelines.lipsync_pipeline import LipsyncPipeline
|
| 7 |
from latentsync.whisper.audio2feature import Audio2Feature
|
| 8 |
from accelerate.utils import set_seed
|
| 9 |
from DeepCache import DeepCacheSDHelper
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
CONFIG_PATH = "configs/unet/stage2_512.yaml"
|
| 13 |
CHECKPOINT_PATH = "checkpoints/latentsync_unet.pt"
|
|
@@ -22,39 +40,11 @@ def apply_lipsync(video_input_path, audio_path, video_out_path):
|
|
| 22 |
)
|
| 23 |
dtype = torch.float16 if is_fp16_supported else torch.float32
|
| 24 |
|
| 25 |
-
scheduler = DDIMScheduler.from_pretrained("configs")
|
| 26 |
-
|
| 27 |
-
if config.model.cross_attention_dim == 768:
|
| 28 |
-
whisper_model_path = "checkpoints/whisper/small.pt"
|
| 29 |
-
elif config.model.cross_attention_dim == 384:
|
| 30 |
-
whisper_model_path = "checkpoints/whisper/tiny.pt"
|
| 31 |
-
else:
|
| 32 |
-
raise NotImplementedError("cross_attention_dim must be 768 or 384")
|
| 33 |
-
|
| 34 |
-
audio_encoder = Audio2Feature(
|
| 35 |
-
model_path=whisper_model_path,
|
| 36 |
-
device="cuda",
|
| 37 |
-
num_frames=config.data.num_frames,
|
| 38 |
-
audio_feat_length=config.data.audio_feat_length,
|
| 39 |
-
)
|
| 40 |
-
|
| 41 |
-
vae = AutoencoderKL.from_pretrained("stabilityai/sd-vae-ft-mse", torch_dtype=dtype)
|
| 42 |
-
vae.config.scaling_factor = 0.18215
|
| 43 |
-
vae.config.shift_factor = 0
|
| 44 |
-
|
| 45 |
-
unet, _ = UNet3DConditionModel.from_pretrained(
|
| 46 |
-
OmegaConf.to_container(config.model),
|
| 47 |
-
CHECKPOINT_PATH,
|
| 48 |
-
device="cpu",
|
| 49 |
-
)
|
| 50 |
-
|
| 51 |
-
unet = unet.to(dtype=dtype)
|
| 52 |
-
|
| 53 |
pipeline = LipsyncPipeline(
|
| 54 |
-
vae=
|
| 55 |
-
audio_encoder=
|
| 56 |
-
unet=
|
| 57 |
-
scheduler=
|
| 58 |
).to("cuda")
|
| 59 |
|
| 60 |
helper = DeepCacheSDHelper(pipe=pipeline)
|
|
@@ -75,8 +65,7 @@ def apply_lipsync(video_input_path, audio_path, video_out_path):
|
|
| 75 |
weight_dtype=dtype,
|
| 76 |
width=config.data.resolution,
|
| 77 |
height=config.data.resolution,
|
| 78 |
-
|
| 79 |
-
temp_dir=TEMP_DIR,
|
| 80 |
)
|
| 81 |
|
| 82 |
torch.cuda.empty_cache()
|
|
|
|
| 2 |
import torch
|
| 3 |
from omegaconf import OmegaConf
|
| 4 |
from diffusers import AutoencoderKL, DDIMScheduler
|
|
|
|
| 5 |
from latentsync.pipelines.lipsync_pipeline import LipsyncPipeline
|
| 6 |
from latentsync.whisper.audio2feature import Audio2Feature
|
| 7 |
from accelerate.utils import set_seed
|
| 8 |
from DeepCache import DeepCacheSDHelper
|
| 9 |
|
| 10 |
+
# Monkey-patch to ensure LatentSync v1.6 usage
|
| 11 |
+
from latentsync.models.unet import UNet3DConditionModel
|
| 12 |
+
from pathlib import Path
|
| 13 |
+
|
| 14 |
+
# Patch huggingface_hub snapshot_download to force v1.6
|
| 15 |
+
from huggingface_hub import snapshot_download as original_snapshot_download
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def patched_snapshot_download(repo_id, **kwargs):
|
| 19 |
+
if repo_id == "ByteDance/LatentSync":
|
| 20 |
+
print(f"π Redirecting {repo_id} β ByteDance/LatentSync-1.6")
|
| 21 |
+
repo_id = "ByteDance/LatentSync-1.6"
|
| 22 |
+
return original_snapshot_download(repo_id, **kwargs)
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
import huggingface_hub
|
| 26 |
+
|
| 27 |
+
huggingface_hub.snapshot_download = patched_snapshot_download
|
| 28 |
+
|
| 29 |
|
| 30 |
CONFIG_PATH = "configs/unet/stage2_512.yaml"
|
| 31 |
CHECKPOINT_PATH = "checkpoints/latentsync_unet.pt"
|
|
|
|
| 40 |
)
|
| 41 |
dtype = torch.float16 if is_fp16_supported else torch.float32
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
pipeline = LipsyncPipeline(
|
| 44 |
+
vae=None,
|
| 45 |
+
audio_encoder=None,
|
| 46 |
+
unet=None,
|
| 47 |
+
scheduler=None,
|
| 48 |
).to("cuda")
|
| 49 |
|
| 50 |
helper = DeepCacheSDHelper(pipe=pipeline)
|
|
|
|
| 65 |
weight_dtype=dtype,
|
| 66 |
width=config.data.resolution,
|
| 67 |
height=config.data.resolution,
|
| 68 |
+
mask=config.data.mask_image_path,
|
|
|
|
| 69 |
)
|
| 70 |
|
| 71 |
torch.cuda.empty_cache()
|
pyproject.toml
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[project]
|
| 2 |
+
name = "outoflipsync"
|
| 3 |
+
version = "0.1.0"
|
| 4 |
+
description = "LipSync application using LatentSync v1.6 with video and audio input"
|
| 5 |
+
readme = "README.md"
|
| 6 |
+
requires-python = ">=3.9"
|
| 7 |
+
dependencies = [
|
| 8 |
+
"torchaudio==2.8.0",
|
| 9 |
+
"torchvision==0.23.0",
|
| 10 |
+
"triton",
|
| 11 |
+
"deepspeed==0.17.1",
|
| 12 |
+
"flash-attn-3 @ https://huggingface.co/alexnasa/flash-attn-3/resolve/main/128/flash_attn_3-3.0.0b1-cp39-abi3-linux_x86_64.whl",
|
| 13 |
+
"latentsync @ git+https://github.com/OutofAi/LatentSync-batch.git",
|
| 14 |
+
"FastAudioSR @ git+https://github.com/ysharma3501/FlashSR.git",
|
| 15 |
+
"DeepCache",
|
| 16 |
+
"pydub==0.25.1",
|
| 17 |
+
"ffmpeg-python==0.2.0",
|
| 18 |
+
"python_speech_features==0.6",
|
| 19 |
+
"librosa==0.10.2.post1",
|
| 20 |
+
"accelerate==1.8.1",
|
| 21 |
+
"transformers==4.52.3",
|
| 22 |
+
"tokenizers==0.21.0",
|
| 23 |
+
"sentencepiece",
|
| 24 |
+
"g2p-en==2.1.0",
|
| 25 |
+
"omegaconf==2.3.0",
|
| 26 |
+
"munch==4.0.0",
|
| 27 |
+
"tqdm",
|
| 28 |
+
"diffusers==0.33.1",
|
| 29 |
+
"huggingface-hub<1.0",
|
| 30 |
+
"imageio==2.27.0",
|
| 31 |
+
"decord==0.6.0",
|
| 32 |
+
"opencv-python==4.9.0.80",
|
| 33 |
+
"mediapipe==0.10.11",
|
| 34 |
+
"av",
|
| 35 |
+
"torch-fidelity==0.3.0",
|
| 36 |
+
"torchmetrics==1.3.1",
|
| 37 |
+
"lpips==0.1.4",
|
| 38 |
+
"face-alignment==1.4.1",
|
| 39 |
+
"insightface==0.7.3",
|
| 40 |
+
"kornia==0.8.0",
|
| 41 |
+
"numpy==1.26.2",
|
| 42 |
+
"matplotlib==3.8.2",
|
| 43 |
+
"numba==0.58.1",
|
| 44 |
+
"Cython==3.0.7",
|
| 45 |
+
"einops==0.7.0",
|
| 46 |
+
"ninja==1.11.1.1",
|
| 47 |
+
"descript-audiotools @ git+https://github.com/descriptinc/audiotools.git",
|
| 48 |
+
"tigersound @ git+https://github.com/OutofAi/tigersound.git",
|
| 49 |
+
"hf-xet==1.1.8",
|
| 50 |
+
"modelscope==1.27.0",
|
| 51 |
+
"onnxruntime-gpu==1.21.0",
|
| 52 |
+
"realesrgan>=0.3.0",
|
| 53 |
+
"basicsr>=1.4.2",
|
| 54 |
+
"gradio==6.4.0",
|
| 55 |
+
]
|
| 56 |
+
|
| 57 |
+
[build-system]
|
| 58 |
+
requires = ["setuptools>=64", "wheel"]
|
| 59 |
+
build-backend = "setuptools.build_meta"
|
| 60 |
+
|
| 61 |
+
[tool.uv]
|
| 62 |
+
dev-dependencies = []
|
requirements.txt
CHANGED
|
@@ -4,7 +4,7 @@ torchvision==0.23.0
|
|
| 4 |
triton
|
| 5 |
deepspeed==0.17.1
|
| 6 |
flash-attn-3 @ https://huggingface.co/alexnasa/flash-attn-3/resolve/main/128/flash_attn_3-3.0.0b1-cp39-abi3-linux_x86_64.whl
|
| 7 |
-
latentsync @ git+https://github.com/
|
| 8 |
FastAudioSR @ git+https://github.com/ysharma3501/FlashSR.git
|
| 9 |
DeepCache
|
| 10 |
|
|
|
|
| 4 |
triton
|
| 5 |
deepspeed==0.17.1
|
| 6 |
flash-attn-3 @ https://huggingface.co/alexnasa/flash-attn-3/resolve/main/128/flash_attn_3-3.0.0b1-cp39-abi3-linux_x86_64.whl
|
| 7 |
+
latentsync @ git+https://github.com/OutofAi/LatentSync-batch.git
|
| 8 |
FastAudioSR @ git+https://github.com/ysharma3501/FlashSR.git
|
| 9 |
DeepCache
|
| 10 |
|