Spaces:
Build error
Build error
Initial deployment of SadTalker with models
Browse files- .gitattributes +1 -0
- README.md +46 -6
- SadTalker +1 -0
- app.py +109 -0
- requirements.txt +23 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,13 +1,53 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
| 11 |
---
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: SadTalker
|
| 3 |
+
emoji: 😭
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 3.50.2
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# SadTalker: Audio-Driven Talking Face Animation
|
| 14 |
+
|
| 15 |
+
This Space demonstrates **SadTalker**, a system for generating realistic talking head videos from a single image and audio input.
|
| 16 |
+
|
| 17 |
+
## Features
|
| 18 |
+
|
| 19 |
+
- 🎭 **Single Image Animation**: Animate any portrait image with audio
|
| 20 |
+
- 🎵 **Audio-Driven**: Synchronize facial movements with speech
|
| 21 |
+
- ⚙️ **Customizable Settings**: Adjust pose style, preprocessing, and enhancement options
|
| 22 |
+
- 🎨 **Face Enhancement**: Optional GFPGAN integration for improved quality
|
| 23 |
+
|
| 24 |
+
## Usage
|
| 25 |
+
|
| 26 |
+
1. **Upload an Image**: Choose a portrait image (preferably with a clear, front-facing face)
|
| 27 |
+
2. **Upload Audio**: Provide an audio file with speech
|
| 28 |
+
3. **Adjust Settings** (optional):
|
| 29 |
+
- **Pose Style**: Choose from 47 different pose styles (0-46)
|
| 30 |
+
- **Face Model Resolution**: 256 or 512 (higher = better quality but slower)
|
| 31 |
+
- **Preprocess Type**: How to handle the input image
|
| 32 |
+
- **Still Mode**: Reduces head motion for a more static result
|
| 33 |
+
- **GFPGAN Enhancer**: Improves face quality in the output
|
| 34 |
+
4. **Generate**: Click the "Generate Video" button and wait for processing
|
| 35 |
+
|
| 36 |
+
## Tips for Best Results
|
| 37 |
+
|
| 38 |
+
- Use clear, well-lit portrait images
|
| 39 |
+
- Front-facing photos work best
|
| 40 |
+
- Audio should be clear with minimal background noise
|
| 41 |
+
- For more details, see the [best practices guide](https://github.com/OpenTalker/SadTalker/blob/main/docs/best_practice.md)
|
| 42 |
+
|
| 43 |
+
## Credits
|
| 44 |
+
|
| 45 |
+
**Paper**: [SadTalker: Learning Realistic 3D Motion Coefficients for Stylized Audio-Driven Single Image Talking Face Animation](https://arxiv.org/abs/2211.12194) (CVPR 2023)
|
| 46 |
+
|
| 47 |
+
**Authors**: Wenxuan Zhang, Xiaodong Cun, Xuan Wang, Yong Zhang, Xi Shen, Yu Guo, Ying Shan, Fei Wang
|
| 48 |
+
|
| 49 |
+
**GitHub**: [OpenTalker/SadTalker](https://github.com/OpenTalker/SadTalker)
|
| 50 |
+
|
| 51 |
+
## License
|
| 52 |
+
|
| 53 |
+
This project is licensed under the MIT License.
|
SadTalker
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
Subproject commit cd4c0465ae0b54a6f85af57f5c65fec9fe23e7f8
|
app.py
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import sys
|
| 3 |
+
|
| 4 |
+
# Add SadTalker to path
|
| 5 |
+
sys.path.append('SadTalker')
|
| 6 |
+
|
| 7 |
+
import gradio as gr
|
| 8 |
+
from SadTalker.src.gradio_demo import SadTalker
|
| 9 |
+
|
| 10 |
+
def sadtalker_demo():
|
| 11 |
+
"""Initialize and return the SadTalker Gradio interface"""
|
| 12 |
+
|
| 13 |
+
checkpoint_path = 'SadTalker/checkpoints'
|
| 14 |
+
config_path = 'SadTalker/src/config'
|
| 15 |
+
|
| 16 |
+
sad_talker = SadTalker(checkpoint_path, config_path, lazy_load=True)
|
| 17 |
+
|
| 18 |
+
with gr.Blocks(analytics_enabled=False, title="SadTalker - Talking Head Generator") as sadtalker_interface:
|
| 19 |
+
gr.Markdown("""
|
| 20 |
+
<div align='center'>
|
| 21 |
+
<h2>😭 SadTalker: Audio-Driven Talking Face Animation</h2>
|
| 22 |
+
<p>Upload an image and audio to generate a talking head video</p>
|
| 23 |
+
<a href='https://arxiv.org/abs/2211.12194'>Paper</a>
|
| 24 |
+
<a href='https://sadtalker.github.io'>Homepage</a>
|
| 25 |
+
<a href='https://github.com/OpenTalker/SadTalker'>GitHub</a>
|
| 26 |
+
</div>
|
| 27 |
+
""")
|
| 28 |
+
|
| 29 |
+
with gr.Row():
|
| 30 |
+
with gr.Column(variant='panel'):
|
| 31 |
+
with gr.Tabs():
|
| 32 |
+
with gr.TabItem('Upload Image'):
|
| 33 |
+
source_image = gr.Image(
|
| 34 |
+
label="Source Image",
|
| 35 |
+
source="upload",
|
| 36 |
+
type="filepath"
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
with gr.Tabs():
|
| 40 |
+
with gr.TabItem('Upload Audio'):
|
| 41 |
+
driven_audio = gr.Audio(
|
| 42 |
+
label="Input Audio",
|
| 43 |
+
source="upload",
|
| 44 |
+
type="filepath"
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
+
with gr.Column(variant='panel'):
|
| 48 |
+
with gr.Tabs():
|
| 49 |
+
with gr.TabItem('Settings'):
|
| 50 |
+
gr.Markdown("Need help? Visit our [best practice page](https://github.com/OpenTalker/SadTalker/blob/main/docs/best_practice.md)")
|
| 51 |
+
|
| 52 |
+
pose_style = gr.Slider(
|
| 53 |
+
minimum=0,
|
| 54 |
+
maximum=46,
|
| 55 |
+
step=1,
|
| 56 |
+
label="Pose Style",
|
| 57 |
+
value=0
|
| 58 |
+
)
|
| 59 |
+
size_of_image = gr.Radio(
|
| 60 |
+
[256, 512],
|
| 61 |
+
value=256,
|
| 62 |
+
label='Face Model Resolution'
|
| 63 |
+
)
|
| 64 |
+
preprocess_type = gr.Radio(
|
| 65 |
+
['crop', 'resize', 'full', 'extcrop', 'extfull'],
|
| 66 |
+
value='crop',
|
| 67 |
+
label='Preprocess Type'
|
| 68 |
+
)
|
| 69 |
+
is_still_mode = gr.Checkbox(
|
| 70 |
+
label="Still Mode (less head motion)"
|
| 71 |
+
)
|
| 72 |
+
batch_size = gr.Slider(
|
| 73 |
+
label="Batch Size",
|
| 74 |
+
step=1,
|
| 75 |
+
minimum=1,
|
| 76 |
+
maximum=10,
|
| 77 |
+
value=2
|
| 78 |
+
)
|
| 79 |
+
enhancer = gr.Checkbox(
|
| 80 |
+
label="GFPGAN Face Enhancer"
|
| 81 |
+
)
|
| 82 |
+
|
| 83 |
+
submit = gr.Button('Generate Video', variant='primary')
|
| 84 |
+
|
| 85 |
+
with gr.Tabs():
|
| 86 |
+
with gr.TabItem('Generated Video'):
|
| 87 |
+
gen_video = gr.Video(label="Generated Video", format="mp4")
|
| 88 |
+
|
| 89 |
+
submit.click(
|
| 90 |
+
fn=sad_talker.test,
|
| 91 |
+
inputs=[
|
| 92 |
+
source_image,
|
| 93 |
+
driven_audio,
|
| 94 |
+
preprocess_type,
|
| 95 |
+
is_still_mode,
|
| 96 |
+
enhancer,
|
| 97 |
+
batch_size,
|
| 98 |
+
size_of_image,
|
| 99 |
+
pose_style
|
| 100 |
+
],
|
| 101 |
+
outputs=[gen_video]
|
| 102 |
+
)
|
| 103 |
+
|
| 104 |
+
return sadtalker_interface
|
| 105 |
+
|
| 106 |
+
if __name__ == "__main__":
|
| 107 |
+
demo = sadtalker_demo()
|
| 108 |
+
demo.queue()
|
| 109 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
torch>=1.12.0
|
| 2 |
+
torchvision>=0.13.0
|
| 3 |
+
numpy==1.23.4
|
| 4 |
+
face_alignment==1.3.5
|
| 5 |
+
imageio==2.19.3
|
| 6 |
+
imageio-ffmpeg==0.4.7
|
| 7 |
+
librosa==0.9.2
|
| 8 |
+
numba
|
| 9 |
+
resampy==0.3.1
|
| 10 |
+
pydub==0.25.1
|
| 11 |
+
scipy==1.10.1
|
| 12 |
+
kornia==0.6.8
|
| 13 |
+
tqdm
|
| 14 |
+
yacs==0.1.8
|
| 15 |
+
pyyaml
|
| 16 |
+
joblib==1.1.0
|
| 17 |
+
scikit-image==0.19.3
|
| 18 |
+
basicsr==1.4.2
|
| 19 |
+
facexlib==0.3.0
|
| 20 |
+
gradio
|
| 21 |
+
gfpgan
|
| 22 |
+
av
|
| 23 |
+
safetensors
|