From 4bb293dddc1e8699c1ad9f49b0a15ee1d857daa6 Mon Sep 17 00:00:00 2001 From: Kai Chen <chenkaidev@gmail.com> Date: Sun, 10 Mar 2019 22:34:43 -0700 Subject: [PATCH] allow specifying multi-scale random mode --- mmdet/datasets/custom.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mmdet/datasets/custom.py b/mmdet/datasets/custom.py index 2ab3be9..38abe05 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() -- GitLab