Skip to content

Commit e4e2ab9

Browse files
batch fix
1 parent a829ca5 commit e4e2ab9

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/common_ui.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ def ensure_gradio_temp_directory():
2323

2424
ensure_gradio_temp_directory()
2525

26+
is_gradio4 = int(gr.__version__[0])>3
2627

2728
def main_ui_panel(is_depth_tab):
2829

29-
is_gradio4 = int(gr.__version__[0])>3
3030
if is_gradio4:
3131
Box = gr.Group
3232
else:
@@ -179,7 +179,7 @@ def main_ui_panel(is_depth_tab):
179179
def update_default_net_size(model_type):
180180
w, h = ModelHolder.get_default_net_size(model_type)
181181
if is_gradio4:
182-
return gr.Slider(step=w), gr.Slider(step=h)
182+
return gr.Slider(value=w), gr.Slider(value=h)
183183
else:
184184
return inp[go.NET_WIDTH].update(value=w), inp[go.NET_HEIGHT].update(value=h)
185185

@@ -314,7 +314,7 @@ def on_ui_tabs():
314314
inp += gr.Checkbox(elem_id="custom_depthmap", label="Use custom DepthMap", value=False)
315315
with gr.TabItem('Batch Process') as depthmap_mode_1:
316316
inp += gr.File(elem_id='image_batch', label="Batch Process", file_count="multiple",
317-
interactive=True, type="binary")
317+
interactive=True, type="filepath")
318318
with gr.TabItem('Batch from Directory') as depthmap_mode_2:
319319
inp += gr.Textbox(elem_id="depthmap_batch_input_dir", label="Input directory",
320320
**backbone.get_hide_dirs(),
@@ -393,7 +393,6 @@ def on_ui_tabs():
393393
depthmap_mode_2.select(lambda: '2', None, inp['depthmap_mode'])
394394
depthmap_mode_3.select(lambda: '3', None, inp['depthmap_mode'])
395395

396-
is_gradio4 = int(gr.__version__[0])>3
397396
def custom_depthmap_change_fn(mode, zero_on, three_on):
398397
hide = mode == '0' and zero_on or mode == '3' and three_on
399398
if is_gradio4:
@@ -532,9 +531,14 @@ def run_generate(*inputs):
532531
if image_batch is None:
533532
return [], None, None, "Please select input images", ""
534533
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])
538542
print(f'{len(inputimages)} images will be processed')
539543
elif depthmap_mode == '2': # Batch from Directory
540544
# TODO: There is a RAM leak when we process batches, I can smell it! Or maybe it is gone.

0 commit comments

Comments
 (0)