ShuangXieIrene / ssds.pytorch

Repository for Single Shot MultiBox Detector and its variants, implemented with pytorch, python3.
MIT License
571 stars 167 forks source link

none result in fssd-mobilenet and yolo-v3-mobilebnet #57

Closed whuzs closed 3 years ago

whuzs commented 5 years ago

when i run the demo, i found this problem as blew:

File "F:\DeepLearning\mobilenetv2_fssd\ssds_pytorch\lib\layers\functions\detection.py", line 149, in forward ids, count = nms(boxes, scores, self.nms_thresh, self.top_k) ValueError: not enough values to unpack (expected 2, got 0)

seongkyun commented 5 years ago

The answer is here. In the ssds.py, change the line scale = torch.Tensor([img.shape[1::-1], img.shape[1::-1]]) to scale = torch.Tensor([img.shape[1], img.shape[0], img.shape[1], img.shape[0]])

and if scores.dim() == 0: to if scores.dim() == 0 or scores.size(0) == 0:

then it will work.

This is because of the version of Pytorch. It supports on Pytorch 1.0.1

woodenchild commented 5 years ago

@seongkyun , thanks a lot for solve this. I tried and it works for me. The code "scale = torch.Tensor([img.shape[1::-1], img.shape[1::-1]])" is located in ssd.py The code "if scores.dim() == 0:" is located in detection.py This changes can work on torch >= 0.4 (it seems that torch uses tensor.size() to describe the dim in 0.4+ and if it is a (1,) u should use .item() .