ucbdrive / hd3

Code for Hierarchical Discrete Distribution Decomposition for Match Density Estimation (CVPR 2019)
BSD 3-Clause "New" or "Revised" License
204 stars 31 forks source link

Inference error #34

Closed Centimo closed 3 years ago

Centimo commented 3 years ago

Hi. I'm trying to run your code: python3 -u inference.py --task=stereo --data_list=test --save_folder=/home/oem/Workspace/Projects/hd3/ --encoder=dlaup --decoder=hda --model_path=/home/oem/Workspace/Projects/hd3/model_zoo/hd3s_things-8b4dcd6d.pth --data_root=/home/oem/Workspace/data/Sampler/Driving/RGB_cleanpass/ --batch_size=1 --flow_format=png --workers=16

I got: [2020-11-23 05:11:44,837 INFO inference.py line 78 38672] Namespace(batch_size=1, context=False, data_list='test', data_root='/home/oem/Workspace/data/Sampler/Driving/RGB_cleanpass/', decoder='hda', encoder='dlaup', evaluate=False, flow_format='png', model_path='/home/oem/Workspace/Projects/hd3/model_zoo/hd3s_things-8b4dcd6d.pth', save_folder='/home/oem/Workspace/Projects/hd3/', task='stereo', workers=16)
[2020-11-23 05:11:44,837 INFO inference.py line 79 38672] => creating model ...
[2020-11-23 05:11:47,280 INFO inference.py line 124 38672] HD3Model(
...
[2020-11-23 05:11:47,290 INFO inference.py line 130 38672] => loading checkpoint '/home/oem/Workspace/Projects /hd3/model_zoo/hd3s_things-8b4dcd6d.pth'
[2020-11-23 05:11:47,392 INFO inference.py line 133 38672] => loaded checkpoint '/home/oem/Workspace/Projects /hd3/model_zoo/hd3s_things-8b4dcd6d.pth'
[2020-11-23 05:11:47,392 INFO inference.py line 144 38672] >>>>>>>>>>>>>>>> Start Test >>>>>>>>>>>>>>>>
Traceback (most recent call last):
File "inference.py", line 246, in
main()
File "inference.py", line 167, in main
output = model(
File "/home/oem/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, kwargs) File "/home/oem/.local/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 159, in forward return self.module(*inputs[0], *kwargs[0]) File "/home/oem/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(input, kwargs) File "/home/oem/Workspace/Projects/hd3/hd3model.py", line 33, in forward ms_prob, ms_vect = self.hd3net(torch.cat(img_list, 1)) File "/home/oem/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, kwargs) File "/home/oem/Workspace/Projects/hd3/models/hd3net.py", line 149, in forward torch.cat([x[:, :3, :, :], x[:, 3:, :, :]], 0)) RuntimeError: Sizes of tensors must match except in dimension 1. Got 1 and 3** (The offending index is 0)

Can you tell what the problem might be? It should be noted that for the launch i had to replace @cupy.util.memoize(for_each_device=True) in the file models/correlation.py in line 288 with @cupy.\_util.memoize(for_each_device=True) (added "_" before util). The result is the same for different versions of python (3.6.12 and 3.8.3), pytorch (1.0.0 and 1.7.0) and CUDA (11.1 and 9.0).

yzcjtr commented 3 years ago

Hi, can you check the shape of x passed to the forward function of hd3net class? Looks like the torch.cat op at line 149 throws this error.

Centimo commented 3 years ago

Hi, can you check the shape of x passed to the forward function of hd3net class? Looks like the torch.cat op at line 149 throws this error.

Yes, the size of x in the second dimension is 4, although it should be 6, as I understood it. Full x shape: [1, 4, 576, 1024]

yzcjtr commented 3 years ago

Yep. Looks strange to me. x should be two images concatenated along the second dimension. Can you check the shape of images loaded from the data loader? If they are ordinary RGB images, the channel dimension should be 3?

yzcjtr commented 3 years ago

I'm closing this due to inactivity.