File size: 937 Bytes
aa95dd5
bc18a34
3c02b31
bd532eb
3c02b31
993c6c8
ec9b0b0
5206fbf
3c02b31
5206fbf
 
 
 
 
bd532eb
 
3c02b31
 
 
 
bd532eb
7d0efdb
3c02b31
2796462
3c02b31
 
 
 
 
 
 
bc18a34
3c02b31
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
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()