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

I can't run the code you provided. #29

Open
ANewAnonymous opened this issue Mar 15, 2019 · 7 comments
Open

I can't run the code you provided. #29

ANewAnonymous opened this issue Mar 15, 2019 · 7 comments

Comments

@ANewAnonymous
Copy link

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.

@zhangwang0537
Copy link

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'>

@ninghongbo123
Copy link

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

@zhqx511
Copy link

zhqx511 commented May 6, 2019

ninghongbo123 is right , up

@Naveenkhasyap
Copy link

@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
Copy link

Naveenkhasyap commented May 31, 2019

@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)

@Fansgithub2019
Copy link

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

@adityajadhav1401
Copy link

@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.

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

7 participants