0

This torchvision.ops.nms(boxes, scores, iou_thres) takes me to the boxes.py file in "C:\Users\anaconda\envs\gpu_low\Lib\site-packages\torchvision\ops" where gpu_low is my virtual environment name. In this boxes.py file there is a function nms:

def nms(boxes: Tensor, scores: Tensor, iou_threshold: float) -> Tensor:
    """
    Performs non-maximum suppression (NMS) on the boxes according
    to their intersection-over-union (IoU).

    NMS iteratively removes lower scoring boxes which have an
    IoU greater than iou_threshold with another (higher scoring)
    box.

    If multiple boxes have the exact same score and satisfy the IoU
    criterion with respect to a reference box, the selected box is
    not guaranteed to be the same between CPU and GPU. This is similar
    to the behavior of argsort in PyTorch when repeated values are present.

    Args:
        boxes (Tensor[N, 4])): boxes to perform NMS on. They
            are expected to be in ``(x1, y1, x2, y2)`` format with ``0 <= x1 < x2`` and
            ``0 <= y1 < y2``.
        scores (Tensor[N]): scores for each one of the boxes
        iou_threshold (float): discards all overlapping boxes with IoU > iou_threshold

    Returns:
        Tensor: int64 tensor with the indices of the elements that have been kept
        by NMS, sorted in decreasing order of scores
    """
    _assert_has_ops()
    #print("nms working")
    return torch.ops.torchvision.nms(boxes, scores, iou_threshold)

Now I can't find torch.ops.torchvision.nms(boxes, scores, iou_threshold) in the return statement

if anybody knows then please help me locate this file/function.(I have already tried finding the location using visual studio code but it can't find the location)

  • Did you `import torchvision.ops`? Is `nms` supposed to be in `torchvision.ops`? If so, why do you have `torch.ops`? – Tim Roberts Nov 12 '22 at 05:37
  • Everything works fine, I just need to find the file of the final nms function(the one called in the return statement) to make some changes to it. This nms function is in the boxes.py file in "torchvision.ops". I could not find any torch.ops and that's why I asked if anybody has ever tried finding it. @TimRoberts – Abhyudaya Singh Nov 12 '22 at 06:21
  • what do you get when you print `torch.ops.torchvision.__file__`? it might be implemented in C which would be why you can't find a corresponding python function – Tadhg McDonald-Jensen Nov 12 '22 at 22:28
  • @TadhgMcDonald-Jensen yes that might be the case. Is there a way to locate it? btw this is what I found: `>>> torch.ops.torchvision.__file__ Traceback (most recent call last): File "", line 1, in File "C:\Users\anaconda\envs\gpu_low\lib\site-packages\torch\_ops.py", line 60, in __getattr__ op = torch._C._jit_get_operation(qualified_op_name) RuntimeError: No such operator torchvision::__file__` – Abhyudaya Singh Nov 12 '22 at 23:37

0 Answers0