Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
#
|
2 |
# !/usr/bin/env python
|
3 |
import numpy as np
|
4 |
import gradio as gr
|
@@ -16,6 +16,7 @@ from PIL import Image
|
|
16 |
|
17 |
|
18 |
def swap_face(source_file, target_file, doFaceEnhancer):
|
|
|
19 |
source_path = "input.jpg"
|
20 |
target_path = "target.jpg"
|
21 |
|
@@ -33,7 +34,7 @@ def swap_face(source_file, target_file, doFaceEnhancer):
|
|
33 |
roop.globals.output_path = normalize_output_path(
|
34 |
roop.globals.source_path, roop.globals.target_path, output_path
|
35 |
)
|
36 |
-
if doFaceEnhancer:
|
37 |
roop.globals.frame_processors = ["face_swapper", "face_enhancer"]
|
38 |
else:
|
39 |
roop.globals.frame_processors = ["face_swapper"]
|
@@ -65,16 +66,25 @@ def swap_face(source_file, target_file, doFaceEnhancer):
|
|
65 |
return output_path
|
66 |
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
app.launch()
|
|
|
1 |
+
# -*- coding: UTF-8 -*-
|
2 |
# !/usr/bin/env python
|
3 |
import numpy as np
|
4 |
import gradio as gr
|
|
|
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 == True:
|
38 |
roop.globals.frame_processors = ["face_swapper", "face_enhancer"]
|
39 |
else:
|
40 |
roop.globals.frame_processors = ["face_swapper"]
|
|
|
66 |
return output_path
|
67 |
|
68 |
|
69 |
+
# Define HTML banners
|
70 |
+
banner1 = gr.HTML("<h1>Welcome to the Face Swap App</h1>")
|
71 |
+
banner2 = gr.HTML("<h2>Upload your source and target images below</h2>")
|
72 |
+
banner3 = gr.HTML("<p>Check the box if you want to use the face enhancer feature</p>")
|
73 |
+
|
74 |
+
# Define the interface with HTML banners
|
75 |
+
app = gr.Interface(
|
76 |
+
fn=swap_face,
|
77 |
+
inputs=[
|
78 |
+
banner1,
|
79 |
+
banner2,
|
80 |
+
gr.Image(label="Source Image"),
|
81 |
+
gr.Image(label="Target Image"),
|
82 |
+
gr.Checkbox(label="Face Enhancer?", info="Do face enhancer?")
|
83 |
+
],
|
84 |
+
outputs="image",
|
85 |
+
live=False,
|
86 |
+
title="Face Swap Application",
|
87 |
+
description="A simple app to swap faces between two images"
|
88 |
+
)
|
89 |
|
90 |
app.launch()
|