Update app.py
Browse files
app.py
CHANGED
@@ -144,7 +144,7 @@ def preprocess_prompt(prompt, image1, image2, image3):
|
|
144 |
elif "6. ์ด๋ฏธ์ง ํฉ์ฑ(์ํํฌํจ)" in prompt:
|
145 |
prompt = "์ฒซ ๋ฒ์งธ ์ด๋ฏธ์ง์ ๋ ๋ฒ์งธ ์ด๋ฏธ์ง(๋๋ ์ธ ๋ฒ์งธ ์ด๋ฏธ์ง)๋ฅผ ์์ฐ์ค๋ฝ๊ฒ ํฉ์ฑํด์ฃผ์ธ์. ๋ชจ๋ ์ด๋ฏธ์ง์ ์ฃผ์ ์์๋ฅผ ํฌํจํ๊ณ , ํนํ ์ํ์ด ๋๋ณด์ด๋๋ก ์กฐํ๋กญ๊ฒ ํตํฉํด์ฃผ์ธ์."
|
146 |
|
147 |
-
prompt += " ์ด๋ฏธ์ง๋ฅผ ์์ฑํด์ฃผ์ธ์."
|
148 |
return prompt
|
149 |
|
150 |
def generate_with_images(prompt, images, variation_index=0):
|
@@ -162,14 +162,16 @@ def generate_with_images(prompt, images, variation_index=0):
|
|
162 |
|
163 |
# ๋ณํ ์ธ๋ฑ์ค์ ๋ฐ๋ผ ํ๋กฌํํธ์ ์ฝ๊ฐ์ ๋ณํ ์ถ๊ฐ
|
164 |
variation_suffixes = [
|
165 |
-
"
|
166 |
-
"
|
167 |
-
"
|
168 |
-
"
|
169 |
]
|
170 |
|
171 |
if variation_index < len(variation_suffixes):
|
172 |
prompt = prompt + variation_suffixes[variation_index]
|
|
|
|
|
173 |
|
174 |
contents = [prompt]
|
175 |
for idx, img in enumerate(images, 1):
|
@@ -230,13 +232,13 @@ def process_images_with_prompt(image1, image2, image3, prompt, variation_index=0
|
|
230 |
final_prompt = processed_prompt
|
231 |
else:
|
232 |
if len(valid_images) == 1:
|
233 |
-
final_prompt = "Please creatively transform this image into a more vivid and artistic version."
|
234 |
logger.info("Default prompt generated for single image")
|
235 |
elif len(valid_images) == 2:
|
236 |
-
final_prompt = "Please seamlessly composite these two images, integrating their key elements harmoniously into a single image."
|
237 |
logger.info("Default prompt generated for two images")
|
238 |
else:
|
239 |
-
final_prompt = "Please creatively composite these three images, combining their main elements into a cohesive and natural scene."
|
240 |
logger.info("Default prompt generated for three images")
|
241 |
|
242 |
result_img, status = generate_with_images(final_prompt, valid_images, variation_index)
|
@@ -302,9 +304,9 @@ with gr.Blocks() as demo:
|
|
302 |
# ์ผ์ชฝ ์
๋ ฅ ์์ญ
|
303 |
with gr.Column(scale=1):
|
304 |
with gr.Row():
|
305 |
-
image1_input = gr.Image(type="pil", label="#1", image_mode="RGB", height=
|
306 |
-
image2_input = gr.Image(type="pil", label="#2", image_mode="RGB", height=
|
307 |
-
image3_input = gr.Image(type="pil", label="#3", image_mode="RGB", height=
|
308 |
prompt_input = gr.Textbox(
|
309 |
lines=3,
|
310 |
placeholder="ํ๋กฌํํธ๋ฅผ ์
๋ ฅํ๊ฑฐ๋ ๋น์๋๋ฉด ์๋ ํฉ์ฑ๋ฉ๋๋ค.",
|
@@ -322,11 +324,11 @@ with gr.Blocks() as demo:
|
|
322 |
with gr.Column(scale=1):
|
323 |
with gr.Row():
|
324 |
with gr.Column():
|
325 |
-
output_image1 = gr.Image(label="์์ฑ๋ ์ด๋ฏธ์ง #1", height=
|
326 |
-
output_image3 = gr.Image(label="์์ฑ๋ ์ด๋ฏธ์ง #3", height=
|
327 |
with gr.Column():
|
328 |
-
output_image2 = gr.Image(label="์์ฑ๋ ์ด๋ฏธ์ง #2", height=
|
329 |
-
output_image4 = gr.Image(label="์์ฑ๋ ์ด๋ฏธ์ง #4", height=
|
330 |
|
331 |
output_text = gr.Textbox(label="์ํ ๋ฉ์์ง", lines=4)
|
332 |
prompt_display = gr.Textbox(label="์ฌ์ฉ๋ ํ๋กฌํํธ (์์ด)", visible=True, lines=4)
|
|
|
144 |
elif "6. ์ด๋ฏธ์ง ํฉ์ฑ(์ํํฌํจ)" in prompt:
|
145 |
prompt = "์ฒซ ๋ฒ์งธ ์ด๋ฏธ์ง์ ๋ ๋ฒ์งธ ์ด๋ฏธ์ง(๋๋ ์ธ ๋ฒ์งธ ์ด๋ฏธ์ง)๋ฅผ ์์ฐ์ค๋ฝ๊ฒ ํฉ์ฑํด์ฃผ์ธ์. ๋ชจ๋ ์ด๋ฏธ์ง์ ์ฃผ์ ์์๋ฅผ ํฌํจํ๊ณ , ํนํ ์ํ์ด ๋๋ณด์ด๋๋ก ์กฐํ๋กญ๊ฒ ํตํฉํด์ฃผ์ธ์."
|
146 |
|
147 |
+
prompt += " ์ด๋ฏธ์ง๋ฅผ ์์ฑํด์ฃผ์ธ์. ์ด๋ฏธ์ง์ ํ
์คํธ๋ ๊ธ์๋ฅผ ํฌํจํ์ง ๋ง์ธ์."
|
148 |
return prompt
|
149 |
|
150 |
def generate_with_images(prompt, images, variation_index=0):
|
|
|
162 |
|
163 |
# ๋ณํ ์ธ๋ฑ์ค์ ๋ฐ๋ผ ํ๋กฌํํธ์ ์ฝ๊ฐ์ ๋ณํ ์ถ๊ฐ
|
164 |
variation_suffixes = [
|
165 |
+
" Create this as the first variation. Do not add any text, watermarks, or labels to the image.",
|
166 |
+
" Create this as the second variation with more vivid colors. Do not add any text, watermarks, or labels to the image.",
|
167 |
+
" Create this as the third variation with a more creative style. Do not add any text, watermarks, or labels to the image.",
|
168 |
+
" Create this as the fourth variation with enhanced details. Do not add any text, watermarks, or labels to the image."
|
169 |
]
|
170 |
|
171 |
if variation_index < len(variation_suffixes):
|
172 |
prompt = prompt + variation_suffixes[variation_index]
|
173 |
+
else:
|
174 |
+
prompt = prompt + " Do not add any text, watermarks, or labels to the image."
|
175 |
|
176 |
contents = [prompt]
|
177 |
for idx, img in enumerate(images, 1):
|
|
|
232 |
final_prompt = processed_prompt
|
233 |
else:
|
234 |
if len(valid_images) == 1:
|
235 |
+
final_prompt = "Please creatively transform this image into a more vivid and artistic version. Do not include any text or watermarks in the generated image."
|
236 |
logger.info("Default prompt generated for single image")
|
237 |
elif len(valid_images) == 2:
|
238 |
+
final_prompt = "Please seamlessly composite these two images, integrating their key elements harmoniously into a single image. Do not include any text or watermarks in the generated image."
|
239 |
logger.info("Default prompt generated for two images")
|
240 |
else:
|
241 |
+
final_prompt = "Please creatively composite these three images, combining their main elements into a cohesive and natural scene. Do not include any text or watermarks in the generated image."
|
242 |
logger.info("Default prompt generated for three images")
|
243 |
|
244 |
result_img, status = generate_with_images(final_prompt, valid_images, variation_index)
|
|
|
304 |
# ์ผ์ชฝ ์
๋ ฅ ์์ญ
|
305 |
with gr.Column(scale=1):
|
306 |
with gr.Row():
|
307 |
+
image1_input = gr.Image(type="pil", label="#1", image_mode="RGB", height=200, width=200)
|
308 |
+
image2_input = gr.Image(type="pil", label="#2", image_mode="RGB", height=200, width=200)
|
309 |
+
image3_input = gr.Image(type="pil", label="#3", image_mode="RGB", height=200, width=200)
|
310 |
prompt_input = gr.Textbox(
|
311 |
lines=3,
|
312 |
placeholder="ํ๋กฌํํธ๋ฅผ ์
๋ ฅํ๊ฑฐ๋ ๋น์๋๋ฉด ์๋ ํฉ์ฑ๋ฉ๋๋ค.",
|
|
|
324 |
with gr.Column(scale=1):
|
325 |
with gr.Row():
|
326 |
with gr.Column():
|
327 |
+
output_image1 = gr.Image(label="์์ฑ๋ ์ด๋ฏธ์ง #1", height=220, width=220)
|
328 |
+
output_image3 = gr.Image(label="์์ฑ๋ ์ด๋ฏธ์ง #3", height=220, width=220)
|
329 |
with gr.Column():
|
330 |
+
output_image2 = gr.Image(label="์์ฑ๋ ์ด๋ฏธ์ง #2", height=220, width=220)
|
331 |
+
output_image4 = gr.Image(label="์์ฑ๋ ์ด๋ฏธ์ง #4", height=220, width=220)
|
332 |
|
333 |
output_text = gr.Textbox(label="์ํ ๋ฉ์์ง", lines=4)
|
334 |
prompt_display = gr.Textbox(label="์ฌ์ฉ๋ ํ๋กฌํํธ (์์ด)", visible=True, lines=4)
|