aheedsajid commited on
Commit
0c8c405
·
verified ·
1 Parent(s): ed732a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -17
app.py CHANGED
@@ -12,7 +12,9 @@ from roop.utilities import normalize_output_path
12
  import os
13
  from PIL import Image
14
 
15
- def swap_face(source_file, target_file, doFaceEnhancer):
 
 
16
  source_path = "input.jpg"
17
  target_path = "target.jpg"
18
 
@@ -31,7 +33,7 @@ def swap_face(source_file, target_file, doFaceEnhancer):
31
  roop.globals.source_path, roop.globals.target_path, output_path
32
  )
33
  if doFaceEnhancer == True:
34
- roop.globals.frame_processors = ["face_swapper", "face_enhancer"]
35
  else:
36
  roop.globals.frame_processors = ["face_swapper"]
37
  roop.globals.headless = True
@@ -61,22 +63,33 @@ def swap_face(source_file, target_file, doFaceEnhancer):
61
  start()
62
  return output_path
63
 
64
- html1 = "<h1>Welcome to Face Swap App</h1>"
65
- html2 = "<p>This app allows you to swap faces in images. Upload your source and target images, and optionally enable face enhancement.</p>"
66
- html3 = "<footer>Created by Your Name</footer>"
67
 
68
  app = gr.Interface(
69
  fn=swap_face,
70
- inputs=[
71
- gr.Image(label="Source Image"),
72
- gr.Image(label="Target Image"),
73
- gr.Checkbox(label="Face Enhancer?", info="Do face enhancer?")
74
- ],
75
- outputs=[
76
- gr.HTML(html1),
77
- "image",
78
- gr.HTML(html2),
79
- gr.HTML(html3)
80
- ]
81
  )
82
- app.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  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"
20
 
 
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
 
63
  start()
64
  return output_path
65
 
 
 
 
66
 
67
  app = gr.Interface(
68
  fn=swap_face,
69
+ inputs=[gr.Image(), gr.Image(), gr.Checkbox(label="face_enhancer?", info="do face enhancer?")],
70
+ outputs="image",
71
+ layout="vertical"
 
 
 
 
 
 
 
 
72
  )
73
+
74
+ # Add HTML sections
75
+ app.components.insert(0, gr.HTML("""
76
+ <div style="background-color: #f0f0f0; padding: 10px; border-radius: 5px;">
77
+ <h3>Banner 1: Welcome to Face Swap!</h3>
78
+ <p>Upload your source and target images to begin.</p>
79
+ </div>
80
+ """))
81
+
82
+ app.components.insert(2, gr.HTML("""
83
+ <div style="background-color: #e0f0e0; padding: 10px; border-radius: 5px;">
84
+ <h4>Banner 2: Optional Face Enhancement</h4>
85
+ <p>Check the box to apply face enhancement to the output.</p>
86
+ </div>
87
+ """))
88
+
89
+ app.components.append(gr.HTML("""
90
+ <div style="background-color: #f0f0f0; padding: 10px; border-radius: 5px;">
91
+ <p>Banner 3: Results will appear below.</p>
92
+ </div>
93
+ """))
94
+
95
+ app.launch()