xhp-hust-2018-2011 / S-DCNet

Implementaion of S-DCNet (ICCV 2019)
MIT License
133 stars 27 forks source link

RuntimeError: Expanded size of Tensor must match existing dimension for non-singleton dimension #6

Open deepanmathibalan opened 4 years ago

deepanmathibalan commented 4 years ago

For the line "cl2h[:,:,rx::rate,ry::rate] = clow*norm" in merge_func.py, I am getting the following runtime error "Expanded size of Tensor must match existing dimension for non-singleton dimension". This happens when the size of chigh is not exactly twice the size of clow. Specifically this happens when clow dimensions are odd numbers. Can you provide a solution on how to fix this issue?

bilel-bj commented 4 years ago

Me the same problem. I did not find a solution.

Traceback (most recent call last): File "/home/bilel/1-demos/Crowd_Analysis/S-DCNet/SHAB_main.py", line 44, in <module> main(opt) File "/home/bilel/1-demos/Crowd_Analysis/S-DCNet/main_process.py", line 76, in main test_phase_video(opt,net,testloader,log_save_path=log_save_path) File "/home/bilel/1-demos/Crowd_Analysis/S-DCNet/Val.py", line 124, in test_phase_video merge_res = net.parse_merge(div_res) File "/home/bilel/1-demos/Crowd_Analysis/S-DCNet/Network/SDCNet.py", line 346, in parse_merge tclow = count_merge_low2high_batch(tclow,tchigh) File "/home/bilel/1-demos/Crowd_Analysis/S-DCNet/Network/merge_func.py", line 22, in count_merge_low2high_batch cl2h[:,:,rx::rate,ry::rate] = clow*norm RuntimeError: The expanded size of the tensor (34) must match the existing size (33) at non-singleton dimension 2. Target sizes: [1, 1, 34, 60]. Tensor sizes: [33, 60]

xhp-hust-2018-2011 commented 4 years ago

In “load_data_V2.py” Line 114, we pad the image to be divisible by 64. So only C0 will be odd, C1 and C2 will be evens. Meanwhile, C1 (C2) will be exactly 2x size of C0(C1). This error is probably caused by incorrect padding.