Update app.py
Browse files
app.py
CHANGED
|
@@ -51,7 +51,7 @@ except Exception as e:
|
|
| 51 |
raise e # fail fast if model load fails
|
| 52 |
|
| 53 |
|
| 54 |
-
pipe,fantasytalking,wav2vec_processor,wav2vec = None,None,None,None
|
| 55 |
@spaces.GPU(duration=1200)
|
| 56 |
def generate_video(
|
| 57 |
image_path,
|
|
@@ -65,30 +65,35 @@ def generate_video(
|
|
| 65 |
inference_steps,
|
| 66 |
seed,
|
| 67 |
):
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
image_path = Path(image_path).absolute().as_posix()
|
| 75 |
-
audio_path = Path(audio_path).absolute().as_posix()
|
| 76 |
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
image_size=image_size,
|
| 88 |
-
max_num_frames=max_num_frames,
|
| 89 |
-
inference_steps=inference_steps,
|
| 90 |
-
seed=seed,
|
| 91 |
-
)
|
| 92 |
|
| 93 |
|
| 94 |
|
|
|
|
| 51 |
raise e # fail fast if model load fails
|
| 52 |
|
| 53 |
|
| 54 |
+
# pipe,fantasytalking,wav2vec_processor,wav2vec = None,None,None,None
|
| 55 |
@spaces.GPU(duration=1200)
|
| 56 |
def generate_video(
|
| 57 |
image_path,
|
|
|
|
| 65 |
inference_steps,
|
| 66 |
seed,
|
| 67 |
):
|
| 68 |
+
try:
|
| 69 |
+
output_dir = Path("./output")
|
| 70 |
+
output_dir.mkdir(parents=True, exist_ok=True)
|
| 71 |
|
| 72 |
+
image_path = Path(image_path).absolute().as_posix()
|
| 73 |
+
audio_path = Path(audio_path).absolute().as_posix()
|
|
|
|
|
|
|
| 74 |
|
| 75 |
+
args = create_args(
|
| 76 |
+
image_path=image_path,
|
| 77 |
+
audio_path=audio_path,
|
| 78 |
+
prompt=prompt or "A person is talking.",
|
| 79 |
+
output_dir=str(output_dir),
|
| 80 |
+
audio_weight=audio_weight,
|
| 81 |
+
prompt_cfg_scale=prompt_cfg_scale,
|
| 82 |
+
audio_cfg_scale=audio_cfg_scale,
|
| 83 |
+
image_size=image_size,
|
| 84 |
+
max_num_frames=max_num_frames,
|
| 85 |
+
inference_steps=inference_steps,
|
| 86 |
+
seed=seed,
|
| 87 |
+
)
|
| 88 |
|
| 89 |
+
# ✅ Run inference using preloaded models
|
| 90 |
+
save_path = main(args, pipe, fantasytalking, wav2vec_processor, wav2vec)
|
| 91 |
+
print(f"✅ Video saved at {save_path}")
|
| 92 |
+
return save_path
|
| 93 |
+
|
| 94 |
+
except Exception as e:
|
| 95 |
+
print(f"❌ Error generating video: {e}")
|
| 96 |
+
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
|
| 98 |
|
| 99 |
|