|
import gradio as gr |
|
import subprocess |
|
from moviepy.editor import VideoFileClip |
|
|
|
def convert_to_mp4_with_aac(input_path, output_path): |
|
|
|
video = VideoFileClip(input_path) |
|
|
|
|
|
video.write_videofile(output_path, codec="libx264", audio_codec="aac") |
|
|
|
return output_path |
|
|
|
|
|
|
|
def execute_command(command: str) -> None: |
|
subprocess.run(command, check=True) |
|
|
|
def infer(): |
|
|
|
output_name = "acknowledgement_english@M030_front_neutral_level1_001@male_face" |
|
|
|
command = [ |
|
f"python", |
|
f"inference_for_demo_video.py", |
|
f"--wav_path=data/audio/acknowledgement_english.m4a", |
|
f"--style_clip_path=data/style_clip/3DMM/M030_front_neutral_level1_001.mat", |
|
f"--pose_path=data/pose/RichardShelby_front_neutral_level1_001.mat", |
|
f"--image_path=data/src_img/uncropped/male_face.png", |
|
f"--cfg_scale=1.0", |
|
f"--max_gen_len=30", |
|
f"--output_name={output_name}" |
|
] |
|
|
|
execute_command(command) |
|
|
|
|
|
input_file = f"output_video/{output_name}.mp4" |
|
output_file = f"{output_name}.mp4" |
|
|
|
result = convert_to_mp4_with_aac(input_file, output_file) |
|
|
|
|
|
return result |
|
|
|
with gr.Blocks() as demo: |
|
with gr.Column(): |
|
with gr.Row(): |
|
with gr.Column(): |
|
run_btn = gr.Button("Run") |
|
with gr.Column(): |
|
output_video = gr.Video(format="mp4") |
|
|
|
run_btn.click( |
|
fn = infer, |
|
inputs = [], |
|
outputs = [output_video] |
|
) |
|
|
|
demo.launch() |