Spaces:
Running
Running
Commit
·
b24dca3
1
Parent(s):
ec0fc56
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from subprocess import call
|
| 3 |
|
| 4 |
-
# UI Components Setup with the generate function
|
| 5 |
with gr.Blocks() as ui:
|
| 6 |
with gr.Row():
|
| 7 |
video = gr.File(label="Video or Image", info="Filepath of video/image that contains faces to use")
|
|
@@ -19,30 +18,31 @@ with gr.Blocks() as ui:
|
|
| 19 |
generate_btn = gr.Button("Generate")
|
| 20 |
with gr.Column():
|
| 21 |
result = gr.Video()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
-
def generate():
|
| 25 |
-
if video is None or audio is None or checkpoint is None:
|
| 26 |
-
return
|
| 27 |
|
| 28 |
-
smooth = "--nosmooth" if no_smooth else ""
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
call(cmd)
|
| 42 |
-
result.value = "results/output.mp4"
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
|
|
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from subprocess import call
|
| 3 |
|
|
|
|
| 4 |
with gr.Blocks() as ui:
|
| 5 |
with gr.Row():
|
| 6 |
video = gr.File(label="Video or Image", info="Filepath of video/image that contains faces to use")
|
|
|
|
| 18 |
generate_btn = gr.Button("Generate")
|
| 19 |
with gr.Column():
|
| 20 |
result = gr.Video()
|
| 21 |
+
|
| 22 |
+
def generate(video, audio, checkpoint, no_smooth, resize_factor, pad_top, pad_bottom, pad_left, pad_right):
|
| 23 |
+
if video is None or audio is None or checkpoint is None:
|
| 24 |
+
return
|
| 25 |
|
| 26 |
+
smooth = "--nosmooth" if no_smooth else ""
|
|
|
|
|
|
|
|
|
|
| 27 |
|
|
|
|
| 28 |
|
| 29 |
+
cmd = [
|
| 30 |
+
"python",
|
| 31 |
+
"inference.py",
|
| 32 |
+
"--checkpoint_path", f"checkpoints/{checkpoint}.pth",
|
| 33 |
+
"--segmentation_path", "checkpoints/face_segmentation.pth",
|
| 34 |
+
"--enhance_face", "gfpgan",
|
| 35 |
+
"--face", video.name,
|
| 36 |
+
"--audio", audio.name,
|
| 37 |
+
"--outfile", "results/output.mp4",
|
| 38 |
+
]
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
+
|
| 41 |
+
call(cmd)
|
| 42 |
+
return "results/output.mp4"
|
| 43 |
|
| 44 |
+
generate_btn.click(
|
| 45 |
+
generate,
|
| 46 |
+
[video, audio, checkpoint, pad_top, pad_bottom, pad_left, pad_right, resize_factor],
|
| 47 |
+
result)
|
| 48 |
+
ui.queue().launch()
|