File size: 792 Bytes
2e6ced0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import gradio as gr
import subprocess
import os
from datetime import datetime

def generate_video(source_image, driven_audio):
    output_dir = "results"
    os.makedirs(output_dir, exist_ok=True)

    timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
    result_path = f"{output_dir}/video_{timestamp}.mp4"

    cmd = f"python inference.py --driven_audio {driven_audio} --source_image {source_image} --result_dir {output_dir} --enhancer gfpgan --pose_style 45 --still --preprocess full"
    subprocess.run(cmd, shell=True)

    return result_path

demo = gr.Interface(
    fn=generate_video,
    inputs=[
        gr.Image(type="filepath", label="Source Image"),
        gr.Audio(type="filepath", label="Driven Audio")
    ],
    outputs=gr.Video(label="Generated Video")
)

demo.launch()