Spaces:
Build error
Build error
import gradio as gr | |
import requests | |
from PIL import Image | |
import io | |
API_KEY = "ZZUIQ4OZASNRQ8B8WYHNW" | |
def generate_image(content, style): | |
headers = { | |
'Authorization': f'Bearer {API_KEY}', | |
} | |
json_data = { | |
'content': content, | |
'style': style, | |
} | |
response = requests.post('https://api.fliki.ai/v1/generate/text-to-image', headers=headers, json=json_data) | |
if response.status_code == 200: | |
image_url = response.json()['url'] | |
image_response = requests.get(image_url) | |
image = Image.open(io.BytesIO(image_response.content)) | |
return image | |
else: | |
raise Exception(f"์ค๋ฅ ๋ฐ์: {response.text}") | |
with gr.Blocks() as demo: | |
with gr.Row(): | |
content_input = gr.Textbox(label="ํ ์คํธ ์ ๋ ฅ") | |
style_input = gr.Dropdown(choices=['3d-model', 'analog-film', 'anime', 'cinematic', | |
'comic-book', 'digital-art', 'enhance', 'fantasy-art', | |
'isometric', 'line-art', 'low-poly', 'modeling-compound', | |
'neon-punk', 'origami', 'photographic', 'pixel-art', | |
'tile-texture'], label="์คํ์ผ ์ ํ") | |
submit_button = gr.Button("์ด๋ฏธ์ง ์์ฑ") | |
output = gr.Image(label="์์ฑ๋ ์ด๋ฏธ์ง", type="pil") | |
submit_button.click( | |
generate_image, | |
inputs=[content_input, style_input], | |
outputs=output | |
) | |
demo.launch() | |