Closed nitinmukesh closed 1 month ago
If I use sd-forge-udav2 it doesn't load in WebUI
2024-09-18 00:05:08,106 - ControlNet - INFO - ControlNet UI callback registered.
C:\usable\webui_forge_cu121_torch231\webui\extensions\sd-forge-udav2\scripts\upgraded_depth_anything_v2.py:246: GradioDeprecationWarning: unexpected argument for Image: display_fn
input_image = gr.Image(label="Input Image", type='numpy', elem_id='img-display-input', height=794, display_fn=lambda x: x)
C:\usable\webui_forge_cu121_torch231\webui\extensions\sd-forge-udav2\scripts\upgraded_depth_anything_v2.py:247: GradioDeprecationWarning: unexpected argument for Image: display_fn
depth_image_slider = gr.Image(label="Colourized Depth Map View", elem_id='img-display-output', height=794, display_fn=lambda x: x)
C:\usable\webui_forge_cu121_torch231\webui\extensions\sd-forge-udav2\scripts\upgraded_depth_anything_v2.py:248: GradioDeprecationWarning: unexpected argument for Image: display_fn
grey_depth_file_single = gr.Image(label="Greyscale Depth Map View", elem_id='img-display-output', height=794, display_fn=lambda x: x)
C:\usable\webui_forge_cu121_torch231\webui\extensions\sd-forge-udav2\scripts\upgraded_depth_anything_v2.py:254: GradioDeprecationWarning: unexpected argument for Button: height
submit_single = gr.Button(value="Compute Depth for Single Image", variant="primary", height=26)
*** Error executing callback ui_tabs_callback for C:\usable\webui_forge_cu121_torch231\webui\extensions\sd-forge-udav2\scripts\upgraded_depth_anything_v2.py
Traceback (most recent call last):
File "C:\usable\webui_forge_cu121_torch231\webui\modules\script_callbacks.py", line 283, in ui_tabs_callback
res += c.callback() or []
File "C:\usable\webui_forge_cu121_torch231\webui\extensions\sd-forge-udav2\scripts\upgraded_depth_anything_v2.py", line 268, in on_ui_tabs
input_images = gr.Files(label="Upload Images", type="file", elem_id="img-display-input")
File "C:\usable\webui_forge_cu121_torch231\webui\venv\lib\site-packages\gradio\component_meta.py", line 163, in wrapper
return fn(self, **kwargs)
File "C:\usable\webui_forge_cu121_torch231\webui\venv\lib\site-packages\gradio\templates.py", line 513, in __init__
super().__init__(
File "C:\usable\webui_forge_cu121_torch231\webui\modules\gradio_extensions.py", line 147, in __repaired_init__
original(self, *args, **fixed_kwargs)
File "C:\usable\webui_forge_cu121_torch231\webui\venv\lib\site-packages\gradio\component_meta.py", line 163, in wrapper
return fn(self, **kwargs)
File "C:\usable\webui_forge_cu121_torch231\webui\venv\lib\site-packages\gradio\components\file.py", line 98, in __init__
raise ValueError(
ValueError: Invalid value for parameter `type`: file. Please choose from one of: ['filepath', 'binary']
It works in the older version of forge before the major update, I will look into this error & get back to you.
Thank you @MackinationsAi
So many breaking changes are introduced every few updates, the extensions stop working. :(
@nitinmukesh - So I did a fresh install of the latest version of forge & then installed sd-forge-udav2_v0.0.5. I had no issues w/ single.img, batch.img, single.vid, batch.vid or today's.gallery tab. Everything worked as it should.
That being said, I took a look at the errors you encountered & made a patch I think might help you get UDAV2 back up & running. Hopefully this works, cheers!
Open 'A:\your_path_to\stable-diffusion-webui-forge\extensions\sd-forge-udav2\scripts\upgraded_depth_anything_v2.py' & replace lines 276 to 309 w/ the following code should solve the issues you are facing.
with gr.Tab("Single Image Processing"):
with gr.Row():
model_encoder_image_single = gr.Dropdown(label="Select Model Encoder:", choices=encoders, value='vitl')
with gr.Row():
input_image = gr.Image(label="Input Image", type='filepath', elem_id='img-display-input', height=794) # Changed type from 'Numpy' to 'filepath' & removed deprecated display_fn from gr.Image
depth_image_slider = gr.Image(label="Colourized Depth Map View", elem_id='img-display-output', height=794) # Removed deprecated display_fn from gr.Image
grey_depth_file_single = gr.Image(label="Greyscale Depth Map View", elem_id='img-display-output', height=794) # Removed deprecated display_fn from gr.Image
with gr.Row():
with gr.Column(scale=8):
colour_map_dropdown_single = gr.Dropdown(label="Select Colour Map Method:", choices=colour_map_methods, value='Spectral')
with gr.Column(scale=1):
colour_map_selection_single = gr.Dropdown(label="Colour Map Method Selection:", choices=colour_map_selections, value='Default')
submit_single = gr.Button(value="Compute Depth for Single Image", variant="primary") # Removed deprecated height argument from gr.Button size 'height=26'
def on_submit_single(image_path, colour_map_method, encoder, selection):
if isinstance(image_path, str): # If it's a file path, open it
image = np.array(Image.open(image_path))
else:
image = image_path # If it's already a NumPy array, use it directly
colourized_filenames, grey_depth_filename = process_image(image, colour_map_method, encoder, selection)
first_colourized_image = Image.open(colourized_filenames[0])
first_colourized_image_np = np.array(first_colourized_image)
return first_colourized_image_np, grey_depth_filename
colour_map_selection_single.change(fn=lambda selection: gr.update(choices=get_colour_map_methods(selection)), inputs=colour_map_selection_single, outputs=colour_map_dropdown_single)
submit_single.click(on_submit_single, inputs=[input_image, colour_map_dropdown_single, model_encoder_image_single, colour_map_selection_single], outputs=[depth_image_slider, grey_depth_file_single])
with gr.Tab("Batch Image Processing"):
with gr.Row():
model_encoder_image_batch = gr.Dropdown(label="Select Model Encoder:", choices=encoders, value='vitl')
with gr.Row():
input_images = gr.Files(label="Upload Images", type="filepath", elem_id="img-display-input") # Changed type from 'file' to 'filepath'
@MackinationsAi
Thank you very much. I will install it now.
So I installed in Forge from extensions tab and make some changes mentioned in other thread to make it work. It is now appearing in Forge.
When I select an image and click on Compute depth for Single image.