Spaces:
Runtime error
Runtime error
aheedsajid
commited on
Commit
•
e99ed63
1
Parent(s):
575eab9
Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,24 @@
|
|
1 |
import gradio as gr
|
2 |
from gradio_client import Client
|
3 |
|
|
|
4 |
image_generation_client = Client("AP123/SDXL-Lightning")
|
5 |
image_swapping_client = Client("aheedsajid/test")
|
6 |
|
|
|
7 |
def generate_and_swap_image(prompt, source_image):
|
8 |
-
|
9 |
generated_image = image_generation_client.predict(prompt, "4-Step", api_name="/generate_image")
|
10 |
-
|
11 |
swapped_image = image_swapping_client.predict(source_image, generated_image, True, api_name="/predict")
|
12 |
-
|
13 |
return swapped_image
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
iface = gr.Interface(
|
16 |
fn=generate_and_swap_image,
|
17 |
inputs=[
|
@@ -20,7 +27,45 @@ iface = gr.Interface(
|
|
20 |
],
|
21 |
outputs=gr.Image(label="Swapped Image"),
|
22 |
title="AI Image with Any Face",
|
23 |
-
description="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
)
|
25 |
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from gradio_client import Client
|
3 |
|
4 |
+
# Clients for image generation and swapping
|
5 |
image_generation_client = Client("AP123/SDXL-Lightning")
|
6 |
image_swapping_client = Client("aheedsajid/test")
|
7 |
|
8 |
+
# Function to generate and swap images
|
9 |
def generate_and_swap_image(prompt, source_image):
|
|
|
10 |
generated_image = image_generation_client.predict(prompt, "4-Step", api_name="/generate_image")
|
|
|
11 |
swapped_image = image_swapping_client.predict(source_image, generated_image, True, api_name="/predict")
|
|
|
12 |
return swapped_image
|
13 |
|
14 |
+
# HTML code for the ad (replace with your actual ad code snippet)
|
15 |
+
ad_code = """
|
16 |
+
<div style="text-align: center;">
|
17 |
+
<iframe src="YOUR_AD_CODE_URL" width="300" height="250"></iframe>
|
18 |
+
</div>
|
19 |
+
"""
|
20 |
+
|
21 |
+
# Gradio interface
|
22 |
iface = gr.Interface(
|
23 |
fn=generate_and_swap_image,
|
24 |
inputs=[
|
|
|
27 |
],
|
28 |
outputs=gr.Image(label="Swapped Image"),
|
29 |
title="AI Image with Any Face",
|
30 |
+
description="""
|
31 |
+
Please donate something so I can get a GPU server. As low as $1 also accepted<br>
|
32 |
+
Generate free AI images with your face or any face.<br>
|
33 |
+
Contact me to bypass NSFW for more creativity and freedom😉<br>
|
34 |
+
<b>Donate something so I can increase the GPU power/queue</b><br>
|
35 |
+
[Click here to Donate](https://nowpayments.io/donation/aheed)<br>
|
36 |
+
Contact me for bulk processing and more AI software at +92-332-4399819<br>
|
37 |
+
Please support me in making better AI tools as I am a solo developer<br>
|
38 |
+
[Click here to Donate](https://nowpayments.io/donation/aheed)<br>
|
39 |
+
<b>Do not duplicate this space without permission.</b>
|
40 |
+
"""
|
41 |
)
|
42 |
|
43 |
+
# Adding the ad section
|
44 |
+
iface = gr.Blocks()
|
45 |
+
|
46 |
+
with iface:
|
47 |
+
gr.Markdown("# AI Image with Any Face")
|
48 |
+
gr.Markdown("""
|
49 |
+
Please donate something so I can get a GPU server. As low as $1 also accepted<br>
|
50 |
+
Generate free AI images with your face or any face.<br>
|
51 |
+
Contact me to bypass NSFW for more creativity and freedom😉<br>
|
52 |
+
<b>Donate something so I can increase the GPU power/queue</b><br>
|
53 |
+
[Click here to Donate](https://nowpayments.io/donation/aheed)<br>
|
54 |
+
Contact me for bulk processing and more AI software at +92-332-4399819<br>
|
55 |
+
Please support me in making better AI tools as I am a solo developer<br>
|
56 |
+
[Click here to Donate](https://nowpayments.io/donation/aheed)<br>
|
57 |
+
<b>Do not duplicate this space without permission.</b>
|
58 |
+
""")
|
59 |
+
|
60 |
+
gr.HTML(ad_code)
|
61 |
+
|
62 |
+
gr.Interface(
|
63 |
+
fn=generate_and_swap_image,
|
64 |
+
inputs=[
|
65 |
+
gr.Textbox(label="Enter your prompt (English)"),
|
66 |
+
gr.Image(label="Source Image", type="filepath"),
|
67 |
+
],
|
68 |
+
outputs=gr.Image(label="Swapped Image")
|
69 |
+
)
|
70 |
+
|
71 |
+
iface.launch()
|