How to get uncropped image using image.show(y=mask)

Hey all,

I’ve been having some trouble while trying to visualize my segmentations. When I run the following code, the raw_image is cropped incorrectly:

for each in data.valid_ds.items[200:205]:
    raw_image = open_image(each)
    y=learn.predict(raw_image)[0];
    print(raw_image.size, y.size)
    raw_image.show(y=y)
    raw_image.show()
    y.show()

The first output returns:

torch.Size([303, 303]) torch.Size([244, 244])

image
image
image

As you can see, the original image is distorted (zoomed in/cropped) when overlaid with the mask via the .show(y=y) method. The original raw_image and the mask (middle and bottom image) are both correct, but the image with the overlaid mask (top) applies an undesirable transformation to the original image.

This problem does not occur when using learn.show_results(), data.show_batch(), etc.

What is causing this? And is there anything I can do about it?

1 Like