SuperPoint-Pytorch
SuperPoint-Pytorch copied to clipboard
box_nms: Boxes are negative values
Hi,
Thank you so much for this implementation. I was trying to train the magicpoint network in Linux, and I encountered this issue in NMS:
RuntimeError: Trying to create tensor with negative dimension -1459651072: [-1459651072]
On investigating, I see that the boxes have negative values. How do I correct this?
File /workspace/SuperPoint/models/magicpoint.py:39, in MagicPoint.forward(self, x)
[37](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/workspace/SuperPoint/models/magicpoint.py:37) prob = output['prob']
[38](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/workspace/SuperPoint/models/magicpoint.py:38) if self.nms is not None:
---> [39](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/workspace/SuperPoint/models/magicpoint.py:39) prob = [box_nms(p.unsqueeze(dim=0),
[40](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/workspace/SuperPoint/models/magicpoint.py:40) self.nms,
[41](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/workspace/SuperPoint/models/magicpoint.py:41) min_prob=self.threshold,
[42](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/workspace/SuperPoint/models/magicpoint.py:42) keep_top_k=self.top_k).squeeze(dim=0) for p in prob]
[43](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/workspace/SuperPoint/models/magicpoint.py:43) prob = torch.stack(prob)
[45](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/workspace/SuperPoint/models/magicpoint.py:45) pred = prob[prob>=self.threshold]
File /workspace/SuperPoint/models/magicpoint.py:39, in <listcomp>(.0)
[37](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/workspace/SuperPoint/models/magicpoint.py:37) prob = output['prob']
[38](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/workspace/SuperPoint/models/magicpoint.py:38) if self.nms is not None:
---> [39](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/workspace/SuperPoint/models/magicpoint.py:39) prob = [box_nms(p.unsqueeze(dim=0),
[40](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/workspace/SuperPoint/models/magicpoint.py:40) self.nms,
[41](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/workspace/SuperPoint/models/magicpoint.py:41) min_prob=self.threshold,
[42](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/workspace/SuperPoint/models/magicpoint.py:42) keep_top_k=self.top_k).squeeze(dim=0) for p in prob]
[43](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/workspace/SuperPoint/models/magicpoint.py:43) prob = torch.stack(prob)
[45](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/workspace/SuperPoint/models/magicpoint.py:45) pred = prob[prob>=self.threshold]
File /workspace/SuperPoint/utils/nms.py:70, in box_nms(prob, size, iou, min_prob, keep_top_k)
[67](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/workspace/SuperPoint/utils/nms.py:67) if boxes.nelement() == 0 or scores.nelement() == 0:
[68](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/workspace/SuperPoint/utils/nms.py:68) print("Error: One of the tensors is empty")
---> [70](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/workspace/SuperPoint/utils/nms.py:70) indices = torchvision.ops.nms(boxes=boxes, scores=scores, iou_threshold=iou)
[71](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/workspace/SuperPoint/utils/nms.py:71) pts = pts[indices,:]
[72](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/workspace/SuperPoint/utils/nms.py:72) scores = scores[indices]
File /usr/local/lib/python3.8/dist-packages/torchvision/ops/boxes.py:41, in nms(boxes, scores, iou_threshold)
[39](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/usr/local/lib/python3.8/dist-packages/torchvision/ops/boxes.py:39) _log_api_usage_once(nms)
[40](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/usr/local/lib/python3.8/dist-packages/torchvision/ops/boxes.py:40) _assert_has_ops()
---> [41](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/usr/local/lib/python3.8/dist-packages/torchvision/ops/boxes.py:41) return torch.ops.torchvision.nms(boxes, scores, iou_threshold)
File /usr/local/lib/python3.8/dist-packages/torch/_ops.py:442, in OpOverloadPacket.__call__(self, *args, **kwargs)
[437](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/usr/local/lib/python3.8/dist-packages/torch/_ops.py:437) def __call__(self, *args, **kwargs):
[438](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/usr/local/lib/python3.8/dist-packages/torch/_ops.py:438) # overloading __call__ to ensure torch.ops.foo.bar()
[439](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/usr/local/lib/python3.8/dist-packages/torch/_ops.py:439) # is still callable from JIT
[440](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/usr/local/lib/python3.8/dist-packages/torch/_ops.py:440) # We save the function ptr as the `op` attribute on
[441](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/usr/local/lib/python3.8/dist-packages/torch/_ops.py:441) # OpOverloadPacket to access it here.
--> [442](https://vscode-remote+attached-002dcontainer-002b7b22636f6e7461696e65724e616d65223a222f7375706572706f696e74227d-0040ssh-002dremote-002b10-002e64-002e60-002e182.vscode-resource.vscode-cdn.net/usr/local/lib/python3.8/dist-packages/torch/_ops.py:442) return self._op(*args, **kwargs or {})
RuntimeError: Trying to create tensor with negative dimension -1707356657: [-1707356657]