akin23 commited on
Commit
2e6ced0
·
verified ·
1 Parent(s): 0799741

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import subprocess
3
+ import os
4
+ from datetime import datetime
5
+
6
+ def generate_video(source_image, driven_audio):
7
+ output_dir = "results"
8
+ os.makedirs(output_dir, exist_ok=True)
9
+
10
+ timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
11
+ result_path = f"{output_dir}/video_{timestamp}.mp4"
12
+
13
+ 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"
14
+ subprocess.run(cmd, shell=True)
15
+
16
+ return result_path
17
+
18
+ demo = gr.Interface(
19
+ fn=generate_video,
20
+ inputs=[
21
+ gr.Image(type="filepath", label="Source Image"),
22
+ gr.Audio(type="filepath", label="Driven Audio")
23
+ ],
24
+ outputs=gr.Video(label="Generated Video")
25
+ )
26
+
27
+ demo.launch()