Spaces:
Build error
Build error
import gradio as gr | |
import requests | |
import base64 | |
from PIL import Image | |
from io import BytesIO | |
def generate_image(content, style): | |
headers = { | |
'Authorization': 'Bearer ZZUIQ4OZASNRQ8B8WYHNW', | |
} | |
json_data = { | |
'content': content, | |
'style': style, | |
} | |
response = requests.post('https://api.fliki.ai/v1/generate/text-to-image', headers=headers, json=json_data) | |
# Assuming the response contains the image in base64 format | |
image_data = response.json().get('image', '') | |
if image_data: | |
image = Image.open(BytesIO(base64.b64decode(image_data))) | |
return image | |
else: | |
return "Error: No image returned" | |
iface = gr.Interface( | |
fn=generate_image, | |
inputs=[gr.Textbox(label="Content"), gr.Textbox(label="Style")], | |
outputs="image", | |
title="Text to Image Generator", | |
description="Enter a description and style to generate an image." | |
) | |
iface.launch() | |