Blane187's picture
Update app.py
4815fd5 verified
raw
history blame
890 Bytes
import gradio as gr
import requests
from PIL import Image
import io
import os
API_URL = "https://api-inference.huggingface.co/models/Blane187/kana-arima-s1-ponyxl-lora-nochekaiser"
API_TOKEN = os.getenv("HF_READ_TOKEN")
headers = {"Authorization": f"Bearer {API_TOKEN}"}
def query(inputs):
response = requests.post(API_URL, headers=headers, json={"inputs": inputs})
image_bytes = response.content
image = Image.open(io.BytesIO(image_bytes))
return image
with gr.Blocks() as demo:
gr.Markdown("## Generate an Image using Hugging Face Model")
with gr.Row():
prompt_input = gr.Textbox(label="Enter a prompt", placeholder="Astronaut riding a horse")
generate_btn = gr.Button("Generate Image")
output_image = gr.Image(label="Generated Image")
generate_btn.click(fn=query, inputs=prompt_input, outputs=output_image)
demo.launch()