Spaces:
Sleeping
Sleeping
File size: 1,142 Bytes
662609f a84048e eb357c6 08b3c57 7a4be7f 66a8af7 7a4be7f 08b3c57 7a4be7f eb357c6 d882530 eb357c6 37ee6de 66a8af7 7a4be7f 66a8af7 a84048e 7921e85 66a8af7 08b3c57 66a8af7 b636da7 7a4be7f 252a108 3c39bfa 93f3ed2 7a4be7f 93f3ed2 7a4be7f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
import gradio_client
from gradio_client import Client, file
from urllib.parse import quote
from huggingface_hub import InferenceClient
import numpy as np
import gradio as gr
hfclient = InferenceClient()
grclient = Client("fancyfeast/joy-caption-alpha-two")
def generate_img(prompt):
return client.text_to_image(prompt)
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):
result = grclient.predict(
input_image=file(img),
name_input="Hello!!",
custom_prompt="Analyze this image like an art critic would with information about its composition, style, symbolism, the use of color, light, any artistic movement it might belong to, etc. Keep it very long.",
api_name="/stream_chat"
)
return result[1]
def rountrip(img):
prompt=interrogate(img)
print(prompt)
url=pollinations_url_seedless(prompt)
return prompt,url
demo = gr.Interface(rountrip, gr.Image(type= 'filepath'),["textbox",gr.Image(label="pollination")])
demo.launch()
|