Spaces:
Runtime error
Runtime error
import gradio as gr | |
import random | |
import requests | |
import io | |
from PIL import Image | |
import os | |
""" | |
API_URL = "https://api-inference.huggingface.co/models/LucyintheSky/lucy-dream-style" | |
headers = {"Authorization": "Bearer " + os.environ.get('TOKEN')} | |
def query(payload): | |
response = requests.post(API_URL, headers=headers, json=payload) | |
return response.content | |
""" | |
def generate(prompt): | |
""" | |
image_bytes = query({ | |
"inputs": "lucy dream style " + prompt, | |
"parameters" : { "negative_prompt": "ugly, deformed, bad quality", | |
"seed": random.randint(0,9999999)} | |
}) | |
image = Image.open(io.BytesIO(image_bytes)) | |
return image | |
""" | |
return None | |
theme = gr.themes.Base( | |
primary_hue="gray", | |
secondary_hue="gray", | |
neutral_hue="gray", | |
font=['Helvetica', 'ui-sans-serif', 'system-ui', 'sans-serif'], | |
).set( | |
button_large_text_weight='400', | |
input_background_fill='#ffffff', | |
#input_border_width='*block_border_width', | |
button_primary_background_fill='#ffd8db', | |
#button_border_width='*block_border_width', | |
) | |
with gr.Blocks(theme=theme) as demo: | |
gr.Markdown(""" | |
<center> <img src="https://cdn-uploads.huggingface.co/production/uploads/650a1281b48ff3906647edd0/rbzPKW_p5XTG9leEO4uFt.png" > </center> | |
<br><br><br> | |
""") | |
img = gr.Image(show_label=False, type='pil') | |
textbox = gr.Textbox(show_label=False, placeholder='type your prompt in here') | |
button = gr.Button("generate", variant="primary") | |
gr.Markdown(""" | |
![image/png](https://cdn-uploads.huggingface.co/production/uploads/650a1281b48ff3906647edd0/OLPLii-mE6VhIiabvJwOm.png) | |
""") | |
button.click(fn=generate, inputs=textbox, outputs=img) | |
textbox.submit(fn=generate, inputs=textbox, outputs=img) | |
demo.launch() |