Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ from PIL import Image
|
|
4 |
import gradio as gr
|
5 |
import logging
|
6 |
import re
|
|
|
7 |
|
8 |
from google import genai
|
9 |
from google.genai import types
|
@@ -87,6 +88,10 @@ def preprocess_prompt(prompt, image1, image2, image3):
|
|
87 |
elif "7. ์ด๋ฏธ์ง ํฉ์ฑ(์คํ์ผ์ ์ฉ)" in prompt:
|
88 |
prompt = "์ฒซ ๋ฒ์งธ ์ด๋ฏธ์ง์ ๋ด์ฉ์ ๋ ๋ฒ์งธ ์ด๋ฏธ์ง์ ์คํ์ผ๋ก ๋ณํํด์ฃผ์ธ์. ์ฒซ ๋ฒ์งธ ์ด๋ฏธ์ง์ ์ฃผ์ ํผ์ฌ์ฒด์ ๊ตฌ๋๋ ์ ์งํ๋, ๋ ๋ฒ์งธ ์ด๋ฏธ์ง์ ์์ ์ ์คํ์ผ, ์์, ์ง๊ฐ์ ์ ์ฉํด์ฃผ์ธ์."
|
89 |
|
|
|
|
|
|
|
|
|
90 |
# ์
๋ ฅ์ด ์ ๊ธฐ๋ฅ๋ค์ ํด๋นํ์ง ์๋ ๊ฒฝ์ฐ ์๋ณธ ํ๋กฌํํธ ์ ์ง
|
91 |
|
92 |
return prompt
|
@@ -131,27 +136,32 @@ def process_images_with_prompt(image1, image2, image3, prompt):
|
|
131 |
parts = []
|
132 |
|
133 |
# ํ
์คํธ ํ๋กฌํํธ ์ถ๊ฐ
|
134 |
-
parts.append(
|
|
|
|
|
135 |
|
136 |
# ์ฌ์ฉ ๊ฐ๋ฅํ ์ด๋ฏธ์ง ์ถ๊ฐ
|
137 |
for idx, img in enumerate(images, 1):
|
138 |
if img is not None:
|
139 |
# PIL ์ด๋ฏธ์ง๋ฅผ ๋ฐ์ดํธ๋ก ๋ณํ
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
with open(img_path, "rb") as f:
|
144 |
-
image_bytes = f.read()
|
145 |
|
146 |
-
# ์ด๋ฏธ์ง๋ฅผ ํํธ๋ก ์ถ๊ฐ
|
147 |
-
parts.append(
|
|
|
|
|
|
|
|
|
|
|
148 |
logger.info(f"์ด๋ฏธ์ง #{idx} ์ถ๊ฐ๋จ")
|
149 |
|
150 |
# ์์ฑ ์ค์
|
151 |
-
generate_content_config =
|
152 |
-
temperature
|
153 |
-
response_modalities
|
154 |
-
|
155 |
|
156 |
# ์์ ํ์ผ ์์ฑ
|
157 |
with tempfile.NamedTemporaryFile(suffix=".png", delete=False) as tmp:
|
@@ -159,14 +169,21 @@ def process_images_with_prompt(image1, image2, image3, prompt):
|
|
159 |
|
160 |
# Gemini ๋ชจ๋ธ๋ก ์์ฒญ ์ ์ก
|
161 |
logger.info(f"Gemini API ์์ฒญ ์์ - ํ๋กฌํํธ: {prompt}")
|
|
|
|
|
162 |
response = client.models.generate_content(
|
163 |
model="gemini-2.0-flash-exp-image-generation",
|
164 |
-
contents=[
|
165 |
-
|
|
|
|
|
|
|
166 |
)
|
167 |
|
168 |
# ์๋ต์์ ์ด๋ฏธ์ง ์ถ์ถ
|
169 |
image_found = False
|
|
|
|
|
170 |
for part in response.candidates[0].content.parts:
|
171 |
if hasattr(part, 'inline_data') and part.inline_data:
|
172 |
save_binary_file(temp_path, part.inline_data.data)
|
@@ -187,13 +204,27 @@ def process_images_with_prompt(image1, image2, image3, prompt):
|
|
187 |
logger.exception("์ด๋ฏธ์ง ์์ฑ ์ค ์ค๋ฅ ๋ฐ์:")
|
188 |
return None, f"์ค๋ฅ ๋ฐ์: {str(e)}"
|
189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
# Gradio ์ธํฐํ์ด์ค
|
191 |
with gr.Blocks() as demo:
|
192 |
gr.HTML(
|
193 |
"""
|
194 |
<div style="text-align: center; margin-bottom: 1rem;">
|
195 |
<h1>๊ฐ๋จํ ์ด๋ฏธ์ง ์์ฑ๊ธฐ</h1>
|
196 |
-
<p>์ด๋ฏธ์ง๋ฅผ ์
๋ก๋ํ๊ณ ๋ฐ๋ก ์คํํ๋ฉด ์๋์ผ๋ก ํฉ์ฑํฉ๋๋ค. ๋๋
|
197 |
</div>
|
198 |
"""
|
199 |
)
|
@@ -206,6 +237,28 @@ with gr.Blocks() as demo:
|
|
206 |
image2_input = gr.Image(type="pil", label="#2", image_mode="RGB")
|
207 |
image3_input = gr.Image(type="pil", label="#3", image_mode="RGB")
|
208 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
# ํ๋กฌํํธ ์
๋ ฅ (์ ํ ์ฌํญ)
|
210 |
prompt_input = gr.Textbox(
|
211 |
lines=3,
|
@@ -213,24 +266,6 @@ with gr.Blocks() as demo:
|
|
213 |
label="ํ๋กฌํํธ (์ ํ ์ฌํญ)"
|
214 |
)
|
215 |
|
216 |
-
# ๊ธฐ๋ฅ ๋ช
๋ น ์ค๋ช
|
217 |
-
gr.HTML(
|
218 |
-
"""
|
219 |
-
<div style="margin: 0.5rem 0; padding: 0.5rem; background-color: #f0f0f0; border-radius: 0.5rem;">
|
220 |
-
<h4>๊ธฐ๋ฅ ๋ช
๋ น ๋ชฉ๋ก:</h4>
|
221 |
-
<ol style="margin-left: 1.5rem;">
|
222 |
-
<li>์ด๋ฏธ์ง ๋ณ๊ฒฝ: <code>#1์ "์ค๋ช
ํด์ฃผ์ธ์"์ผ๋ก ๋ฐ๊ฟ๋ผ</code></li>
|
223 |
-
<li>๊ธ์์ง์ฐ๊ธฐ: <code>#1์์ "์ค๊ตญ์ด"๋ฅผ ์ง์๋ผ</code></li>
|
224 |
-
<li>์ผ๊ตด๋ฐ๊พธ๊ธฐ: <code>#1์ ์ธ๋ฌผ์ #2์ ์ผ๊ตด๋ก ๋ฐ๊ฟ๋ผ</code></li>
|
225 |
-
<li>์ท๋ฐ๊พธ๊ธฐ: <code>#1์ ์ธ๋ฌผ์ #2 ๋๋ #3์ ์ท์ผ๋ก ๋ณ๊ฒฝํ๋ผ</code></li>
|
226 |
-
<li>๋ฐฐ๊ฒฝ๋ฐ๊พธ๊ธฐ: <code>#1์ ์ด๋ฏธ์ง์ #2์ ๋ฐฐ๊ฒฝ์ผ๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ฐ๊ฟ๋ผ</code></li>
|
227 |
-
<li>์ด๋ฏธ์ง ํฉ์ฑ(์ํํฌํจ): <code>#1์ #2 ๋๋ #3์ ๋ฅผ ํฉ์ฑํ๋ผ</code></li>
|
228 |
-
<li>์ด๋ฏธ์ง ํฉ์ฑ(์คํ์ผ์ ์ฉ): <code>#1์ #2๋ฅผ ์คํ์ผ๋ก ๋ณํํ๋ผ</code></li>
|
229 |
-
</ol>
|
230 |
-
</div>
|
231 |
-
"""
|
232 |
-
)
|
233 |
-
|
234 |
# ์์ฑ ๋ฒํผ
|
235 |
submit_btn = gr.Button("์ด๋ฏธ์ง ์์ฑ", variant="primary")
|
236 |
|
@@ -242,28 +277,39 @@ with gr.Blocks() as demo:
|
|
242 |
# ์ฌ์ฉ๋ ํ๋กฌํํธ ํ์
|
243 |
prompt_display = gr.Textbox(label="์ฌ์ฉ๋ ํ๋กฌํํธ", visible=True)
|
244 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
# ์ด๋ฏธ์ง ์์ฑ ๋ฒํผ ํด๋ฆญ ์ด๋ฒคํธ
|
246 |
def process_and_show_prompt(image1, image2, image3, prompt):
|
247 |
# ์ด๋ฏธ์ง ๊ฐ์ ํ์ธ
|
248 |
images = [image1, image2, image3]
|
249 |
valid_images = [img for img in images if img is not None]
|
250 |
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
if
|
255 |
-
|
256 |
-
|
257 |
-
|
|
|
|
|
|
|
258 |
else:
|
259 |
-
auto_prompt =
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
|
|
267 |
|
268 |
submit_btn.click(
|
269 |
fn=process_and_show_prompt,
|
@@ -271,17 +317,17 @@ with gr.Blocks() as demo:
|
|
271 |
outputs=[output_image, output_text, prompt_display],
|
272 |
)
|
273 |
|
274 |
-
gr.
|
275 |
"""
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
"""
|
286 |
)
|
287 |
|
|
|
4 |
import gradio as gr
|
5 |
import logging
|
6 |
import re
|
7 |
+
import io
|
8 |
|
9 |
from google import genai
|
10 |
from google.genai import types
|
|
|
88 |
elif "7. ์ด๋ฏธ์ง ํฉ์ฑ(์คํ์ผ์ ์ฉ)" in prompt:
|
89 |
prompt = "์ฒซ ๋ฒ์งธ ์ด๋ฏธ์ง์ ๋ด์ฉ์ ๋ ๋ฒ์งธ ์ด๋ฏธ์ง์ ์คํ์ผ๋ก ๋ณํํด์ฃผ์ธ์. ์ฒซ ๋ฒ์งธ ์ด๋ฏธ์ง์ ์ฃผ์ ํผ์ฌ์ฒด์ ๊ตฌ๋๋ ์ ์งํ๋, ๋ ๋ฒ์งธ ์ด๋ฏธ์ง์ ์์ ์ ์คํ์ผ, ์์, ์ง๊ฐ์ ์ ์ฉํด์ฃผ์ธ์."
|
90 |
|
91 |
+
# ๊ฐ๋จํ ์์ ๋ณ๊ฒฝ ์์ฒญ ์ฒ๋ฆฌ
|
92 |
+
elif "์ ๋ถ์์์ผ๋ก ๋ฐ๊ฟ๋ผ" in prompt or "๋ฅผ ๋ถ์์์ผ๋ก ๋ฐ๊ฟ๋ผ" in prompt:
|
93 |
+
prompt = "์ฒซ ๋ฒ์งธ ์ด๋ฏธ์ง๋ฅผ ๋ถ์์ ํค์ผ๋ก ๋ณ๊ฒฝํด์ฃผ์ธ์. ์ ์ฒด์ ์ธ ์์์ ๋ถ์ ๊ณ์ด๋ก ์กฐ์ ํ๊ณ ์์ฐ์ค๋ฌ์ด ๋๋์ ์ ์งํด์ฃผ์ธ์."
|
94 |
+
|
95 |
# ์
๋ ฅ์ด ์ ๊ธฐ๋ฅ๋ค์ ํด๋นํ์ง ์๋ ๊ฒฝ์ฐ ์๋ณธ ํ๋กฌํํธ ์ ์ง
|
96 |
|
97 |
return prompt
|
|
|
136 |
parts = []
|
137 |
|
138 |
# ํ
์คํธ ํ๋กฌํํธ ์ถ๊ฐ
|
139 |
+
parts.append({
|
140 |
+
"text": prompt
|
141 |
+
})
|
142 |
|
143 |
# ์ฌ์ฉ ๊ฐ๋ฅํ ์ด๋ฏธ์ง ์ถ๊ฐ
|
144 |
for idx, img in enumerate(images, 1):
|
145 |
if img is not None:
|
146 |
# PIL ์ด๋ฏธ์ง๋ฅผ ๋ฐ์ดํธ๋ก ๋ณํ
|
147 |
+
img_byte_arr = io.BytesIO()
|
148 |
+
img.save(img_byte_arr, format='PNG')
|
149 |
+
img_bytes = img_byte_arr.getvalue()
|
|
|
|
|
150 |
|
151 |
+
# ์ด๋ฏธ์ง๋ฅผ ํํธ๋ก ์ถ๊ฐ (genai.types.Part ๋์ ์ง์ ๋์
๋๋ฆฌ ์ฌ์ฉ)
|
152 |
+
parts.append({
|
153 |
+
"inline_data": {
|
154 |
+
"mime_type": "image/png",
|
155 |
+
"data": img_bytes
|
156 |
+
}
|
157 |
+
})
|
158 |
logger.info(f"์ด๋ฏธ์ง #{idx} ์ถ๊ฐ๋จ")
|
159 |
|
160 |
# ์์ฑ ์ค์
|
161 |
+
generate_content_config = {
|
162 |
+
"temperature": 1.0,
|
163 |
+
"response_modalities": ["image"]
|
164 |
+
}
|
165 |
|
166 |
# ์์ ํ์ผ ์์ฑ
|
167 |
with tempfile.NamedTemporaryFile(suffix=".png", delete=False) as tmp:
|
|
|
169 |
|
170 |
# Gemini ๋ชจ๋ธ๋ก ์์ฒญ ์ ์ก
|
171 |
logger.info(f"Gemini API ์์ฒญ ์์ - ํ๋กฌํํธ: {prompt}")
|
172 |
+
|
173 |
+
# API ์์ฒญ ํ์ ์์
|
174 |
response = client.models.generate_content(
|
175 |
model="gemini-2.0-flash-exp-image-generation",
|
176 |
+
contents=[{
|
177 |
+
"role": "user",
|
178 |
+
"parts": parts
|
179 |
+
}],
|
180 |
+
generation_config=generate_content_config
|
181 |
)
|
182 |
|
183 |
# ์๋ต์์ ์ด๋ฏธ์ง ์ถ์ถ
|
184 |
image_found = False
|
185 |
+
|
186 |
+
# ์๋ต ๊ตฌ์กฐ ์ฒ๋ฆฌ
|
187 |
for part in response.candidates[0].content.parts:
|
188 |
if hasattr(part, 'inline_data') and part.inline_data:
|
189 |
save_binary_file(temp_path, part.inline_data.data)
|
|
|
204 |
logger.exception("์ด๋ฏธ์ง ์์ฑ ์ค ์ค๋ฅ ๋ฐ์:")
|
205 |
return None, f"์ค๋ฅ ๋ฐ์: {str(e)}"
|
206 |
|
207 |
+
# ๊ธฐ๋ฅ ์ ํ ์ฝ๋ฐฑ
|
208 |
+
def update_prompt_from_function(function_choice, custom_text=""):
|
209 |
+
function_templates = {
|
210 |
+
"1. ์ด๋ฏธ์ง ๋ณ๊ฒฝ": f'#1์ "{custom_text if custom_text else "์ํ๋ ์ค๋ช
"}"์ผ๋ก ๋ฐ๊ฟ๋ผ',
|
211 |
+
"2. ๊ธ์์ง์ฐ๊ธฐ": f'#1์์ "{custom_text if custom_text else "์ง์ธ ํ
์คํธ"}"๋ฅผ ์ง์๋ผ',
|
212 |
+
"3. ์ผ๊ตด๋ฐ๊พธ๊ธฐ": "#1์ ์ธ๋ฌผ์ #2์ ์ผ๊ตด๋ก ๋ฐ๊ฟ๋ผ",
|
213 |
+
"4. ์ท๋ฐ๊พธ๊ธฐ": "#1์ ์ธ๋ฌผ์ #2 ๋๋ #3์ ์ท์ผ๋ก ๋ณ๊ฒฝํ๋ผ",
|
214 |
+
"5. ๋ฐฐ๊ฒฝ๋ฐ๊พธ๊ธฐ": "#1์ ์ด๋ฏธ์ง์ #2์ ๋ฐฐ๊ฒฝ์ผ๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ฐ๊ฟ๋ผ",
|
215 |
+
"6. ์ด๋ฏธ์ง ํฉ์ฑ(์ํํฌํจ)": "#1์ #2 ๋๋ #3์ ๋ฅผ ํฉ์ฑํ๋ผ",
|
216 |
+
"7. ์ด๋ฏธ์ง ํฉ์ฑ(์คํ์ผ์ ์ฉ)": "#1์ #2๋ฅผ ์คํ์ผ๋ก ๋ณํํ๋ผ"
|
217 |
+
}
|
218 |
+
|
219 |
+
return function_templates.get(function_choice, "")
|
220 |
+
|
221 |
# Gradio ์ธํฐํ์ด์ค
|
222 |
with gr.Blocks() as demo:
|
223 |
gr.HTML(
|
224 |
"""
|
225 |
<div style="text-align: center; margin-bottom: 1rem;">
|
226 |
<h1>๊ฐ๋จํ ์ด๋ฏธ์ง ์์ฑ๊ธฐ</h1>
|
227 |
+
<p>์ด๋ฏธ์ง๋ฅผ ์
๋ก๋ํ๊ณ ๋ฐ๋ก ์คํํ๋ฉด ์๋์ผ๋ก ํฉ์ฑํฉ๋๋ค. ๋๋ ์๋ ๊ธฐ๋ฅ์ ์ ํํ ์ ์์ต๋๋ค.</p>
|
228 |
</div>
|
229 |
"""
|
230 |
)
|
|
|
237 |
image2_input = gr.Image(type="pil", label="#2", image_mode="RGB")
|
238 |
image3_input = gr.Image(type="pil", label="#3", image_mode="RGB")
|
239 |
|
240 |
+
# ๊ธฐ๋ฅ ์ ํ ๋๋กญ๋ค์ด๊ณผ ์ปค์คํ
ํ
์คํธ ์
๋ ฅ
|
241 |
+
with gr.Row():
|
242 |
+
function_dropdown = gr.Dropdown(
|
243 |
+
choices=[
|
244 |
+
"1. ์ด๋ฏธ์ง ๋ณ๊ฒฝ",
|
245 |
+
"2. ๊ธ์์ง์ฐ๊ธฐ",
|
246 |
+
"3. ์ผ๊ตด๋ฐ๊พธ๊ธฐ",
|
247 |
+
"4. ์ท๋ฐ๊พธ๊ธฐ",
|
248 |
+
"5. ๋ฐฐ๊ฒฝ๋ฐ๊พธ๊ธฐ",
|
249 |
+
"6. ์ด๋ฏธ์ง ํฉ์ฑ(์ํํฌํจ)",
|
250 |
+
"7. ์ด๋ฏธ์ง ํฉ์ฑ(์คํ์ผ์ ์ฉ)"
|
251 |
+
],
|
252 |
+
label="๊ธฐ๋ฅ ์ ํ",
|
253 |
+
value=None
|
254 |
+
)
|
255 |
+
custom_text_input = gr.Textbox(
|
256 |
+
label="์ปค์คํ
ํ
์คํธ (1, 2๋ฒ ๊ธฐ๋ฅ์ฉ)",
|
257 |
+
placeholder="์: ๋ถ์์, ์์ฑํ ์คํ์ผ, ์ค๊ตญ์ด..."
|
258 |
+
)
|
259 |
+
|
260 |
+
apply_function_btn = gr.Button("๊ธฐ๋ฅ ์ ์ฉ")
|
261 |
+
|
262 |
# ํ๋กฌํํธ ์
๋ ฅ (์ ํ ์ฌํญ)
|
263 |
prompt_input = gr.Textbox(
|
264 |
lines=3,
|
|
|
266 |
label="ํ๋กฌํํธ (์ ํ ์ฌํญ)"
|
267 |
)
|
268 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
# ์์ฑ ๋ฒํผ
|
270 |
submit_btn = gr.Button("์ด๋ฏธ์ง ์์ฑ", variant="primary")
|
271 |
|
|
|
277 |
# ์ฌ์ฉ๋ ํ๋กฌํํธ ํ์
|
278 |
prompt_display = gr.Textbox(label="์ฌ์ฉ๋ ํ๋กฌํํธ", visible=True)
|
279 |
|
280 |
+
# ๊ธฐ๋ฅ ์ ์ฉ ๋ฒํผ ์ด๋ฒคํธ
|
281 |
+
apply_function_btn.click(
|
282 |
+
fn=update_prompt_from_function,
|
283 |
+
inputs=[function_dropdown, custom_text_input],
|
284 |
+
outputs=[prompt_input]
|
285 |
+
)
|
286 |
+
|
287 |
# ์ด๋ฏธ์ง ์์ฑ ๋ฒํผ ํด๋ฆญ ์ด๋ฒคํธ
|
288 |
def process_and_show_prompt(image1, image2, image3, prompt):
|
289 |
# ์ด๋ฏธ์ง ๊ฐ์ ํ์ธ
|
290 |
images = [image1, image2, image3]
|
291 |
valid_images = [img for img in images if img is not None]
|
292 |
|
293 |
+
try:
|
294 |
+
# ์๋ ํ๋กฌํํธ ์์ฑ ๋๋ ํ๋กฌํํธ ์ ์ฒ๋ฆฌ
|
295 |
+
auto_prompt = prompt
|
296 |
+
if not prompt or not prompt.strip():
|
297 |
+
if len(valid_images) == 1:
|
298 |
+
auto_prompt = "์ด ์ด๋ฏธ์ง๋ฅผ ์ฐฝ์์ ์ผ๋ก ๋ณํํด์ฃผ์ธ์. ๋ ์์ํ๊ณ ์์ ์ ์ธ ๋ฒ์ ์ผ๋ก ๋ง๋ค์ด์ฃผ์ธ์."
|
299 |
+
elif len(valid_images) == 2:
|
300 |
+
auto_prompt = "์ด ๋ ์ด๋ฏธ์ง๋ฅผ ์์ฐ์ค๋ฝ๊ฒ ํฉ์ฑํด์ฃผ์ธ์. ๋ ์ด๋ฏธ์ง์ ์์๋ฅผ ์กฐํ๋กญ๊ฒ ํตํฉํ์ฌ ํ๋์ ์ด๋ฏธ์ง๋ก ๋ง๋ค์ด์ฃผ์ธ์."
|
301 |
+
else:
|
302 |
+
auto_prompt = "์ด ์ธ ์ด๋ฏธ์ง๋ฅผ ์ฐฝ์์ ์ผ๋ก ํฉ์ฑํด์ฃผ์ธ์. ๋ชจ๋ ์ด๋ฏธ์ง์ ์ฃผ์ ๏ฟฝ๏ฟฝ์๋ฅผ ํฌํจํ๋ ์์ฐ์ค๋ฝ๊ณ ์ผ๊ด๋ ํ๋์ ์ฅ๋ฉด์ผ๋ก ๋ง๋ค์ด์ฃผ์ธ์."
|
303 |
else:
|
304 |
+
auto_prompt = preprocess_prompt(prompt, image1, image2, image3)
|
305 |
+
|
306 |
+
# ์ด๋ฏธ์ง ์์ฑ ํจ์ ํธ์ถ
|
307 |
+
result_img, status = process_images_with_prompt(image1, image2, image3, prompt)
|
308 |
+
|
309 |
+
return result_img, status, auto_prompt
|
310 |
+
except Exception as e:
|
311 |
+
logger.exception("์ฒ๋ฆฌ ์ค ์ค๋ฅ ๋ฐ์:")
|
312 |
+
return None, f"์ค๋ฅ ๋ฐ์: {str(e)}", prompt
|
313 |
|
314 |
submit_btn.click(
|
315 |
fn=process_and_show_prompt,
|
|
|
317 |
outputs=[output_image, output_text, prompt_display],
|
318 |
)
|
319 |
|
320 |
+
gr.Markdown(
|
321 |
"""
|
322 |
+
### ์ฌ์ฉ ๋ฐฉ๋ฒ:
|
323 |
+
|
324 |
+
1. **์๋ ํฉ์ฑ**: ์ด๋ฏธ์ง๋ง ์
๋ก๋ํ๊ณ ํ๋กฌํํธ๋ฅผ ๋น์๋๋ฉด ์๋์ผ๋ก ํฉ์ฑ๋ฉ๋๋ค
|
325 |
+
2. **๊ธฐ๋ฅ ์ฌ์ฉ**: ๋๋กญ๋ค์ด์์ ์ํ๋ ๊ธฐ๋ฅ์ ์ ํํ๊ณ '๊ธฐ๋ฅ ์ ์ฉ' ๋ฒํผ์ ํด๋ฆญํ์ธ์
|
326 |
+
3. **์ปค์คํ
ํ
์คํธ**: ์ด๋ฏธ์ง ๋ณ๊ฒฝ์ด๋ ๊ธ์์ง์ฐ๊ธฐ ๊ธฐ๋ฅ์ ์ ํํ ๋ ์ถ๊ฐ ์ค๋ช
์ ์
๋ ฅํ ์ ์์ต๋๋ค
|
327 |
+
4. **์ด๋ฏธ์ง ์ฐธ์กฐ**: #1, #2, #3์ผ๋ก ๊ฐ ์ด๋ฏธ์ง๋ฅผ ์ฐธ์กฐํ ์ ์์ต๋๋ค
|
328 |
+
5. **์ผ๋ถ ์ด๋ฏธ์ง๋ง**: ํ์ํ ์ด๋ฏธ์ง๋ง ์
๋ก๋ํด๋ ๊ธฐ๋ฅ ์คํ์ด ๊ฐ๋ฅํฉ๋๋ค
|
329 |
+
|
330 |
+
> **ํ**: ๊ธฐ๋ฅ์ ์ ํํ ํ์๋ ํ๋กฌํํธ๋ฅผ ์ง์ ์์ ํ ์ ์์ต๋๋ค
|
331 |
"""
|
332 |
)
|
333 |
|