Reputation: 41
I'm working on a custom Faster RCNN with Detectron2 framework and I have a doubt about transformation during training and inference. I created a custom Trainer inheriting from DefaultTrainer class and I overridden build_train_loader
and build_test_loader
. the following code represent what I did:
@classmethod
def build_train_loader(cls, cfg):
mapper = DatasetMapper(cfg, is_train=True, augmentations=custom_aug(is_train=True))
return build_detection_train_loader(cfg, mapper=mapper)
I did equivalent with is_train=False
for build_test_loader(...)
method. Now I don't know if only transformation in custom_aug
are executed or also the transformation specified into cfg
file. In particular, for Faster-RCNN, I referred to these string into configuration file:
# By default, {MIN,MAX}_SIZE options are used in transforms.ResizeShortestEdge.
# Please refer to ResizeShortestEdge for detailed definition.
# Size of the smallest side of the image during training
_C.INPUT.MIN_SIZE_TRAIN = (800,)
# Sample size of smallest side by choice or random selection from range give by
# INPUT.MIN_SIZE_TRAIN
_C.INPUT.MIN_SIZE_TRAIN_SAMPLING = "choice"
# Maximum size of the side of the image during training
_C.INPUT.MAX_SIZE_TRAIN = 1333
# Size of the smallest side of the image during testing. Set to zero to disable resize in testing.
_C.INPUT.MIN_SIZE_TEST = 800
# Maximum size of the side of the image during testing
_C.INPUT.MAX_SIZE_TEST = 1333
# Mode for flipping images used in data augmentation during training
# choose one of ["horizontal, "vertical", "none"]
_C.INPUT.RANDOM_FLIP = "horizontal"
So, my question is, these transformations will be executed along these into custom_aug
or will be "overridden" by custom_aug
?
Upvotes: 1
Views: 598
Reputation: 13
These "default" augmentations will be overridden with your custom augmentations.
The DefaultTrainer in Detectron 2 applies two augmentations by default:
This behavior is hard-coded into Detectron2 and is a direct consequence of the provided config file. See here. This is also evident if you see the default config files (.yaml) provided by Detectron2 for many pre-trained models which have several settings for the parameters used by these two basic augmentations.
If you want to be absolutely certain about the kind of augmentations being applied during training and inference, please check the logs after you instantiate your custom trainer class. The logs will contain a line such as the following:
[05/22 13:03:06 d2.data.dataset_mapper]: [DatasetMapper] Augmentations used in inference: [ResizeShortestEdge(short_edge_length=(800, 800), max_size=1333, sample_style='choice')]
Upvotes: 0