CCPD icon indicating copy to clipboard operation
CCPD copied to clipboard

I can't run the code you provided.

Open ANewAnonymous opened this issue 6 years ago • 7 comments

I tried to run demo.py. Here is the complete code: python demo.py -i ./demo -m ../fh02.pth But the following error is prompted: Traceback (most recent call last): File "demo.py", line 280, in fps_pred, y_pred = model_conv(x) File "D:\Development\DevelopmentEnvironment\Miniconda3\lib\site-packages\torch\nn\modules\module.py", line 489, in call result = self.forward(*input, **kwargs) File "D:\Development\DevelopmentEnvironment\Miniconda3\lib\site-packages\torch\nn\parallel\data_parallel.py", line 141, in forward return self.module(*inputs[0], **kwargs[0]) File "D:\Development\DevelopmentEnvironment\Miniconda3\lib\site-packages\torch\nn\modules\module.py", line 489, in call result = self.forward(*input, **kwargs) File "demo.py", line 210, in forward roi1 = roi_pooling_ims(_x1, boxNew.mm(p1), size=(16, 8)) File "D:\Development\DevelopmentProject\Python\CCPD-master\rpnet\roi_pooling.py", line 73, in roi_pooling_ims output.append(adaptive_max_pool(im, size)) File "D:\Development\DevelopmentProject\Python\CCPD-master\rpnet\roi_pooling.py", line 35, in adaptive_max_pool return AdaptiveMaxPool2d(size[0], size[1])(input) File "D:\Development\DevelopmentProject\Python\CCPD-master\rpnet\roi_pooling.py", line 18, in forward self.backend = type2backend[type(input)] File "D:\Development\DevelopmentEnvironment\Miniconda3\lib\site-packages\torch_thnn_init.py", line 15, in getitem return self.backends[name].load() KeyError: <class 'torch.Tensor'>

I run: python wR2.py -i ./CCPD_2019/CCPD2019 -b 4 The following error occurred: Traceback (most recent call last):

File "wR2.py", line 226, in trainloader = DataLoader(dst, batch_size=batchSize, shuffle=True, num_workers=4) File "D:\Development\DevelopmentEnvironment\Miniconda3\lib\site-packages\torch\utils\data\dataloader.py", line 802, in init sampler = RandomSampler(dataset) File "D:\Development\DevelopmentEnvironment\Miniconda3\lib\site-packages\torch\utils\data\sampler.py", line 64, in init "value, but got num_samples={}".format(self.num_samples)) ValueError: num_samples should be a positive integeral value, but got num_samples=0

I run python rpnet.py -i ./CCPD_2019/CCPD2019 -b 4 -se 0 -f ./wR2 -t ./demo and error: Traceback (most recent call last): File "rpnet.py", line 406, in trainloader = DataLoader(dst, batch_size=batchSize, shuffle=True, num_workers=8) File "D:\Development\DevelopmentEnvironment\Miniconda3\lib\site-packages\torch\utils\data\dataloader.py", line 802, in init sampler = RandomSampler(dataset) File "D:\Development\DevelopmentEnvironment\Miniconda3\lib\site-packages\torch\utils\data\sampler.py", line 64, in init "value, but got num_samples={}".format(self.num_samples)) ValueError: num_samples should be a positive integeral value, but got num_samples=0

Can you help me solve this problem? I will appreciate your help very much.

ANewAnonymous avatar Mar 15 '19 13:03 ANewAnonymous

File "demo.py", line 273, in fps_pred, y_pred = model_conv(x) File "/usr/local/pytorch-3/lib/python3.5/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(*input, **kwargs) File "/usr/local/pytorch-3/lib/python3.5/site-packages/torch/nn/parallel/data_parallel.py", line 123, in forward outputs = self.parallel_apply(replicas, inputs, kwargs) File "/usr/local/pytorch-3/lib/python3.5/site-packages/torch/nn/parallel/data_parallel.py", line 133, in parallel_apply return parallel_apply(replicas, inputs, kwargs, self.device_ids[:len(replicas)]) File "/usr/local/pytorch-3/lib/python3.5/site-packages/torch/nn/parallel/parallel_apply.py", line 77, in parallel_apply raise output File "/usr/local/pytorch-3/lib/python3.5/site-packages/torch/nn/parallel/parallel_apply.py", line 53, in _worker output = module(*input, **kwargs) File "/usr/local/pytorch-3/lib/python3.5/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(*input, **kwargs) File "demo.py", line 229, in forward roi1 = roi_pooling_ims(_x1, boxNew.mm(p1), size=(16, 8)) File "/home/Masx/CCPD/rpnet/roi_pooling.py", line 73, in roi_pooling_ims output.append(adaptive_max_pool(im, size)) File "/home/Masx/CCPD/rpnet/roi_pooling.py", line 35, in adaptive_max_pool return AdaptiveMaxPool2d(size[0], size[1])(input) File "/home/Masx/CCPD/rpnet/roi_pooling.py", line 18, in forward self._backend = type2backend[type(input)] File "/usr/local/pytorch-3/lib/python3.5/site-packages/torch/_thnn/init.py", line 15, in getitem return self.backends[name].load() KeyError: <class 'torch.Tensor'>

zhangwang0537 avatar Mar 18 '19 08:03 zhangwang0537

You guys need to modify type(input) as input.type() in roi_pooling.py, line 18 ,then it works. This error caused by api changes of different pytorch version

ninghongbo123 avatar Mar 19 '19 02:03 ninghongbo123

ninghongbo123 is right , up

zhqx511 avatar May 06 '19 03:05 zhqx511

@ninghongbo123 yes it solved one error but later got other error once we fix this, may i know the pytorch version in which it runs.

home/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/_thnn/utils.py", line 27, in getattr raise NotImplementedError NotImplementedError

Naveenkhasyap avatar May 30 '19 07:05 Naveenkhasyap

@ninghongbo123 yes it solved one error but later got other error once we fix this, may i know the pytorch version in which it runs.

home/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/_thnn/utils.py", line 27, in getattr raise NotImplementedError NotImplementedError

Figured out that i was using latest pytorch 1.1 and the model has been built on 0.3 so downgraded the package it worked, for anyone trying this out I recommend them to have a environment with below versions strictly so that they wont face any issue. python: pytorch(0.3.1), numpy(1.14.3), cv2(2.4.9.1). system: Cuda(release 9.1, V9.1.85)

Naveenkhasyap avatar May 31 '19 14:05 Naveenkhasyap

@Naveenkhasyap The same error occurred. Can't solve the problem without modifying or reducing the environment? Is there any other way?

Fansgithub2019 avatar Jul 07 '19 04:07 Fansgithub2019

@Naveenkhasyap Hey, can you let me know how exactly did you install python: pytorch(0.3.1), numpy(1.14.3), cv2(2.4.9.1). system: Cuda(release 9.1, V9.1.85) I am trying to use conda to install but facing a lot of issues. Please let me know. I have been stuck on this for a week now.

adityajadhav1401 avatar Sep 10 '19 23:09 adityajadhav1401