Skip to content

Commit a3c8ddf

Browse files
authored
Merge pull request open-mmlab#391 from hellock/master
allow specifying multi-scale random mode
2 parents 189d609 + 4bb293d commit a3c8ddf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

mmdet/datasets/custom.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def __init__(self,
4040
img_prefix,
4141
img_scale,
4242
img_norm_cfg,
43+
multiscale_mode='value',
4344
size_divisor=None,
4445
proposal_file=None,
4546
num_max_proposals=1000,
@@ -73,6 +74,10 @@ def __init__(self,
7374
# normalization configs
7475
self.img_norm_cfg = img_norm_cfg
7576

77+
# multi-scale mode (only applicable for multi-scale training)
78+
self.multiscale_mode = multiscale_mode
79+
assert multiscale_mode in ['value', 'range']
80+
7681
# max proposals per image
7782
self.num_max_proposals = num_max_proposals
7883
# flip ratio
@@ -196,7 +201,8 @@ def prepare_train_img(self, idx):
196201

197202
# apply transforms
198203
flip = True if np.random.rand() < self.flip_ratio else False
199-
img_scale = random_scale(self.img_scales) # sample a scale
204+
# randomly sample a scale
205+
img_scale = random_scale(self.img_scales, self.multiscale_mode)
200206
img, img_shape, pad_shape, scale_factor = self.img_transform(
201207
img, img_scale, flip, keep_ratio=self.resize_keep_ratio)
202208
img = img.copy()

0 commit comments

Comments
 (0)