Kims12 commited on
Commit
45ee188
·
verified ·
1 Parent(s): dc29646

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -12
app.py CHANGED
@@ -53,6 +53,8 @@ def initialize_backgrounds():
53
  """모든 배경 옵션 초기화 함수"""
54
  global SIMPLE_BACKGROUNDS, STUDIO_BACKGROUNDS, NATURE_BACKGROUNDS, INDOOR_BACKGROUNDS
55
  global TECHNOLOGY_BACKGROUNDS, COLORFUL_PATTERN_BACKGROUNDS, ABSTRACT_BACKGROUNDS
 
 
56
 
57
  # 디렉토리 내 모든 파일 로깅
58
  logger.info(f"Backgrounds 디렉토리 경로: {BACKGROUNDS_DIR}")
@@ -66,6 +68,8 @@ def initialize_backgrounds():
66
  TECHNOLOGY_BACKGROUNDS = load_background_json("tech-backgrounds-final.json") # 파일 이름 수정
67
  COLORFUL_PATTERN_BACKGROUNDS = load_background_json("colorful-pattern-backgrounds.json") # 파일 이름 수정
68
  ABSTRACT_BACKGROUNDS = load_background_json("abstract_backgrounds.json")
 
 
69
 
70
  # 기본값 설정 (파일이 없거나 비어있는 경우)
71
  if not SIMPLE_BACKGROUNDS:
@@ -82,6 +86,9 @@ def initialize_backgrounds():
82
  COLORFUL_PATTERN_BACKGROUNDS = {"화려한 꽃 패턴": "vibrant floral pattern backdrop"}
83
  if not ABSTRACT_BACKGROUNDS:
84
  ABSTRACT_BACKGROUNDS = {"네온 라이트": "neon light abstract background with vibrant glowing elements"}
 
 
 
85
 
86
  logger.info("모든 배경 옵션 초기화 완료")
87
 
@@ -96,17 +103,9 @@ def initialize_dropdowns():
96
  tech_choices = list(TECHNOLOGY_BACKGROUNDS.keys())
97
  colorful_choices = list(COLORFUL_PATTERN_BACKGROUNDS.keys())
98
  abstract_choices = list(ABSTRACT_BACKGROUNDS.keys())
99
-
100
- # 빈 배열 체크 및 로깅
101
- if not tech_choices:
102
- logger.warning("테크놀로지 배경 옵션이 비어 있습니다. JSON 파일을 확인하세요.")
103
- tech_choices = ["기본 테크놀로지 배경"]
104
- if not colorful_choices:
105
- logger.warning("컬러풀 패턴 배경 옵션이 비어 있습니다. JSON 파일을 확인하세요.")
106
- colorful_choices = ["기본 컬러풀 배경"]
107
-
108
- logger.info(f"테크놀로지 배경 옵션 수: {len(tech_choices)}")
109
- logger.info(f"컬러풀 패턴 배경 옵션 수: {len(colorful_choices)}")
110
 
111
  return {
112
  "simple": simple_choices,
@@ -116,6 +115,8 @@ def initialize_dropdowns():
116
  "tech": tech_choices,
117
  "colorful": colorful_choices,
118
  "abstract": abstract_choices
 
 
119
  }
120
 
121
 
@@ -353,6 +354,14 @@ def get_selected_background_info(bg_type, simple, studio, nature, indoor, tech,
353
  "name": abstract,
354
  "english": ABSTRACT_BACKGROUNDS.get(abstract, "abstract background")
355
  }
 
 
 
 
 
 
 
 
356
  else:
357
  return {
358
  "category": "기본 배경",
@@ -517,7 +526,7 @@ def create_app():
517
  image_input = gr.Image(label="상품 이미지 업로드", type="pil")
518
 
519
  background_type = gr.Radio(
520
- choices=["심플 배경", "스튜디오 배경", "자연 환경", "실내 환경", "테크놀로지 배경", "컬러풀 패턴 배경", "추상/특수 배경"],
521
  label="배경 유형",
522
  value="심플 배경"
523
  )
@@ -569,6 +578,15 @@ def create_app():
569
  label="추상/특수 배경 선택",
570
  visible=False,
571
  interactive=True
 
 
 
 
 
 
 
 
 
572
  )
573
  additional_info = gr.Textbox(
574
  label="추가 요청사항 (선택사항)",
@@ -585,6 +603,8 @@ def create_app():
585
  tech_dropdown: gr.update(visible=(bg_type == "테크놀로지 배경")),
586
  colorful_dropdown: gr.update(visible=(bg_type == "컬러풀 패턴 배경")),
587
  abstract_dropdown: gr.update(visible=(bg_type == "추상/특수 배경"))
 
 
588
  }
589
  background_type.change(
590
  fn=update_dropdowns,
 
53
  """모든 배경 옵션 초기화 함수"""
54
  global SIMPLE_BACKGROUNDS, STUDIO_BACKGROUNDS, NATURE_BACKGROUNDS, INDOOR_BACKGROUNDS
55
  global TECHNOLOGY_BACKGROUNDS, COLORFUL_PATTERN_BACKGROUNDS, ABSTRACT_BACKGROUNDS
56
+ global JEWELRY_BACKGROUNDS # 쥬얼리 배경 추가
57
+
58
 
59
  # 디렉토리 내 모든 파일 로깅
60
  logger.info(f"Backgrounds 디렉토리 경로: {BACKGROUNDS_DIR}")
 
68
  TECHNOLOGY_BACKGROUNDS = load_background_json("tech-backgrounds-final.json") # 파일 이름 수정
69
  COLORFUL_PATTERN_BACKGROUNDS = load_background_json("colorful-pattern-backgrounds.json") # 파일 이름 수정
70
  ABSTRACT_BACKGROUNDS = load_background_json("abstract_backgrounds.json")
71
+ JEWELRY_BACKGROUNDS = load_background_json("jewelry-backgrounds.json")
72
+
73
 
74
  # 기본값 설정 (파일이 없거나 비어있는 경우)
75
  if not SIMPLE_BACKGROUNDS:
 
86
  COLORFUL_PATTERN_BACKGROUNDS = {"화려한 꽃 패턴": "vibrant floral pattern backdrop"}
87
  if not ABSTRACT_BACKGROUNDS:
88
  ABSTRACT_BACKGROUNDS = {"네온 라이트": "neon light abstract background with vibrant glowing elements"}
89
+ if not jewelry_choices:
90
+ logger.warning("쥬얼리 배경 옵션이 비어 있습니다. JSON 파일을 확인하세요.")
91
+ jewelry_choices = ["기본 쥬얼리 배경"]
92
 
93
  logger.info("모든 배경 옵션 초기화 완료")
94
 
 
103
  tech_choices = list(TECHNOLOGY_BACKGROUNDS.keys())
104
  colorful_choices = list(COLORFUL_PATTERN_BACKGROUNDS.keys())
105
  abstract_choices = list(ABSTRACT_BACKGROUNDS.keys())
106
+ jewelry_choices = list(JEWELRY_BACKGROUNDS.keys())
107
+
108
+
 
 
 
 
 
 
 
 
109
 
110
  return {
111
  "simple": simple_choices,
 
115
  "tech": tech_choices,
116
  "colorful": colorful_choices,
117
  "abstract": abstract_choices
118
+ "jewelry": jewelry_choices # 새로 추가
119
+
120
  }
121
 
122
 
 
354
  "name": abstract,
355
  "english": ABSTRACT_BACKGROUNDS.get(abstract, "abstract background")
356
  }
357
+
358
+ elif bg_type == "쥬얼리 배경":
359
+ return {
360
+ "category": "쥬얼리 배경",
361
+ "name": jewelry,
362
+ "english": JEWELRY_BACKGROUNDS.get(jewelry, "jewelry backdrop")
363
+ }
364
+
365
  else:
366
  return {
367
  "category": "기본 배경",
 
526
  image_input = gr.Image(label="상품 이미지 업로드", type="pil")
527
 
528
  background_type = gr.Radio(
529
+ choices=["심플 배경", "스튜디오 배경", "자연 환경", "실내 환경", "테크놀로지 배경", "컬러풀 패턴 배경", "추상/특수 배경", "쥬얼리 배경"],
530
  label="배경 유형",
531
  value="심플 배경"
532
  )
 
578
  label="추상/특수 배경 선택",
579
  visible=False,
580
  interactive=True
581
+
582
+ jewelry_dropdown = gr.Dropdown(
583
+ choices=dropdown_options["jewelry"],
584
+ value=dropdown_options["jewelry"][0] if dropdown_options["jewelry"] else None,
585
+ label="쥬얼리 배경 선택",
586
+ visible=False,
587
+ interactive=True
588
+ )
589
+
590
  )
591
  additional_info = gr.Textbox(
592
  label="추가 요청사항 (선택사항)",
 
603
  tech_dropdown: gr.update(visible=(bg_type == "테크놀로지 배경")),
604
  colorful_dropdown: gr.update(visible=(bg_type == "컬러풀 패턴 배경")),
605
  abstract_dropdown: gr.update(visible=(bg_type == "추상/특수 배경"))
606
+ jewelry_dropdown: gr.update(visible=(bg_type == "쥬얼리 배경")) # 쥬얼리 드롭다운 추가
607
+
608
  }
609
  background_type.change(
610
  fn=update_dropdowns,