Update app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,7 @@ from google.genai import types
|
|
11 |
from dotenv import load_dotenv
|
12 |
load_dotenv()
|
13 |
|
|
|
14 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
15 |
logger = logging.getLogger(__name__)
|
16 |
|
@@ -19,11 +20,7 @@ def save_binary_file(file_name, data):
|
|
19 |
f.write(data)
|
20 |
|
21 |
def translate_prompt_to_english(prompt):
|
22 |
-
|
23 |
-
์
๋ ฅ๋ ํ๋กฌํํธ์ ํ๊ธ์ด ํฌํจ๋์ด ์์ผ๋ฉด Geminiโ2.0โflash ๋ชจ๋ธ์ ์ฌ์ฉํ์ฌ ์์ด๋ก ๋ฒ์ญํฉ๋๋ค.
|
24 |
-
ํ๊ธ์ด ์์ผ๋ฉด ์๋ณธ ํ๋กฌํํธ๋ฅผ ๊ทธ๋๋ก ๋ฐํํฉ๋๋ค.
|
25 |
-
์ค์: #1, #2, #3 ํ๊ทธ๋ ๋ฒ์ญ ์ ํ์ ๋ฐ๋์ ๋ณด์กด๋์ด์ผ ํฉ๋๋ค.
|
26 |
-
"""
|
27 |
if not re.search("[๊ฐ-ํฃ]", prompt):
|
28 |
return prompt
|
29 |
|
@@ -88,9 +85,7 @@ def translate_prompt_to_english(prompt):
|
|
88 |
return prompt
|
89 |
|
90 |
def preprocess_prompt(prompt, image1, image2, image3):
|
91 |
-
|
92 |
-
ํ๋กฌํํธ๋ฅผ ์ฒ๋ฆฌํ๊ณ ๊ธฐ๋ฅ ๋ช
๋ น์ ํด์
|
93 |
-
"""
|
94 |
has_img1 = image1 is not None
|
95 |
has_img2 = image2 is not None
|
96 |
has_img3 = image3 is not None
|
@@ -139,10 +134,7 @@ def preprocess_prompt(prompt, image1, image2, image3):
|
|
139 |
return prompt
|
140 |
|
141 |
def generate_with_images(prompt, images, variation_index=0):
|
142 |
-
|
143 |
-
API ํธ์ถ์ ํตํด ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๊ณ ๊ฒฐ๊ณผ ์ด๋ฏธ์ง๋ฅผ ๋ฐํํฉ๋๋ค.
|
144 |
-
variation_index๋ก ๋ค์ํ ๋ณํ๋ฅผ ์ค๋๋ค.
|
145 |
-
"""
|
146 |
try:
|
147 |
api_key = os.environ.get("GEMINI_API_KEY")
|
148 |
if not api_key:
|
@@ -204,10 +196,7 @@ def generate_with_images(prompt, images, variation_index=0):
|
|
204 |
return None, f"์ค๋ฅ ๋ฐ์: {str(e)}"
|
205 |
|
206 |
def process_images_with_prompt(image1, image2, image3, prompt, variation_index=0, max_retries=3):
|
207 |
-
|
208 |
-
3๊ฐ์ ์ด๋ฏธ์ง์ ํ๋กฌํํธ๋ฅผ ์ฒ๋ฆฌํ์ฌ ์ต์ข
์์ด ํ๋กฌํํธ(final_prompt)๋ฅผ ์์ฑํ ํ,
|
209 |
-
API๋ฅผ ํธ์ถํ์ฌ ๊ฒฐ๊ณผ ์ด๋ฏธ์ง๋ฅผ ๋ฐํํฉ๋๋ค. ์๋ฌ ๋ฐ์ ์ ์ต๋ max_retries ํ์๋งํผ ์ฌ์๋ํฉ๋๋ค.
|
210 |
-
"""
|
211 |
retry_count = 0
|
212 |
last_error = None
|
213 |
|
@@ -252,9 +241,7 @@ def process_images_with_prompt(image1, image2, image3, prompt, variation_index=0
|
|
252 |
return None, f"์ต๋ ์ฌ์๋ ํ์({max_retries}ํ) ์ด๊ณผ ํ ์คํจ: {last_error}", prompt
|
253 |
|
254 |
def generate_multiple_images(image1, image2, image3, prompt, progress=gr.Progress()):
|
255 |
-
|
256 |
-
์ฌ๋ฌ ๊ฐ์ ์ด๋ฏธ์ง๋ฅผ ์ฐจ๋ก๋๋ก ์์ฑํฉ๋๋ค.
|
257 |
-
"""
|
258 |
results = []
|
259 |
statuses = []
|
260 |
prompts = []
|
@@ -289,12 +276,7 @@ def generate_multiple_images(image1, image2, image3, prompt, progress=gr.Progres
|
|
289 |
|
290 |
return results[0], results[1], results[2], results[3], combined_status, combined_prompts
|
291 |
|
292 |
-
#
|
293 |
-
# ์๋๋ GFPGAN ์ฐธ์กฐ์ฝ๋๋ฅผ ํญ์ผ๋ก ์ถ๊ฐํ ๋ถ๋ถ (๊ธฐ๋ฅ ๊ตฌํ ๋ฐ UI ๊ฐ์ )
|
294 |
-
# ๊ธฐ์กด GFPGAN ๊ด๋ จ ์ฝ๋์์ version๊ณผ Rescaling factor ๊ด๋ จ UI๋ ์ ๊ฑฐํ๊ณ ,
|
295 |
-
# GFPGANv1.4๋ฅผ ๊ณ ์ ์ผ๋ก ์ฌ์ฉํฉ๋๋ค.
|
296 |
-
# =====================================================================
|
297 |
-
|
298 |
import sys
|
299 |
from torchvision.transforms import functional
|
300 |
sys.modules["torchvision.transforms.functional_tensor"] = functional
|
@@ -306,7 +288,7 @@ from realesrgan.utils import RealESRGANer
|
|
306 |
import torch
|
307 |
import cv2
|
308 |
|
309 |
-
# ํ์ํ ๋ชจ๋ธ ๋ค์ด๋ก๋
|
310 |
if not os.path.exists('realesr-general-x4v3.pth'):
|
311 |
os.system("wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-x4v3.pth -P .")
|
312 |
if not os.path.exists('GFPGANv1.4.pth'):
|
@@ -361,153 +343,560 @@ def upscaler(img, version, scale):
|
|
361 |
print('์ ์ฒด ์์ธ ๋ฐ์:', error)
|
362 |
return None
|
363 |
|
364 |
-
# GFPGAN ์
์ค์ผ์ผ๋ฌ ํจ์ (๋ฒ์ ๊ณผ ์ค์ผ์ผ์ ๊ณ ์ )
|
365 |
def upscaler_korean(img):
|
366 |
return upscaler(img, "GFPGANv1.4", 2)
|
367 |
|
368 |
-
#
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
380 |
</div>
|
381 |
-
|
382 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
383 |
|
384 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
385 |
with gr.Column(scale=1):
|
386 |
-
with gr.
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
placeholder="ํ๋กฌํํธ๋ฅผ ์
๋ ฅํ๊ฑฐ๋ ๋น์๋๋ฉด ์๋ ํฉ์ฑ๋ฉ๋๋ค.",
|
393 |
-
label="ํ๋กฌํํธ (์ ํ ์ฌํญ)"
|
394 |
-
)
|
395 |
-
with gr.Row():
|
396 |
-
image_change_btn1 = gr.Button("์ด๋ฏธ์ง ๋ณ๊ฒฝ-1")
|
397 |
-
image_change_btn2 = gr.Button("์ด๋ฏธ์ง ๋ณ๊ฒฝ-2")
|
398 |
-
text_remove_btn = gr.Button("๊ธ์ ์ง์ฐ๊ธฐ")
|
399 |
-
text_change_btn = gr.Button("๊ธ์ ๋ณ๊ฒฝํ๊ธฐ")
|
400 |
-
clothes_change_btn1 = gr.Button("๊ฐ์ ์ํ์ฐฉ์ฉ-1")
|
401 |
-
clothes_change_btn2 = gr.Button("๊ฐ์ ์ํ์ฐฉ์ฉ-2")
|
402 |
-
holding_product_btn = gr.Button("์ํ๋ค๊ณ ์๊ธฐ")
|
403 |
-
background_change_btn = gr.Button("๋ฐฐ๊ฒฝ ๋ฐ๊พธ๊ธฐ")
|
404 |
-
composite_product_btn = gr.Button("๋ถ๋ถ ์ง์ฐ๊ธฐ")
|
405 |
-
submit_btn = gr.Button("์ด๋ฏธ์ง ์์ฑ (4์ฅ)", variant="primary")
|
406 |
-
|
407 |
-
gr.Markdown(
|
408 |
-
"""
|
409 |
-
### ์ฌ์ฉ ๋ฐฉ๋ฒ:
|
410 |
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
|
|
|
|
416 |
|
417 |
-
|
418 |
-
""
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
["down/์์ด๋ ๊ณ ๋ชจํ.png", None, None, "(#1์ ๋ ๊ณ ๋ชจํ)์์ ์ฒญ์์์ด๋ ๊ณ ๋ฅผ ์ ๊ฑฐํ ํ, ๊ทธ ์๋ฆฌ๋ฅผ ์ฃผ๋ณ ๋ฐฐ๊ฒฝ๊ณผ ์์ฐ์ค๋ฝ๊ฒ ์ด์ฐ๋ฌ์ง๋๋ก ์ฑ์์ฃผ์ธ์. ๋จ, ์ด๋ฏธ์ง์ ๋ค๋ฅธ ๋ถ๋ถ์ ์ฃผ์ ์์๋ ๋์ผํ๊ฒ ์ ์งํด ํด์ผํ๋ค."]
|
432 |
-
]
|
433 |
-
|
434 |
-
gr.Examples(
|
435 |
-
examples=examples,
|
436 |
-
inputs=[image1_input, image2_input, image3_input, prompt_input],
|
437 |
-
elem_id="examples-grid"
|
438 |
-
)
|
439 |
-
|
440 |
with gr.Column(scale=1):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
441 |
with gr.Row():
|
442 |
with gr.Column():
|
443 |
-
|
444 |
-
|
|
|
445 |
with gr.Column():
|
446 |
-
|
447 |
-
|
448 |
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
demo.queue()
|
513 |
-
demo.launch()
|
|
|
11 |
from dotenv import load_dotenv
|
12 |
load_dotenv()
|
13 |
|
14 |
+
# ๊ธฐ์กด ์ฝ๋ ์ ์ง (๋ก๊น
, ํจ์ ๋ฑ ๋ชจ๋ ๊ธฐ๋ฅ ์ฝ๋)
|
15 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
16 |
logger = logging.getLogger(__name__)
|
17 |
|
|
|
20 |
f.write(data)
|
21 |
|
22 |
def translate_prompt_to_english(prompt):
|
23 |
+
# ๊ธฐ์กด ํจ์ ์ ์ง
|
|
|
|
|
|
|
|
|
24 |
if not re.search("[๊ฐ-ํฃ]", prompt):
|
25 |
return prompt
|
26 |
|
|
|
85 |
return prompt
|
86 |
|
87 |
def preprocess_prompt(prompt, image1, image2, image3):
|
88 |
+
# ๊ธฐ์กด ํจ์ ์ ์ง
|
|
|
|
|
89 |
has_img1 = image1 is not None
|
90 |
has_img2 = image2 is not None
|
91 |
has_img3 = image3 is not None
|
|
|
134 |
return prompt
|
135 |
|
136 |
def generate_with_images(prompt, images, variation_index=0):
|
137 |
+
# ๊ธฐ์กด ํจ์ ์ ์ง
|
|
|
|
|
|
|
138 |
try:
|
139 |
api_key = os.environ.get("GEMINI_API_KEY")
|
140 |
if not api_key:
|
|
|
196 |
return None, f"์ค๋ฅ ๋ฐ์: {str(e)}"
|
197 |
|
198 |
def process_images_with_prompt(image1, image2, image3, prompt, variation_index=0, max_retries=3):
|
199 |
+
# ๊ธฐ์กด ํจ์ ์ ์ง
|
|
|
|
|
|
|
200 |
retry_count = 0
|
201 |
last_error = None
|
202 |
|
|
|
241 |
return None, f"์ต๋ ์ฌ์๋ ํ์({max_retries}ํ) ์ด๊ณผ ํ ์คํจ: {last_error}", prompt
|
242 |
|
243 |
def generate_multiple_images(image1, image2, image3, prompt, progress=gr.Progress()):
|
244 |
+
# ๊ธฐ์กด ํจ์ ์ ์ง
|
|
|
|
|
245 |
results = []
|
246 |
statuses = []
|
247 |
prompts = []
|
|
|
276 |
|
277 |
return results[0], results[1], results[2], results[3], combined_status, combined_prompts
|
278 |
|
279 |
+
# GFPGAN ๊ด๋ จ ์ฝ๋ ์ ์ง
|
|
|
|
|
|
|
|
|
|
|
280 |
import sys
|
281 |
from torchvision.transforms import functional
|
282 |
sys.modules["torchvision.transforms.functional_tensor"] = functional
|
|
|
288 |
import torch
|
289 |
import cv2
|
290 |
|
291 |
+
# ํ์ํ ๋ชจ๋ธ ๋ค์ด๋ก๋
|
292 |
if not os.path.exists('realesr-general-x4v3.pth'):
|
293 |
os.system("wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-x4v3.pth -P .")
|
294 |
if not os.path.exists('GFPGANv1.4.pth'):
|
|
|
343 |
print('์ ์ฒด ์์ธ ๋ฐ์:', error)
|
344 |
return None
|
345 |
|
|
|
346 |
def upscaler_korean(img):
|
347 |
return upscaler(img, "GFPGANv1.4", 2)
|
348 |
|
349 |
+
# ์ปค์คํ
CSS ์คํ์ผ
|
350 |
+
custom_css = """
|
351 |
+
:root {
|
352 |
+
--primary-color: #5561e9;
|
353 |
+
--secondary-color: #6c8aff;
|
354 |
+
--accent-color: #ff6b6b;
|
355 |
+
--background-color: #f0f5ff;
|
356 |
+
--card-bg: #ffffff;
|
357 |
+
--text-color: #334155;
|
358 |
+
--border-radius: 18px;
|
359 |
+
--shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
|
360 |
+
}
|
361 |
+
|
362 |
+
body {
|
363 |
+
font-family: 'Pretendard', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
|
364 |
+
background-color: var(--background-color);
|
365 |
+
color: var(--text-color);
|
366 |
+
line-height: 1.6;
|
367 |
+
}
|
368 |
+
|
369 |
+
/* Gradio ์ปจํ
์ด๋ ์ค๋ฒ๋ผ์ด๋ */
|
370 |
+
.gradio-container {
|
371 |
+
max-width: 100% !important;
|
372 |
+
margin: 0 auto !important;
|
373 |
+
padding: 0 !important;
|
374 |
+
background-color: var(--background-color) !important;
|
375 |
+
}
|
376 |
+
|
377 |
+
/* ์๋จ ํค๋ */
|
378 |
+
.app-header {
|
379 |
+
background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
|
380 |
+
color: white;
|
381 |
+
padding: 2rem;
|
382 |
+
border-radius: var(--border-radius);
|
383 |
+
margin-bottom: 1.5rem;
|
384 |
+
box-shadow: var(--shadow);
|
385 |
+
text-align: center;
|
386 |
+
}
|
387 |
+
|
388 |
+
.app-header h1 {
|
389 |
+
margin: 0;
|
390 |
+
font-size: 2.5rem;
|
391 |
+
font-weight: 700;
|
392 |
+
letter-spacing: -0.5px;
|
393 |
+
}
|
394 |
+
|
395 |
+
.app-header p {
|
396 |
+
margin: 0.75rem 0 0;
|
397 |
+
font-size: 1.1rem;
|
398 |
+
opacity: 0.9;
|
399 |
+
}
|
400 |
+
|
401 |
+
/* ํจ๋ ์คํ์ผ๋ง */
|
402 |
+
.panel {
|
403 |
+
background-color: var(--card-bg);
|
404 |
+
border-radius: var(--border-radius);
|
405 |
+
box-shadow: var(--shadow);
|
406 |
+
padding: 1.5rem;
|
407 |
+
margin-bottom: 1.5rem;
|
408 |
+
border: 1px solid rgba(0, 0, 0, 0.04);
|
409 |
+
transition: transform 0.3s ease;
|
410 |
+
}
|
411 |
+
|
412 |
+
.panel:hover {
|
413 |
+
transform: translateY(-5px);
|
414 |
+
}
|
415 |
+
|
416 |
+
/* ์น์
์ ๋ชฉ */
|
417 |
+
.section-title {
|
418 |
+
font-size: 1.5rem;
|
419 |
+
font-weight: 700;
|
420 |
+
color: var(--primary-color);
|
421 |
+
margin-bottom: 1rem;
|
422 |
+
padding-bottom: 0.5rem;
|
423 |
+
border-bottom: 2px solid var(--secondary-color);
|
424 |
+
display: flex;
|
425 |
+
align-items: center;
|
426 |
+
}
|
427 |
+
|
428 |
+
.section-title i {
|
429 |
+
margin-right: 0.5rem;
|
430 |
+
font-size: 1.4rem;
|
431 |
+
}
|
432 |
+
|
433 |
+
/* ๋ฒํผ ์คํ์ผ๋ง */
|
434 |
+
.custom-button {
|
435 |
+
background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
|
436 |
+
color: white !important;
|
437 |
+
border: none !important;
|
438 |
+
border-radius: calc(var(--border-radius) - 5px) !important;
|
439 |
+
padding: 0.8rem 1.2rem !important;
|
440 |
+
font-weight: 600 !important;
|
441 |
+
cursor: pointer !important;
|
442 |
+
transition: all 0.3s ease !important;
|
443 |
+
box-shadow: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08);
|
444 |
+
text-transform: none !important;
|
445 |
+
display: flex !important;
|
446 |
+
align-items: center !important;
|
447 |
+
justify-content: center !important;
|
448 |
+
}
|
449 |
+
|
450 |
+
.custom-button:hover {
|
451 |
+
transform: translateY(-2px) !important;
|
452 |
+
box-shadow: 0 7px 14px rgba(50, 50, 93, 0.1), 0 3px 6px rgba(0, 0, 0, 0.08) !important;
|
453 |
+
}
|
454 |
+
|
455 |
+
.custom-button.primary {
|
456 |
+
background: linear-gradient(135deg, var(--accent-color), #ff9a8b) !important;
|
457 |
+
}
|
458 |
+
|
459 |
+
.custom-button i {
|
460 |
+
margin-right: 0.5rem;
|
461 |
+
}
|
462 |
+
|
463 |
+
/* ์ด๋ฏธ์ง ์ปจํ
์ด๋ */
|
464 |
+
.image-container {
|
465 |
+
border-radius: var(--border-radius);
|
466 |
+
overflow: hidden;
|
467 |
+
border: 1px solid rgba(0, 0, 0, 0.08);
|
468 |
+
transition: all 0.3s ease;
|
469 |
+
background-color: white;
|
470 |
+
}
|
471 |
+
|
472 |
+
.image-container:hover {
|
473 |
+
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
|
474 |
+
}
|
475 |
+
|
476 |
+
/* ํญ ์ปจํ
์ด๋ */
|
477 |
+
.custom-tabs {
|
478 |
+
background-color: transparent !important;
|
479 |
+
border: none !important;
|
480 |
+
margin-bottom: 1rem;
|
481 |
+
}
|
482 |
+
|
483 |
+
.custom-tabs button {
|
484 |
+
background-color: rgba(255, 255, 255, 0.7) !important;
|
485 |
+
border: none !important;
|
486 |
+
border-radius: var(--border-radius) var(--border-radius) 0 0 !important;
|
487 |
+
padding: 0.8rem 1.5rem !important;
|
488 |
+
font-weight: 600 !important;
|
489 |
+
color: var(--text-color) !important;
|
490 |
+
transition: all 0.3s ease !important;
|
491 |
+
}
|
492 |
+
|
493 |
+
.custom-tabs button[aria-selected="true"] {
|
494 |
+
background-color: var(--primary-color) !important;
|
495 |
+
color: white !important;
|
496 |
+
}
|
497 |
+
|
498 |
+
/* ์
๋ ฅ ํ๋ */
|
499 |
+
.custom-input {
|
500 |
+
border-radius: calc(var(--border-radius) - 5px) !important;
|
501 |
+
border: 1px solid rgba(0, 0, 0, 0.1) !important;
|
502 |
+
padding: 0.8rem 1rem !important;
|
503 |
+
transition: all 0.3s ease !important;
|
504 |
+
}
|
505 |
+
|
506 |
+
.custom-input:focus {
|
507 |
+
border-color: var(--primary-color) !important;
|
508 |
+
box-shadow: 0 0 0 2px rgba(85, 97, 233, 0.2) !important;
|
509 |
+
}
|
510 |
+
|
511 |
+
/* ์ฌ์ฉ์ ๋งค๋ด์ผ */
|
512 |
+
.user-manual {
|
513 |
+
background-color: white;
|
514 |
+
padding: 2rem;
|
515 |
+
border-radius: var(--border-radius);
|
516 |
+
box-shadow: var(--shadow);
|
517 |
+
margin-top: 2rem;
|
518 |
+
}
|
519 |
+
|
520 |
+
.manual-title {
|
521 |
+
font-size: 1.8rem;
|
522 |
+
font-weight: 700;
|
523 |
+
color: var(--primary-color);
|
524 |
+
margin-bottom: 1.5rem;
|
525 |
+
text-align: center;
|
526 |
+
display: flex;
|
527 |
+
align-items: center;
|
528 |
+
justify-content: center;
|
529 |
+
}
|
530 |
+
|
531 |
+
.manual-title i {
|
532 |
+
margin-right: 0.5rem;
|
533 |
+
font-size: 1.8rem;
|
534 |
+
}
|
535 |
+
|
536 |
+
.manual-section {
|
537 |
+
margin-bottom: 1.5rem;
|
538 |
+
padding: 1.2rem;
|
539 |
+
background-color: #f8faff;
|
540 |
+
border-radius: calc(var(--border-radius) - 5px);
|
541 |
+
}
|
542 |
+
|
543 |
+
.manual-section-title {
|
544 |
+
font-size: 1.3rem;
|
545 |
+
font-weight: 700;
|
546 |
+
margin-bottom: 1rem;
|
547 |
+
color: var(--primary-color);
|
548 |
+
display: flex;
|
549 |
+
align-items: center;
|
550 |
+
}
|
551 |
+
|
552 |
+
.manual-section-title i {
|
553 |
+
margin-right: 0.5rem;
|
554 |
+
font-size: 1.2rem;
|
555 |
+
}
|
556 |
+
|
557 |
+
.manual-text {
|
558 |
+
font-size: 1rem;
|
559 |
+
line-height: 1.7;
|
560 |
+
}
|
561 |
+
|
562 |
+
.manual-text strong {
|
563 |
+
color: var(--accent-color);
|
564 |
+
}
|
565 |
+
|
566 |
+
.tip-box {
|
567 |
+
background-color: rgba(255, 107, 107, 0.1);
|
568 |
+
border-left: 3px solid var(--accent-color);
|
569 |
+
padding: 1rem 1.2rem;
|
570 |
+
margin: 1rem 0;
|
571 |
+
border-radius: 8px;
|
572 |
+
}
|
573 |
+
|
574 |
+
/* ๋ฒํผ ๊ทธ๋ฃน */
|
575 |
+
.button-grid {
|
576 |
+
display: grid;
|
577 |
+
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
|
578 |
+
gap: 0.8rem;
|
579 |
+
margin-bottom: 1.2rem;
|
580 |
+
}
|
581 |
+
|
582 |
+
/* ๋ก๋ฉ ์ ๋๋ฉ์ด์
*/
|
583 |
+
.progress-container {
|
584 |
+
background-color: rgba(255, 255, 255, 0.9);
|
585 |
+
border-radius: var(--border-radius);
|
586 |
+
padding: 2rem;
|
587 |
+
box-shadow: var(--shadow);
|
588 |
+
text-align: center;
|
589 |
+
}
|
590 |
+
|
591 |
+
.progress-bar {
|
592 |
+
height: 8px;
|
593 |
+
border-radius: 4px;
|
594 |
+
background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
|
595 |
+
margin: 1rem 0;
|
596 |
+
}
|
597 |
+
|
598 |
+
/* ์์ ๊ทธ๋ฆฌ๋ */
|
599 |
+
.examples-grid {
|
600 |
+
display: grid;
|
601 |
+
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
|
602 |
+
gap: 1rem;
|
603 |
+
margin: 1.5rem 0;
|
604 |
+
}
|
605 |
+
|
606 |
+
.example-card {
|
607 |
+
background: white;
|
608 |
+
border-radius: var(--border-radius);
|
609 |
+
overflow: hidden;
|
610 |
+
box-shadow: var(--shadow);
|
611 |
+
transition: transform 0.3s ease;
|
612 |
+
}
|
613 |
+
|
614 |
+
.example-card:hover {
|
615 |
+
transform: translateY(-5px);
|
616 |
+
}
|
617 |
+
|
618 |
+
/* ๋ฐ์ํ */
|
619 |
+
@media (max-width: 768px) {
|
620 |
+
.button-grid {
|
621 |
+
grid-template-columns: repeat(2, 1fr);
|
622 |
+
}
|
623 |
+
}
|
624 |
+
|
625 |
+
/* ์ ์ฒด ์ธํฐํ์ด์ค ๋ฅ๊ทผ ๋ชจ์๋ฆฌ */
|
626 |
+
.block, .prose, .gr-prose, .gr-form, .gr-panel {
|
627 |
+
border-radius: var(--border-radius) !important;
|
628 |
+
}
|
629 |
+
|
630 |
+
/* ๋ฉ์ธ ์ปจํ
์ธ ์คํฌ๋กค๋ฐ */
|
631 |
+
::-webkit-scrollbar {
|
632 |
+
width: 8px;
|
633 |
+
height: 8px;
|
634 |
+
}
|
635 |
+
|
636 |
+
::-webkit-scrollbar-track {
|
637 |
+
background: rgba(0, 0, 0, 0.05);
|
638 |
+
border-radius: 10px;
|
639 |
+
}
|
640 |
+
|
641 |
+
::-webkit-scrollbar-thumb {
|
642 |
+
background: var(--secondary-color);
|
643 |
+
border-radius: 10px;
|
644 |
+
}
|
645 |
+
"""
|
646 |
+
|
647 |
+
# FontAwesome ์์ด์ฝ ํฌํจ
|
648 |
+
fontawesome_link = """
|
649 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
650 |
+
"""
|
651 |
+
|
652 |
+
# ์ฑ ํค๋ HTML
|
653 |
+
header_html = """
|
654 |
+
<div class="app-header">
|
655 |
+
<h1>โจ ์ด์ปค๋จธ์ค ์ด๋ฏธ์ง ๋ง๋ฒ์ฌ โจ</h1>
|
656 |
+
<p>์ฝ๊ณ ๋น ๋ฅด๊ฒ ์ํ ์ด๋ฏธ์ง๋ฅผ ํธ์งํ๊ณ ์์ฑํ์ธ์! ํ ๋ฒ์ ํด๋ฆญ์ผ๋ก ์ ๋ฌธ์ ์ธ ์ด๋ฏธ์ง๋ฅผ ๋ง๋ค ์ ์์ต๋๋ค.</p>
|
657 |
+
</div>
|
658 |
+
"""
|
659 |
+
|
660 |
+
# ์ฌ์ฉ์ ๋งค๋ด์ผ HTML
|
661 |
+
user_manual_html = """
|
662 |
+
<div class="user-manual">
|
663 |
+
<div class="manual-title"><i class="fas fa-book"></i> ์ฌ์ฉ ์ค๋ช
์</div>
|
664 |
+
|
665 |
+
<div class="manual-section">
|
666 |
+
<div class="manual-section-title"><i class="fas fa-magic"></i> ๊ธฐ๋ณธ ์ฌ์ฉ๋ฒ</div>
|
667 |
+
<p class="manual-text">
|
668 |
+
<span style="font-size: 1.1rem; font-weight: 600; color: #5561e9;">1๏ธโฃ ์ด๋ฏธ์ง ์
๋ก๋</span><br>
|
669 |
+
์ต๋ 3๊ฐ์ ์ด๋ฏธ์ง๋ฅผ ์
๋ก๋ํ ์ ์์ต๋๋ค. ์ฒซ ๋ฒ์งธ ์ด๋ฏธ์ง๋ ํ์์
๋๋ค.<br><br>
|
670 |
+
|
671 |
+
<span style="font-size: 1.1rem; font-weight: 600; color: #5561e9;">2๏ธโฃ ํ๋กฌํํธ ์
๋ ฅ ๋๋ ๋ฒํผ ์ ํ</span><br>
|
672 |
+
๋ณํํ๊ณ ์ถ์ ๋ด์ฉ์ ์ง์ ์
๋ ฅํ๊ฑฐ๋, ๋ฏธ๋ฆฌ ์ ์๋ ๋ฒํผ ์ค ํ๋๋ฅผ ์ ํํ์ธ์.<br><br>
|
673 |
+
|
674 |
+
<span style="font-size: 1.1rem; font-weight: 600; color: #5561e9;">3๏ธโฃ ์ด๋ฏธ์ง ์์ฑ</span><br>
|
675 |
+
'์ด๋ฏธ์ง ์์ฑ' ๋ฒํผ์ ํด๋ฆญํ๋ฉด 4๊ฐ์ง ๋ฒ์ ์ ์ด๋ฏธ์ง๊ฐ ์์ฑ๋ฉ๋๋ค.
|
676 |
+
</p>
|
677 |
+
</div>
|
678 |
+
|
679 |
+
<div class="manual-section">
|
680 |
+
<div class="manual-section-title"><i class="fas fa-hashtag"></i> ์ด๋ฏธ์ง ์ฐธ์กฐ ๋ฐฉ๋ฒ</div>
|
681 |
+
<p class="manual-text">
|
682 |
+
ํ๋กฌํํธ์์ ๋ค์ ํ๊ทธ๋ฅผ ์ฌ์ฉํ์ฌ ๊ฐ ์ด๋ฏธ์ง๋ฅผ ์ฐธ์กฐํ ์ ์์ต๋๋ค:
|
683 |
+
<ul>
|
684 |
+
<li><strong style="font-size: 1.05rem;">#1</strong> - ์ฒซ ๋ฒ์งธ ์ด๋ฏธ์ง</li>
|
685 |
+
<li><strong style="font-size: 1.05rem;">#2</strong> - ๋ ๋ฒ์งธ ์ด๋ฏธ์ง</li>
|
686 |
+
<li><strong style="font-size: 1.05rem;">#3</strong> - ์ธ ๋ฒ์งธ ์ด๋ฏธ์ง</li>
|
687 |
+
</ul>
|
688 |
+
|
689 |
+
<div class="tip-box">
|
690 |
+
<i class="fas fa-lightbulb"></i> <strong>ํ:</strong> ์๋ฅผ ๋ค์ด, "(#1์ ์ฌ์ฑ๋ชจ๋ธ)์ด (#2์ ์ ๊ธ๋ผ์ค)๋ฅผ ์ฐฉ์ฉํ ๋ชจ์ต"๊ณผ ๊ฐ์ด ์ฌ์ฉํ ์ ์์ต๋๋ค.
|
691 |
+
</div>
|
692 |
+
</p>
|
693 |
+
</div>
|
694 |
+
|
695 |
+
<div class="manual-section">
|
696 |
+
<div class="manual-section-title"><i class="fas fa-tools"></i> ์ฃผ์ ๊ธฐ๋ฅ</div>
|
697 |
+
<div class="manual-text">
|
698 |
+
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem;">
|
699 |
+
<div>
|
700 |
+
<p style="font-size: 1.1rem; font-weight: 600; color: #ff6b6b;"><i class="fas fa-exchange-alt"></i> ์ด๋ฏธ์ง ๋ณ๊ฒฝ</p>
|
701 |
+
ํฌ์ฆ๋ ์คํ์ผ์ ๋ณ๊ฒฝํ๋ฉด์ ์๋ณธ์ ์ฃผ์ ์์๋ ์ ์งํฉ๋๋ค.
|
702 |
</div>
|
703 |
+
|
704 |
+
<div>
|
705 |
+
<p style="font-size: 1.1rem; font-weight: 600; color: #ff6b6b;"><i class="fas fa-eraser"></i> ๊ธ์ ์ง์ฐ๊ธฐ/๋ณ๊ฒฝ</p>
|
706 |
+
์ด๋ฏธ์ง์ ํ
์คํธ๋ฅผ ์์ฐ์ค๋ฝ๊ฒ ์ ๊ฑฐํ๊ฑฐ๋ ๋ค๋ฅธ ํ
์คํธ๋ก ๋ณ๊ฒฝํฉ๋๋ค.
|
707 |
+
</div>
|
708 |
+
|
709 |
+
<div>
|
710 |
+
<p style="font-size: 1.1rem; font-weight: 600; color: #ff6b6b;"><i class="fas fa-tshirt"></i> ๊ฐ์ ์ํ์ฐฉ์ฉ</p>
|
711 |
+
๋ชจ๋ธ์๊ฒ ๋ค๋ฅธ ์ด๋ฏธ์ง์ ์ํ์ ์์ฐ์ค๋ฝ๊ฒ ์ฐฉ์ฉ์ํต๋๋ค.
|
712 |
+
</div>
|
713 |
+
|
714 |
+
<div>
|
715 |
+
<p style="font-size: 1.1rem; font-weight: 600; color: #ff6b6b;"><i class="fas fa-image"></i> ๋ฐฐ๊ฒฝ ๋ฐ๊พธ๊ธฐ</p>
|
716 |
+
์ฃผ์ ํผ์ฌ์ฒด๋ ์ ์งํ๋ฉฐ ๋ฐฐ๊ฒฝ๋ง ๊ต์ฒดํฉ๋๋ค.
|
717 |
+
</div>
|
718 |
+
</div>
|
719 |
+
</div>
|
720 |
+
</div>
|
721 |
+
|
722 |
+
<div class="manual-section">
|
723 |
+
<div class="manual-section-title"><i class="fas fa-search-plus"></i> GFPGAN ์
์ค์ผ์ผ๋ฌ</div>
|
724 |
+
<p class="manual-text">
|
725 |
+
<span style="font-size: 1.1rem; font-weight: 600; color: #5561e9;">์ด๋ฏธ์ง ๊ฐ์ ๊ธฐ๋ฅ</span><br>
|
726 |
+
์ ํด์๋ ์ด๋ฏธ์ง๋ฅผ ๊ณ ํด์๋๋ก ๋ณํํ๊ณ , ์ผ๊ตด์ ์์ฐ์ค๋ฝ๊ฒ ๋ณต์ํฉ๋๋ค.<br>
|
727 |
+
ํนํ ๋ค์๊ณผ ๊ฐ์ ๊ฒฝ์ฐ์ ํจ๊ณผ์ ์
๋๋ค:
|
728 |
+
<ul>
|
729 |
+
<li>ํด์๋๊ฐ ๋ฎ์ ์ด๋ฏธ์ง ๊ฐ์ </li>
|
730 |
+
<li>ํ๋ฆฟํ๊ฑฐ๋ ๋
ธ์ด์ฆ๊ฐ ์๋ ์ผ๊ตด ๋ณต์</li>
|
731 |
+
<li>์ด๋ฏธ์ง ์ ๋ฐ์ ์ธ ์ ๋ช
๋ ํฅ์</li>
|
732 |
+
</ul>
|
733 |
|
734 |
+
<div class="tip-box">
|
735 |
+
<i class="fas fa-lightbulb"></i> <strong>ํ:</strong> ์ด๋ฏธ์ง์ ํฌ๊ธฐ๊ฐ ์์์๋ก ์ฒ๋ฆฌ ์๋๊ฐ ๋น ๋ฆ
๋๋ค. ์ผ๊ตด์ด ํฌํจ๋ ์ด๋ฏธ์ง์์ ๊ฐ์ฅ ์ข์ ๊ฒฐ๊ณผ๋ฅผ ์ป์ ์ ์์ต๋๋ค.
|
736 |
+
</div>
|
737 |
+
</p>
|
738 |
+
</div>
|
739 |
+
</div>
|
740 |
+
"""
|
741 |
+
|
742 |
+
# UI ๊ตฌ์ฑ
|
743 |
+
with gr.Blocks(css=custom_css) as demo:
|
744 |
+
gr.HTML(fontawesome_link)
|
745 |
+
gr.HTML(header_html)
|
746 |
+
|
747 |
+
with gr.Tabs(elem_classes="custom-tabs") as tabs:
|
748 |
+
with gr.TabItem("โจ ์ด์ปค๋จธ์ค ์ด๋ฏธ์ง ์์ฑ๊ธฐ", elem_classes="tab-content"):
|
749 |
+
with gr.Row(equal_height=True):
|
750 |
with gr.Column(scale=1):
|
751 |
+
with gr.Box(elem_classes="panel"):
|
752 |
+
gr.HTML('<div class="section-title"><i class="fas fa-upload"></i> ์ด๋ฏธ์ง ์
๋ก๋</div>')
|
753 |
+
with gr.Row():
|
754 |
+
image1_input = gr.Image(type="pil", label="#1", image_mode="RGB", elem_classes="image-container", height=220)
|
755 |
+
image2_input = gr.Image(type="pil", label="#2", image_mode="RGB", elem_classes="image-container", height=220)
|
756 |
+
image3_input = gr.Image(type="pil", label="#3", image_mode="RGB", elem_classes="image-container", height=220)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
757 |
|
758 |
+
gr.HTML('<div class="section-title"><i class="fas fa-keyboard"></i> ํ๋กฌํํธ ์
๋ ฅ</div>')
|
759 |
+
prompt_input = gr.Textbox(
|
760 |
+
lines=3,
|
761 |
+
placeholder="ํ๋กฌํํธ๋ฅผ ์
๋ ฅํ๊ฑฐ๋ ๋น์๋๋ฉด ์๋ ํฉ์ฑ๋ฉ๋๋ค. '#1', '#2', '#3'์ผ๋ก ๊ฐ ์ด๋ฏธ์ง๋ฅผ ์ฐธ์กฐํ ์ ์์ต๋๋ค.",
|
762 |
+
label="ํ๋กฌํํธ (์ ํ ์ฌํญ)",
|
763 |
+
elem_classes="custom-input"
|
764 |
+
)
|
765 |
|
766 |
+
gr.HTML('<div class="section-title"><i class="fas fa-sliders-h"></i> ๋ณํ ์ต์
</div>')
|
767 |
+
with gr.Column(elem_classes="button-grid"):
|
768 |
+
image_change_btn1 = gr.Button('<i class="fas fa-sync-alt"></i> ์ด๋ฏธ์ง ๋ณ๊ฒฝ-1', elem_classes="custom-button")
|
769 |
+
image_change_btn2 = gr.Button('<i class="fas fa-sync-alt"></i> ์ด๋ฏธ์ง ๋ณ๊ฒฝ-2', elem_classes="custom-button")
|
770 |
+
text_remove_btn = gr.Button('<i class="fas fa-eraser"></i> ๊ธ์ ์ง์ฐ๊ธฐ', elem_classes="custom-button")
|
771 |
+
text_change_btn = gr.Button('<i class="fas fa-font"></i> ๊ธ์ ๋ณ๊ฒฝ', elem_classes="custom-button")
|
772 |
+
clothes_change_btn1 = gr.Button('<i class="fas fa-tshirt"></i> ์ํ์ฐฉ์ฉ-1', elem_classes="custom-button")
|
773 |
+
clothes_change_btn2 = gr.Button('<i class="fas fa-glasses"></i> ์ํ์ฐฉ์ฉ-2', elem_classes="custom-button")
|
774 |
+
holding_product_btn = gr.Button('<i class="fas fa-wine-glass"></i> ์ํ๋ค๊ณ ์๊ธฐ', elem_classes="custom-button")
|
775 |
+
background_change_btn = gr.Button('<i class="fas fa-image"></i> ๋ฐฐ๊ฒฝ ๋ฐ๊พธ๊ธฐ', elem_classes="custom-button")
|
776 |
+
composite_product_btn = gr.Button('<i class="fas fa-cut"></i> ๋ถ๋ถ ์ง์ฐ๊ธฐ', elem_classes="custom-button")
|
777 |
+
|
778 |
+
submit_btn = gr.Button('<i class="fas fa-magic"></i> ์ด๋ฏธ์ง ์์ฑ (4์ฅ)', elem_classes="custom-button primary")
|
779 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
780 |
with gr.Column(scale=1):
|
781 |
+
with gr.Box(elem_classes="panel"):
|
782 |
+
gr.HTML('<div class="section-title"><i class="fas fa-images"></i> ์์ฑ๋ ์ด๋ฏธ์ง</div>')
|
783 |
+
with gr.Row():
|
784 |
+
with gr.Column():
|
785 |
+
output_image1 = gr.Image(label="์ด๋ฏธ์ง #1", elem_classes="image-container")
|
786 |
+
output_image3 = gr.Image(label="์ด๋ฏธ์ง #3", elem_classes="image-container")
|
787 |
+
with gr.Column():
|
788 |
+
output_image2 = gr.Image(label="์ด๋ฏธ์ง #2", elem_classes="image-container")
|
789 |
+
output_image4 = gr.Image(label="์ด๋ฏธ์ง #4", elem_classes="image-container")
|
790 |
+
|
791 |
+
gr.HTML('<div class="section-title"><i class="fas fa-info-circle"></i> ๊ฒฐ๊ณผ ์ ๋ณด</div>')
|
792 |
+
output_text = gr.Textbox(label="์ํ ๋ฉ์์ง", lines=2, elem_classes="custom-input")
|
793 |
+
prompt_display = gr.Textbox(label="์ฌ์ฉ๋ ํ๋กฌํํธ (์์ด)", visible=True, lines=2, elem_classes="custom-input")
|
794 |
+
|
795 |
+
gr.HTML('<div class="section-title"><i class="fas fa-lightbulb"></i> ์์ ์ด๋ฏธ์ง</div>')
|
796 |
+
with gr.Box(elem_classes="panel"):
|
797 |
+
examples = [
|
798 |
+
["down/๋ชจ๋ธ.jpg", None, None, "(#1์ ์ฌ์ฑ)์ด ์ด์ง ๋ค๋ก ๋์๋ณด๋ ๋ชจ์ต์ผ๋ก ์ต๋ํ ์ด์ seed๋ฅผ ์ ์งํํ
์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํ๋ผ."],
|
799 |
+
["down/์์ด๋ ๊ณ ๋ชจํ.png", None, None, "(#1 ๋ ๋ชจ๋ชจํ)์์ ์ฒญ์์์ด๋ ๊ณ ๋ง ๊ฒ์์ ๊ณ ๋๋ ๊ณ ๋ก ๋ณ๊ฒฝํ๊ณ ๋๋จธ์ง ๋ถ๋ถ์ seed๋ฅผ ๋ณ๊ฒฝ์ ํ์ง๋ง๋ผ."],
|
800 |
+
["down/์ค๊ตญ์ด.png", None, None, "(#1 ์ด๋ฏธ์ง)์ ์๋ ์ค๊ตญ์ด๋ฅผ ๋ชจ๋ ์ ๊ฑฐํ๋ผ."],
|
801 |
+
["down/ํ
์คํธ.webp", None, None, '(#1์ ํ
์คํธ)๋ฅผ ์คํ์ผ์ ์ ์งํ์ฒด ํ
์คํธ๋ง "Hello"๋ก ๋ฐ๊ฟ๋ผ'],
|
802 |
+
["down/๋ชจ๋ธ.jpg", "down/์ ๊ธ๋ผ์ค.png", "down/์ฒญ๋ฐ์ง.png", "(#1์ ์ฌ์ฑ๋ชจ๋ธ)์ด ์ ์ฒด ๋น์จ๊ณผ ํฌ์ฆ๋ ์ ์นํ ์ฒด (#2์ ์ ๊ธ๋ผ์ค)์ (#3์ ์ฒญ๋ฐ์ง)๋ฅผ ์ง์ ๋ชจ๋ธ์ด ์ฐฉ์ฉํ๊ฒ ์ฒ๋ผ ์์ฐ์ค๋ฝ๊ฒ ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๋ผ."],
|
803 |
+
["down/๋ชจ๋ธ.jpg", "down/์ ๊ธ๋ผ์ค.png", "down/์นดํ์ ๊ฒฝ.png", "(#1์ ์ฌ์ฑ๋ชจ๋ธ)์ด ์ ์ฒด ๋น์จ๊ณผ ํฌ์ฆ๋ ์ ์นํ ์ฒด (#2์ ์ ๊ธ๋ผ์ค)๋ฅผ ์ง์ ๋ชจ๋ธ์ด ์ฐฉ์ฉํ ๊ฒ์ฒ๋ผ (#3์ ์ฅ์)์์ ์์์ ์์ ์๋ ์์ฐ์ค๋ฌ์ด ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๋ผ."],
|
804 |
+
["down/๋ชจ๋ธ.jpg", "down/์์ธ์.png", None, "(#1์ ์ฌ์ฑ๋ชจ๋ธ)์ด ์ ์ฒด ๋น์จ๊ณผ ํฌ์ฆ๋ ์ ์นํ ์ฒด (#2์ ์์ธ์)์ ์ฌ์ฑ๋ชจ๋ธ์ด ํ๋ณดํ ์์ธ์์ ๋๋ณด์ด๊ฒ ๋ค๊ณ ์๋ ์์ฐ์ค๋ฌ์ด ๋ชจ์ต์ผ๋ก ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๋ผ."],
|
805 |
+
["down/๋ชจ๋ธ.jpg", "down/์นดํ์ ๊ฒฝ.png", None, "(#1์ ์ฌ์ฑ๋ชจ๋ธ)์ด (#2 ์ด๋ฏธ์ง์ ๋ฐฐ๊ฒฝ)์ ์ฃผ์ ํผ์ฌ์ฒด๋ ๊ทธ๋๋ก ์ ์งํ์ฌ ์ด๋ฏธ์ง์ ๋ถ์๊ธฐ๊ฐ ์์ฐ์ค๋ฝ๊ฒ ์ด์ฐ๋ฌ์ง๋๋ก ์์ฑํ๋ผ."],
|
806 |
+
["down/์์ด๋ ๊ณ ๋ชจํ.png", None, None, "(#1์ ๋ ๊ณ ๋ชจํ)์์ ์ฒญ์์์ด๋ ๊ณ ๋ฅผ ์ ๊ฑฐํ ํ, ๊ทธ ์๋ฆฌ๋ฅผ ์ฃผ๋ณ ๋ฐฐ๊ฒฝ๊ณผ ์์ฐ์ค๋ฝ๊ฒ ์ด์ฐ๋ฌ์ง๋๋ก ์ฑ์์ฃผ์ธ์. ๋จ, ์ด๋ฏธ์ง์ ๋ค๋ฅธ ๋ถ๋ถ์ ์ฃผ์ ์์๋ ๋์ผํ๊ฒ ์ ์งํด ํด์ผํ๋ค."]
|
807 |
+
]
|
808 |
+
|
809 |
+
gr.Examples(
|
810 |
+
examples=examples,
|
811 |
+
inputs=[image1_input, image2_input, image3_input, prompt_input],
|
812 |
+
elem_id="examples-grid",
|
813 |
+
elem_classes="examples-grid"
|
814 |
+
)
|
815 |
+
|
816 |
+
# ์ฌ์ฉ์ ๋งค๋ด์ผ
|
817 |
+
gr.HTML(user_manual_html)
|
818 |
+
|
819 |
+
with gr.TabItem("๐ GFPGAN ์
์ค์ผ์ผ๋ฌ", elem_classes="tab-content"):
|
820 |
+
with gr.Row():
|
821 |
+
with gr.Column(elem_classes="panel"):
|
822 |
+
gr.HTML('<div class="section-title"><i class="fas fa-search-plus"></i> ์ด๋ฏธ์ง ์
์ค์ผ์ผ & ๋ณต์</div>')
|
823 |
+
gr.HTML("""
|
824 |
+
<p style="margin-bottom: 1rem; font-size: 1.05rem;">
|
825 |
+
GFPGANv1.4 ๋ชจ๋ธ์ ์ฌ์ฉํ์ฌ ์ด๋ฏธ์ง๋ฅผ ๊ณ ํด์๋๋ก ๋ณํํ๊ณ ์ผ๊ตด์ ๋ณต์ํฉ๋๋ค.
|
826 |
+
</p>
|
827 |
+
<div class="tip-box">
|
828 |
+
<i class="fas fa-lightbulb"></i> <strong>ํ:</strong> ํด์๋๊ฐ ๋ฎ๊ฑฐ๋ ํ์ง์ด ๋จ์ด์ง๋ ์ด๋ฏธ์ง, ํนํ ์ผ๊ตด ์ด๋ฏธ์ง์ ํจ๊ณผ์ ์
๋๋ค.
|
829 |
+
</div>
|
830 |
+
""")
|
831 |
+
|
832 |
with gr.Row():
|
833 |
with gr.Column():
|
834 |
+
gr.HTML('<div class="section-title"><i class="fas fa-upload"></i> ์
๋ ฅ ์ด๋ฏธ์ง</div>')
|
835 |
+
gfpgan_input = gr.Image(type="filepath", label="์
๋ก๋", elem_classes="image-container")
|
836 |
+
|
837 |
with gr.Column():
|
838 |
+
gr.HTML('<div class="section-title"><i class="fas fa-download"></i> ๊ฒฐ๊ณผ ์ด๋ฏธ์ง</div>')
|
839 |
+
gfpgan_output = gr.Image(type="numpy", label="์
์ค์ผ์ผ ๊ฒฐ๊ณผ", elem_classes="image-container")
|
840 |
|
841 |
+
gfpgan_btn = gr.Button('<i class="fas fa-magic"></i> ์
์ค์ผ์ผ ๋ฐ ๋ณต์', elem_classes="custom-button primary")
|
842 |
+
|
843 |
+
# ๋ฒํผ ์ด๋ฒคํธ ์ฐ๊ฒฐ
|
844 |
+
image_change_btn1.click(
|
845 |
+
fn=lambda: "(#1์ ์ฌ์ฑ)์ด ์ด์ง ๋ค๋ก ๋์๋ณด๋ ๋ชจ์ต์ผ๋ก ์ต๋ํ ์ด์ seed๋ฅผ ์ ์งํํ
์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํ๋ผ.",
|
846 |
+
inputs=[],
|
847 |
+
outputs=prompt_input
|
848 |
+
)
|
849 |
+
image_change_btn2.click(
|
850 |
+
fn=lambda: "(#1 ๋ ๋ชจ๋ชจํ)์์ ์ฒญ์์์ด๋ ๊ณ ๋ง ๊ฒ์์ ๊ณ ๋๋ ๊ณ ๋ก ๋ณ๊ฒฝํ๊ณ ๋๋จธ์ง ๋ถ๋ถ์ seed๋ฅผ ๋ณ๊ฒฝ์ ํ์ง๋ง๋ผ.",
|
851 |
+
inputs=[],
|
852 |
+
outputs=prompt_input
|
853 |
+
)
|
854 |
+
text_remove_btn.click(
|
855 |
+
fn=lambda: "(#1 ์ด๋ฏธ์ง)์ ์๋ ์ค๊ตญ์ด๋ฅผ ๋ชจ๋ ์ ๊ฑฐํ๋ผ.",
|
856 |
+
inputs=[],
|
857 |
+
outputs=prompt_input
|
858 |
+
)
|
859 |
+
text_change_btn.click(
|
860 |
+
fn=lambda: '(#1์ ํ
์คํธ)๋ฅผ ์คํ์ผ์ ์ ์งํ์ฒด ํ
์คํธ๋ง "Hello"๋ก ๋ฐ๊ฟ๋ผ',
|
861 |
+
inputs=[],
|
862 |
+
outputs=prompt_input
|
863 |
+
)
|
864 |
+
clothes_change_btn1.click(
|
865 |
+
fn=lambda: "(#1์ ์ฌ์ฑ๋ชจ๊ฒ)์ด ์ ์ฒด ๋น์จ๊ณผ ํฌ์ฆ๋ ์ ์นํ ์ฒด (#2์ ์ ๊ธ๋ผ์ค)์ (#3์ ์ฒญ๋ฐ์ง)๋ฅผ ์ง์ ๋ชจ๋ธ์ด ์ฐฉ์ฉํ๊ฒ ์ฒ๋ผ ์์ฐ์ค๋ฝ๊ฒ ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๋ผ.",
|
866 |
+
inputs=[],
|
867 |
+
outputs=prompt_input
|
868 |
+
)
|
869 |
+
clothes_change_btn2.click(
|
870 |
+
fn=lambda: "(#1์ ์ฌ์ฑ๋ชจ๋ธ)์ด ์ ์ฒด ๋น์จ๊ณผ ํฌ์ฆ๋ ์ ์นํ ์ฒด (#2์ ์ ๊ธ๋ผ์ค)๋ฅผ ์ง์ ๋ชจ๋ธ์ด ์ฐฉ์ฉํ ๊ฒ์ฒ๋ผ (#3์ ์ฅ์)์์ ์์์ ์์ ์๋ ์์ฐ์ค๋ฌ์ด ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๋ผ.",
|
871 |
+
inputs=[],
|
872 |
+
outputs=prompt_input
|
873 |
+
)
|
874 |
+
holding_product_btn.click(
|
875 |
+
fn=lambda: "(#1์ ์ฌ์ฑ๋ชจ๋ธ)์ด ์ ์ฒด ๋น์จ๊ณผ ํฌ์ฆ๋ ์ ์นํ ์ฒด (#2์ ์์ธ์)์ ์ฌ์ฑ๋ชจ๋ธ์ด ํ๋ณดํ ์์ธ์์ ๋๋ณด์ด๊ฒ ๋ค๊ณ ์๋ ์์ฐ์ค๋ฌ์ด ๋ชจ์ต์ผ๋ก ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๋ผ.",
|
876 |
+
inputs=[],
|
877 |
+
outputs=prompt_input
|
878 |
+
)
|
879 |
+
background_change_btn.click(
|
880 |
+
fn=lambda: "(#1์ ์ฌ์ฑ๋ชจ๋ธ)์ด (#2 ์ด๋ฏธ์ง์ ๋ฐฐ๊ฒฝ)์ ์ฃผ์ ํผ์ฌ์ฒด๋ ๊ทธ๋๋ก ์ ์งํ์ฌ ๋ ์ด๋ฏธ์ง์ ๋ถ์๊ธฐ๊ฐ ์์ฐ์ค๋ฝ๊ฒ ์ด์ฐ๋ฌ์ง๋๋ก ์์ฑํ๋ผ.",
|
881 |
+
inputs=[],
|
882 |
+
outputs=prompt_input
|
883 |
+
)
|
884 |
+
composite_product_btn.click(
|
885 |
+
fn=lambda: "(#1์ ๋ ๊ณ ๋ชจํ)์์ ์ฒญ์์์ด๋ ๊ณ ๋ฅผ ์ ๊ฑฐํ ํ, ๊ทธ ์๋ฆฌ๋ฅผ ์ฃผ๋ณ ๋ฐฐ๊ฒฝ๊ณผ ์์ฐ์ค๋ฝ๊ฒ ์ด์ฐ๋ฌ์ง๋๋ก ์ฑ์์ฃผ์ธ์. ๋จ, ์ด๋ฏธ์ง์ ๋ค๋ฅธ ๋ถ๋ถ์ ์ฃผ์ ์์๋ ๋์ผํ๊ฒ ์ ์งํด ํด์ผํ๋ค.",
|
886 |
+
inputs=[],
|
887 |
+
outputs=prompt_input
|
888 |
+
)
|
889 |
+
submit_btn.click(
|
890 |
+
fn=generate_multiple_images,
|
891 |
+
inputs=[image1_input, image2_input, image3_input, prompt_input],
|
892 |
+
outputs=[output_image1, output_image2, output_image3, output_image4, output_text, prompt_display],
|
893 |
+
)
|
894 |
+
|
895 |
+
gfpgan_btn.click(
|
896 |
+
fn=upscaler_korean,
|
897 |
+
inputs=gfpgan_input,
|
898 |
+
outputs=gfpgan_output
|
899 |
+
)
|
900 |
+
|
901 |
+
demo.queue()
|
902 |
+
demo.launch()
|
|
|
|
|
|