thygate / stable-diffusion-webui-depthmap-script

High Resolution Depth Maps for Stable Diffusion WebUI
MIT License
1.72k stars 159 forks source link

ValueError: Number of output components does not match number of values returned from from function f #158

Open ProGamerGov opened 1 year ago

ProGamerGov commented 1 year ago

I get the following errors when trying to create depthmaps for 6000x3000 and 6144x3072

DepthMap v0.3.8
device: cuda
Loading model weights from  ./models/leres/res101.pth
initialize network with normal
loading the model from ./models/pix2pix\latest_net_G.pth
Computing depthmap(s) ..
  0%|                                                                                            | 0/1 [00:00<?, ?it/s]

wholeImage being processed in : 1568
Adjust factor is: 1.0
Selecting patches ...
Target resolution:  (1568, 3136, 3)
Resulting depthmap resolution will be : (3000, 6000)
patches to process: 13
         processing patch 0 / 12 | [ 643    0 3000 3000]
         processing patch 1 / 12 | [1286    0 3000 3000]
         processing patch 2 / 12 | [1929    0 3000 3000]
         processing patch 3 / 12 | [2571    0 3000 3000]
         processing patch 4 / 12 | [  31   31 2939 2939]
         processing patch 5 / 12 | [3429  214 2571 2571]
         processing patch 6 / 12 | [   0    0 1714 1714]
         processing patch 7 / 12 | [   0  643 1714 1714]
         processing patch 8 / 12 | [ 643    0 1714 1714]
         processing patch 9 / 12 | [1286    0 1714 1714]
         processing patch 10 / 12 | [1929    0 1714 1714]
         processing patch 11 / 12 | [2571    0 1714 1714]
         processing patch 12 / 12 | [3214    0 1714 1714]
  0%|                                                                                            | 0/1 [00:28<?, ?it/s]
Error completing request
Arguments: (0, <PIL.Image.Image image mode=RGB size=6000x3000 at 0x1723CEDE7A0>, None, '', '', 0, 0, 512, 512, False, False, True, True, True, False, False, 1, False, True, False, 2, 4, 0, False, 0, 1, False, False, 'u2net', False, False, False, 0, 2) {}
Traceback (most recent call last):
  File "C:\Users\caps\Desktop\sd.webui\webui\modules\call_queue.py", line 56, in f
    res = list(func(*args, **kwargs))
  File "C:\Users\caps\Desktop\sd.webui\webui\modules\call_queue.py", line 37, in f
    res = func(*args, **kwargs)
  File "C:\Users\caps\Desktop\sd.webui\webui\extensions\stable-diffusion-webui-depthmap-script\scripts\depthmap.py", line 1158, in run_generate
    outputs, mesh_fi = run_depthmap(None, outpath, imageArr, imageNameArr, compute_device, model_type, net_width, net_height, match_size, invert_depth, boost, save_depth, show_depth, show_heat, combine_output, combine_output_axis, gen_stereo, gen_stereotb, gen_anaglyph, stereo_divergence, stereo_fill, stereo_balance, clipdepth, clipthreshold_far, clipthreshold_near, inpaint, inpaint_vids, fnExt, vid_ssaa, background_removal, background_removed_images, save_background_removal_masks, False)
  File "C:\Users\caps\Desktop\sd.webui\webui\extensions\stable-diffusion-webui-depthmap-script\scripts\depthmap.py", line 448, in run_depthmap
    images.save_image(Image.fromarray(img_output), path=outpath, basename=basename, seed=None, prompt=None, extension=opts.samples_format, info=info, short_filename=True,no_prompt=True, grid=False, pnginfo_section_name="extras", existing_info=None, forced_filename=None)
  File "C:\Users\caps\Desktop\sd.webui\webui\modules\images.py", line 593, in save_image
    image = image.resize((round(opts.target_side_length), round(image.height * opts.target_side_length / image.width)), LANCZOS)
  File "C:\Users\caps\Desktop\sd.webui\system\python\lib\site-packages\PIL\Image.py", line 2192, in resize
    return self._new(self.im.resize(size, resample, box))
ValueError: image has wrong mode

Traceback (most recent call last):
  File "C:\Users\caps\Desktop\sd.webui\system\python\lib\site-packages\gradio\blocks.py", line 987, in postprocess_data
    if predictions[i] is components._Keywords.FINISHED_ITERATING:
IndexError: tuple index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\caps\Desktop\sd.webui\system\python\lib\site-packages\gradio\routes.py", line 394, in run_predict
    output = await app.get_blocks().process_api(
  File "C:\Users\caps\Desktop\sd.webui\system\python\lib\site-packages\gradio\blocks.py", line 1078, in process_api
    data = self.postprocess_data(fn_index, result["prediction"], state)
  File "C:\Users\caps\Desktop\sd.webui\system\python\lib\site-packages\gradio\blocks.py", line 991, in postprocess_data
    raise ValueError(
ValueError: Number of output components does not match number of values returned from from function f

DepthMap v0.3.8
device: cuda
Loading model weights from  ./models/leres/res101.pth
initialize network with normal
loading the model from ./models/pix2pix\latest_net_G.pth
Computing depthmap(s) ..
  0%|                                                                                            | 0/1 [00:00<?, ?it/s]

wholeImage being processed in : 1568
Adjust factor is: 1.0
Selecting patches ...
Target resolution:  (1568, 3136, 3)
Resulting depthmap resolution will be : (3072, 6144)
patches to process: 13
         processing patch 0 / 12 | [ 658    0 3072 3072]
         processing patch 1 / 12 | [1317    0 3072 3072]
         processing patch 2 / 12 | [1975    0 3072 3072]
         processing patch 3 / 12 | [2633    0 3072 3072]
         processing patch 4 / 12 | [  31   31 3009 3009]
         processing patch 5 / 12 | [3511  219 2633 2633]
         processing patch 6 / 12 | [   0    0 1755 1755]
         processing patch 7 / 12 | [   0  658 1755 1755]
         processing patch 8 / 12 | [ 658    0 1755 1755]
         processing patch 9 / 12 | [1317    0 1755 1755]
         processing patch 10 / 12 | [1975    0 1755 1755]
         processing patch 11 / 12 | [2633    0 1755 1755]
         processing patch 12 / 12 | [3291    0 1755 1755]
  0%|                                                                                            | 0/1 [00:22<?, ?it/s]
Error completing request
Arguments: (0, <PIL.Image.Image image mode=RGB size=6144x3072 at 0x17211F55CF0>, None, '', '', 0, 0, 512, 512, False, False, True, True, True, False, False, 1, False, True, False, 2, 4, 0, False, 0, 1, False, False, 'u2net', False, False, False, 0, 2) {}
Traceback (most recent call last):
  File "C:\Users\caps\Desktop\sd.webui\webui\modules\call_queue.py", line 56, in f
    res = list(func(*args, **kwargs))
  File "C:\Users\caps\Desktop\sd.webui\webui\modules\call_queue.py", line 37, in f
    res = func(*args, **kwargs)
  File "C:\Users\caps\Desktop\sd.webui\webui\extensions\stable-diffusion-webui-depthmap-script\scripts\depthmap.py", line 1158, in run_generate
    outputs, mesh_fi = run_depthmap(None, outpath, imageArr, imageNameArr, compute_device, model_type, net_width, net_height, match_size, invert_depth, boost, save_depth, show_depth, show_heat, combine_output, combine_output_axis, gen_stereo, gen_stereotb, gen_anaglyph, stereo_divergence, stereo_fill, stereo_balance, clipdepth, clipthreshold_far, clipthreshold_near, inpaint, inpaint_vids, fnExt, vid_ssaa, background_removal, background_removed_images, save_background_removal_masks, False)
  File "C:\Users\caps\Desktop\sd.webui\webui\extensions\stable-diffusion-webui-depthmap-script\scripts\depthmap.py", line 448, in run_depthmap
    images.save_image(Image.fromarray(img_output), path=outpath, basename=basename, seed=None, prompt=None, extension=opts.samples_format, info=info, short_filename=True,no_prompt=True, grid=False, pnginfo_section_name="extras", existing_info=None, forced_filename=None)
  File "C:\Users\caps\Desktop\sd.webui\webui\modules\images.py", line 593, in save_image
    image = image.resize((round(opts.target_side_length), round(image.height * opts.target_side_length / image.width)), LANCZOS)
  File "C:\Users\caps\Desktop\sd.webui\system\python\lib\site-packages\PIL\Image.py", line 2192, in resize
    return self._new(self.im.resize(size, resample, box))
ValueError: image has wrong mode

Traceback (most recent call last):
  File "C:\Users\caps\Desktop\sd.webui\system\python\lib\site-packages\gradio\blocks.py", line 987, in postprocess_data
    if predictions[i] is components._Keywords.FINISHED_ITERATING:
IndexError: tuple index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\caps\Desktop\sd.webui\system\python\lib\site-packages\gradio\routes.py", line 394, in run_predict
    output = await app.get_blocks().process_api(
  File "C:\Users\caps\Desktop\sd.webui\system\python\lib\site-packages\gradio\blocks.py", line 1078, in process_api
    data = self.postprocess_data(fn_index, result["prediction"], state)
  File "C:\Users\caps\Desktop\sd.webui\system\python\lib\site-packages\gradio\blocks.py", line 991, in postprocess_data
    raise ValueError(
ValueError: Number of output components does not match number of values returned from from function f
thygate commented 1 year ago

ValueError: image has wrong mode

6000x3000 and 6144x3072

The problem seems to happen when trying to save the PIL image after it has been generated.

Those are very large images, have you verified if smaller images work ?

(Note: For images that large you definitely want to set a much larger Rmax (max wholesize for boost) to get a higher resolution merged depthmap. See Settings on WebUI Settings tab in README )

ProGamerGov commented 1 year ago

@thygate I resized the image to smaller size and it worked, so it does appear that the size is causing the problem somehow.

thygate commented 1 year ago

File "C:\Users\caps\Desktop\sd.webui\webui\modules\images.py", line 593, in save_image image = image.resize((round(opts.target_side_length), round(image.height * opts.target_side_length / image.width)), LANCZOS) File "C:\Users\caps\Desktop\sd.webui\system\python\lib\site-packages\PIL\Image.py", line 2192, in resize return self._new(self.im.resize(size, resample, box)) ValueError: image has wrong mode

I'm not sure what the cause of this is..