ssboost commited on
Commit
0814c0c
·
verified ·
1 Parent(s): d1d6c1b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -18
app.py CHANGED
@@ -142,9 +142,9 @@ def create_app():
142
  font=[gr.themes.GoogleFont("Noto Sans KR"), "ui-sans-serif", "system-ui"]
143
  )) as demo:
144
  gr.HTML(fontawesome_link)
145
- # 메인
146
  with gr.Column(elem_classes="custom-section-group custom-frame"):
147
- gr.HTML('<div class="section-title"><img src="https://cdn-icons-png.flaticon.com/512/681/681443.png"> 상품 배경 이미지 예시 갤러리</div>')
148
  with gr.Row():
149
  example_input_image = gr.Image(label="입력 이미지", elem_classes="image-container")
150
  with gr.Column():
@@ -154,23 +154,32 @@ def create_app():
154
  example_additional_info = gr.Textbox(label="추가 요청사항", interactive=False)
155
  example_output_image = gr.Image(label="결과 이미지", elem_classes="image-container")
156
 
157
- # 갤러리 뷰
158
  with gr.Column(elem_classes="custom-section-group"):
159
- with gr.Row(elem_classes="example-gallery"):
160
- for idx, ex in enumerate(product_background_examples):
161
- item = gr.Image(value=ex[5], show_label=False, elem_classes="example-item")
162
- item.select(
163
- fn=load_example,
164
- inputs=None,
165
- outputs=[
166
- example_input_image,
167
- example_bg_type,
168
- example_bg_option,
169
- example_product_name,
170
- example_additional_info,
171
- example_output_image
172
- ]
173
- )
 
 
 
 
 
 
 
 
 
174
 
175
  # 첫 번째 예시 자동 로드
176
  demo.load(
 
142
  font=[gr.themes.GoogleFont("Noto Sans KR"), "ui-sans-serif", "system-ui"]
143
  )) as demo:
144
  gr.HTML(fontawesome_link)
145
+ # 메인 뷰: 첫 번째 예시
146
  with gr.Column(elem_classes="custom-section-group custom-frame"):
147
+ gr.HTML('<div class="section-title"><img src="https://cdn-icons-png.flaticon.com/512/681/681443.png"> 배경 유형별 예시</div>')
148
  with gr.Row():
149
  example_input_image = gr.Image(label="입력 이미지", elem_classes="image-container")
150
  with gr.Column():
 
154
  example_additional_info = gr.Textbox(label="추가 요청사항", interactive=False)
155
  example_output_image = gr.Image(label="결과 이미지", elem_classes="image-container")
156
 
157
+ # 배경 유형별 갤러리 뷰
158
  with gr.Column(elem_classes="custom-section-group"):
159
+ # 유형별 그룹핑
160
+ bg_groups = {}
161
+ for idx, ex in enumerate(product_background_examples):
162
+ bg_groups.setdefault(ex[1], []).append((idx, ex))
163
+ for bg_type, items in bg_groups.items():
164
+ # 그룹 헤더
165
+ gr.HTML(f'<div class="section-title">{bg_type}</div>')
166
+ # 그룹 아이템
167
+ with gr.Row(elem_classes="example-gallery"):
168
+ for idx, ex in items:
169
+ item = gr.Image(value=ex[5], show_label=False, elem_classes="example-item")
170
+ item.select(
171
+ fn=load_example,
172
+ inputs=None,
173
+ outputs=[
174
+ example_input_image,
175
+ example_bg_type,
176
+ example_bg_option,
177
+ example_product_name,
178
+ example_additional_info,
179
+ example_output_image
180
+ ],
181
+ _js=None
182
+ )
183
 
184
  # 첫 번째 예시 자동 로드
185
  demo.load(