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
|
@@ -14,7 +14,9 @@ from roop.utilities import normalize_output_path
|
|
14 |
import os
|
15 |
from PIL import Image
|
16 |
|
17 |
-
|
|
|
|
|
18 |
source_path = "input.jpg"
|
19 |
target_path = "target.jpg"
|
20 |
|
@@ -32,8 +34,8 @@ def swap_face(source_file, target_file, doFaceEnhancer):
|
|
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",
|
37 |
else:
|
38 |
roop.globals.frame_processors = ["face_swapper"]
|
39 |
roop.globals.headless = True
|
@@ -63,13 +65,14 @@ def swap_face(source_file, target_file, doFaceEnhancer):
|
|
63 |
start()
|
64 |
return output_path
|
65 |
|
66 |
-
# HTML code for the ad
|
67 |
ad_code = """
|
68 |
<div style="text-align: center;">
|
69 |
<iframe src="https://www.fiverr.com/gig_widgets?id=U2FsdGVkX1+9vQaosK0mq7xGXzIb/5hdFYIQsmHlpeMwFm5gingveDZKXBz2oJwV7ZwvToxseOx/KzKtr77ryB3qTb83/+GvCyI8OKpZcSgM0sDHzEPlZnqNeu8Db4y/IXlAceA1UcYT5Z3cW5vBLrgJ/WOpyMWSiyfwwMmGngjltQBexcivW7ukRd+/0yos7GCbfGjGdnLPHm2LB/CB9w2mA1i8cVv9LU+UUdj/O5KLRXtnychl9wAMkPTpmwMiyuAfUZy0nbK/Xa5O2UecmCvn7wicTr0TCTpLmIxaEh3YftXOVr9e36OGVYTmy5nlsgujkqJPI7wL0dXfon0ru4kvoycC7UD6m/whMoxrWZOf386qV2eEeXzk3vKO/emXUUfSavtofzSBtjLcyAOVhnHJg27PvVPgvFTQdy0o3F1M0DaHYTVW3Ln45MPYvMSH&affiliate_id=36184&strip_google_tagmanager=true" loading="lazy" data-with-title="false" class="fiverr_nga_frame" frameborder="0" height="350" width="100%" referrerpolicy="no-referrer-when-downgrade" data-mode="random_gigs" onload=" var frame = this; var script = document.createElement('script'); script.addEventListener('load', function() { window.FW_SDK.register(frame); }); script.setAttribute('src', 'https://www.fiverr.com/gig_widgets/sdk'); document.body.appendChild(script); " ></iframe>
|
70 |
</div>
|
71 |
-
"""
|
72 |
|
|
|
73 |
ad_code2 = """
|
74 |
<div style="text-align: center;">
|
75 |
<a href="https://beta.publishers.adsterra.com/referral/UNXJYTziBP" target="_blank" style="display: inline-block;">
|
@@ -79,22 +82,10 @@ ad_code2 = """
|
|
79 |
<img fetchpriority="high" decoding="async" width="468" height="120" src="https://ziverr.xyz/wp-content/uploads/2024/06/PASSIVE-1.gif" class="attachment-large size-large wp-image-1266" alt="">
|
80 |
</a>
|
81 |
</div>
|
82 |
-
"""
|
83 |
-
|
84 |
-
with gr.Blocks() as app:
|
85 |
-
gr.HTML(ad_code)
|
86 |
-
input_image1 = gr.Image()
|
87 |
-
input_image2 = gr.Image()
|
88 |
-
face_enhancer = gr.Checkbox(label="face_enhancer?", info="do face enhancer?")
|
89 |
-
output_image = gr.Image()
|
90 |
-
swap_face_button = gr.Button("Swap Face")
|
91 |
|
92 |
-
swap_face_button.click(
|
93 |
-
fn=swap_face,
|
94 |
-
inputs=[input_image1, input_image2, face_enhancer],
|
95 |
-
outputs=output_image
|
96 |
-
)
|
97 |
-
|
98 |
-
gr.HTML(ad_code2)
|
99 |
|
|
|
|
|
|
|
100 |
app.launch()
|
|
|
1 |
+
# -* coding:UTF-8 -*
|
2 |
# !/usr/bin/env python
|
3 |
import numpy as np
|
4 |
import gradio as gr
|
|
|
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 == True:
|
38 |
+
roop.globals.frame_processors = ["face_swapper","face_enhancer"]
|
39 |
else:
|
40 |
roop.globals.frame_processors = ["face_swapper"]
|
41 |
roop.globals.headless = True
|
|
|
65 |
start()
|
66 |
return output_path
|
67 |
|
68 |
+
# HTML code for the ad banner
|
69 |
ad_code = """
|
70 |
<div style="text-align: center;">
|
71 |
<iframe src="https://www.fiverr.com/gig_widgets?id=U2FsdGVkX1+9vQaosK0mq7xGXzIb/5hdFYIQsmHlpeMwFm5gingveDZKXBz2oJwV7ZwvToxseOx/KzKtr77ryB3qTb83/+GvCyI8OKpZcSgM0sDHzEPlZnqNeu8Db4y/IXlAceA1UcYT5Z3cW5vBLrgJ/WOpyMWSiyfwwMmGngjltQBexcivW7ukRd+/0yos7GCbfGjGdnLPHm2LB/CB9w2mA1i8cVv9LU+UUdj/O5KLRXtnychl9wAMkPTpmwMiyuAfUZy0nbK/Xa5O2UecmCvn7wicTr0TCTpLmIxaEh3YftXOVr9e36OGVYTmy5nlsgujkqJPI7wL0dXfon0ru4kvoycC7UD6m/whMoxrWZOf386qV2eEeXzk3vKO/emXUUfSavtofzSBtjLcyAOVhnHJg27PvVPgvFTQdy0o3F1M0DaHYTVW3Ln45MPYvMSH&affiliate_id=36184&strip_google_tagmanager=true" loading="lazy" data-with-title="false" class="fiverr_nga_frame" frameborder="0" height="350" width="100%" referrerpolicy="no-referrer-when-downgrade" data-mode="random_gigs" onload=" var frame = this; var script = document.createElement('script'); script.addEventListener('load', function() { window.FW_SDK.register(frame); }); script.setAttribute('src', 'https://www.fiverr.com/gig_widgets/sdk'); document.body.appendChild(script); " ></iframe>
|
72 |
</div>
|
73 |
+
"""
|
74 |
|
75 |
+
# HTML code for the ad banner
|
76 |
ad_code2 = """
|
77 |
<div style="text-align: center;">
|
78 |
<a href="https://beta.publishers.adsterra.com/referral/UNXJYTziBP" target="_blank" style="display: inline-block;">
|
|
|
82 |
<img fetchpriority="high" decoding="async" width="468" height="120" src="https://ziverr.xyz/wp-content/uploads/2024/06/PASSIVE-1.gif" class="attachment-large size-large wp-image-1266" alt="">
|
83 |
</a>
|
84 |
</div>
|
85 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
+
app = gr.Interface(
|
89 |
+
fn=swap_face, inputs=[gr.Image(), gr.Image(),gr.Checkbox(label="face_enhancer?", info="do face enhancer?")],gr.HTML(ad_code2), outputs="image"
|
90 |
+
)
|
91 |
app.launch()
|