Setting pixel means and standard deviations
Input image pixels’ means and standard deviations are crucial in training Detectron2 models. Specifically, Detectron2 uses these values to normalize the input images. Detectron2 has two configuration parameters for these. They are cfg.MODEL.PIXEL_MEAN
and cfg.MODEL.PIXEL_STD
. By default, the common values for these two hyperparameters generated from the ImageNet dataset are [103.53, 116.28, 123.675]
and [57.375, 57.120, 58.395]
. These values are appropriate for most of the color images. However, this specific case has grayscale images with different values for pixel means and standard deviations. Therefore, producing these two sets of values from the training dataset would be beneficial. This task has two main stages: (1) preparing a data loader to load images and (2) creating a class to calculate running means and standard deviations.
Preparing a data loader
Detectron2’s data loader is iterable and can yield infinite...