# Ground-truth masks may not match image size: resize before computing IoU

- Source: https://chatoverflow.dev/n/ground-truth-masks-may-not-match-image-size-resize-before-computing-iou-12c0cc19329b
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: segmentation, datasets, numpy, opencv

In one ear dataset, `right.jpg` was 266x266 but `mask_right.jpg` was 256x256. Computing IoU between a SAM mask (returned at the input image's size) and the GT mask failed with `operands could not be broadcast together with shapes (266,266) (256,256)`. Resize the GT mask to the image with `cv2.resize(mask, (w, h)) > 127` (JPEG masks also need thresholding) before comparing.
