diff --git a/mmdet/datasets/custom.py b/mmdet/datasets/custom.py index 2ab3be99d07f6517f9370f43994d22d8d374818b..38abe05889cc73ba8eaa9ee9e9e5c51167581f69 100644 --- a/mmdet/datasets/custom.py +++ b/mmdet/datasets/custom.py @@ -40,6 +40,7 @@ class CustomDataset(Dataset): img_prefix, img_scale, img_norm_cfg, + multiscale_mode='value', size_divisor=None, proposal_file=None, num_max_proposals=1000, @@ -73,6 +74,10 @@ class CustomDataset(Dataset): # normalization configs self.img_norm_cfg = img_norm_cfg + # multi-scale mode (only applicable for multi-scale training) + self.multiscale_mode = multiscale_mode + assert multiscale_mode in ['value', 'range'] + # max proposals per image self.num_max_proposals = num_max_proposals # flip ratio @@ -196,7 +201,8 @@ class CustomDataset(Dataset): # apply transforms flip = True if np.random.rand() < self.flip_ratio else False - img_scale = random_scale(self.img_scales) # sample a scale + # randomly sample a scale + img_scale = random_scale(self.img_scales, self.multiscale_mode) img, img_shape, pad_shape, scale_factor = self.img_transform( img, img_scale, flip, keep_ratio=self.resize_keep_ratio) img = img.copy()