aheedsajid commited on
Commit
385c2cd
·
verified ·
1 Parent(s): 48d5b0c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -20
app.py CHANGED
@@ -13,7 +13,7 @@ import os
13
  from PIL import Image
14
 
15
 
16
- def swap_face(source_file, target_file, doFaceEnhancer):
17
 
18
  source_path = "input.jpg"
19
  target_path = "target.jpg"
@@ -32,8 +32,8 @@ def swap_face(source_file, target_file, doFaceEnhancer):
32
  roop.globals.output_path = normalize_output_path(
33
  roop.globals.source_path, roop.globals.target_path, output_path
34
  )
35
- if doFaceEnhancer:
36
- roop.globals.frame_processors = ["face_swapper", "face_enhancer"]
37
  else:
38
  roop.globals.frame_processors = ["face_swapper"]
39
  roop.globals.headless = True
@@ -64,20 +64,7 @@ def swap_face(source_file, target_file, doFaceEnhancer):
64
  return output_path
65
 
66
 
67
- html_section_1 = "<div><h1>Welcome to the Face Swap App</h1></div>"
68
- html_section_2 = "<div><p>Upload your source and target images to swap faces. Optionally, use the face enhancer feature.</p></div>"
69
- html_section_3 = "<div><p>After processing, the swapped image will be displayed below.</p></div>"
70
-
71
- with gr.Blocks() as app:
72
- gr.HTML(html_section_1)
73
- gr.HTML(html_section_2)
74
- gr.HTML(html_section_3)
75
- source_img = gr.Image()
76
- target_img = gr.Image()
77
- face_enhancer = gr.Checkbox(label="face_enhancer?", info="do face enhancer?")
78
- output_img = gr.Image()
79
-
80
- btn = gr.Button("Submit")
81
- btn.click(swap_face, inputs=[source_img, target_img, face_enhancer], outputs=output_img)
82
-
83
- app.launch()
 
13
  from PIL import Image
14
 
15
 
16
+ def swap_face(source_file, target_file,doFaceEnhancer):
17
 
18
  source_path = "input.jpg"
19
  target_path = "target.jpg"
 
32
  roop.globals.output_path = normalize_output_path(
33
  roop.globals.source_path, roop.globals.target_path, output_path
34
  )
35
+ if doFaceEnhancer == True:
36
+ roop.globals.frame_processors = ["face_swapper","face_enhancer"]
37
  else:
38
  roop.globals.frame_processors = ["face_swapper"]
39
  roop.globals.headless = True
 
64
  return output_path
65
 
66
 
67
+ app = gr.Interface(
68
+ fn=swap_face, inputs=[gr.Image(), gr.Image(),gr.Checkbox(label="face_enhancer?", info="do face enhancer?")], outputs="image"
69
+ )
70
+ app.launch()