hyejavideo / app.py
seawolf2357's picture
Update app.py
438e70b
raw
history blame
980 Bytes
import gradio as gr
import requests
# Function to call the API and generate the image
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)
# Handle the response here based on the API's response format
# If the response is a URL:
# return response.json()['url']
# If the response is binary data:
return response.content
# Define the Gradio interface
iface = gr.Interface(
fn=generate_image,
inputs=[gr.Textbox(label="Content"), gr.Textbox(label="Style")],
outputs=gr.Image(type="auto"), # 'auto' will automatically handle URLs or binary data
title="Text to Image Generator",
description="Enter a description and style to generate an image."
)
# Launch the interface
iface.launch()