Update app.py
Browse files
app.py
CHANGED
|
@@ -11,9 +11,12 @@ from roop.core import (
|
|
| 11 |
)
|
| 12 |
from roop.processors.frame.core import get_frame_processors_modules
|
| 13 |
from roop.utilities import normalize_output_path
|
|
|
|
| 14 |
from PIL import Image
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
| 17 |
source_path = "input.jpg"
|
| 18 |
target_path = "target.jpg"
|
| 19 |
|
|
@@ -31,12 +34,10 @@ def swap_face(source_file, target_file, do_face_enhancer):
|
|
| 31 |
roop.globals.output_path = normalize_output_path(
|
| 32 |
roop.globals.source_path, roop.globals.target_path, output_path
|
| 33 |
)
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
roop.globals.frame_processors = ["face_swapper", "face_enhancer"]
|
| 37 |
else:
|
| 38 |
roop.globals.frame_processors = ["face_swapper"]
|
| 39 |
-
|
| 40 |
roop.globals.headless = True
|
| 41 |
roop.globals.keep_fps = True
|
| 42 |
roop.globals.keep_audio = True
|
|
@@ -64,16 +65,8 @@ def swap_face(source_file, target_file, do_face_enhancer):
|
|
| 64 |
start()
|
| 65 |
return output_path
|
| 66 |
|
|
|
|
| 67 |
app = gr.Interface(
|
| 68 |
-
fn=swap_face,
|
| 69 |
-
inputs=[
|
| 70 |
-
gr.Image(),
|
| 71 |
-
gr.Image(),
|
| 72 |
-
gr.Checkbox(label="Enable Face Enhancer", default=False, key="do_face_enhancer", info="Toggle face enhancer on/off")
|
| 73 |
-
],
|
| 74 |
-
outputs="image"
|
| 75 |
)
|
| 76 |
-
app.launch()
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
|
|
|
| 11 |
)
|
| 12 |
from roop.processors.frame.core import get_frame_processors_modules
|
| 13 |
from roop.utilities import normalize_output_path
|
| 14 |
+
import os
|
| 15 |
from PIL import Image
|
| 16 |
|
| 17 |
+
|
| 18 |
+
def swap_face(source_file, target_file,doFaceEnhancer):
|
| 19 |
+
|
| 20 |
source_path = "input.jpg"
|
| 21 |
target_path = "target.jpg"
|
| 22 |
|
|
|
|
| 34 |
roop.globals.output_path = normalize_output_path(
|
| 35 |
roop.globals.source_path, roop.globals.target_path, output_path
|
| 36 |
)
|
| 37 |
+
if doFaceEnhancer :
|
| 38 |
+
roop.globals.frame_processors = ["face_swapper","face_enhancer"]
|
|
|
|
| 39 |
else:
|
| 40 |
roop.globals.frame_processors = ["face_swapper"]
|
|
|
|
| 41 |
roop.globals.headless = True
|
| 42 |
roop.globals.keep_fps = True
|
| 43 |
roop.globals.keep_audio = True
|
|
|
|
| 65 |
start()
|
| 66 |
return output_path
|
| 67 |
|
| 68 |
+
|
| 69 |
app = gr.Interface(
|
| 70 |
+
fn=swap_face, inputs=[gr.Image(), gr.Image(),gr.Checkbox(label="face_enhancer?", info="do face enhancer?")], outputs="image"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
)
|
| 72 |
+
app.launch()
|
|
|
|
|
|
|
|
|