File size: 1,420 Bytes
d0ba07f
 
 
 
 
 
 
a95a6ef
 
 
d0ba07f
 
8b5c4f1
5e61196
 
d0ba07f
5e61196
 
d0ba07f
 
8b5c4f1
5e61196
 
 
d0ba07f
 
 
8b5c4f1
a95a6ef
 
d0ba07f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import gradio as gr
from registry import registry

def create_filter_controls():
    controls = {}
    for filter_name in registry.filters:
        params = registry.params_map.get(filter_name, {})
        filter_group = gr.Group(visible=filter_name == "Original") # Create group here
        filter_controls_list = []
        with filter_group: # Put controls inside the group
            for param_name, config in params.items():
                if config['type'] == int:
                    slider = gr.Slider(
                        minimum=config.get('min', 1),
                        maximum=config.get('max', 100),
                        value=config['default'],
                        label=param_name.replace('_', ' ').title(),
                        step=config.get('step', 1)
                    )
                elif config['type'] == float:
                    slider = gr.Slider(
                        minimum=config.get('min', 0.1),
                        maximum=config.get('max', 10.0),
                        step=config.get('step', 0.1),
                        value=config['default'],
                        label=param_name.replace('_', ' ').title()
                    )
                filter_controls_list.append(slider)
        controls[filter_name] = filter_group # Store the group
        filter_group.children = filter_controls_list # Add controls to the group
    return controls