CJHMPower / Simultaneous-Traffic-Sign-Detection-and-Classification-with-RetinaNet

72 stars 28 forks source link

RuntimeError: expected type torch.FloatTensor but got torch.LongTensor #6

Open EliBenny opened 5 years ago

EliBenny commented 5 years ago

When trying to test I get:

File "../../encoder.py", line 48, in get_anchor_boxes xy = (xy * grid_size).view(fm_w, fm_h, 1, 2).expand(fm_w, fm_h, 9, 2) RuntimeError: expected type torch.FloatTensor but got torch.LongTensor

CJHMPower commented 5 years ago

I think it is because of the version of pytorch, please try pytorch 0.3.0.

plzhai commented 4 years ago

When trying to test I get:

File "../../encoder.py", line 48, in get_anchor_boxes xy = (xy * grid_size).view(fm_w, fm_h, 1, 2).expand(fm_w, fm_h, 9, 2) RuntimeError: expected type torch.FloatTensor but got torch.LongTensor

try: xy = (xy.float() * grid_size.float()).view(fm_w, fm_h, 1, 2).expand(fm_w, fm_h, 9, 2)