Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from gradio_client import Client
|
| 2 |
+
import numpy as np
|
| 3 |
+
import gradio as gr
|
| 4 |
+
def generate_img(prompt):
|
| 5 |
+
client = Client("ameerazam08/SDXS-GPU-Demo")
|
| 6 |
+
result = client.predict(
|
| 7 |
+
prompt=prompt,
|
| 8 |
+
api_name="/generate_image"
|
| 9 |
+
)
|
| 10 |
+
return result
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
from gradio_client import Client
|
| 14 |
+
def interrogate(img):
|
| 15 |
+
from gradio_client import Client
|
| 16 |
+
|
| 17 |
+
client = Client("https://pharmapsychotic-clip-interrogator.hf.space/")
|
| 18 |
+
result = client.predict(
|
| 19 |
+
img, # str (filepath or URL to image)
|
| 20 |
+
|
| 21 |
+
"ViT-L (best for Stable Diffusion 1.*)", # str (Option from: ['ViT-L (best for Stable Diffusion 1.*)'])
|
| 22 |
+
"best", # str in 'Mode' Radio component
|
| 23 |
+
fn_index=3
|
| 24 |
+
)
|
| 25 |
+
print(result)
|
| 26 |
+
def rountrip(im):
|
| 27 |
+
prompt=interrogate(img)
|
| 28 |
+
return generate_img(prompt)
|
| 29 |
+
|
| 30 |
+
demo = gr.Interface(rountrip, gr.Image(),gr.Image())
|
| 31 |
+
demo.launch()
|