manavisrani07 commited on
Commit
ab1abf8
1 Parent(s): 506eed4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -27
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import gradio as gr
2
  from subprocess import call
3
 
4
- # UI Components Setup
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,36 +19,30 @@ with gr.Blocks() as ui:
19
  generate_btn = gr.Button("Generate")
20
  with gr.Column():
21
  result = gr.Video()
22
-
23
- # Define the generate function
24
- def generate(video, audio, checkpoint, no_smooth, resize_factor, pad_top, pad_bottom, pad_left, pad_right):
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
- cmd = [
31
- "python",
32
- "inference.py",
33
- "--checkpoint_path", f"checkpoints/{checkpoint}.pth",
34
- "--segmentation_path", "checkpoints/face_segmentation.pth",
35
- "--enhance_face", "gfpgan",
36
- "--face", video.name,
37
- "--audio", audio.name,
38
- "--outfile", "results/output.mp4",
39
- ]
40
-
41
- call(cmd)
42
- return "results/output.mp4"
43
 
44
- # Click event for the Generate button
45
- generate_btn.click(
46
- generate,
47
- [video, audio, checkpoint, no_smooth, resize_factor, pad_top, pad_bottom, pad_left, pad_right],
48
- result)
49
 
50
  # Create the interface
51
- iface = gr.Interface(ui.queue(), "web", debug=True)
52
 
53
  # Launch the interface
54
- iface.launch()
 
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
  generate_btn = gr.Button("Generate")
20
  with gr.Column():
21
  result = gr.Video()
 
 
 
 
 
22
 
23
+ # Define the generate function
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
+ cmd = [
31
+ "python3.8", # Use Python 3.8
32
+ "inference.py",
33
+ "--checkpoint_path", f"checkpoints/{checkpoint}.pth",
34
+ "--segmentation_path", "checkpoints/face_segmentation.pth",
35
+ "--enhance_face", "gfpgan",
36
+ "--face", video.name,
37
+ "--audio", audio.name,
38
+ "--outfile", "results/output.mp4",
39
+ ]
 
40
 
41
+ call(cmd)
42
+ result.value = "results/output.mp4"
 
 
 
43
 
44
  # Create the interface
45
+ iface = gr.Interface(ui.queue(), generate_btn, "web", debug=True)
46
 
47
  # Launch the interface
48
+ iface.launch(share=True)