Update app.py
Browse files
app.py
CHANGED
@@ -31,6 +31,8 @@ INDOOR_BACKGROUNDS = {}
|
|
31 |
TECHNOLOGY_BACKGROUNDS = {}
|
32 |
COLORFUL_PATTERN_BACKGROUNDS = {}
|
33 |
ABSTRACT_BACKGROUNDS = {}
|
|
|
|
|
34 |
|
35 |
# ------------------- 배경 JSON 파일 로드 함수 -------------------
|
36 |
def load_background_json(filename):
|
@@ -462,11 +464,11 @@ def generate_prompt_with_gemini(product_name, background_info, additional_info="
|
|
462 |
return f"프롬프트 생성 중 오류가 발생했습니다: {str(e)}"
|
463 |
|
464 |
# ------------------- 단일 이미지 생성 함수 -------------------
|
465 |
-
def generate_product_image(image, bg_type, simple, studio, nature, indoor, tech, colorful, abstract, product_name, additional_info):
|
466 |
if image is None:
|
467 |
return None, "이미지를 업로드해주세요.", "이미지를 업로드 후 프롬프트를 생성해주세요."
|
468 |
product_name = product_name.strip() or "제품"
|
469 |
-
background_info = get_selected_background_info(bg_type, simple, studio, nature, indoor, tech, colorful, abstract)
|
470 |
generated_prompt = generate_prompt_with_gemini(product_name, background_info, additional_info)
|
471 |
if "Gemini API 키가 설정되지 않았습니다" in generated_prompt:
|
472 |
warning_msg = (
|
@@ -482,11 +484,11 @@ def generate_product_image(image, bg_type, simple, studio, nature, indoor, tech,
|
|
482 |
return result_image, status, final_prompt
|
483 |
|
484 |
# ------------------- 4장 이미지 생성 함수 -------------------
|
485 |
-
def generate_product_images(image, bg_type, simple, studio, nature, indoor, tech, colorful, abstract, product_name, additional_info):
|
486 |
if image is None:
|
487 |
return None, None, None, None, "이미지를 업로드해주세요.", "이미지를 업로드 후 프롬프트를 생성해주세요."
|
488 |
product_name = product_name.strip() or "제품"
|
489 |
-
background_info = get_selected_background_info(bg_type, simple, studio, nature, indoor, tech, colorful, abstract)
|
490 |
generated_prompt = generate_prompt_with_gemini(product_name, background_info, additional_info)
|
491 |
if "Gemini API 키가 설정되지 않았습니다" in generated_prompt:
|
492 |
warning_msg = (
|
@@ -640,13 +642,13 @@ def create_app():
|
|
640 |
|
641 |
single_btn.click(
|
642 |
fn=modified_single_image_gen,
|
643 |
-
inputs=[image_input, background_type, simple_dropdown, studio_dropdown, nature_dropdown, indoor_dropdown, tech_dropdown, colorful_dropdown, abstract_dropdown, product_name, additional_info],
|
644 |
outputs=[prompt_output, image_output1, image_output2, image_output3, image_output4, status_output]
|
645 |
)
|
646 |
|
647 |
multi_btn.click(
|
648 |
fn=generate_product_images,
|
649 |
-
inputs=[image_input, background_type, simple_dropdown, studio_dropdown, nature_dropdown, indoor_dropdown, tech_dropdown, colorful_dropdown, abstract_dropdown, product_name, additional_info],
|
650 |
outputs=[image_output1, image_output2, image_output3, image_output4, status_output, prompt_output]
|
651 |
)
|
652 |
|
|
|
31 |
TECHNOLOGY_BACKGROUNDS = {}
|
32 |
COLORFUL_PATTERN_BACKGROUNDS = {}
|
33 |
ABSTRACT_BACKGROUNDS = {}
|
34 |
+
JEWELRY_BACKGROUNDS = {} # 쥬얼리 배경 전역 변수 추가
|
35 |
+
|
36 |
|
37 |
# ------------------- 배경 JSON 파일 로드 함수 -------------------
|
38 |
def load_background_json(filename):
|
|
|
464 |
return f"프롬프트 생성 중 오류가 발생했습니다: {str(e)}"
|
465 |
|
466 |
# ------------------- 단일 이미지 생성 함수 -------------------
|
467 |
+
def generate_product_image(image, bg_type, simple, studio, nature, indoor, tech, colorful, abstract, jewelry, product_name, additional_info):
|
468 |
if image is None:
|
469 |
return None, "이미지를 업로드해주세요.", "이미지를 업로드 후 프롬프트를 생성해주세요."
|
470 |
product_name = product_name.strip() or "제품"
|
471 |
+
background_info = get_selected_background_info(bg_type, simple, studio, nature, indoor, tech, colorful, abstract, jewelry)
|
472 |
generated_prompt = generate_prompt_with_gemini(product_name, background_info, additional_info)
|
473 |
if "Gemini API 키가 설정되지 않았습니다" in generated_prompt:
|
474 |
warning_msg = (
|
|
|
484 |
return result_image, status, final_prompt
|
485 |
|
486 |
# ------------------- 4장 이미지 생성 함수 -------------------
|
487 |
+
def generate_product_images(image, bg_type, simple, studio, nature, indoor, tech, colorful, abstract, jewelry, product_name, additional_info):
|
488 |
if image is None:
|
489 |
return None, None, None, None, "이미지를 업로드해주세요.", "이미지를 업로드 후 프롬프트를 생성해주세요."
|
490 |
product_name = product_name.strip() or "제품"
|
491 |
+
background_info = get_selected_background_info(bg_type, simple, studio, nature, indoor, tech, colorful, abstract, jewelry)
|
492 |
generated_prompt = generate_prompt_with_gemini(product_name, background_info, additional_info)
|
493 |
if "Gemini API 키가 설정되지 않았습니다" in generated_prompt:
|
494 |
warning_msg = (
|
|
|
642 |
|
643 |
single_btn.click(
|
644 |
fn=modified_single_image_gen,
|
645 |
+
inputs=[image_input, background_type, simple_dropdown, studio_dropdown, nature_dropdown, indoor_dropdown, tech_dropdown, colorful_dropdown, abstract_dropdown, jewelry_dropdown, product_name, additional_info],
|
646 |
outputs=[prompt_output, image_output1, image_output2, image_output3, image_output4, status_output]
|
647 |
)
|
648 |
|
649 |
multi_btn.click(
|
650 |
fn=generate_product_images,
|
651 |
+
inputs=[image_input, background_type, simple_dropdown, studio_dropdown, nature_dropdown, indoor_dropdown, tech_dropdown, colorful_dropdown, abstract_dropdown, jewelry_dropdown, product_name, additional_info],
|
652 |
outputs=[image_output1, image_output2, image_output3, image_output4, status_output, prompt_output]
|
653 |
)
|
654 |
|