fix: remove GFPGAN download, skip enhancer (not needed)
Browse files
app.py
CHANGED
|
@@ -1,35 +1,49 @@
|
|
| 1 |
"""
|
| 2 |
AIBRUH/ditto — Amanda's talking head engine.
|
| 3 |
-
SadTalker
|
| 4 |
-
ZeroGPU A100 Space.
|
| 5 |
"""
|
| 6 |
import gradio as gr
|
| 7 |
import spaces
|
| 8 |
-
import os
|
| 9 |
-
import sys
|
| 10 |
-
import subprocess
|
| 11 |
-
import tempfile
|
| 12 |
|
| 13 |
-
# ── One-time setup ──────────────────────────────────────────────────────────
|
| 14 |
SADTALKER = "/tmp/SadTalker"
|
| 15 |
CKPT = f"{SADTALKER}/checkpoints"
|
| 16 |
-
GFPGAN = f"{SADTALKER}/gfpgan/weights"
|
| 17 |
|
| 18 |
def _setup():
|
| 19 |
-
if
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
_setup()
|
| 32 |
|
|
|
|
|
|
|
|
|
|
| 33 |
from src.gradio_demo import SadTalker as _ST # noqa: E402
|
| 34 |
|
| 35 |
_sad: _ST | None = None
|
|
@@ -43,14 +57,14 @@ def _load():
|
|
| 43 |
|
| 44 |
@spaces.GPU
|
| 45 |
def infer(source_image: str, driven_audio: str):
|
| 46 |
-
"""image
|
| 47 |
st = _load()
|
| 48 |
result = st.test(
|
| 49 |
source_image=source_image,
|
| 50 |
driven_audio=driven_audio,
|
| 51 |
preprocess="crop",
|
| 52 |
-
still_mode=True,
|
| 53 |
-
use_enhancer=False,
|
| 54 |
batch_size=1,
|
| 55 |
size=256,
|
| 56 |
pose_style=0,
|
|
@@ -65,13 +79,17 @@ def infer(source_image: str, driven_audio: str):
|
|
| 65 |
return result
|
| 66 |
|
| 67 |
|
| 68 |
-
with gr.Blocks(title="AIBRUH/ditto
|
| 69 |
-
gr.Markdown("## AIBRUH/ditto · Amanda Talking Head Engine")
|
| 70 |
with gr.Row():
|
| 71 |
-
img_in = gr.Image(type="filepath", label="Source Portrait")
|
| 72 |
aud_in = gr.Audio(type="filepath", label="Driving Audio (WAV)")
|
| 73 |
-
btn = gr.Button("Generate", variant="primary")
|
| 74 |
vid_out = gr.Video(label="Amanda Speaking")
|
| 75 |
btn.click(fn=infer, inputs=[img_in, aud_in], outputs=vid_out, api_name="infer")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
demo.launch()
|
|
|
|
| 1 |
"""
|
| 2 |
AIBRUH/ditto — Amanda's talking head engine.
|
| 3 |
+
SadTalker ZeroGPU A100: portrait image + audio → MP4 talking head video.
|
|
|
|
| 4 |
"""
|
| 5 |
import gradio as gr
|
| 6 |
import spaces
|
| 7 |
+
import os, sys, subprocess, tempfile
|
|
|
|
|
|
|
|
|
|
| 8 |
|
|
|
|
| 9 |
SADTALKER = "/tmp/SadTalker"
|
| 10 |
CKPT = f"{SADTALKER}/checkpoints"
|
|
|
|
| 11 |
|
| 12 |
def _setup():
|
| 13 |
+
if os.path.exists(f"{CKPT}/SadTalker_V0.0.2_256.safetensors"):
|
| 14 |
+
return # already done
|
| 15 |
+
|
| 16 |
+
# Clone SadTalker source
|
| 17 |
+
if not os.path.exists(SADTALKER):
|
| 18 |
+
subprocess.run(
|
| 19 |
+
["git", "clone", "--depth=1",
|
| 20 |
+
"https://github.com/OpenTalker/SadTalker.git", SADTALKER],
|
| 21 |
+
check=True,
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
os.makedirs(CKPT, exist_ok=True)
|
| 25 |
+
|
| 26 |
+
# Download SadTalker checkpoints (no GFPGAN — we skip the enhancer)
|
| 27 |
+
from huggingface_hub import snapshot_download
|
| 28 |
+
snapshot_download(
|
| 29 |
+
repo_id="vinthony/SadTalker-V002rc",
|
| 30 |
+
local_dir=CKPT,
|
| 31 |
+
ignore_patterns=["*.md", "*.txt"],
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
# Install SadTalker deps that aren't in requirements.txt
|
| 35 |
+
subprocess.run(
|
| 36 |
+
[sys.executable, "-m", "pip", "install", "-q",
|
| 37 |
+
"face-alignment", "imageio", "imageio-ffmpeg",
|
| 38 |
+
"pydub", "scipy", "kornia==0.6.8", "basicsr"],
|
| 39 |
+
check=False,
|
| 40 |
+
)
|
| 41 |
|
| 42 |
_setup()
|
| 43 |
|
| 44 |
+
if SADTALKER not in sys.path:
|
| 45 |
+
sys.path.insert(0, SADTALKER)
|
| 46 |
+
|
| 47 |
from src.gradio_demo import SadTalker as _ST # noqa: E402
|
| 48 |
|
| 49 |
_sad: _ST | None = None
|
|
|
|
| 57 |
|
| 58 |
@spaces.GPU
|
| 59 |
def infer(source_image: str, driven_audio: str):
|
| 60 |
+
"""Portrait image + WAV audio → talking head MP4."""
|
| 61 |
st = _load()
|
| 62 |
result = st.test(
|
| 63 |
source_image=source_image,
|
| 64 |
driven_audio=driven_audio,
|
| 65 |
preprocess="crop",
|
| 66 |
+
still_mode=True, # minimal head sway — portrait mode
|
| 67 |
+
use_enhancer=False, # no GFPGAN needed
|
| 68 |
batch_size=1,
|
| 69 |
size=256,
|
| 70 |
pose_style=0,
|
|
|
|
| 79 |
return result
|
| 80 |
|
| 81 |
|
| 82 |
+
with gr.Blocks(title="AIBRUH/ditto · Amanda Engine") as demo:
|
| 83 |
+
gr.Markdown("## AIBRUH/ditto · Amanda Talking Head Engine\n*SadTalker ZeroGPU — portrait image + audio → talking head video*")
|
| 84 |
with gr.Row():
|
| 85 |
+
img_in = gr.Image(type="filepath", label="Source Portrait (JPG/PNG)")
|
| 86 |
aud_in = gr.Audio(type="filepath", label="Driving Audio (WAV)")
|
| 87 |
+
btn = gr.Button("Generate Talking Head", variant="primary")
|
| 88 |
vid_out = gr.Video(label="Amanda Speaking")
|
| 89 |
btn.click(fn=infer, inputs=[img_in, aud_in], outputs=vid_out, api_name="infer")
|
| 90 |
+
gr.Examples(
|
| 91 |
+
examples=[],
|
| 92 |
+
inputs=[img_in, aud_in],
|
| 93 |
+
)
|
| 94 |
|
| 95 |
demo.launch()
|