MiDaS icon indicating copy to clipboard operation
MiDaS copied to clipboard

RuntimeError: view size is not compatible with input tensor's size and stride

Open c1p81 opened this issue 4 years ago • 0 comments

hi working in conda i can use midas_v21_small and midas_v21 and everything is ok

using hybrid (file dpt_hybrid-mida-501f0c75.pt in weights) i have this error (on the same input image on midas_v21)

Any suggestions?? Thanks Luca

update this error is relative to Ubuntu LTS 18.04. In Apple M1 everything works fine

processing input/luca.jpg (1/3) /home/luca/.local/lib/python3.6/site-packages/torch/nn/functional.py:3635: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details. "See the documentation of nn.Upsample for details.".format(mode) Traceback (most recent call last): File "run.py", line 188, in run(args.input_path, args.output_path, args.model_weights, args.model_type, args.optimize) File "run.py", line 122, in run prediction = model.forward(sample) File "/home/luca/Downloads/MiDaS-master/midas/dpt_depth.py", line 108, in forward return super().forward(x).squeeze(dim=1) File "/home/luca/Downloads/MiDaS-master/midas/dpt_depth.py", line 71, in forward layer_1, layer_2, layer_3, layer_4 = forward_vit(self.pretrained, x) File "/home/luca/Downloads/MiDaS-master/midas/vit.py", line 59, in forward_vit glob = pretrained.model.forward_flex(x) File "/home/luca/Downloads/MiDaS-master/midas/vit.py", line 127, in forward_flex x = self.patch_embed.backbone(x) File "/home/luca/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) File "/home/luca/.local/lib/python3.6/site-packages/timm/models/resnetv2.py", line 409, in forward x = self.forward_features(x) File "/home/luca/.local/lib/python3.6/site-packages/timm/models/resnetv2.py", line 403, in forward_features x = self.stem(x) File "/home/luca/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) File "/home/luca/.local/lib/python3.6/site-packages/torch/nn/modules/container.py", line 141, in forward input = module(input) File "/home/luca/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) File "/home/luca/.local/lib/python3.6/site-packages/timm/models/layers/std_conv.py", line 70, in forward self.weight.view(1, self.out_channels, -1), None, None,

RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

c1p81 avatar Dec 20 '21 13:12 c1p81