Spaces:
Build error
Build error
Commit
ยท
3c02b31
1
Parent(s):
bd532eb
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,12 @@
|
|
1 |
import gradio as gr
|
2 |
import requests
|
|
|
3 |
from PIL import Image
|
4 |
-
import
|
5 |
-
|
6 |
-
API_KEY = "ZZUIQ4OZASNRQ8B8WYHNW"
|
7 |
|
8 |
def generate_image(content, style):
|
9 |
headers = {
|
10 |
-
'Authorization':
|
11 |
}
|
12 |
json_data = {
|
13 |
'content': content,
|
@@ -15,29 +14,20 @@ def generate_image(content, style):
|
|
15 |
}
|
16 |
response = requests.post('https://api.fliki.ai/v1/generate/text-to-image', headers=headers, json=json_data)
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
image = Image.open(
|
22 |
return image
|
23 |
else:
|
24 |
-
|
25 |
-
|
26 |
-
with gr.Blocks() as demo:
|
27 |
-
with gr.Row():
|
28 |
-
content_input = gr.Textbox(label="ํ
์คํธ ์
๋ ฅ")
|
29 |
-
style_input = gr.Dropdown(choices=['3d-model', 'analog-film', 'anime', 'cinematic',
|
30 |
-
'comic-book', 'digital-art', 'enhance', 'fantasy-art',
|
31 |
-
'isometric', 'line-art', 'low-poly', 'modeling-compound',
|
32 |
-
'neon-punk', 'origami', 'photographic', 'pixel-art',
|
33 |
-
'tile-texture'], label="์คํ์ผ ์ ํ")
|
34 |
-
submit_button = gr.Button("์ด๋ฏธ์ง ์์ฑ")
|
35 |
-
output = gr.Image(label="์์ฑ๋ ์ด๋ฏธ์ง", type="pil")
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
42 |
|
43 |
-
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
+
import base64
|
4 |
from PIL import Image
|
5 |
+
from io import BytesIO
|
|
|
|
|
6 |
|
7 |
def generate_image(content, style):
|
8 |
headers = {
|
9 |
+
'Authorization': 'Bearer ZZUIQ4OZASNRQ8B8WYHNW',
|
10 |
}
|
11 |
json_data = {
|
12 |
'content': content,
|
|
|
14 |
}
|
15 |
response = requests.post('https://api.fliki.ai/v1/generate/text-to-image', headers=headers, json=json_data)
|
16 |
|
17 |
+
# Assuming the response contains the image in base64 format
|
18 |
+
image_data = response.json().get('image', '')
|
19 |
+
if image_data:
|
20 |
+
image = Image.open(BytesIO(base64.b64decode(image_data)))
|
21 |
return image
|
22 |
else:
|
23 |
+
return "Error: No image returned"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
+
iface = gr.Interface(
|
26 |
+
fn=generate_image,
|
27 |
+
inputs=[gr.Textbox(label="Content"), gr.Textbox(label="Style")],
|
28 |
+
outputs="image",
|
29 |
+
title="Text to Image Generator",
|
30 |
+
description="Enter a description and style to generate an image."
|
31 |
+
)
|
32 |
|
33 |
+
iface.launch()
|