|
import os |
|
import shutil |
|
from huggingface_hub import snapshot_download |
|
import gradio as gr |
|
from scripts.inference import inference_process |
|
import argparse |
|
|
|
|
|
hallo_dir = snapshot_download(repo_id="fudan-generative-ai/hallo") |
|
|
|
|
|
new_dir = 'pretrained_models' |
|
|
|
|
|
os.makedirs(new_dir, exist_ok=True) |
|
|
|
|
|
for filename in os.listdir(hallo_dir): |
|
shutil.move(os.path.join(hallo_dir, filename), os.path.join(new_dir, filename)) |
|
|
|
def run_inference(source_image, driving_audio, progress=gr.Progress(track_tqdm=True)): |
|
|
|
args = argparse.Namespace( |
|
config='configs/inference/default.yaml', |
|
source_image=source_image, |
|
driving_audio=driving_audio, |
|
output='output.mp4', |
|
pose_weight=1.0, |
|
face_weight=1.0, |
|
lip_weight=1.0, |
|
face_expand_ratio=1.2, |
|
checkpoint=None |
|
) |
|
|
|
|
|
inference_process(args) |
|
|
|
|
|
return 'output.mp4' |
|
|
|
iface = gr.Interface( |
|
fn=run_inference, |
|
inputs=[gr.Image(type="filepath"), gr.Audio(type="filepath")], |
|
outputs="video" |
|
) |
|
|
|
iface.launch() |