Skip to content

Commit

Permalink
Merge pull request #391 from hellock/master
Browse files Browse the repository at this point in the history
allow specifying multi-scale random mode
  • Loading branch information
hellock authored Mar 12, 2019
2 parents 189d609 + 4bb293d commit a3c8ddf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion mmdet/datasets/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(self,
img_prefix,
img_scale,
img_norm_cfg,
multiscale_mode='value',
size_divisor=None,
proposal_file=None,
num_max_proposals=1000,
Expand Down Expand Up @@ -73,6 +74,10 @@ def __init__(self,
# 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
Expand Down Expand Up @@ -196,7 +201,8 @@ def prepare_train_img(self, idx):

# 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()
Expand Down

0 comments on commit a3c8ddf

Please sign in to comment.