voxel51 / eta

ETA: Extensible Toolkit for Analytics
https://voxel51.com
Apache License 2.0
29 stars 13 forks source link

Handling zero height/width when resizing images #569

Closed brimoor closed 2 years ago

brimoor commented 2 years ago

eta.core.image.resize() was not previously robust to degenerate cases where an input/output width/height was zero. This PR resolves that.

import fiftyone as fo
import numpy as np

detection = fo.Detection(
    label="empty",
    bounding_box=[0, 0, 0, 0],
    mask=np.zeros((0, 0)),
)

# Previously would raise an error; now succeeds
segmentation = detection.to_segmentation(frame_size=(32, 32))