Are the input images resized to fixed width and height during the training in detectron2?

Viewed 886

Are the input images resized to fixed width and height during the training in detectron2? and if yes please explain why? thanks!

1 Answers

Yes, it is. The reason is, large images cannot fit into the memory. Even, with 8GB GPU it is not possible to train with high resolution images.

Besides, there is trade off between image size and batch size; the larger image, the smaller batch size.

In Detectron2, you can change the minimum image size in the configuration like this:

from detectron2.config import get_cfg
cfg = get_cfg()
# minimum image size for the train set
cfg.INPUT.MIN_SIZE_TRAIN = (800,)
# maximum image size for the train set
cfg.INPUT.MAX_SIZE_TRAIN = 1333
# minimum image size for the test set
cfg.INPUT.MIN_SIZE_TEST = 800
# maximum image size for the test set
cfg.INPUT.MAX_SIZE_TEST = 1333

The image size is set for width of the image, and height is fitted correspondingly to avoid disordered images.

Besides, you can set multiple image sizes, so that during training one is selected randomly per image. like this:

cfg .INPUT.MIN_SIZE_TRAIN = (600, 900, 900)
cfg .INPUT.MIN_SIZE_TRAIN_SAMPLING = "choice"

For more information, see here.

Related