seawolf2357 commited on
Commit
5206fbf
ยท
1 Parent(s): ec9b0b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -13
app.py CHANGED
@@ -5,27 +5,34 @@ API_KEY = "ZZUIQ4OZASNRQ8B8WYHNW"
5
  API_URL = "https://api.fliki.ai/v1/generate/text-to-image"
6
 
7
  def generate_image(content, style):
8
- payload = {"content": content, "style": style}
9
- headers = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}
10
-
11
- response = requests.post(API_URL, json=payload, headers=headers)
 
 
 
 
 
 
12
  if response.status_code == 200:
13
- return response.json()['url'] # ์ด๋ฏธ์ง€ ๋‹ค์šด๋กœ๋“œ URL ๋ฐ˜ํ™˜
14
  else:
15
  raise Exception(f"์˜ค๋ฅ˜ ๋ฐœ์ƒ: {response.status_code}")
16
 
 
 
 
 
 
 
 
17
  with gr.Blocks() as demo:
18
  with gr.Row():
19
  content_input = gr.Textbox(label="ํ…์ŠคํŠธ ์ž…๋ ฅ")
20
- style_input = gr.Dropdown(
21
- choices=["3d-model", "analog-film", "anime", "cinematic", "comic-book",
22
- "digital-art", "enhance", "fantasy-art", "isometric", "line-art",
23
- "low-poly", "modeling-compound", "neon-punk", "origami",
24
- "photographic", "pixel-art", "tile-texture"],
25
- label="์Šคํƒ€์ผ ์„ ํƒ"
26
- )
27
  submit_button = gr.Button("์ด๋ฏธ์ง€ ์ƒ์„ฑ")
28
- output = gr.Image(label="์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€")
29
 
30
  submit_button.click(
31
  generate_image,
 
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(API_URL, headers=headers, json=json_data)
17
+
18
  if response.status_code == 200:
19
+ return response.json()['url']
20
  else:
21
  raise Exception(f"์˜ค๋ฅ˜ ๋ฐœ์ƒ: {response.status_code}")
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=styles, label="์Šคํƒ€์ผ ์„ ํƒ")
 
 
 
 
 
 
34
  submit_button = gr.Button("์ด๋ฏธ์ง€ ์ƒ์„ฑ")
35
+ output = gr.Image(label="์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€", type="pil")
36
 
37
  submit_button.click(
38
  generate_image,