Spaces:
Build error
Build error
Commit
ยท
bd532eb
1
Parent(s):
5206fbf
Update app.py
Browse files
app.py
CHANGED
@@ -1,36 +1,36 @@
|
|
1 |
import gradio as gr
|
2 |
import requests
|
|
|
|
|
3 |
|
4 |
API_KEY = "ZZUIQ4OZASNRQ8B8WYHNW"
|
5 |
-
API_URL = "https://api.fliki.ai/v1/generate/text-to-image"
|
6 |
|
7 |
def generate_image(content, style):
|
8 |
headers = {
|
9 |
'Authorization': f'Bearer {API_KEY}',
|
10 |
-
'Content-Type': 'application/json',
|
11 |
}
|
12 |
json_data = {
|
13 |
'content': content,
|
14 |
'style': style,
|
15 |
}
|
16 |
-
response = requests.post(
|
17 |
-
|
18 |
if response.status_code == 200:
|
19 |
-
|
|
|
|
|
|
|
20 |
else:
|
21 |
-
raise Exception(f"์ค๋ฅ ๋ฐ์: {response.
|
22 |
-
|
23 |
-
styles = [
|
24 |
-
"3d-model", "analog-film", "anime", "cinematic", "comic-book",
|
25 |
-
"digital-art", "enhance", "fantasy-art", "isometric", "line-art",
|
26 |
-
"low-poly", "modeling-compound", "neon-punk", "origami",
|
27 |
-
"photographic", "pixel-art", "tile-texture"
|
28 |
-
]
|
29 |
|
30 |
with gr.Blocks() as demo:
|
31 |
with gr.Row():
|
32 |
content_input = gr.Textbox(label="ํ
์คํธ ์
๋ ฅ")
|
33 |
-
style_input = gr.Dropdown(choices=
|
|
|
|
|
|
|
|
|
34 |
submit_button = gr.Button("์ด๋ฏธ์ง ์์ฑ")
|
35 |
output = gr.Image(label="์์ฑ๋ ์ด๋ฏธ์ง", type="pil")
|
36 |
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
+
from PIL import Image
|
4 |
+
import io
|
5 |
|
6 |
API_KEY = "ZZUIQ4OZASNRQ8B8WYHNW"
|
|
|
7 |
|
8 |
def generate_image(content, style):
|
9 |
headers = {
|
10 |
'Authorization': f'Bearer {API_KEY}',
|
|
|
11 |
}
|
12 |
json_data = {
|
13 |
'content': content,
|
14 |
'style': style,
|
15 |
}
|
16 |
+
response = requests.post('https://api.fliki.ai/v1/generate/text-to-image', headers=headers, json=json_data)
|
17 |
+
|
18 |
if response.status_code == 200:
|
19 |
+
image_url = response.json()['url']
|
20 |
+
image_response = requests.get(image_url)
|
21 |
+
image = Image.open(io.BytesIO(image_response.content))
|
22 |
+
return image
|
23 |
else:
|
24 |
+
raise Exception(f"์ค๋ฅ ๋ฐ์: {response.text}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|