TencentYoutuResearch / CrowdCounting-P2PNet

The official codes for the ICCV2021 Oral presentation "Rethinking Counting and Localization in Crowds: A Purely Point-Based Framework"
Other
423 stars 114 forks source link

RuntimeError when doing image resize in run_test.py. please help ~ #46

Closed slent310 closed 12 months ago

slent310 commented 1 year ago

hello ~thanks for this great job. I get some trouble when resizing images in run_tset.py. I modify new_width and new_height like this:

# load the images
img_raw = Image.open(data_path+img_path).convert('RGB')
# round the size
width, height = img_raw.size
img_raw = img_raw.resize((int(width*0.5), int(height*0.5)), Image.ANTIALIAS)

there is the error message: Namespace(backbone='vgg16_bn', gpu_id=0, line=2, output_dir='./logs/', row=2, weight_path='./weights/SHTechA.pth') File "run_test.py", line 140, in main(args) File "run_test.py", line 107, in main result = self.forward(*input, *kwargs) File "D:\working_space_HJ\CrowdCounting-P2PNet-main\models\p2pnet.py", line 215, in forward features_fpn = self.fpn([features[1], features[2], features[3]]) File "C:\ProgramData\Anaconda3\envs\crowd\lib\site-packages\torch\nn\modules\module.py", line 550, in call result = self.forward(input, kwargs) File "D:\working_space_HJ\CrowdCounting-P2PNet-main\models\p2pnet.py", line 183, in forward P4_x = P5_upsampled_x + P4_x RuntimeError: The size of tensor a (134) must match the size of tensor b (135) at non-singleton dimension 2**

please help me and I'm really appreciate it if anyone could answer these questions. Thanks very much. ^ ^

testifier commented 1 year ago

New width, height has to be divisible by 128

slent310 commented 12 months ago

New width, height has to be divisible by 128

thank you. It works ^ ^