Spaces:
Runtime error
Runtime error
File size: 1,861 Bytes
dd42ab6 3a87fa9 dd42ab6 b8f0747 deac1cf f433912 deac1cf c3b9c17 6127590 deac1cf f433912 b8f0747 deac1cf dd42ab6 |
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 |
import gradio as gr
import requests
import io
from PIL import Image
import os
API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0"
def query(payload):
auth_hf_api_token = os.environ.get("AUTH_HF_API_TOKEN")
authorization = "Bearer " + auth_hf_api_token
headers = {"Authorization": authorization}
response = requests.post(API_URL, headers=headers, json=payload)
return response.content
def genImage(character_name, description_of_the_character):
input = "Create a movie poster for " + character_name + "," + description_of_the_character + ",Disney Pixar movie style"
image_bytes = query({
"inputs": input,
})
image = Image.open(io.BytesIO(image_bytes))
return image
theme = gr.themes.Soft(radius_size=gr.themes.sizes.radius_none).set(body_background_fill="white")
demo = gr.Interface(genImage,
title="Bing Image Creator",
description="AI disney poster creator by https://www.bingimagecreator.cc",
inputs=[
gr.Textbox(lines=1, placeholder="Name your character",label="character name"),
gr.Textbox(lines=4, placeholder="Describe your character",label="description of your character")
], outputs=["image"], examples=[
["Mickey Mouse", "An anthropomorphic mouse who typically wears red shorts, large yellow shoes, and white gloves, Mickey is one of the world's most recognizable fictional characters."],
["Donald Duck", "An anthropomorphic white duck with a yellow-orange bill, legs, and feet. He typically wears a sailor shirt and cap with a bow tie."],
["Milo", "A curious and adventurous young scientist who dreams of exploring the furthest reaches of the galaxy."]
], theme=theme).queue(concurrency_count=100, api_open=False).launch(show_api=False, show_error=False)
demo.launch() |