Search code examples
pytorchdata-augmentation

Resize Vs CenterCrop Vs RandomResizedCrop Vs RandomCrop


Can anyone tell me in which situations the above functions are used and how they affect the image size? I want to resize the Cat V Dogs images and i am a bit confuse about how to use them.


Solution

  • There are lots of details in TorchVision documentation actually.

    The typical use case is for object detection or image segmentation tasks, but other uses could exist.

    Here is a non-exhaustive list of uses:

    • Resize is used in Convolutional Neural Networks to adapt the input image to the network input shape, in this case this is not data-augmentation but just pre-processing. It can also be used in Fully Convolutional Networks to emulate different scales for an input image, this is data-augmentation.
    • CenterCrop RandomCrop and RandomResizedCrop are used in segmentation tasks to train a network on fine details without impeding too much burden during training. For with a database of 2048x2048 images you can train on 512x512 sub-images and then at test time infer on full resolution images. It is also used in object detection networks as data-augmentation. The resized variant lets you combine the previous resize operation.

    All of them potentially change the image resolution.