Closed siddharthkale97 closed 5 years ago
I also encountered the same problem, I have tried to change a few things without success. Help, please.
I think I found the source of the problem. When you use:
print(x_y_offset.device) print(prediction.device)
you get cuda:0
for x_y_offset and cpu
for prediction!
I just don't know how to solve this. I'm using colab notebook.
OK, I got it! (works for me)
After prediction[:,:,4] = torch.sigmoid(prediction[:,:,4])
add: prediction = prediction.cuda()
without the added line prediction
is calculated in the CPU thus the problem!
Please keep me posted if it solves your problem.
OK, I got it! (works for me) After
prediction[:,:,4] = torch.sigmoid(prediction[:,:,4])
add:prediction = prediction.cuda()
without the added line
prediction
is calculated in the CPU thus the problem!Please keep me posted if it solves your problem.
I tried with adding prediction = prediction.cuda() but I kept on getting the error. But I aslo encountered a strange thing. While following the tutorial I got this problem, but strangely the problem was solved when I cloned the repo and then run the program on a test timage. Anyway thanks for your help
In util.py file I am getting an error at the line
prediction[:,:,:2] += x_y_offset
saying that
Traceback (most recent call last): File "darknet.py", line 239, in
pred = model(inp, torch.cuda.is_available())
File "C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "darknet.py", line 225, in forward
x = predict_transform(x, inp_dim, anchors, num_classes, CUDA)
File "C:\Users\Siddharth Kale\Desktop\Coding Essentials\codes\Convoulution_Neural_Nets\yolo-pytorch\util.py", line 43, in predict_transform
prediction[:,:,:2] += x_y_offset
RuntimeError: Expected object of type torch.FloatTensor but found type torch.cuda.FloatTensor for argument #4 'other'
Couldn't find any solutions, could someone suggest something to get rid of this error``