toshas commited on
Commit
cb0a9b1
·
1 Parent(s): d716def

add visibility flags for the right selector and advanced settings

Browse files
Files changed (1) hide show
  1. gradio_dualvision/app_template.py +8 -1
gradio_dualvision/app_template.py CHANGED
@@ -63,7 +63,9 @@ class DualVisionApp(gr.Blocks):
63
  squeeze_canvas=True,
64
  squeeze_viewport_height_pct=75,
65
  left_selector_visible=False,
 
66
  advanced_settings_can_be_half_width=True,
 
67
  key_original_image="Original",
68
  spaces_zero_gpu_enabled=False,
69
  spaces_zero_gpu_duration=None,
@@ -86,8 +88,10 @@ class DualVisionApp(gr.Blocks):
86
  squeeze_canvas: When True, the image is fit to the browser viewport. When False, the image is fit to width (Default: `True`).
87
  squeeze_viewport_height_pct: Percentage of the browser viewport height (Default: `75`).
88
  left_selector_visible: Whether controls for changing modalities in the left part of the slider are visible (Default: `False`).
 
89
  key_original_image: Name of the key under which the input image is shown in the modality selectors (Default: `"Original"`).
90
  advanced_settings_can_be_half_width: Whether allow placing advanced settings dropdown in half-column space whenever possible (Default: `True`).
 
91
  spaces_zero_gpu_enabled: When True, the app wraps the processing function with the ZeroGPU decorator.
92
  spaces_zero_gpu_duration: Defines an integer duration in seconds passed into the ZeroGPU decorator.
93
  slider_position: Position of the slider between 0 and 100 (Default: `50`).
@@ -117,7 +121,9 @@ class DualVisionApp(gr.Blocks):
117
  self.input_cls = None
118
  self.input_kwargs = None
119
  self.left_selector_visible = left_selector_visible
 
120
  self.advanced_settings_can_be_half_width = advanced_settings_can_be_half_width
 
121
  if spaces_zero_gpu_enabled:
122
  self.process_components = spaces.GPU(
123
  self.process_components, duration=spaces_zero_gpu_duration
@@ -585,6 +591,7 @@ class DualVisionApp(gr.Blocks):
585
  show_label=False,
586
  container=False,
587
  elem_id="selector_right",
 
588
  render=not reverse_visual_order,
589
  )
590
  if reverse_visual_order:
@@ -611,7 +618,7 @@ class DualVisionApp(gr.Blocks):
611
  )
612
 
613
  def make_advanced_settings(self):
614
- with gr.Accordion("Advanced Settings", open=False):
615
  user_components = self.build_user_components()
616
  if not isinstance(user_components, dict) or any(
617
  not isinstance(k, str) or not isinstance(v, Component)
 
63
  squeeze_canvas=True,
64
  squeeze_viewport_height_pct=75,
65
  left_selector_visible=False,
66
+ right_selector_visible=True,
67
  advanced_settings_can_be_half_width=True,
68
+ advanced_settings_visible=True,
69
  key_original_image="Original",
70
  spaces_zero_gpu_enabled=False,
71
  spaces_zero_gpu_duration=None,
 
88
  squeeze_canvas: When True, the image is fit to the browser viewport. When False, the image is fit to width (Default: `True`).
89
  squeeze_viewport_height_pct: Percentage of the browser viewport height (Default: `75`).
90
  left_selector_visible: Whether controls for changing modalities in the left part of the slider are visible (Default: `False`).
91
+ right_selector_visible: Whether controls for changing modalities in the right part of the slider are visible (Default: `True`).
92
  key_original_image: Name of the key under which the input image is shown in the modality selectors (Default: `"Original"`).
93
  advanced_settings_can_be_half_width: Whether allow placing advanced settings dropdown in half-column space whenever possible (Default: `True`).
94
+ advanced_settings_visible: Whether the advanced settings dropdown is visible (Default: `True`).
95
  spaces_zero_gpu_enabled: When True, the app wraps the processing function with the ZeroGPU decorator.
96
  spaces_zero_gpu_duration: Defines an integer duration in seconds passed into the ZeroGPU decorator.
97
  slider_position: Position of the slider between 0 and 100 (Default: `50`).
 
121
  self.input_cls = None
122
  self.input_kwargs = None
123
  self.left_selector_visible = left_selector_visible
124
+ self.right_selector_visible = right_selector_visible
125
  self.advanced_settings_can_be_half_width = advanced_settings_can_be_half_width
126
+ self.advanced_settings_visible = advanced_settings_visible
127
  if spaces_zero_gpu_enabled:
128
  self.process_components = spaces.GPU(
129
  self.process_components, duration=spaces_zero_gpu_duration
 
591
  show_label=False,
592
  container=False,
593
  elem_id="selector_right",
594
+ visible=self.right_selector_visible,
595
  render=not reverse_visual_order,
596
  )
597
  if reverse_visual_order:
 
618
  )
619
 
620
  def make_advanced_settings(self):
621
+ with gr.Accordion("Advanced Settings", open=False, visible=self.advanced_settings_visible):
622
  user_components = self.build_user_components()
623
  if not isinstance(user_components, dict) or any(
624
  not isinstance(k, str) or not isinstance(v, Component)