forked from fudan-generative-vision/hallo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: gradio WebUI (fudan-generative-vision#51)
* WebUI + Audio Fix 1. audio fix: explicitly specify the audio codec in `util.py`, otherwise the video is technically corrupt and doesn't play sound 2. web ui: gradio web ui 3. print the current step while running inference gradio * lint * update
- Loading branch information
1 parent
ec80fdf
commit 07ffd49
Showing
4 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
""" | ||
This script is a gradio web ui. | ||
The script takes an image and an audio clip, and lets you configure all the | ||
variables such as cfg_scale, pose_weight, face_weight, lip_weight, etc. | ||
Usage: | ||
This script can be run from the command line with the following command: | ||
python scripts/app.py | ||
""" | ||
import argparse | ||
|
||
import gradio as gr | ||
from inference import inference_process | ||
|
||
|
||
def predict(image, audio, size, steps, fps, cfg, pose_weight, face_weight, lip_weight, face_expand_ratio): | ||
""" | ||
Create a gradio interface with the configs. | ||
""" | ||
config = { | ||
'data': { | ||
'source_image': { | ||
'width': size, | ||
'height': size | ||
}, | ||
'export_video': { | ||
'fps': fps | ||
} | ||
}, | ||
'cfg_scale': cfg, | ||
'source_image': image, | ||
'driving_audio': audio, | ||
'pose_weight': pose_weight, | ||
'face_weight': face_weight, | ||
'lip_weight': lip_weight, | ||
'face_expand_ratio': face_expand_ratio, | ||
'config': 'configs/inference/default.yaml', | ||
'checkpoint': None, | ||
'output': ".cache/output.mp4", | ||
'inference_steps': steps | ||
} | ||
args = argparse.Namespace() | ||
for key, value in config.items(): | ||
setattr(args, key, value) | ||
return inference_process(args) | ||
|
||
app = gr.Interface( | ||
fn=predict, | ||
inputs=[ | ||
gr.Image(label="source image (no webp)", type="filepath", format="jpeg"), | ||
gr.Audio(label="source audio", type="filepath"), | ||
gr.Number(label="size", value=512, minimum=256, maximum=512, step=64, precision=0), | ||
gr.Number(label="steps", value=40, minimum=1, step=1, precision=0), | ||
gr.Number(label="fps", value=25, minimum=1, step=1, precision=0), | ||
gr.Slider(label="CFG Scale", value=3.5, minimum=0, maximum=10, step=0.01), | ||
gr.Number(label="pose weight", value=1.0), | ||
gr.Number(label="face weight", value=1.0), | ||
gr.Number(label="lip weight", value=1.0), | ||
gr.Number(label="face expand ratio", value=1.2), | ||
], | ||
outputs=[gr.Video()], | ||
) | ||
app.launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters