Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ from dofaker import FaceSwapper, PoseSwapper
|
|
5 |
|
6 |
|
7 |
def parse_args():
|
8 |
-
parser = argparse.ArgumentParser(description='running face swap')
|
9 |
parser.add_argument(
|
10 |
'--inbrowser',
|
11 |
help=
|
@@ -41,43 +41,43 @@ def swap_pose(input_path, target_path, use_enhancer, use_sr, scale):
|
|
41 |
def main():
|
42 |
args = parse_args()
|
43 |
|
44 |
-
with gr.Blocks(title='
|
45 |
-
gr.Markdown('
|
46 |
-
with gr.Tab('FaceSwapper'):
|
47 |
-
gr.Markdown('
|
48 |
-
with gr.Tab('Image'):
|
49 |
with gr.Row():
|
50 |
with gr.Column():
|
51 |
-
gr.Markdown('The source image to be swapped')
|
52 |
-
image_input = gr.Image(type='filepath')
|
53 |
with gr.Row():
|
54 |
with gr.Column():
|
55 |
gr.Markdown(
|
56 |
-
'target face included in source image')
|
57 |
-
dst_face_image = gr.Image(type='filepath')
|
58 |
with gr.Column():
|
59 |
gr.Markdown(
|
60 |
-
'source face to replace target face')
|
61 |
-
src_face_image = gr.Image(type='filepath')
|
62 |
|
63 |
with gr.Column():
|
64 |
-
output_image = gr.Image(type='filepath')
|
65 |
use_enhancer = gr.Checkbox(
|
66 |
-
label="face enhance",
|
67 |
-
info="Whether use face enhance model.")
|
68 |
with gr.Row():
|
69 |
use_sr = gr.Checkbox(
|
70 |
-
label="super resolution",
|
71 |
-
info="Whether use image resolution model.")
|
72 |
scale = gr.Number(
|
73 |
-
value=1, label='image super resolution scale')
|
74 |
with gr.Row():
|
75 |
face_sim_thre = gr.Number(
|
76 |
value=0.6,
|
77 |
-
label='face similarity threshold',
|
78 |
minimum=0.0,
|
79 |
maximum=1.0)
|
80 |
-
convert_button = gr.Button('Swap')
|
81 |
convert_button.click(fn=swap_face,
|
82 |
inputs=[
|
83 |
image_input, dst_face_image,
|
@@ -85,41 +85,41 @@ def main():
|
|
85 |
use_sr, scale, face_sim_thre
|
86 |
],
|
87 |
outputs=[output_image],
|
88 |
-
api_name='image swap')
|
89 |
|
90 |
-
with gr.Tab('Video'):
|
91 |
with gr.Row():
|
92 |
with gr.Column():
|
93 |
-
gr.Markdown('The source video to be swapped')
|
94 |
video_input = gr.Video()
|
95 |
with gr.Row():
|
96 |
with gr.Column():
|
97 |
gr.Markdown(
|
98 |
-
'target face included in source image')
|
99 |
dst_face_image = gr.Image(type='filepath')
|
100 |
with gr.Column():
|
101 |
gr.Markdown(
|
102 |
-
'source face to replace target face')
|
103 |
src_face_image = gr.Image(type='filepath')
|
104 |
|
105 |
with gr.Column():
|
106 |
output_video = gr.Video()
|
107 |
use_enhancer = gr.Checkbox(
|
108 |
-
label="face enhance",
|
109 |
-
info="Whether use face enhance model.")
|
110 |
with gr.Row():
|
111 |
use_sr = gr.Checkbox(
|
112 |
-
label="super resolution",
|
113 |
-
info="Whether use image resolution model.")
|
114 |
scale = gr.Number(
|
115 |
-
value=1, label='image super resolution scale')
|
116 |
with gr.Row():
|
117 |
face_sim_thre = gr.Number(
|
118 |
value=0.6,
|
119 |
-
label='face similarity threshold',
|
120 |
minimum=0.0,
|
121 |
maximum=1.0)
|
122 |
-
convert_button = gr.Button('Swap')
|
123 |
convert_button.click(fn=swap_face,
|
124 |
inputs=[
|
125 |
video_input, dst_face_image,
|
@@ -127,37 +127,37 @@ def main():
|
|
127 |
use_sr, scale, face_sim_thre
|
128 |
],
|
129 |
outputs=[output_video],
|
130 |
-
api_name='video swap')
|
131 |
|
132 |
-
with gr.Tab('PoseSwapper'):
|
133 |
-
gr.Markdown('
|
134 |
-
with gr.Tab('Image'):
|
135 |
with gr.Row():
|
136 |
with gr.Column():
|
137 |
-
gr.Markdown('The source image to be swapped')
|
138 |
-
image_input = gr.Image(type='filepath')
|
139 |
-
gr.Markdown('The target image with pose')
|
140 |
-
target = gr.Image(type='filepath')
|
141 |
|
142 |
with gr.Column():
|
143 |
-
output_image = gr.Image(type='filepath')
|
144 |
use_enhancer = gr.Checkbox(
|
145 |
-
label="face enhance",
|
146 |
-
info="Whether use face enhance model.")
|
147 |
with gr.Row():
|
148 |
use_sr = gr.Checkbox(
|
149 |
-
label="super resolution",
|
150 |
-
info="Whether use image resolution model.")
|
151 |
scale = gr.Number(
|
152 |
-
value=1, label='image super resolution scale')
|
153 |
-
convert_button = gr.Button('Swap')
|
154 |
convert_button.click(fn=swap_pose,
|
155 |
inputs=[
|
156 |
image_input, target,
|
157 |
use_enhancer, use_sr, scale
|
158 |
],
|
159 |
outputs=[output_image],
|
160 |
-
api_name='image swap')
|
161 |
|
162 |
# with gr.Tab('Video'):
|
163 |
# with gr.Row():
|
|
|
5 |
|
6 |
|
7 |
def parse_args():
|
8 |
+
parser = argparse.ArgumentParser(description='โณrunning face swap')
|
9 |
parser.add_argument(
|
10 |
'--inbrowser',
|
11 |
help=
|
|
|
41 |
def main():
|
42 |
args = parse_args()
|
43 |
|
44 |
+
with gr.Blocks(title='FaceClone') as web_ui:
|
45 |
+
gr.Markdown('๐งธFaceClone๐งธ Deepfake Swap Face and Pose')
|
46 |
+
with gr.Tab('๐FaceSwapper'):
|
47 |
+
gr.Markdown('๐งธFaceClone๐งธ power by Gradio')
|
48 |
+
with gr.Tab('๐ฅImage'):
|
49 |
with gr.Row():
|
50 |
with gr.Column():
|
51 |
+
gr.Markdown('๐๏ธThe source image to be swapped')
|
52 |
+
image_input = gr.Image(type='๐filepath')
|
53 |
with gr.Row():
|
54 |
with gr.Column():
|
55 |
gr.Markdown(
|
56 |
+
'๐ญtarget face included in source image')
|
57 |
+
dst_face_image = gr.Image(type='๐filepath')
|
58 |
with gr.Column():
|
59 |
gr.Markdown(
|
60 |
+
'๐งโ๐ฆณsource face to replace target face')
|
61 |
+
src_face_image = gr.Image(type='๐filepath')
|
62 |
|
63 |
with gr.Column():
|
64 |
+
output_image = gr.Image(type='๐filepath')
|
65 |
use_enhancer = gr.Checkbox(
|
66 |
+
label="๐face enhance",
|
67 |
+
info="๐งฟWhether use face enhance model.")
|
68 |
with gr.Row():
|
69 |
use_sr = gr.Checkbox(
|
70 |
+
label="๐ ๏ธsuper resolution",
|
71 |
+
info="โ๏ธWhether use image resolution model.")
|
72 |
scale = gr.Number(
|
73 |
+
value=1, label='๐image super resolution scale')
|
74 |
with gr.Row():
|
75 |
face_sim_thre = gr.Number(
|
76 |
value=0.6,
|
77 |
+
label='๐งฒface similarity threshold',
|
78 |
minimum=0.0,
|
79 |
maximum=1.0)
|
80 |
+
convert_button = gr.Button('๐Swap')
|
81 |
convert_button.click(fn=swap_face,
|
82 |
inputs=[
|
83 |
image_input, dst_face_image,
|
|
|
85 |
use_sr, scale, face_sim_thre
|
86 |
],
|
87 |
outputs=[output_image],
|
88 |
+
api_name='๐image swap')
|
89 |
|
90 |
+
with gr.Tab('๐ฅ๏ธVideo'):
|
91 |
with gr.Row():
|
92 |
with gr.Column():
|
93 |
+
gr.Markdown('๐๏ธThe source video to be swapped')
|
94 |
video_input = gr.Video()
|
95 |
with gr.Row():
|
96 |
with gr.Column():
|
97 |
gr.Markdown(
|
98 |
+
'๐นtarget face included in source image')
|
99 |
dst_face_image = gr.Image(type='filepath')
|
100 |
with gr.Column():
|
101 |
gr.Markdown(
|
102 |
+
'๐งsource face to replace target face')
|
103 |
src_face_image = gr.Image(type='filepath')
|
104 |
|
105 |
with gr.Column():
|
106 |
output_video = gr.Video()
|
107 |
use_enhancer = gr.Checkbox(
|
108 |
+
label="๐ธface enhance",
|
109 |
+
info="๐ทWhether use face enhance model.")
|
110 |
with gr.Row():
|
111 |
use_sr = gr.Checkbox(
|
112 |
+
label="๐super resolution",
|
113 |
+
info="๐ฆWhether use image resolution model.")
|
114 |
scale = gr.Number(
|
115 |
+
value=1, label='๐๏ธimage super resolution scale')
|
116 |
with gr.Row():
|
117 |
face_sim_thre = gr.Number(
|
118 |
value=0.6,
|
119 |
+
label='๐face similarity threshold',
|
120 |
minimum=0.0,
|
121 |
maximum=1.0)
|
122 |
+
convert_button = gr.Button('๐Swap')
|
123 |
convert_button.click(fn=swap_face,
|
124 |
inputs=[
|
125 |
video_input, dst_face_image,
|
|
|
127 |
use_sr, scale, face_sim_thre
|
128 |
],
|
129 |
outputs=[output_video],
|
130 |
+
api_name='๐กvideo swap')
|
131 |
|
132 |
+
with gr.Tab('๐ฎPoseSwapper'):
|
133 |
+
gr.Markdown('๐งธFaceClone๐งธ Deepfake power by Gradio')
|
134 |
+
with gr.Tab('๐ทImage'):
|
135 |
with gr.Row():
|
136 |
with gr.Column():
|
137 |
+
gr.Markdown('๐งโ๐ฆณThe source image to be swapped')
|
138 |
+
image_input = gr.Image(type='๐filepath')
|
139 |
+
gr.Markdown('๐ณ๏ธThe target image with pose')
|
140 |
+
target = gr.Image(type='๐filepath')
|
141 |
|
142 |
with gr.Column():
|
143 |
+
output_image = gr.Image(type='๐filepath')
|
144 |
use_enhancer = gr.Checkbox(
|
145 |
+
label="๐face enhance",
|
146 |
+
info="๐งพWhether use face enhance model.")
|
147 |
with gr.Row():
|
148 |
use_sr = gr.Checkbox(
|
149 |
+
label="๐ ๏ธsuper resolution",
|
150 |
+
info="โWhether use image resolution model.")
|
151 |
scale = gr.Number(
|
152 |
+
value=1, label='๐ธimage super resolution scale')
|
153 |
+
convert_button = gr.Button('๐งฟSwap')
|
154 |
convert_button.click(fn=swap_pose,
|
155 |
inputs=[
|
156 |
image_input, target,
|
157 |
use_enhancer, use_sr, scale
|
158 |
],
|
159 |
outputs=[output_image],
|
160 |
+
api_name='๐ญimage swap')
|
161 |
|
162 |
# with gr.Tab('Video'):
|
163 |
# with gr.Row():
|