YOLOv3_PyTorch
YOLOv3_PyTorch copied to clipboard
Problem in grid generating
Hi, it occurs to me when i test on my own dataset sized at (1248, 416).
File "/home/kuro/dev/virtualenvs/pytorch37/lib/python3.7/site-packages/torch/nn/modules/module.py", line 477, in __call__
result = self.forward(*input, **kwargs)
File "/home/kuro/dev/projects/YOLOv3_PyTorch/test/../nets/yolo_loss.py", line 74, in forward
bs * self.num_anchors, 1, 1).view(x.shape).type(FloatTensor)
RuntimeError: invalid argument 2: size '[1 x 3 x 13 x 39]' is invalid for input with 4563 elements at /pytorch/aten/src/TH/THStorage.cpp:84
I then found it working correctly when I modified line 73 - 76 of yolo_loss.py
as follow:
grid_x = torch.linspace(0, in_w-1, in_w).repeat(in_h, 1).repeat(
bs * self.num_anchors, 1, 1).view(x.shape).type(FloatTensor)
grid_y = torch.linspace(0, in_h-1, in_h).repeat(in_w, 1).t().repeat(
bs * self.num_anchors, 1, 1).view(y.shape).type(FloatTensor)
I exchanged position of repeat(in_h, 1) and repeat(in_w,1) and found it working well. I wonder if it's a bug, please checkout.
I had the same problem, exchanging the repeat functions works, this happens if your input image is not squared