eienmojiki commited on
Commit
96cd1bf
·
verified ·
1 Parent(s): 8a71b8a

Update Gradio app with multiple files

Browse files
Files changed (2) hide show
  1. app.py +5 -6
  2. components.py +4 -3
app.py CHANGED
@@ -158,7 +158,7 @@ def create_app():
158
 
159
  gr.Markdown("### ⚙️ Tùy chỉnh")
160
  # Tạo các điều khiển bộ lọc động
161
- filter_controls = create_filter_controls()
162
 
163
  # Right Column - Output
164
  with gr.Column(scale=2):
@@ -209,9 +209,9 @@ def create_app():
209
 
210
  # Lấy các tham số cho filter hiện tại
211
  params = {}
212
- if filter_name in filter_controls and hasattr(filter_controls[filter_name], 'children'):
213
  param_names = list(registry.params_map.get(filter_name, {}).keys())
214
- controls_list = filter_controls[filter_name].children
215
  for i, param_name in enumerate(param_names):
216
  if i < len(controls_list):
217
  params[param_name] = args[i]
@@ -233,9 +233,8 @@ def create_app():
233
 
234
  # Thu thập tất cả control components
235
  all_control_components = []
236
- for filter_name in filter_controls:
237
- if hasattr(filter_controls[filter_name], 'children'):
238
- all_control_components.extend(filter_controls[filter_name].children)
239
 
240
  # Kết nối sự kiện
241
  filter_select.change(
 
158
 
159
  gr.Markdown("### ⚙️ Tùy chỉnh")
160
  # Tạo các điều khiển bộ lọc động
161
+ filter_controls, control_components = create_filter_controls()
162
 
163
  # Right Column - Output
164
  with gr.Column(scale=2):
 
209
 
210
  # Lấy các tham số cho filter hiện tại
211
  params = {}
212
+ if filter_name in control_components:
213
  param_names = list(registry.params_map.get(filter_name, {}).keys())
214
+ controls_list = control_components[filter_name]
215
  for i, param_name in enumerate(param_names):
216
  if i < len(controls_list):
217
  params[param_name] = args[i]
 
233
 
234
  # Thu thập tất cả control components
235
  all_control_components = []
236
+ for filter_name in control_components:
237
+ all_control_components.extend(control_components[filter_name])
 
238
 
239
  # Kết nối sự kiện
240
  filter_select.change(
components.py CHANGED
@@ -4,11 +4,12 @@ from registry import registry
4
  def create_filter_controls():
5
  """Tạo các điều khiển cho từng bộ lọc"""
6
  controls = {}
 
7
 
8
  for filter_name in registry.filters:
9
  params = registry.params_map.get(filter_name, {})
10
 
11
- with gr.Group(visible=filter_name == "Original") as filter_group:
12
  filter_controls_list = []
13
 
14
  if params:
@@ -43,7 +44,7 @@ def create_filter_controls():
43
  else:
44
  gr.Markdown("*✨ Bộ lọc này không có tham số tùy chỉnh - Nhấn 'Áp dụng' để sử dụng!*")
45
 
46
- filter_group.children = filter_controls_list
47
  controls[filter_name] = filter_group
 
48
 
49
- return controls
 
4
  def create_filter_controls():
5
  """Tạo các điều khiển cho từng bộ lọc"""
6
  controls = {}
7
+ control_components = {}
8
 
9
  for filter_name in registry.filters:
10
  params = registry.params_map.get(filter_name, {})
11
 
12
+ with gr.Column(visible=filter_name == "Original") as filter_group:
13
  filter_controls_list = []
14
 
15
  if params:
 
44
  else:
45
  gr.Markdown("*✨ Bộ lọc này không có tham số tùy chỉnh - Nhấn 'Áp dụng' để sử dụng!*")
46
 
 
47
  controls[filter_name] = filter_group
48
+ control_components[filter_name] = filter_controls_list
49
 
50
+ return controls, control_components