kuangliu / torchcv

TorchCV: a PyTorch vision library mimics ChainerCV
MIT License
394 stars 70 forks source link

Problem in getting anchor box #44

Closed AlanStark closed 5 years ago

AlanStark commented 6 years ago

When I train the FPNSSD on my dataset, I encounter the problem as below.

Traceback (most recent call last): File "train.py", line 37, in box_coder = FPNSSDBoxCoder() File "/home/masterpy/GitLab/Aerial-Detection/torchcv/models/fpnssd/box_coder.py", line 15, in init self.anchor_boxes = self._get_anchor_boxes(input_size=torch.tensor([512.,512.])) File "/home/masterpy/GitLab/Aerial-Detection/torchcv/models/fpnssd/box_coder.py", line 58, in _get_anchor_boxes xy = (xy*grid_size).view(fm_h,fm_w,1,2).expand(fm_h,fm_w,9,2) RuntimeError: Expected object of type torch.LongTensor but found type torch.FloatTensor for argument #2 'other'

Could you help me resolve it?

AlanStark commented 6 years ago

Fix by casting grid_size to long

AlanStark commented 6 years ago

When I train the FPNSSD on my dataset, I encounter the problem of LongTensor / FloatTensor mismatch problem all the time. Does it result from PyTorch Version conflict?

nico1as commented 5 years ago

You could fix the issue by casting all floatTensor to longTensor (not that much)