Jonny001 commited on
Commit
93cb7cc
·
verified ·
1 Parent(s): 06b856f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -8
app.py CHANGED
@@ -12,7 +12,8 @@ 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
 
17
  source_path = "input.jpg"
18
  target_path = "target.jpg"
@@ -31,8 +32,8 @@ def swap_face(source_file, target_file,doFaceEnhancer):
31
  roop.globals.output_path = normalize_output_path(
32
  roop.globals.source_path, roop.globals.target_path, output_path
33
  )
34
- if doFaceEnhancer == True:
35
- roop.globals.frame_processors = ["face_swapper","face_enhancer"]
36
  else:
37
  roop.globals.frame_processors = ["face_swapper"]
38
  roop.globals.headless = True
@@ -43,7 +44,7 @@ def swap_face(source_file, target_file,doFaceEnhancer):
43
  roop.globals.video_encoder = "libx264"
44
  roop.globals.video_quality = 18
45
  roop.globals.max_memory = suggest_max_memory()
46
- roop.globals.execution_providers = decode_execution_providers(["cpu"])
47
  roop.globals.execution_threads = suggest_execution_threads()
48
 
49
  print(
@@ -63,7 +64,20 @@ def swap_face(source_file, target_file,doFaceEnhancer):
63
  return output_path
64
 
65
 
66
- app = gr.Interface(
67
- fn=swap_face, inputs=[gr.Image(), gr.Image(),gr.Checkbox(label="Apply", info="Face Enhancer")], outputs="image", theme="NoCrypt/miku", description="Sorry for the inconvenience. The model is currently running using CPU, which might affect performance. We appreciate your understanding."
68
- )
69
- 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"
 
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
 
44
  roop.globals.video_encoder = "libx264"
45
  roop.globals.video_quality = 18
46
  roop.globals.max_memory = suggest_max_memory()
47
+ roop.globals.execution_providers = decode_execution_providers(["cuda"])
48
  roop.globals.execution_threads = suggest_execution_threads()
49
 
50
  print(
 
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 for HD Results.</p><h2><br /><strong>For fast and bulk Swap:</strong>&nbsp;<a href="https://picfy.xyz/" target="_blank" rel="noopener">https://picfy.xyz/</a><br /> <strong>Support me USDT (TRC-20): TAe7hsSVWtMEYz3G5V1UiUdYPQVqm28bKx</h2></div>'
69
+
70
+ app = gr.Blocks()
71
+
72
+ with app:
73
+ gr.HTML(html_section_1)
74
+ gr.HTML(html_section_2)
75
+ gr.Interface(
76
+ fn=swap_face,
77
+ inputs=[gr.Image(), gr.Image(), gr.Checkbox(label="Apply", info="Face Enhancer")],
78
+ outputs="image",
79
+ theme="NoCrypt/miku",
80
+ description="Sorry for the inconvenience. The model is currently running using CPU, which might affect performance. We appreciate your understanding."
81
+ )
82
+
83
+ app.launch()