Transforms: Resize vs CenterCrop

What are your preferences and the reasoning behind them?

I saw this transform in my Udacity class, and it seemed redundant in the use of both:

transform = transforms.Compose([transforms.Resize(255),
                                 transforms.CenterCrop(224),
                                 transforms.ToTensor()])

I was thinking Resize keeps the amount of information the same, but distorts it. It seems like CenterCrop risks cutting out important bits, but what it does keep isn’t overly distorted.

Just a newb question! :smiley:

2 Likes

it seems to me that whomever created this transform function is expecting non-uniform input image. the Resize functions is there only to ensure uniformity, and center crop reduce background noise.

2 Likes

What do you mean non-uniform? As in the size is non-uniform (which is true), or something else?

What sort of background would one expect? This is the Cat and Dog dataset, by the way.

non uniform as in the size of the image.
And most likely the subject of interest in at the center of the image, hence the center crop.

3 Likes