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, ImageEnhance, ImageFilter
|
4 |
+
import gradio as gr
|
5 |
+
import logging
|
6 |
+
import re
|
7 |
+
import time
|
8 |
+
import cv2
|
9 |
+
import numpy as np
|
10 |
+
from io import BytesIO
|
11 |
+
from datetime import datetime, timedelta
|
12 |
+
import random
|
13 |
+
from dotenv import load_dotenv
|
14 |
+
from gradio_client import Client, handle_file
|
15 |
+
|
16 |
+
load_dotenv()
|
17 |
+
|
18 |
+
# ๋ก๊น
์ค์
|
19 |
+
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
20 |
+
logger = logging.getLogger(__name__)
|
21 |
+
|
22 |
+
|
23 |
+
# API ์๋ํฌ์ธํธ ์ค์ (ํ๊ฒฝ๋ณ์์์๋ง ์ค์ )
|
24 |
+
API_ENDPOINT = os.environ.get("API_ENDPOINT", "")
|
25 |
+
|
26 |
+
if not API_ENDPOINT:
|
27 |
+
raise ValueError("API_ENDPOINT ํ๊ฒฝ๋ณ์๊ฐ ์ค์ ๋์ง ์์์ต๋๋ค.")
|
28 |
+
|
29 |
+
# ํด๋ผ์ด์ธํธ ์ด๊ธฐํ
|
30 |
+
try:
|
31 |
+
client = Client(API_ENDPOINT)
|
32 |
+
logger.info("ํด๋ผ์ด์ธํธ ์ด๊ธฐํ ์๋ฃ")
|
33 |
+
except Exception as e:
|
34 |
+
logger.error(f"ํด๋ผ์ด์ธํธ ์ด๊ธฐํ ์คํจ: {e}")
|
35 |
+
raise
|
36 |
+
|
37 |
+
def safe_client_call(api_name, **kwargs):
|
38 |
+
"""์์ ํ ํด๋ผ์ด์ธํธ ํธ์ถ ํจ์"""
|
39 |
+
try:
|
40 |
+
return client.predict(api_name=api_name, **kwargs)
|
41 |
+
except Exception as e:
|
42 |
+
logger.error(f"API ํธ์ถ ์คํจ ({api_name}): {e}")
|
43 |
+
return None
|
44 |
+
|
45 |
+
def convert_image_to_file(image):
|
46 |
+
"""PIL Image ๊ฐ์ฒด๋ฅผ ์์ ํ์ผ๋ก ๋ณํ"""
|
47 |
+
if image is None:
|
48 |
+
return None
|
49 |
+
|
50 |
+
try:
|
51 |
+
# PIL Image ๊ฐ์ฒด์ธ ๊ฒฝ์ฐ
|
52 |
+
if hasattr(image, 'save'):
|
53 |
+
# ์์ ํ์ผ ์์ฑ
|
54 |
+
temp_file = tempfile.NamedTemporaryFile(suffix='.png', delete=False)
|
55 |
+
image.save(temp_file.name, format='PNG')
|
56 |
+
temp_file.close()
|
57 |
+
return temp_file.name
|
58 |
+
# ์ด๋ฏธ ํ์ผ ๊ฒฝ๋ก์ธ ๊ฒฝ์ฐ
|
59 |
+
elif isinstance(image, str):
|
60 |
+
return image
|
61 |
+
# ๊ธฐํ ๊ฒฝ์ฐ
|
62 |
+
else:
|
63 |
+
return image
|
64 |
+
except Exception as e:
|
65 |
+
logger.error(f"์ด๋ฏธ์ง ํ์ผ ๋ณํ ์คํจ: {e}")
|
66 |
+
return None
|
67 |
+
|
68 |
+
# ========== ์ด๋ฏธ์ง ์์ฑ๊ธฐ ๊ด๋ จ ํจ์ (ํด๋ผ์ด์ธํธ API ํ์ฉ) ==========
|
69 |
+
def generate_single_image(image1, image2, image3, prompt):
|
70 |
+
"""๋จ์ผ ์ด๋ฏธ์ง ์์ฑ - ์๋ณธ ํจ์๋ช
์ ์ง"""
|
71 |
+
try:
|
72 |
+
# ์ด๋ฏธ์ง ํ์ผ ์ฒ๋ฆฌ - PIL Image๋ฅผ ์์ ํ์ผ๋ก ๋ณํ
|
73 |
+
image1_path = convert_image_to_file(image1)
|
74 |
+
image2_path = convert_image_to_file(image2)
|
75 |
+
image3_path = convert_image_to_file(image3)
|
76 |
+
|
77 |
+
# handle_file๋ก ์ฒ๋ฆฌ
|
78 |
+
image1_file = handle_file(image1_path) if image1_path else None
|
79 |
+
image2_file = handle_file(image2_path) if image2_path else None
|
80 |
+
image3_file = handle_file(image3_path) if image3_path else None
|
81 |
+
|
82 |
+
result = safe_client_call(
|
83 |
+
"/generate_single_image",
|
84 |
+
image1=image1_file,
|
85 |
+
image2=image2_file,
|
86 |
+
image3=image3_file,
|
87 |
+
prompt=prompt
|
88 |
+
)
|
89 |
+
|
90 |
+
if result:
|
91 |
+
return result[0], result[1], result[2]
|
92 |
+
else:
|
93 |
+
return None, "API ํธ์ถ ์คํจ", ""
|
94 |
+
|
95 |
+
except Exception as e:
|
96 |
+
logger.error(f"๋จ์ผ ์ด๋ฏธ์ง ์์ฑ ์คํจ: {e}")
|
97 |
+
return None, f"์ค๋ฅ ๋ฐ์: {str(e)}", ""
|
98 |
+
|
99 |
+
def generate_multiple_images(image1, image2, image3, prompt, progress=gr.Progress()):
|
100 |
+
"""๋ค์ค ์ด๋ฏธ์ง ์์ฑ - ์๋ณธ ํจ์๋ช
์ ์ง"""
|
101 |
+
try:
|
102 |
+
progress(0, desc="์ด๋ฏธ์ง ์์ฑ ์ค๋น ์ค...")
|
103 |
+
|
104 |
+
# ์ด๋ฏธ์ง ํ์ผ ์ฒ๋ฆฌ - PIL Image๋ฅผ ์์ ํ์ผ๋ก ๋ณํ
|
105 |
+
image1_path = convert_image_to_file(image1)
|
106 |
+
image2_path = convert_image_to_file(image2)
|
107 |
+
image3_path = convert_image_to_file(image3)
|
108 |
+
|
109 |
+
# handle_file๋ก ์ฒ๋ฆฌ
|
110 |
+
image1_file = handle_file(image1_path) if image1_path else None
|
111 |
+
image2_file = handle_file(image2_path) if image2_path else None
|
112 |
+
image3_file = handle_file(image3_path) if image3_path else None
|
113 |
+
|
114 |
+
progress(0.5, desc="์ด๋ฏธ์ง ์์ฑ ์ค...")
|
115 |
+
|
116 |
+
result = safe_client_call(
|
117 |
+
"/generate_multiple_images",
|
118 |
+
image1=image1_file,
|
119 |
+
image2=image2_file,
|
120 |
+
image3=image3_file,
|
121 |
+
prompt=prompt
|
122 |
+
)
|
123 |
+
|
124 |
+
progress(1.0, desc="์ด๋ฏธ์ง ์์ฑ ์๋ฃ!")
|
125 |
+
|
126 |
+
if result:
|
127 |
+
return result[0], result[1], result[2], result[3]
|
128 |
+
else:
|
129 |
+
return None, None, "API ํธ์ถ ์คํจ", ""
|
130 |
+
|
131 |
+
except Exception as e:
|
132 |
+
logger.error(f"๋ค์ค ์ด๋ฏธ์ง ์์ฑ ์คํจ: {e}")
|
133 |
+
return None, None, f"์ค๋ฅ ๋ฐ์: {str(e)}", ""
|
134 |
+
|
135 |
+
# ========== ํ๋กฌํํธ ํ
ํ๋ฆฟ ํจ์๋ค - ํด๋ผ์ด์ธํธ API ํ์ฉ ==========
|
136 |
+
def get_prompt_template_1():
|
137 |
+
"""ํ๋กฌํํธ ํ
ํ๋ฆฟ 1 - ๋ถ๋ถ๋ณ๊ฒฝ-1"""
|
138 |
+
return "(#1์ ์ฌ์ฑ)์ด ์ด์ง ๋ค๋ก ๋์๋ณด๋ ๋ชจ์ต์ผ๋ก ์ต๋ํ ์ด์ seed๋ฅผ ์ ์งํํ
์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํ๋ผ."
|
139 |
+
|
140 |
+
def get_prompt_template_2():
|
141 |
+
"""ํ๋กฌํํธ ํ
ํ๋ฆฟ 2 - ๋ถ๋ถ๋ณ๊ฒฝ-2"""
|
142 |
+
return "(#1 ๋ ๋ชจ๋ชจํ)๏ฟฝ๏ฟฝ์ ์ฒญ์์์ด๋ ๊ณ ๋ง ๊ฒ์์ ๊ณ ๋๋ ๊ณ ๋ก ๋ณ๊ฒฝํ๊ณ ๋๋จธ์ง ๋ถ๋ถ์ seed๋ฅผ ๋ณ๊ฒฝ์ ํ์ง๋ง๋ผ."
|
143 |
+
|
144 |
+
def get_prompt_template_3():
|
145 |
+
"""ํ๋กฌํํธ ํ
ํ๋ฆฟ 3 - ๋ถ๋ถ๋ณ๊ฒฝ-3"""
|
146 |
+
return "(#1 ์ฌํ์ฉ ์ผ์๋ฐ์ค)์์ ์ผ์์ด ๋ด๊ธด 3์์ ์ฝ๋ผ๊ฐ ๋์ฌ์๋ ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๋ผ."
|
147 |
+
|
148 |
+
def get_prompt_template_4():
|
149 |
+
"""ํ๋กฌํํธ ํ
ํ๋ฆฟ 4 - ๊ธ์์ง์ฐ๊ธฐ"""
|
150 |
+
return "(#1 ์ด๋ฏธ์ง)์ ์๋ ์ค๊ตญ์ด๋ฅผ ๋ชจ๋ ์ ๊ฑฐํ๋ผ."
|
151 |
+
|
152 |
+
def get_prompt_template_5():
|
153 |
+
"""ํ๋กฌํํธ ํ
ํ๋ฆฟ 5 - ๊ธ์๋ณ๊ฒฝ"""
|
154 |
+
return '(#1์ ํ
์คํธ)๋ฅผ ์คํ์ผ์ ์ ์งํ์ฒด ํ
์คํธ๋ง "Hello"๋ก ๋ฐ๊ฟ๋ผ'
|
155 |
+
|
156 |
+
def get_prompt_template_6():
|
157 |
+
"""ํ๋กฌํํธ ํ
ํ๋ฆฟ 6 - ์ํ์ฐฉ์ฉ-1"""
|
158 |
+
return "(#1์ ์ฌ์ฑ๋ชจ๋ธ)์ด ์ ์ฒด ๋น์จ๊ณผ ํฌ์ฆ๋ ์ ์งํ ์ฒด (#2์ ์ ๊ธ๋ผ์ค)์ (#3์ ์ฒญ๋ฐ์ง)๋ฅผ ์ง์ ๋ชจ๋ธ์ด ์ฐฉ์ฉํ๊ฒ ์ฒ๋ผ ์์ฐ์ค๋ฝ๊ฒ ๋ชจ์ต์ ์์ฑํ๋ผ."
|
159 |
+
|
160 |
+
def get_prompt_template_7():
|
161 |
+
"""ํ๋กฌํํธ ํ
ํ๋ฆฟ 7 - ์ํ์ฐฉ์ฉ-2"""
|
162 |
+
return "(#1์ ์ฌ์ฑ๋ชจ๋ธ)์ด (#2์ ์ ๊ธ๋ผ์ค)์ ์ฐฉ์ฉํ๊ณ (#3์ ๋ท๋ฐฐ๊ฒฝ์ ์นดํ์ ์ฒด๊ฐ ๋ณด์ด๋ฉฐ) ์์์ ์์ ์๋ ๋ชจ์ต์ ์์ฑํ๋ผ."
|
163 |
+
|
164 |
+
def get_prompt_template_8():
|
165 |
+
"""ํ๋กฌํํธ ํ
ํ๋ฆฟ 8 - ์ํ๋ค๊ณ """
|
166 |
+
return "(#1์ ์ฌ์ฑ๋ชจ๋ธ)์ด(#2์ ์์ธ์)์ ๋ค๊ณ ์๋ ์์ฐ์ค๋ฌ์ด ๋ชจ์ต์ ์์ฑํ๋ผ."
|
167 |
+
|
168 |
+
def get_prompt_template_9():
|
169 |
+
"""ํ๋กฌํํธ ํ
ํ๋ฆฟ 9 - ๋ฐฐ๊ฒฝ๋ฐ๊พธ๊ธฐ"""
|
170 |
+
return "(#1์ ์ฌ์ฑ๋ชจ๋ธ)์ด (#2 ์นดํ)์์ ์์ฐ์ค๋ฝ๊ฒ ์๋ ๋ชจ์ต์ ์์ฑํ๋ผ."
|
171 |
+
|
172 |
+
def get_prompt_template_10():
|
173 |
+
"""ํ๋กฌํํธ ํ
ํ๋ฆฟ 10 - ๋ถ๋ถ์ง์ฐ๊ธฐ"""
|
174 |
+
return "(#1์ ๋ ๊ณ ๋ชจํ)์์ ์ฒญ์์์ด๋ ๊ณ ๋ฅผ ์ ๊ฑฐํ ํ, ๊ทธ ์๋ฆฌ๋ฅผ ์ฃผ๋ณ ๋ฐฐ๊ฒฝ๊ณผ ์์ฐ์ค๋ฝ๊ฒ ์ด์ฐ๋ฌ์ง๋๋ก ์ฑ์์ฃผ์ธ์. ๋จ, ์ด๋ฏธ์ง์ ๋ค๋ฅธ ๋ถ๋ถ์ ์ฃผ์ ์์๋ ๋์ผํ๊ฒ ์ ์ง ํด์ผํ๋ค."
|
175 |
+
|
176 |
+
def get_prompt_template_11():
|
177 |
+
"""ํ๋กฌํํธ ํ
ํ๋ฆฟ 11 - ์ด๋ฏธ์งํ์ฅ"""
|
178 |
+
return "(#1 ์ด๋ฏธ์ง)๋ฅผ ์๋ณธ๊ทธ๋๋ก ์ค์์ ๋๊ณ ๋น์จ๋ก ์ ์งํ ์ฒด ์์๋ ๋ฐ ์ข์ฐ๋ก ํฌ๊ฒ ํ์ฅํ๋ผ."
|
179 |
+
|
180 |
+
def get_prompt_template_12():
|
181 |
+
"""ํ๋กฌํํธ ํ
ํ๋ฆฟ 12 - ํ๋ ์ดํ
-1"""
|
182 |
+
return "(#1์
๋ฌ๋)์ ๋ด์ ์ฉ๊ธฐ๋ ๋ฒ๋ฆฌ๊ณ ๋๊ณ ํฐ ์์ ์ ์์ (#1์
๋ฌ๋)์์๋ง ๊ฐ๋ ์ฑ์์ ์์
์ ์ธ ๊ฐ๋๋ก ์ด์ธ๋ฆฌ๋ ์ํ๊ณผ ํจ๊ป ํ๋ ์ดํ
ํ ๋ชจ์ต์ ์ด๋ฏธ์ง๋ก ์์ฑํ๋ผ. "
|
183 |
+
|
184 |
+
def get_prompt_template_13():
|
185 |
+
"""ํ๋กฌํํธ ํ
ํ๋ฆฟ 13 - ํ๋ ์ดํ
-2"""
|
186 |
+
return "(#2 ํ๋ ์ดํ
ํ ์ด๋ฏธ์ง)์ ๋ด๊ธด ์์์ (#1 ์๋ฌ๋)๋ก ๋ฐ๊พธ๊ณ ๋๋จธ์ง๋ ์๋๋ฅผ ์ ์งํ ์ฒด ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๋ผ."
|
187 |
+
|
188 |
+
def get_prompt_template_14():
|
189 |
+
"""ํ๋กฌํํธ ํ
ํ๋ฆฟ 14 - ํ๋ ์ดํ
-3"""
|
190 |
+
return "(#1์ปต)์ ๋ธ๊ธฐ, ๋ฐ๋๋ผ, ์ด์ฝ ์์ด์คํฌ๋ฆผ์ ๋ด๊ณ ๊ทธ ์์ ์ด์ฝ ์๋ฝ์ด ํ๋ฅด๊ฒ ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๋ผ."
|
191 |
+
|
192 |
+
# ๋คํฌ๋ชจ๋ ์๋ ์ ์ฉ ์ปค์คํ
CSS ์คํ์ผ
|
193 |
+
custom_css = """
|
194 |
+
/* ============================================
|
195 |
+
๋คํฌ๋ชจ๋ ์๋ ๋ณ๊ฒฝ ํ
ํ๋ฆฟ CSS
|
196 |
+
============================================ */
|
197 |
+
|
198 |
+
/* 1. CSS ๋ณ์ ์ ์ (๋ผ์ดํธ๋ชจ๋ - ๊ธฐ๋ณธ๊ฐ) */
|
199 |
+
:root {
|
200 |
+
/* ๋ฉ์ธ ์ปฌ๋ฌ */
|
201 |
+
--primary-color: #FB7F0D;
|
202 |
+
--secondary-color: #ff9a8b;
|
203 |
+
--accent-color: #FF6B6B;
|
204 |
+
|
205 |
+
/* ๋ฐฐ๊ฒฝ ์ปฌ๋ฌ */
|
206 |
+
--background-color: #FFFFFF;
|
207 |
+
--card-bg: #ffffff;
|
208 |
+
--input-bg: #ffffff;
|
209 |
+
|
210 |
+
/* ํ
์คํธ ์ปฌ๋ฌ */
|
211 |
+
--text-color: #334155;
|
212 |
+
--text-secondary: #64748b;
|
213 |
+
|
214 |
+
/* ๋ณด๋ ๋ฐ ๊ตฌ๋ถ์ */
|
215 |
+
--border-color: #dddddd;
|
216 |
+
--border-light: #e5e5e5;
|
217 |
+
|
218 |
+
/* ํ
์ด๋ธ ์ปฌ๋ฌ */
|
219 |
+
--table-even-bg: #f3f3f3;
|
220 |
+
--table-hover-bg: #f0f0f0;
|
221 |
+
|
222 |
+
/* ๊ทธ๋ฆผ์ */
|
223 |
+
--shadow: 0 8px 30px rgba(251, 127, 13, 0.08);
|
224 |
+
--shadow-light: 0 2px 4px rgba(0, 0, 0, 0.1);
|
225 |
+
|
226 |
+
/* ๊ธฐํ */
|
227 |
+
--border-radius: 18px;
|
228 |
+
}
|
229 |
+
|
230 |
+
/* 2. ๋คํฌ๋ชจ๋ ์์ ๋ณ์ (์๋ ๊ฐ์ง) */
|
231 |
+
@media (prefers-color-scheme: dark) {
|
232 |
+
:root {
|
233 |
+
/* ๋ฐฐ๊ฒฝ ์ปฌ๋ฌ */
|
234 |
+
--background-color: #1a1a1a;
|
235 |
+
--card-bg: #2d2d2d;
|
236 |
+
--input-bg: #2d2d2d;
|
237 |
+
|
238 |
+
/* ํ
์คํธ ์ปฌ๋ฌ */
|
239 |
+
--text-color: #e5e5e5;
|
240 |
+
--text-secondary: #a1a1aa;
|
241 |
+
|
242 |
+
/* ๋ณด๋ ๋ฐ ๊ตฌ๋ถ์ */
|
243 |
+
--border-color: #404040;
|
244 |
+
--border-light: #525252;
|
245 |
+
|
246 |
+
/* ํ
์ด๋ธ ์ปฌ๋ฌ */
|
247 |
+
--table-even-bg: #333333;
|
248 |
+
--table-hover-bg: #404040;
|
249 |
+
|
250 |
+
/* ๊ทธ๋ฆผ์ */
|
251 |
+
--shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
|
252 |
+
--shadow-light: 0 2px 4px rgba(0, 0, 0, 0.2);
|
253 |
+
}
|
254 |
+
}
|
255 |
+
|
256 |
+
/* 3. ์๋ ๋คํฌ๋ชจ๋ ํด๋์ค (Gradio ํ ๊ธ์ฉ) */
|
257 |
+
[data-theme="dark"],
|
258 |
+
.dark,
|
259 |
+
.gr-theme-dark {
|
260 |
+
/* ๋ฐฐ๊ฒฝ ์ปฌ๋ฌ */
|
261 |
+
--background-color: #1a1a1a;
|
262 |
+
--card-bg: #2d2d2d;
|
263 |
+
--input-bg: #2d2d2d;
|
264 |
+
|
265 |
+
/* ํ
์คํธ ์ปฌ๋ฌ */
|
266 |
+
--text-color: #e5e5e5;
|
267 |
+
--text-secondary: #a1a1aa;
|
268 |
+
|
269 |
+
/* ๋ณด๋ ๋ฐ ๊ตฌ๋ถ์ */
|
270 |
+
--border-color: #404040;
|
271 |
+
--border-light: #525252;
|
272 |
+
|
273 |
+
/* ํ
์ด๋ธ ์ปฌ๋ฌ */
|
274 |
+
--table-even-bg: #333333;
|
275 |
+
--table-hover-bg: #404040;
|
276 |
+
|
277 |
+
/* ๊ทธ๋ฆผ์ */
|
278 |
+
--shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
|
279 |
+
--shadow-light: 0 2px 4px rgba(0, 0, 0, 0.2);
|
280 |
+
}
|
281 |
+
|
282 |
+
/* 4. ๊ธฐ๋ณธ ์์ ๋คํฌ๋ชจ๋ ์ ์ฉ */
|
283 |
+
body {
|
284 |
+
font-family: 'Pretendard', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
|
285 |
+
background-color: var(--background-color) !important;
|
286 |
+
color: var(--text-color) !important;
|
287 |
+
line-height: 1.6;
|
288 |
+
transition: background-color 0.3s ease, color 0.3s ease;
|
289 |
+
}
|
290 |
+
|
291 |
+
/* 5. Gradio ์ปจํ
์ด๋ ๊ฐ์ ์ ์ฉ */
|
292 |
+
.gradio-container,
|
293 |
+
.gradio-container *,
|
294 |
+
.gr-app,
|
295 |
+
.gr-app *,
|
296 |
+
.gr-interface {
|
297 |
+
background-color: var(--background-color) !important;
|
298 |
+
color: var(--text-color) !important;
|
299 |
+
}
|
300 |
+
|
301 |
+
/* Gradio ์ปจํ
์ด๋ ์ค๋ฒ๋ผ์ด๋ */
|
302 |
+
.gradio-container {
|
303 |
+
max-width: 100% !important;
|
304 |
+
width: 100% !important;
|
305 |
+
margin: 0 auto !important;
|
306 |
+
padding: 0 !important;
|
307 |
+
background-color: var(--background-color) !important;
|
308 |
+
box-sizing: border-box !important;
|
309 |
+
}
|
310 |
+
|
311 |
+
/* ์ถ๊ฐ: ๋ด๋ถ ์ปจํ
์ด๋๋ 100% ๋๋น๋ก ์ค์ */
|
312 |
+
.contain {
|
313 |
+
max-width: 100% !important;
|
314 |
+
width: 100% !important;
|
315 |
+
}
|
316 |
+
|
317 |
+
/* ์ถ๊ฐ: ๊ฐ ํ(Row)๋ 100% ๋๋น๋ก ์ค์ */
|
318 |
+
.gr-padded {
|
319 |
+
padding: 0 !important;
|
320 |
+
width: 100% !important;
|
321 |
+
max-width: 100% !important;
|
322 |
+
}
|
323 |
+
|
324 |
+
/* 6. ์นด๋ ๋ฐ ํจ๋ ์คํ์ผ */
|
325 |
+
.gr-group,
|
326 |
+
.gr-form,
|
327 |
+
.gr-box,
|
328 |
+
.gr-panel,
|
329 |
+
.custom-frame,
|
330 |
+
[class*="frame"],
|
331 |
+
[class*="card"],
|
332 |
+
[class*="panel"] {
|
333 |
+
background-color: var(--card-bg) !important;
|
334 |
+
border-radius: var(--border-radius) !important;
|
335 |
+
box-shadow: var(--shadow) !important;
|
336 |
+
padding: 1.5rem !important;
|
337 |
+
margin-bottom: 1.5rem !important;
|
338 |
+
border: 1px solid var(--border-color) !important;
|
339 |
+
transition: transform 0.3s ease, background-color 0.3s ease;
|
340 |
+
color: var(--text-color) !important;
|
341 |
+
}
|
342 |
+
|
343 |
+
.gr-group:hover {
|
344 |
+
transform: translateY(-5px);
|
345 |
+
}
|
346 |
+
|
347 |
+
/* 7. ์
๋ ฅ ํ๋ ์คํ์ผ */
|
348 |
+
input[type="text"],
|
349 |
+
input[type="number"],
|
350 |
+
input[type="email"],
|
351 |
+
input[type="password"],
|
352 |
+
textarea,
|
353 |
+
select,
|
354 |
+
.gr-input,
|
355 |
+
.gr-text-input,
|
356 |
+
.gr-textarea,
|
357 |
+
.gr-dropdown {
|
358 |
+
background-color: var(--input-bg) !important;
|
359 |
+
color: var(--text-color) !important;
|
360 |
+
border: 1px solid var(--border-color) !important;
|
361 |
+
border-radius: var(--border-radius) !important;
|
362 |
+
padding: 12px !important;
|
363 |
+
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05) !important;
|
364 |
+
transition: all 0.3s ease !important;
|
365 |
+
}
|
366 |
+
|
367 |
+
input[type="text"]:focus,
|
368 |
+
input[type="number"]:focus,
|
369 |
+
input[type="email"]:focus,
|
370 |
+
input[type="password"]:focus,
|
371 |
+
textarea:focus,
|
372 |
+
select:focus,
|
373 |
+
.gr-input:focus,
|
374 |
+
.gr-text-input:focus,
|
375 |
+
.gr-textarea:focus,
|
376 |
+
.gr-dropdown:focus {
|
377 |
+
border-color: var(--primary-color) !important;
|
378 |
+
outline: none !important;
|
379 |
+
box-shadow: 0 0 0 2px rgba(251, 127, 13, 0.2) !important;
|
380 |
+
}
|
381 |
+
|
382 |
+
/* 8. ๋ผ๋ฒจ ๋ฐ ํ
์คํธ ์์ */
|
383 |
+
label,
|
384 |
+
.gr-label,
|
385 |
+
.gr-checkbox label,
|
386 |
+
.gr-radio label,
|
387 |
+
p, span, div {
|
388 |
+
color: var(--text-color) !important;
|
389 |
+
}
|
390 |
+
|
391 |
+
/* 9. ์น์
์ ๋ชฉ */
|
392 |
+
.section-title {
|
393 |
+
font-size: 22px !important;
|
394 |
+
font-weight: 700 !important;
|
395 |
+
color: var(--text-color) !important;
|
396 |
+
margin-bottom: 1rem !important;
|
397 |
+
padding-bottom: 0.5rem !important;
|
398 |
+
border-bottom: 2px solid var(--primary-color) !important;
|
399 |
+
display: flex;
|
400 |
+
align-items: center;
|
401 |
+
}
|
402 |
+
|
403 |
+
.section-title span {
|
404 |
+
color: var(--primary-color);
|
405 |
+
}
|
406 |
+
|
407 |
+
/* 10. ๋ฒํผ ์คํ์ผ๋ง */
|
408 |
+
.custom-button {
|
409 |
+
background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)) !important;
|
410 |
+
color: white !important;
|
411 |
+
font-weight: 600 !important;
|
412 |
+
border: none !important;
|
413 |
+
border-radius: 30px !important;
|
414 |
+
padding: 12px 24px !important;
|
415 |
+
box-shadow: 0 4px 8px rgba(251, 127, 13, 0.25) !important;
|
416 |
+
transition: all 0.3s ease !important;
|
417 |
+
text-transform: none !important;
|
418 |
+
display: flex !important;
|
419 |
+
align-items: center !important;
|
420 |
+
justify-content: center !important;
|
421 |
+
}
|
422 |
+
|
423 |
+
.custom-button:hover {
|
424 |
+
transform: translateY(-2px) !important;
|
425 |
+
box-shadow: 0 6px 12px rgba(251, 127, 13, 0.3) !important;
|
426 |
+
}
|
427 |
+
|
428 |
+
.custom-button.primary {
|
429 |
+
background: linear-gradient(135deg, var(--accent-color), #ff9a8b) !important;
|
430 |
+
}
|
431 |
+
|
432 |
+
button:not([class*="custom"]):not([class*="primary"]):not([class*="secondary"]) {
|
433 |
+
background-color: var(--card-bg) !important;
|
434 |
+
color: var(--text-color) !important;
|
435 |
+
border: 1px solid var(--border-color) !important;
|
436 |
+
border-radius: var(--border-radius) !important;
|
437 |
+
transition: all 0.3s ease !important;
|
438 |
+
}
|
439 |
+
|
440 |
+
/* 11. ์ด๋ฏธ์ง ์ปจํ
์ด๋ */
|
441 |
+
.image-container {
|
442 |
+
border-radius: var(--border-radius);
|
443 |
+
overflow: hidden;
|
444 |
+
border: 1px solid var(--border-color);
|
445 |
+
transition: all 0.3s ease;
|
446 |
+
background-color: var(--card-bg);
|
447 |
+
}
|
448 |
+
|
449 |
+
.image-container:hover {
|
450 |
+
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
|
451 |
+
}
|
452 |
+
|
453 |
+
/* 12. ํ
์ด๋ธ ์คํ์ผ */
|
454 |
+
table {
|
455 |
+
background-color: var(--card-bg) !important;
|
456 |
+
color: var(--text-color) !important;
|
457 |
+
border-color: var(--border-color) !important;
|
458 |
+
}
|
459 |
+
|
460 |
+
table th {
|
461 |
+
background-color: var(--primary-color) !important;
|
462 |
+
color: white !important;
|
463 |
+
border-color: var(--border-color) !important;
|
464 |
+
}
|
465 |
+
|
466 |
+
table td {
|
467 |
+
background-color: var(--card-bg) !important;
|
468 |
+
color: var(--text-color) !important;
|
469 |
+
border-color: var(--border-color) !important;
|
470 |
+
}
|
471 |
+
|
472 |
+
table tbody tr:nth-child(even) {
|
473 |
+
background-color: var(--table-even-bg) !important;
|
474 |
+
}
|
475 |
+
|
476 |
+
table tbody tr:hover {
|
477 |
+
background-color: var(--table-hover-bg) !important;
|
478 |
+
}
|
479 |
+
|
480 |
+
/* 13. ์ฒดํฌ๋ฐ์ค ๋ฐ ๋ผ๋์ค ๋ฒํผ */
|
481 |
+
input[type="checkbox"],
|
482 |
+
input[type="radio"] {
|
483 |
+
accent-color: var(--primary-color) !important;
|
484 |
+
}
|
485 |
+
|
486 |
+
/* 14. ๋ฒํผ ๊ทธ๋ฃน */
|
487 |
+
.button-grid {
|
488 |
+
display: grid;
|
489 |
+
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
|
490 |
+
gap: 0.8rem;
|
491 |
+
margin-bottom: 1.2rem;
|
492 |
+
}
|
493 |
+
|
494 |
+
/* 15. ์คํฌ๋กค๋ฐ ์คํ์ผ */
|
495 |
+
::-webkit-scrollbar-thumb:hover {
|
496 |
+
background: var(--secondary-color);
|
497 |
+
}
|
498 |
+
|
499 |
+
/* 16. ์์ฝ๋์ธ ๋ฐ ๋๋กญ๋ค์ด */
|
500 |
+
details {
|
501 |
+
background-color: var(--card-bg) !important;
|
502 |
+
border-color: var(--border-color) !important;
|
503 |
+
color: var(--text-color) !important;
|
504 |
+
}
|
505 |
+
|
506 |
+
details summary {
|
507 |
+
background-color: var(--card-bg) !important;
|
508 |
+
color: var(--text-color) !important;
|
509 |
+
}
|
510 |
+
|
511 |
+
/* 17. ํดํ ๋ฐ ํ์
*/
|
512 |
+
[data-tooltip]:hover::after,
|
513 |
+
.tooltip,
|
514 |
+
.popup {
|
515 |
+
background-color: var(--card-bg) !important;
|
516 |
+
color: var(--text-color) !important;
|
517 |
+
border-color: var(--border-color) !important;
|
518 |
+
box-shadow: var(--shadow-light) !important;
|
519 |
+
}
|
520 |
+
|
521 |
+
/* 18. ๋ชจ๋ฌ ๋ฐ ์ค๋ฒ๋ ์ด */
|
522 |
+
.modal,
|
523 |
+
.overlay,
|
524 |
+
[class*="modal"],
|
525 |
+
[class*="overlay"] {
|
526 |
+
background-color: var(--card-bg) !important;
|
527 |
+
color: var(--text-color) !important;
|
528 |
+
border-color: var(--border-color) !important;
|
529 |
+
}
|
530 |
+
|
531 |
+
/* 19. ์ถ๊ฐ Gradio ์ปดํฌ๋ํธ๋ค */
|
532 |
+
.gr-block,
|
533 |
+
.gr-group,
|
534 |
+
.gr-row,
|
535 |
+
.gr-column {
|
536 |
+
background-color: var(--background-color) !important;
|
537 |
+
color: var(--text-color) !important;
|
538 |
+
}
|
539 |
+
|
540 |
+
/* 20. ์ฝ๋ ๋ธ๋ก ๋ฐ pre ํ๊ทธ */
|
541 |
+
code,
|
542 |
+
pre,
|
543 |
+
.code-block {
|
544 |
+
background-color: var(--table-even-bg) !important;
|
545 |
+
color: var(--text-color) !important;
|
546 |
+
border-color: var(--border-color) !important;
|
547 |
+
}
|
548 |
+
|
549 |
+
/* 21. ์๋ฆผ ๋ฐ ๋ฉ์์ง */
|
550 |
+
.alert,
|
551 |
+
.message,
|
552 |
+
.notification,
|
553 |
+
[class*="alert"],
|
554 |
+
[class*="message"],
|
555 |
+
[class*="notification"] {
|
556 |
+
background-color: var(--card-bg) !important;
|
557 |
+
color: var(--text-color) !important;
|
558 |
+
border-color: var(--border-color) !important;
|
559 |
+
}
|
560 |
+
|
561 |
+
/* 22. ์ ๋๋ฉ์ด์
์คํ์ผ */
|
562 |
+
@keyframes fadeIn {
|
563 |
+
from { opacity: 0; transform: translateY(10px); }
|
564 |
+
to { opacity: 1; transform: translateY(0); }
|
565 |
+
}
|
566 |
+
|
567 |
+
.fade-in {
|
568 |
+
animation: fadeIn 0.5s ease-out;
|
569 |
+
}
|
570 |
+
|
571 |
+
/* 23. Examples ์น์
์คํ์ผ */
|
572 |
+
.examples-section {
|
573 |
+
display: grid;
|
574 |
+
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
|
575 |
+
gap: 1.5rem;
|
576 |
+
margin-top: 1rem;
|
577 |
+
}
|
578 |
+
|
579 |
+
.example-item {
|
580 |
+
background-color: var(--card-bg);
|
581 |
+
border-radius: var(--border-radius);
|
582 |
+
overflow: hidden;
|
583 |
+
box-shadow: var(--shadow);
|
584 |
+
transition: transform 0.3s ease, background-color 0.3s ease;
|
585 |
+
}
|
586 |
+
|
587 |
+
.example-item:hover {
|
588 |
+
transform: translateY(-5px);
|
589 |
+
}
|
590 |
+
|
591 |
+
/* 24. ์ ํ ์ ๋๋ฉ์ด์
*/
|
592 |
+
* {
|
593 |
+
transition: background-color 0.3s ease,
|
594 |
+
color 0.3s ease,
|
595 |
+
border-color 0.3s ease !important;
|
596 |
+
}
|
597 |
+
|
598 |
+
/* 25. ๋ฐ์ํ */
|
599 |
+
@media (max-width: 768px) {
|
600 |
+
.button-grid {
|
601 |
+
grid-template-columns: repeat(2, 1fr);
|
602 |
+
}
|
603 |
+
.examples-section {
|
604 |
+
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
|
605 |
+
}
|
606 |
+
}
|
607 |
+
"""
|
608 |
+
|
609 |
+
# FontAwesome ์์ด์ฝ ํฌํจ
|
610 |
+
fontawesome_link = """
|
611 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
612 |
+
"""
|
613 |
+
|
614 |
+
# ์ ๋ชฉ๊ณผ ์ฌ์ฉ ๊ฐ์ด๋ ์ ๊ฑฐ
|
615 |
+
header_html = ""
|
616 |
+
image_generator_guide_html = ""
|
617 |
+
|
618 |
+
# UI ๊ตฌ์ฑ
|
619 |
+
with gr.Blocks(css=custom_css, theme=gr.themes.Default(
|
620 |
+
primary_hue="orange",
|
621 |
+
secondary_hue="orange",
|
622 |
+
font=[gr.themes.GoogleFont("Noto Sans KR"), "ui-sans-serif", "system-ui"]
|
623 |
+
)) as demo:
|
624 |
+
gr.HTML(fontawesome_link)
|
625 |
+
|
626 |
+
with gr.Row(equal_height=True):
|
627 |
+
with gr.Column(scale=1):
|
628 |
+
# ======== ์ด๋ฏธ์ง ์
๋ก๋ ๋ฐ ์ค์ ์น์
========
|
629 |
+
with gr.Group():
|
630 |
+
gr.HTML('<div class="section-title"><i class="fas fa-upload"></i> <span>์ด๋ฏธ์ง ์
๋ก๋ ๋ฐ ์ค์ </span></div>')
|
631 |
+
with gr.Row():
|
632 |
+
image1_input = gr.Image(type="pil", label="#1", image_mode="RGB", elem_classes="image-container", height=400)
|
633 |
+
image2_input = gr.Image(type="pil", label="#2", image_mode="RGB", elem_classes="image-container", height=400)
|
634 |
+
image3_input = gr.Image(type="pil", label="#3", image_mode="RGB", elem_classes="image-container", height=400)
|
635 |
+
|
636 |
+
# ํ๋กฌํํธ ์
๋ ฅ ํ๋ ์ถ๊ฐ
|
637 |
+
prompt_input = gr.Textbox(
|
638 |
+
lines=3,
|
639 |
+
placeholder="ํ๋กฌํํธ๋ฅผ ์
๋ ฅํ๊ฑฐ๋ ๋น์๋๋ฉด ์๋ ํฉ์ฑ๋ฉ๋๋ค. '#1', '#2', '#3'์ผ๋ก ๊ฐ ์ด๋ฏธ์ง๋ฅผ ์ฐธ์กฐํ ์ ์์ต๋๋ค.",
|
640 |
+
label="ํ๋กฌํํธ (์ ํ ์ฌํญ)",
|
641 |
+
elem_classes="gr-text-input"
|
642 |
+
)
|
643 |
+
|
644 |
+
# ======== ๋ณํ ์ต์
์น์
========
|
645 |
+
with gr.Group():
|
646 |
+
gr.HTML('<div class="section-title"><i class="fas fa-sliders-h"></i> <span>ํ๋กฌํํธ ํ
ํ๋ฆฟ</span></div>')
|
647 |
+
with gr.Column(elem_classes="button-grid"):
|
648 |
+
image_change_btn1 = gr.Button('๐ ๋ถ๋ถ๋ณ๊ฒฝ-1', elem_classes="custom-button")
|
649 |
+
image_change_btn2 = gr.Button('๐ ๋ถ๋ถ๋ณ๊ฒฝ-2', elem_classes="custom-button")
|
650 |
+
image_change_btn3= gr.Button('๐ ๋ถ๋ถ๋ณ๊ฒฝ-3', elem_classes="custom-button")
|
651 |
+
text_remove_btn = gr.Button('๐งน ๊ธ์์ง์ฐ๊ธฐ', elem_classes="custom-button")
|
652 |
+
text_change_btn = gr.Button('๐ค ๊ธ์๋ณ๊ฒฝ', elem_classes="custom-button")
|
653 |
+
clothes_change_btn1 = gr.Button('๐ ์ํ์ฐฉ์ฉ-1', elem_classes="custom-button")
|
654 |
+
clothes_change_btn2 = gr.Button('๐ ์ํ์ฐฉ์ฉ-2', elem_classes="custom-button")
|
655 |
+
holding_product_btn = gr.Button('๐ท ์ํ๋ค๊ณ ', elem_classes="custom-button")
|
656 |
+
background_change_btn = gr.Button('๐ผ๏ธ ๋ฐฐ๊ฒฝ๋ฐ๊พธ๊ธฐ', elem_classes="custom-button")
|
657 |
+
composite_product_btn = gr.Button('โ๏ธ ๋ถ๋ถ์ง์ฐ๊ธฐ', elem_classes="custom-button")
|
658 |
+
outpainting_btn = gr.Button('๐ ์ด๋ฏธ์งํ์ฅ', elem_classes="custom-button")
|
659 |
+
food_btn_1 = gr.Button('๐ฝ๏ธ ํ๋ ์ดํ
-1', elem_classes="custom-button")
|
660 |
+
food_btn_2 = gr.Button('๐ฝ๏ธ ํ๋ ์ดํ
-2', elem_classes="custom-button")
|
661 |
+
food_btn_3 = gr.Button('๐ฝ๏ธ ํ๋ ์ดํ
-3', elem_classes="custom-button")
|
662 |
+
|
663 |
+
# ======== ์ด๋ฏธ์ง ์์ฑ ์น์
========
|
664 |
+
with gr.Group():
|
665 |
+
gr.HTML('<div class="section-title"><i class="fas fa-image"></i> <span>์ด๋ฏธ์ง ์์ฑ</span></div>')
|
666 |
+
submit_single_btn = gr.Button('โจ ์ด๋ฏธ์ง ์์ฑ (1์ฅ)', elem_classes="custom-button primary")
|
667 |
+
submit_btn = gr.Button('โจ ์ด๋ฏธ์ง ์์ฑ (2์ฅ)', elem_classes="custom-button primary")
|
668 |
+
|
669 |
+
with gr.Column(scale=1):
|
670 |
+
# ======== ์์ฑ๋ ์ด๋ฏธ์ง ์น์
========
|
671 |
+
with gr.Group():
|
672 |
+
gr.HTML('<div class="section-title"><i class="fas fa-images"></i> <span>์์ฑ๋ ์ด๋ฏธ์ง</span></div>')
|
673 |
+
with gr.Row():
|
674 |
+
with gr.Column():
|
675 |
+
output_image1 = gr.Image(label="์ด๋ฏธ์ง #1", elem_classes="image-container", height=400)
|
676 |
+
with gr.Column():
|
677 |
+
output_image2 = gr.Image(label="์ด๋ฏธ์ง #2", elem_classes="image-container", height=400)
|
678 |
+
|
679 |
+
# ======== ๊ฒฐ๊ณผ ์ ๋ณด ์น์
========
|
680 |
+
with gr.Group():
|
681 |
+
gr.HTML('<div class="section-title"><i class="fas fa-info-circle"></i> <span>๊ฒฐ๊ณผ ์ ๋ณด</span></div>')
|
682 |
+
output_text = gr.Textbox(label="์ํ ๋ฉ์์ง", lines=2, elem_classes="gr-text-input")
|
683 |
+
prompt_display = gr.Textbox(label="์ฌ์ฉ๋ ํ๋กฌํํธ (์์ด)", visible=True, lines=2, elem_classes="gr-text-input")
|
684 |
+
|
685 |
+
# ======== ์์ ์ด๋ฏธ์ง ์น์
========
|
686 |
+
gr.HTML('<div class="section-title"><i class="fas fa-lightbulb"></i> <span>์์ ์ด๋ฏธ์ง</span></div>')
|
687 |
+
|
688 |
+
# ๋ชจ๋ ์์ ํ ํ์ด์ง์ ํ์
|
689 |
+
examples = [
|
690 |
+
["down/๋ชจ๋ธ.jpg", None, None, "(#1์ ์ฌ์ฑ)์ด ์ด์ง ๋ค๋ก ๋์๋ณด๋ ๋ชจ์ต์ผ๋ก ์ต๋ํ ์ด์ seed๋ฅผ ์ ์งํ์ฒด ์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํ๋ผ."],
|
691 |
+
["down/์์ด๋ ๊ณ ๋ชจํ.png", None, None, "(#1 ๋ ๋ชจ๋ชจํ)์์ ์ฒญ์์์ด๋ ๊ณ ๋ง ๊ฒ์์ ๊ณ ๋๋ ๊ณ ๋ก ๋ณ๊ฒฝํ๊ณ ๋๋จธ์ง ๋ถ๋ถ์ seed๋ฅผ ๋ณ๊ฒฝ์ ํ์ง๋ง๋ผ."],
|
692 |
+
["down/์ผ์๊ฐ๋ฐฉ.png", None, None, "(#1 ์ฌํ์ฉ ์ผ์๋ฐ์ค)์์ ์ผ์์ด ๋ด๊ธด 3์์ ์ฝ๋ผ๊ฐ ๋์ฌ์๋ ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๋ผ."],
|
693 |
+
["down/์ค๊ตญ์ด.png", None, None, "(#1 ์ด๋ฏธ์ง)์ ์๋ ์ค๊ตญ์ด๋ฅผ ๋ชจ๋ ์ ๊ฑฐํ๋ผ."],
|
694 |
+
["down/ํ
์คํธ.webp", None, None, '(#1์ ํ
์คํธ)๋ฅผ ์คํ์ผ์ ์ ์งํ์ฒด ํ
์คํธ๋ง "Hello"๋ก ๋ฐ๊ฟ๋ผ'],
|
695 |
+
["down/๋ชจ๋ธ2.png", "down/์ ๊ธ๋ผ์ค.png", "down/์ฒญ๋ฐ์ง.png", "(#1์ ์ฌ์ฑ๋ชจ๋ธ)์ด ์ ์ฒด ๋น์จ๊ณผ ํฌ์ฆ๋ ์ ์งํ ์ฒด (#2์ ์ ๊ธ๋ผ์ค)์ (#3์ ์ฒญ๋ฐ์ง)๋ฅผ ์ง์ ๋ชจ๋ธ์ด ์ฐฉ์ฉํ๊ฒ ์ฒ๋ผ ์์ฐ์ค๋ฝ๊ฒ ๋ชจ์ต์ ์์ฑํ๋ผ."],
|
696 |
+
["down/๋ชจ๋ธ2.png", "down/์ ๊ธ๋ผ์ค.png", "down/์นดํ์ ๊ฒฝ.png", "(#1์ ์ฌ์ฑ๋ชจ๋ธ)์ด (#2์ ์ ๊ธ๋ผ์ค)์ ์ฐฉ์ฉํ๊ณ (#3์ ๋ท๋ฐฐ๊ฒฝ์ ์นดํ์ ์ฒด๊ฐ ๋ณด์ด๋ฉฐ) ์์์ ์์ ์๋ ๋ชจ์ต์ ์์ฑํ๋ผ."],
|
697 |
+
["down/๋ชจ๋ธ2.png", "down/์์ธ์.png", None, "(#1์ ์ฌ์ฑ๋ชจ๋ธ)์ด(#2์ ์์ธ์)์ ๋ค๊ณ ์๋ ์์ฐ์ค๋ฌ์ด ๋ชจ์ต์ ์์ฑํ๏ฟฝ๏ฟฝ๏ฟฝ."],
|
698 |
+
["down/๋ชจ๋ธ2.png", "down/์นดํ์ ๊ฒฝ.png", None, "(#1์ ์ฌ์ฑ๋ชจ๋ธ)์ด (#2 ์นดํ)์์ ์์ฐ์ค๋ฝ๊ฒ ์๋ ๋ชจ์ต์ ์์ฑํ๋ผ."],
|
699 |
+
["down/์์ด๋ ๊ณ ๋ชจํ.png", None, None, "(#1์ ๋ ๊ณ ๋ชจํ)์์ ์ฒญ์์์ด๋ ๊ณ ๋ฅผ ์ ๊ฑฐํ ํ, ๊ทธ ์๋ฆฌ๋ฅผ ์ฃผ๋ณ ๋ฐฐ๊ฒฝ๊ณผ ์์ฐ์ค๋ฝ๊ฒ ์ด์ฐ๋ฌ์ง๋๋ก ์ฑ์์ฃผ์ธ์. ๋จ, ์ด๋ฏธ์ง์ ๋ค๋ฅธ ๋ถ๋ถ์ ์ฃผ์ ์์๋ ๋์ผํ๊ฒ ์ ์งํด์ผํ๋ค."],
|
700 |
+
["down/์นดํ์ ๊ฒฝ.png", None, None, "(#1 ์ด๋ฏธ์ง)๋ฅผ ์๋ณธ๊ทธ๋๋ก ์ค์์ ๋๊ณ ๋น์จ๋ก ์ ์งํ ์ฒด ์์๋ ๋ฐ ์ข์ฐ๋ก ํฌ๊ฒ ํ์ฅํ๋ผ."],
|
701 |
+
["down/์๋ฌ๋.png", None, None, "(#1์
๋ฌ๋)์ ๋ด์ ์ฉ๊ธฐ๋ ๋ฒ๋ฆฌ๊ณ ๋๊ณ ํฐ ์์ ์ ์์ (#1์
๋ฌ๋)์์๋ง ๊ฐ๋ ์ฑ์์ ์์
์ ์ธ ๊ฐ๋๋ก ์ด์ธ๋ฆฌ๋ ์ํ๊ณผ ํจ๊ป ํ๋ ์ดํ
ํ ๋ชจ์ต์ ์ด๋ฏธ์ง๋ก ์์ฑํ๋ผ. "],
|
702 |
+
["down/์๋ฌ๋.png", "down/ํ๋ ์ดํ
.png", None, "(#2 ํ๋ ์ดํ
ํ ์ด๋ฏธ์ง)์ ๋ด๊ธด ์์์ (#1 ์๋ฌ๋)๋ก ๋ฐ๊พธ๊ณ ๋๋จธ์ง๋ ์๋๋ฅผ ์ ์งํ ์ฒด ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๋ผ."],
|
703 |
+
["down/์ปต.png", None, None, "(#1์ปต)์ ๋ธ๊ธฐ, ๋ฐ๋๋ผ, ์ด์ฝ ์์ด์คํฌ๋ฆผ์ ๋ด๊ณ ๊ทธ ์์ ์ด์ฝ ์๋ฝ์ด ํ๋ฅด๊ฒ ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๋ผ."]
|
704 |
+
]
|
705 |
+
|
706 |
+
# ๋ชจ๋ ์์ ๋ฅผ ํ ํ์ด์ง์ ํ์ํ๋๋ก ์์ ๋ ๋ถ๋ถ
|
707 |
+
gr.Examples(
|
708 |
+
examples=examples,
|
709 |
+
inputs=[image1_input, image2_input, image3_input, prompt_input],
|
710 |
+
examples_per_page=len(examples) # ๋ชจ๋ ์์ ๋ฅผ ํ ํ์ด์ง์ ํ์
|
711 |
+
)
|
712 |
+
|
713 |
+
# ========== ์ด๋ฏธ์ง ์์ฑ๊ธฐ ์ด๋ฒคํธ ์ฐ๊ฒฐ ==========
|
714 |
+
# ๋ฒํผ ์ด๋ฒคํธ ์ฐ๊ฒฐ - ํ๋กฌํํธ ํ
ํ๋ฆฟ
|
715 |
+
image_change_btn1.click(fn=get_prompt_template_1, outputs=prompt_input)
|
716 |
+
image_change_btn2.click(fn=get_prompt_template_2, outputs=prompt_input)
|
717 |
+
image_change_btn3.click(fn=get_prompt_template_3, outputs=prompt_input)
|
718 |
+
text_remove_btn.click(fn=get_prompt_template_4, outputs=prompt_input)
|
719 |
+
text_change_btn.click(fn=get_prompt_template_5, outputs=prompt_input)
|
720 |
+
clothes_change_btn1.click(fn=get_prompt_template_6, outputs=prompt_input)
|
721 |
+
clothes_change_btn2.click(fn=get_prompt_template_7, outputs=prompt_input)
|
722 |
+
holding_product_btn.click(fn=get_prompt_template_8, outputs=prompt_input)
|
723 |
+
background_change_btn.click(fn=get_prompt_template_9, outputs=prompt_input)
|
724 |
+
composite_product_btn.click(fn=get_prompt_template_10, outputs=prompt_input)
|
725 |
+
outpainting_btn.click(fn=get_prompt_template_11, outputs=prompt_input)
|
726 |
+
food_btn_1.click(fn=get_prompt_template_12, outputs=prompt_input)
|
727 |
+
food_btn_2.click(fn=get_prompt_template_13, outputs=prompt_input)
|
728 |
+
food_btn_3.click(fn=get_prompt_template_14, outputs=prompt_input)
|
729 |
+
|
730 |
+
# ๋จ์ผ ์ด๋ฏธ์ง ์์ฑ ๋ฒํผ ์ด๋ฒคํธ ์ฐ๊ฒฐ
|
731 |
+
submit_single_btn.click(
|
732 |
+
fn=generate_single_image,
|
733 |
+
inputs=[image1_input, image2_input, image3_input, prompt_input],
|
734 |
+
outputs=[output_image1, output_text, prompt_display],
|
735 |
+
)
|
736 |
+
|
737 |
+
# 2์ฅ ์ด๋ฏธ์ง ์์ฑ ๋ฒํผ ์ด๋ฒคํธ ์ฐ๊ฒฐ
|
738 |
+
submit_btn.click(
|
739 |
+
fn=generate_multiple_images,
|
740 |
+
inputs=[image1_input, image2_input, image3_input, prompt_input],
|
741 |
+
outputs=[output_image1, output_image2, output_text, prompt_display],
|
742 |
+
)
|
743 |
+
|
744 |
+
# ์ ํ๋ฆฌ์ผ์ด์
์คํ
|
745 |
+
demo.queue()
|
746 |
+
demo.launch(share=False, inbrowser=True, width="100%")
|