Skip to content

Commit 2fbfbba

Browse files
committed
Improvements for standalone interface
1 parent 8b884fa commit 2fbfbba

File tree

1 file changed

+12
-24
lines changed

1 file changed

+12
-24
lines changed

src/common_ui.py

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ def main_ui_panel(is_depth_tab):
2828
with gr.Group():
2929
with gr.Row():
3030
inp += 'boost', gr.Checkbox(label="BOOST (multi-resolution merging)", value=True)
31-
with gr.Group(visible=False) as options_depend_on_boost:
32-
inp += 'match_size', gr.Checkbox(label="Match net size to input size", value=False)
31+
inp += 'match_size', gr.Checkbox(label="Match net size to input size", value=False)
3332
with gr.Row(visible=False) as options_depend_on_match_size:
3433
inp += 'net_width', gr.Slider(minimum=64, maximum=2048, step=64, label='Net width', value=448)
3534
inp += 'net_height', gr.Slider(minimum=64, maximum=2048, step=64, label='Net height', value=448)
@@ -62,10 +61,9 @@ def main_ui_panel(is_depth_tab):
6261
inp += "gen_stereo", gr.Checkbox(label="Generate stereoscopic image(s)", value=False)
6362
with gr.Group(visible=False) as stereo_options:
6463
with gr.Row():
65-
with gr.Row():
66-
inp += "stereo_modes", gr.CheckboxGroup(
67-
["left-right", "right-left", "top-bottom", "bottom-top", "red-cyan-anaglyph"],
68-
label="Output", value=["left-right", "red-cyan-anaglyph"])
64+
inp += "stereo_modes", gr.CheckboxGroup(
65+
["left-right", "right-left", "top-bottom", "bottom-top", "red-cyan-anaglyph"],
66+
label="Output", value=["left-right", "red-cyan-anaglyph"])
6967
with gr.Row():
7068
inp += "stereo_divergence", gr.Slider(minimum=0.05, maximum=10.005, step=0.01,
7169
label='Divergence (3D effect)',
@@ -137,10 +135,10 @@ def update_delault_net_size(model_type):
137135
)
138136

139137
inp['boost'].change(
140-
fn=lambda a, b: (options_depend_on_boost.update(visible=not a),
138+
fn=lambda a, b: (inp['match_size'].update(visible=not a),
141139
options_depend_on_match_size.update(visible=not a and not b)),
142140
inputs=[inp['boost'], inp['match_size']],
143-
outputs=[options_depend_on_boost, options_depend_on_match_size]
141+
outputs=[inp['match_size'], options_depend_on_match_size]
144142
)
145143
inp['match_size'].change(
146144
fn=lambda a, b: options_depend_on_match_size.update(visible=not a and not b),
@@ -176,11 +174,8 @@ def update_delault_net_size(model_type):
176174
outputs=[inp['clipthreshold_far']]
177175
)
178176

179-
def stereo_options_visibility(v):
180-
return stereo_options.update(visible=v)
181-
182177
inp['gen_stereo'].change(
183-
fn=stereo_options_visibility,
178+
fn=lambda v: stereo_options.update(visible=v),
184179
inputs=[inp['gen_stereo']],
185180
outputs=[stereo_options]
186181
)
@@ -191,22 +186,15 @@ def stereo_options_visibility(v):
191186
outputs=[mesh_options]
192187
)
193188

194-
def inpaint_options_visibility(v):
195-
return inpaint_options_row_0.update(visible=v)
196-
197189
if is_depth_tab:
198190
inp['inpaint'].change(
199-
fn=inpaint_options_visibility,
191+
fn=lambda v: inpaint_options_row_0.update(visible=v),
200192
inputs=[inp['inpaint']],
201193
outputs=[inpaint_options_row_0]
202194
)
203195

204-
def background_removal_options_visibility(v):
205-
return bgrem_options_row_1.update(visible=v), \
206-
bgrem_options_row_2.update(visible=v)
207-
208196
inp['background_removal'].change(
209-
fn=background_removal_options_visibility,
197+
fn=lambda v: (bgrem_options_row_1.update(visible=v), bgrem_options_row_2.update(visible=v)),
210198
inputs=[inp['background_removal']],
211199
outputs=[bgrem_options_row_1, bgrem_options_row_2]
212200
)
@@ -215,7 +203,7 @@ def background_removal_options_visibility(v):
215203

216204
def on_ui_tabs():
217205
inp = GradioComponentBundle()
218-
with gr.Blocks(analytics_enabled=False) as depthmap_interface:
206+
with gr.Blocks(analytics_enabled=False, title="DepthMap") as depthmap_interface:
219207
with gr.Row().style(equal_height=False):
220208
with gr.Column(variant='panel'):
221209
inp += 'depthmap_mode', gr.HTML(visible=False, value='0')
@@ -382,7 +370,7 @@ def run_generate(*inputs):
382370

383371
if depthmap_mode == '0': # Single image
384372
if depthmap_input_image is None:
385-
return [], None, None, "Please select an input image!"
373+
return [], None, None, "Please select an input image"
386374
inputimages.append(depthmap_input_image)
387375
inputnames.append(None)
388376
if custom_depthmap:
@@ -394,7 +382,7 @@ def run_generate(*inputs):
394382
inputdepthmaps.append(None)
395383
if depthmap_mode == '1': # Batch Process
396384
if image_batch is None:
397-
return [], None, None, "Please select input images!", ""
385+
return [], None, None, "Please select input images", ""
398386
for img in image_batch:
399387
image = Image.open(os.path.abspath(img.name))
400388
inputimages.append(image)

0 commit comments

Comments
 (0)