eienmojiki commited on
Commit
6f7bd55
·
verified ·
1 Parent(s): 4e37a66

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -26,11 +26,10 @@ def create_app():
26
 
27
  # Thêm các control vào UI
28
  control_components = []
29
- for filter_name, control_list in controls.items():
30
- group = gr.Group(visible=filter_name == "Original") # Create group here, outside with
31
- filter_groups[filter_name] = group # Store group
32
  with group: # Put controls inside the group
33
- for component in control_list:
34
  control_components.append(component) # Collect sliders for event handling
35
 
36
  with gr.Column():
@@ -41,7 +40,7 @@ def create_app():
41
  updates = []
42
  for group_name, group in filter_groups.items():
43
  visibility = (group_name == filter_name)
44
- updates.append(gr.update(visible=visibility)) # Changed from gr.Group.update
45
  return updates
46
 
47
 
@@ -55,8 +54,8 @@ def create_app():
55
  try:
56
  image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
57
  params = {
58
- k.split('_', 1)[1]: v
59
- for k, v in kwargs.items()
60
  if k.startswith(filter_name)
61
  }
62
 
@@ -76,7 +75,7 @@ def create_app():
76
  filter_select.change(
77
  update_controls,
78
  inputs=filter_select,
79
- outputs=list(filter_groups.values()) # Pass list of groups as outputs
80
  )
81
 
82
  input_components_process = [input_image, filter_select] + control_components
 
26
 
27
  # Thêm các control vào UI
28
  control_components = []
29
+ filter_groups = controls # Assign controls directly to filter_groups
30
+ for filter_name, group in filter_groups.items(): # Iterate through groups
 
31
  with group: # Put controls inside the group
32
+ for component in group.children:
33
  control_components.append(component) # Collect sliders for event handling
34
 
35
  with gr.Column():
 
40
  updates = []
41
  for group_name, group in filter_groups.items():
42
  visibility = (group_name == filter_name)
43
+ updates.append(gr.Group.update(visible=visibility)) # Use gr.Group.update
44
  return updates
45
 
46
 
 
54
  try:
55
  image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
56
  params = {
57
+ k.split('_', 1)[1]: v
58
+ for k, v in kwargs.items()
59
  if k.startswith(filter_name)
60
  }
61
 
 
75
  filter_select.change(
76
  update_controls,
77
  inputs=filter_select,
78
+ outputs=[filter_groups[name] for name in filter_groups] # Pass list of groups as outputs
79
  )
80
 
81
  input_components_process = [input_image, filter_select] + control_components