| import gradio_client |
| from gradio_client import Client, file |
| from urllib.parse import quote |
|
|
|
|
| import numpy as np |
| import gradio as gr |
| def generate_img(prompt): |
| client = Client("ameerazam08/SDXS-GPU-Demo") |
| client.view_api() |
| result = client.predict( |
| prompt=prompt, |
| api_name="/generate_image" |
| ) |
| return result |
|
|
| def pollinations_url_seedless(a, width=512, height=512): |
| urlprompt=quote(str(a)) |
| url=f"https://image.pollinations.ai/prompt/{urlprompt}?width={width}&height={height}" |
| return url |
|
|
| def interrogate(img): |
| from gradio_client import Client |
| |
| |
| client = Client("https://pharmapsychotic-clip-interrogator.hf.space/") |
| client.view_api() |
| result = client.predict( |
| img, |
| "ViT-L (best for Stable Diffusion 1.*)", |
| "best", |
| fn_index=3 |
| ) |
| return result |
| def rountrip(img): |
| prompt=interrogate(img) |
| print(prompt) |
| url=pollinations_url_seedless(prompt) |
| return generate_img(prompt),prompt |
|
|
| demo = gr.Interface(rountrip, gr.Image(type= 'filepath'),[gr.Image(type= 'filepath'),"textbox"]) |
| demo.launch() |
|
|