Spaces:
Runtime error
Runtime error
| 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() |