Update app.py
Browse files
app.py
CHANGED
@@ -11,12 +11,9 @@ 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 |
-
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,10 +31,12 @@ def swap_face(source_file, target_file,doFaceEnhancer):
|
|
34 |
roop.globals.output_path = normalize_output_path(
|
35 |
roop.globals.source_path, roop.globals.target_path, output_path
|
36 |
)
|
37 |
-
|
38 |
-
|
|
|
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,8 +64,16 @@ def swap_face(source_file, target_file,doFaceEnhancer):
|
|
65 |
start()
|
66 |
return output_path
|
67 |
|
68 |
-
|
69 |
app = gr.Interface(
|
70 |
-
fn=swap_face,
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
)
|
72 |
app.launch()
|
|
|
|
|
|
|
|
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 |
+
def swap_face(source_file, target_file, do_face_enhancer):
|
|
|
|
|
17 |
source_path = "input.jpg"
|
18 |
target_path = "target.jpg"
|
19 |
|
|
|
31 |
roop.globals.output_path = normalize_output_path(
|
32 |
roop.globals.source_path, roop.globals.target_path, output_path
|
33 |
)
|
34 |
+
|
35 |
+
if do_face_enhancer:
|
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 |
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 |
+
|