Spaces:
Sleeping
Sleeping
File size: 931 Bytes
5a021c1 59ad75b f2b6373 ff7fdc3 c24b0df ff7fdc3 a167063 59ad75b f2b6373 3a63ef3 f2b6373 693c649 f2b6373 59ad75b f2b6373 c24b0df 875a5b4 59ad75b |
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 |
import gradio as gr
import requests
from PIL import Image
import io
import os
API_URL = "https://api-inference.huggingface.co/models/GenAIJake/d3xt3r-l1tt13-dachshund"
headers = {"Authorization": f"Bearer {os.getenv('HF_TOKEN')}"}
def generate(prompt):
try:
payload = {
"inputs": prompt,
"parameters": {
"num_inference_steps": 5
}
}
response = requests.post(API_URL, headers=headers, json=payload)
image = Image.open(io.BytesIO(response.content))
return image
except Exception as e:
return f"Error generating image: {str(e)}"
# Create the Gradio interface
demo = gr.Interface(
fn=generate,
inputs=gr.Textbox(label="Enter your prompt"),
outputs=gr.Image(label="Generated Image"),
title="D3xt3r L1tt13 Dachshund Generator",
description="Generate images of a cute dachshund character."
)
demo.launch()
|