Spaces:
Running on Zero
Running on Zero
Update lipsync.py
Browse files- lipsync.py +32 -31
lipsync.py
CHANGED
|
@@ -1,31 +1,32 @@
|
|
| 1 |
-
|
| 2 |
-
from latentsync.pipelines.lipsync_pipeline import LipsyncPipeline
|
| 3 |
-
import torch
|
| 4 |
-
|
| 5 |
-
pipeline = LipsyncPipeline(
|
| 6 |
-
scheduler=None,
|
| 7 |
-
vae=None,
|
| 8 |
-
audio_encoder=None,
|
| 9 |
-
unet=None,
|
| 10 |
-
).to("cuda")
|
| 11 |
-
|
| 12 |
-
def apply_lipsync(video_input_path, audio_path, video_out_path):
|
| 13 |
-
|
| 14 |
-
torch.manual_seed(1234)
|
| 15 |
-
|
| 16 |
-
print(f"Initial seed: {torch.initial_seed()}")
|
| 17 |
-
|
| 18 |
-
pipeline(
|
| 19 |
-
video_path=video_input_path,
|
| 20 |
-
audio_path=audio_path,
|
| 21 |
-
video_out_path=video_out_path,
|
| 22 |
-
video_mask_path=video_out_path.replace(".mp4", "_mask.mp4"),
|
| 23 |
-
num_frames=16,
|
| 24 |
-
num_inference_steps=20,
|
| 25 |
-
guidance_scale=1.0,
|
| 26 |
-
weight_dtype=torch.float16,
|
| 27 |
-
width=256,
|
| 28 |
-
height=256,
|
| 29 |
-
)
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
| 1 |
+
# ByteDance/LatentSync
|
| 2 |
+
from latentsync.pipelines.lipsync_pipeline import LipsyncPipeline
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
pipeline = LipsyncPipeline(
|
| 6 |
+
scheduler=None,
|
| 7 |
+
vae=None,
|
| 8 |
+
audio_encoder=None,
|
| 9 |
+
unet=None,
|
| 10 |
+
).to("cuda")
|
| 11 |
+
|
| 12 |
+
def apply_lipsync(video_input_path, audio_path, video_out_path):
|
| 13 |
+
|
| 14 |
+
torch.manual_seed(1234)
|
| 15 |
+
|
| 16 |
+
print(f"Initial seed: {torch.initial_seed()}")
|
| 17 |
+
|
| 18 |
+
pipeline(
|
| 19 |
+
video_path=video_input_path,
|
| 20 |
+
audio_path=audio_path,
|
| 21 |
+
video_out_path=video_out_path,
|
| 22 |
+
video_mask_path=video_out_path.replace(".mp4", "_mask.mp4"),
|
| 23 |
+
num_frames=16,
|
| 24 |
+
num_inference_steps=20,
|
| 25 |
+
guidance_scale=1.0,
|
| 26 |
+
weight_dtype=torch.float16,
|
| 27 |
+
width=256,
|
| 28 |
+
height=256,
|
| 29 |
+
)
|
| 30 |
+
torch.cuda.empty_cache()
|
| 31 |
+
|
| 32 |
+
return video_out_path
|