Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature tensors with different shapes. #6

Closed
cnu1439 opened this issue Jan 8, 2022 · 3 comments
Closed

Feature tensors with different shapes. #6

cnu1439 opened this issue Jan 8, 2022 · 3 comments

Comments

@cnu1439
Copy link

cnu1439 commented Jan 8, 2022

Hi,
thanks for the code. When i was testing with pre-trained models with test image I'm getting following error. Attaching test image.
Thanks.

(prn_test) dev@linux:/workspace/planerecnet$ python3 simple_inference.py --config=PlaneRecNet_101_config --trained_model=weights/PlaneRecNet_101_9_125000.pth --image=test.jpg:/workspace/test.jpg
Inference image: test.jpg
torch.Size([425, 640, 3])
test.jpg
/home/dev/miniconda/envs/prn_test/lib/python3.9/site-packages/torch/functional.py:445: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at /opt/conda/conda-bld/pytorch_1634272204863/work/aten/src/ATen/native/TensorShape.cpp:2157.)
return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]
torch.Size([1, 128, 107, 160])
torch.Size([1, 128, 108, 160])
Traceback (most recent call last):
File "/workspace/planerecnet/simple_inference.py", line 357, in
inference_image(net, inp, out, depth_mode=args.depth_mode)
File "/workspace/planerecnet/simple_inference.py", line 154, in inference_image
results = net(batch)
File "/home/dev/miniconda/envs/prn_test/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/workspace/planerecnet/planerecnet.py", line 93, in forward
mask_pred = self.mask_head(mask_features)
File "/home/dev/miniconda/envs/prn_test/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/workspace/planerecnet/planerecnet.py", line 494, in forward
feature_add_all_level += self.convs_all_levelsi
RuntimeError: The size of tensor a (107) must match the size of tensor b (108) at non-singleton dimension 2

test

@wangyusenofficial
Copy link

I think this due to the Unet structure, the input img size must be guaranteed to be divided by 2^n (n is the number of unet layers).

@cnu1439
Copy link
Author

cnu1439 commented Jan 10, 2022

yeah. got it. working now. thanks for the reply.

@EryiXie
Copy link
Owner

EryiXie commented Jan 16, 2022

To be more accurate, the image height and width should be evenly divided by 32.

@cnu1439 cnu1439 closed this as completed Mar 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants