Spaces:
Build error
Build error
Commit
·
bb5f8de
1
Parent(s):
438e70b
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import requests
|
|
|
|
|
3 |
|
4 |
# Function to call the API and generate the image
|
5 |
def generate_image(content, style):
|
@@ -12,18 +14,15 @@ def generate_image(content, style):
|
|
12 |
}
|
13 |
response = requests.post('https://api.fliki.ai/v1/generate/text-to-image', headers=headers, json=json_data)
|
14 |
|
15 |
-
#
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
# If the response is binary data:
|
20 |
-
return response.content
|
21 |
|
22 |
# Define the Gradio interface
|
23 |
iface = gr.Interface(
|
24 |
fn=generate_image,
|
25 |
inputs=[gr.Textbox(label="Content"), gr.Textbox(label="Style")],
|
26 |
-
outputs=gr.Image(type="
|
27 |
title="Text to Image Generator",
|
28 |
description="Enter a description and style to generate an image."
|
29 |
)
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
+
import numpy as np
|
4 |
+
from PIL import Image # Needed to convert binary data to numpy array
|
5 |
|
6 |
# Function to call the API and generate the image
|
7 |
def generate_image(content, style):
|
|
|
14 |
}
|
15 |
response = requests.post('https://api.fliki.ai/v1/generate/text-to-image', headers=headers, json=json_data)
|
16 |
|
17 |
+
# Convert binary data to numpy array
|
18 |
+
image = Image.open(BytesIO(response.content))
|
19 |
+
return np.array(image)
|
|
|
|
|
|
|
20 |
|
21 |
# Define the Gradio interface
|
22 |
iface = gr.Interface(
|
23 |
fn=generate_image,
|
24 |
inputs=[gr.Textbox(label="Content"), gr.Textbox(label="Style")],
|
25 |
+
outputs=gr.Image(type="numpy"), # Use numpy type for image output
|
26 |
title="Text to Image Generator",
|
27 |
description="Enter a description and style to generate an image."
|
28 |
)
|