Skip to content

ops.masks_to_boxes , RuntimeError: min(): Expected reduction dim to be specified for input.numel() == 0. Specify the reduction dim with the 'dim' argument. #9346

@Pinnh

Description

@Pinnh

🐛 Describe the bug

The function ops.masks_to_boxes can't deal masks with one or more zero matrix.

My simple solution:

`
for index, mask in enumerate(masks):
y, x = torch.where(mask != 0)

    if y.numel() == 0 or x.numel() == 0:
        bounding_boxes[index, :] = 0
    else:
        bounding_boxes[index, 0] = torch.min(x)
        bounding_boxes[index, 1] = torch.min(y)
        bounding_boxes[index, 2] = torch.max(x)
        bounding_boxes[index, 3] = torch.max(y)

`

Versions

0.22.0 and upper

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions