@@ -23,10 +23,10 @@ def ensure_gradio_temp_directory():
23
23
24
24
ensure_gradio_temp_directory ()
25
25
26
+ is_gradio4 = int (gr .__version__ [0 ])> 3
26
27
27
28
def main_ui_panel (is_depth_tab ):
28
29
29
- is_gradio4 = int (gr .__version__ [0 ])> 3
30
30
if is_gradio4 :
31
31
Box = gr .Group
32
32
else :
@@ -179,7 +179,7 @@ def main_ui_panel(is_depth_tab):
179
179
def update_default_net_size (model_type ):
180
180
w , h = ModelHolder .get_default_net_size (model_type )
181
181
if is_gradio4 :
182
- return gr .Slider (step = w ), gr .Slider (step = h )
182
+ return gr .Slider (value = w ), gr .Slider (value = h )
183
183
else :
184
184
return inp [go .NET_WIDTH ].update (value = w ), inp [go .NET_HEIGHT ].update (value = h )
185
185
@@ -314,7 +314,7 @@ def on_ui_tabs():
314
314
inp += gr .Checkbox (elem_id = "custom_depthmap" , label = "Use custom DepthMap" , value = False )
315
315
with gr .TabItem ('Batch Process' ) as depthmap_mode_1 :
316
316
inp += gr .File (elem_id = 'image_batch' , label = "Batch Process" , file_count = "multiple" ,
317
- interactive = True , type = "binary " )
317
+ interactive = True , type = "filepath " )
318
318
with gr .TabItem ('Batch from Directory' ) as depthmap_mode_2 :
319
319
inp += gr .Textbox (elem_id = "depthmap_batch_input_dir" , label = "Input directory" ,
320
320
** backbone .get_hide_dirs (),
@@ -393,7 +393,6 @@ def on_ui_tabs():
393
393
depthmap_mode_2 .select (lambda : '2' , None , inp ['depthmap_mode' ])
394
394
depthmap_mode_3 .select (lambda : '3' , None , inp ['depthmap_mode' ])
395
395
396
- is_gradio4 = int (gr .__version__ [0 ])> 3
397
396
def custom_depthmap_change_fn (mode , zero_on , three_on ):
398
397
hide = mode == '0' and zero_on or mode == '3' and three_on
399
398
if is_gradio4 :
@@ -532,9 +531,14 @@ def run_generate(*inputs):
532
531
if image_batch is None :
533
532
return [], None , None , "Please select input images" , ""
534
533
for img in image_batch :
535
- image = Image .open (os .path .abspath (img .name ))
536
- inputimages .append (image )
537
- inputnames .append (os .path .splitext (img .orig_name )[0 ])
534
+ if not is_gradio4 :
535
+ image = Image .open (os .path .abspath (img .name ))
536
+ inputimages .append (image )
537
+ inputnames .append (os .path .splitext (img .orig_name )[0 ])
538
+ else :
539
+ image = Image .open (os .path .abspath (img ))
540
+ inputimages .append (image )
541
+ inputnames .append (os .path .splitext (img )[0 ])
538
542
print (f'{ len (inputimages )} images will be processed' )
539
543
elif depthmap_mode == '2' : # Batch from Directory
540
544
# TODO: There is a RAM leak when we process batches, I can smell it! Or maybe it is gone.
0 commit comments