@@ -25,17 +25,18 @@ def main_ui_panel(is_depth_tab):
25
25
'zoedepth_n (indoor)' , 'zoedepth_k (outdoor)' , 'zoedepth_nk' ],
26
26
value = 'res101' ,
27
27
type = "index" )
28
- with gr .Group ():
28
+ with gr .Box ():
29
29
with gr .Row ():
30
30
inp += 'boost' , gr .Checkbox (label = "BOOST (multi-resolution merging)" , value = True )
31
31
inp += 'match_size' , gr .Checkbox (label = "Match net size to input size" , value = False )
32
32
with gr .Row (visible = False ) as options_depend_on_match_size :
33
33
inp += 'net_width' , gr .Slider (minimum = 64 , maximum = 2048 , step = 64 , label = 'Net width' , value = 448 )
34
34
inp += 'net_height' , gr .Slider (minimum = 64 , maximum = 2048 , step = 64 , label = 'Net height' , value = 448 )
35
35
36
- with gr .Group ():
36
+ with gr .Box ():
37
37
with gr .Row ():
38
- inp += "save_outputs" , gr .Checkbox (label = "Save Outputs" , value = True ) # 50% of width
38
+ with gr .Group ():
39
+ inp += "save_outputs" , gr .Checkbox (label = "Save Outputs" , value = True ) # 50% of width
39
40
with gr .Group (): # 50% of width
40
41
inp += "output_depth" , gr .Checkbox (label = "Output DepthMap" , value = True )
41
42
inp += "invert_depth" , gr .Checkbox (label = "Invert (black=near, white=far)" , value = False )
@@ -44,22 +45,22 @@ def main_ui_panel(is_depth_tab):
44
45
label = "Combine input and depthmap into one image" , value = False )
45
46
inp += "combine_output_axis" , gr .Radio (label = "Combine axis" , choices = ['Vertical' , 'Horizontal' ],
46
47
value = 'Horizontal' , type = "index" , visible = False )
47
- with gr .Group ():
48
+ with gr .Box ():
48
49
with gr .Row ():
49
50
inp += 'clipdepth' , gr .Checkbox (label = "Clip and renormalize DepthMap" , value = False )
50
51
with gr .Row (visible = False ) as clip_options_row_1 :
51
52
inp += "clipthreshold_far" , gr .Slider (minimum = 0 , maximum = 1 , step = 0.001 , label = 'Far clip' , value = 0 )
52
53
inp += "clipthreshold_near" , gr .Slider (minimum = 0 , maximum = 1 , step = 0.001 , label = 'Near clip' , value = 1 )
53
54
54
- with gr .Group ():
55
+ with gr .Box ():
55
56
with gr .Row ():
56
57
inp += "show_heat" , gr .Checkbox (label = "Generate HeatMap" , value = False )
57
58
# gr.Checkbox(label="Generate NormalMap", value=False) # TODO: this is a fake door
58
59
59
- with gr .Group ():
60
+ with gr .Box ():
60
61
with gr .Row ():
61
62
inp += "gen_stereo" , gr .Checkbox (label = "Generate stereoscopic image(s)" , value = False )
62
- with gr .Group (visible = False ) as stereo_options :
63
+ with gr .Column (visible = False ) as stereo_options :
63
64
with gr .Row ():
64
65
inp += "stereo_modes" , gr .CheckboxGroup (
65
66
["left-right" , "right-left" , "top-bottom" , "bottom-top" , "red-cyan-anaglyph" ],
@@ -80,41 +81,42 @@ def main_ui_panel(is_depth_tab):
80
81
label = 'Balance between eyes' ,
81
82
value = 0.0 )
82
83
83
- with gr .Group ():
84
- with gr .Row ():
84
+ with gr .Box ():
85
+ with gr .Column ():
85
86
inp += "gen_mesh" , gr .Checkbox (
86
87
label = "Generate simple 3D mesh" , value = False , visible = True )
87
- with gr .Group (visible = False ) as mesh_options :
88
+ with gr .Column (visible = False ) as mesh_options :
88
89
with gr .Row ():
89
90
gr .HTML (value = "Generates fast, accurate only with ZoeDepth models and no boost, no custom maps" )
90
91
with gr .Row ():
91
92
inp += "mesh_occlude" , gr .Checkbox (label = "Remove occluded edges" , value = True , visible = True )
92
93
inp += "mesh_spherical" , gr .Checkbox (label = "Equirectangular projection" , value = False , visible = True )
93
94
94
95
if is_depth_tab :
95
- with gr .Group ():
96
- with gr .Row ():
96
+ with gr .Box ():
97
+ with gr .Column ():
97
98
inp += "inpaint" , gr .Checkbox (
98
99
label = "Generate 3D inpainted mesh" , value = False )
99
- with gr .Group (visible = False ) as inpaint_options_row_0 :
100
+ with gr .Column (visible = False ) as inpaint_options_row_0 :
100
101
gr .HTML ("Generation is sloooow, required for generating videos" )
101
102
inp += "inpaint_vids" , gr .Checkbox (
102
103
label = "Generate 4 demo videos with 3D inpainted mesh." , value = False )
103
104
gr .HTML ("More options for generating video can be found in the Generate video tab" )
104
105
105
- with gr .Group ():
106
+ with gr .Box ():
106
107
# TODO: it should be clear from the UI that there is an option of the background removal
107
108
# that does not use the model selected above
108
109
with gr .Row ():
109
110
inp += "background_removal" , gr .Checkbox (label = "Remove background" , value = False )
110
- with gr .Row (visible = False ) as bgrem_options_row_1 :
111
- inp += "save_background_removal_masks" , gr .Checkbox (label = "Save the foreground masks" , value = False )
112
- inp += "pre_depth_background_removal" , gr .Checkbox (label = "Pre-depth background removal" , value = False )
113
- with gr .Row (visible = False ) as bgrem_options_row_2 :
114
- inp += "background_removal_model" , gr .Dropdown (label = "Rembg Model" ,
115
- choices = ['u2net' , 'u2netp' , 'u2net_human_seg' ,
116
- 'silueta' ],
117
- value = 'u2net' , type = "value" )
111
+ with gr .Column (visible = False ) as bgrem_options :
112
+ with gr .Row ():
113
+ inp += "save_background_removal_masks" , gr .Checkbox (label = "Save the foreground masks" , value = False )
114
+ inp += "pre_depth_background_removal" , gr .Checkbox (label = "Pre-depth background removal" , value = False )
115
+ with gr .Row ():
116
+ inp += "background_removal_model" , gr .Dropdown (label = "Rembg Model" ,
117
+ choices = ['u2net' , 'u2netp' , 'u2net_human_seg' ,
118
+ 'silueta' ],
119
+ value = 'u2net' , type = "value" )
118
120
119
121
with gr .Box ():
120
122
gr .HTML (f"{ SCRIPT_FULL_NAME } <br/>" )
@@ -194,9 +196,9 @@ def update_delault_net_size(model_type):
194
196
)
195
197
196
198
inp ['background_removal' ].change (
197
- fn = lambda v : ( bgrem_options_row_1 .update (visible = v ), bgrem_options_row_2 . update ( visible = v ) ),
199
+ fn = lambda v : bgrem_options .update (visible = v ),
198
200
inputs = [inp ['background_removal' ]],
199
- outputs = [bgrem_options_row_1 , bgrem_options_row_2 ]
201
+ outputs = [bgrem_options ]
200
202
)
201
203
202
204
return inp
@@ -209,13 +211,13 @@ def on_ui_tabs():
209
211
inp += 'depthmap_mode' , gr .HTML (visible = False , value = '0' )
210
212
with gr .Tabs ():
211
213
with gr .TabItem ('Single Image' ) as depthmap_mode_0 :
212
- with gr .Row ():
213
- inp += gr .Image ( label = "Source" , source = "upload" , interactive = True , type = "pil" ,
214
- elem_id = "depthmap_input_image" )
215
- with gr . Group ( visible = False ) as custom_depthmap_row_0 :
214
+ with gr .Group ():
215
+ with gr .Row ():
216
+ inp += gr . Image ( label = "Source" , source = "upload" , interactive = True , type = "pil" ,
217
+ elem_id = "depthmap_input_image" )
216
218
# TODO: depthmap generation settings should disappear when using this
217
219
inp += gr .File (label = "Custom DepthMap" , file_count = "single" , interactive = True ,
218
- type = "file" , elem_id = 'custom_depthmap_img' )
220
+ type = "file" , elem_id = 'custom_depthmap_img' , visible = False )
219
221
inp += gr .Checkbox (elem_id = "custom_depthmap" , label = "Use custom DepthMap" , value = False )
220
222
with gr .TabItem ('Batch Process' ) as depthmap_mode_1 :
221
223
inp += gr .File (elem_id = 'image_batch' , label = "Batch Process" , file_count = "multiple" ,
@@ -291,13 +293,10 @@ def on_ui_tabs():
291
293
depthmap_mode_1 .select (lambda : '1' , None , inp ['depthmap_mode' ])
292
294
depthmap_mode_2 .select (lambda : '2' , None , inp ['depthmap_mode' ])
293
295
294
- def custom_depthmap_visibility (v ):
295
- return custom_depthmap_row_0 .update (visible = v )
296
-
297
296
inp ['custom_depthmap' ].change (
298
- fn = custom_depthmap_visibility ,
297
+ fn = lambda v : inp [ 'custom_depthmap_img' ]. update ( visible = v ) ,
299
298
inputs = [inp ['custom_depthmap' ]],
300
- outputs = [custom_depthmap_row_0 ]
299
+ outputs = [inp [ 'custom_depthmap_img' ] ]
301
300
)
302
301
303
302
unloadmodels .click (
0 commit comments