Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,77 +1,42 @@
|
|
| 1 |
-
import os
|
| 2 |
import gradio as gr
|
| 3 |
import subprocess
|
| 4 |
from pathlib import Path
|
| 5 |
-
import
|
| 6 |
-
|
| 7 |
-
# Simple setup
|
| 8 |
-
ROOT = Path("/tmp/musehub")
|
| 9 |
-
ROOT.mkdir(exist_ok=True)
|
| 10 |
|
| 11 |
-
def
|
| 12 |
-
|
|
|
|
|
|
|
| 13 |
try:
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
"python", "inference.py",
|
| 22 |
-
"--face", image_path,
|
| 23 |
-
"--audio", audio_path,
|
| 24 |
-
"--outfile", str(output)
|
| 25 |
-
]
|
| 26 |
-
|
| 27 |
-
subprocess.run(cmd, check=True, cwd="/app/video-retalking")
|
| 28 |
-
|
| 29 |
-
if output.exists():
|
| 30 |
-
return str(output), "✅ Video generated!"
|
| 31 |
-
return None, "❌ Generation failed"
|
| 32 |
|
|
|
|
|
|
|
| 33 |
except Exception as e:
|
| 34 |
-
return None,
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
], check=True)
|
| 49 |
-
|
| 50 |
-
# Download checkpoints
|
| 51 |
-
subprocess.run([
|
| 52 |
-
"bash", "scripts/download_models.sh"
|
| 53 |
-
], cwd=repo_dir, check=True)
|
| 54 |
-
|
| 55 |
-
return True
|
| 56 |
-
except:
|
| 57 |
-
return False
|
| 58 |
|
| 59 |
-
#
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
with gr.Row():
|
| 64 |
-
with gr.Column():
|
| 65 |
-
image = gr.Image(type="filepath", label="Face Image")
|
| 66 |
-
audio = gr.Audio(type="filepath", label="Audio File")
|
| 67 |
-
btn = gr.Button("🚀 Generate", variant="primary")
|
| 68 |
-
|
| 69 |
-
with gr.Column():
|
| 70 |
-
video = gr.Video(label="Result")
|
| 71 |
-
status = gr.Textbox(label="Status")
|
| 72 |
-
|
| 73 |
-
btn.click(generate_lipsync, [image, audio], [video, status])
|
| 74 |
|
| 75 |
-
|
| 76 |
-
setup_model()
|
| 77 |
-
demo.launch()
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import subprocess
|
| 3 |
from pathlib import Path
|
| 4 |
+
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
def generate(image, audio):
|
| 7 |
+
if not image or not audio:
|
| 8 |
+
return None, "Upload both files"
|
| 9 |
+
|
| 10 |
try:
|
| 11 |
+
# Use makeittalk - simple and reliable
|
| 12 |
+
result = subprocess.run([
|
| 13 |
+
"python", "main_end2end.py",
|
| 14 |
+
"--jpg", image,
|
| 15 |
+
"--audio", audio,
|
| 16 |
+
"--config", "config/simple.yaml"
|
| 17 |
+
], capture_output=True, cwd="/app/makeittalk")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
output = Path("/app/makeittalk/examples/output.mp4")
|
| 20 |
+
return str(output) if output.exists() else None, "Done!"
|
| 21 |
except Exception as e:
|
| 22 |
+
return None, str(e)
|
| 23 |
|
| 24 |
+
demo = gr.Interface(
|
| 25 |
+
fn=generate,
|
| 26 |
+
inputs=[
|
| 27 |
+
gr.Image(type="filepath", label="Face"),
|
| 28 |
+
gr.Audio(type="filepath", label="Audio")
|
| 29 |
+
],
|
| 30 |
+
outputs=[
|
| 31 |
+
gr.Video(label="Result"),
|
| 32 |
+
gr.Textbox(label="Status")
|
| 33 |
+
],
|
| 34 |
+
title="AI Lip Sync"
|
| 35 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
+
# Setup on start
|
| 38 |
+
if not Path("/app/makeittalk").exists():
|
| 39 |
+
subprocess.run(["git", "clone", "https://github.com/yzhou359/MakeItTalk.git", "/app/makeittalk"])
|
| 40 |
+
subprocess.run(["bash", "quick_demo.sh"], cwd="/app/makeittalk")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
+
demo.launch()
|
|
|
|
|
|