"git@developer.sourcefind.cn:change/sglang.git" did not exist on "5c0efa562bb2370b2172cb4b79b356a85d93f809"
Unverified Commit a3c8ddf7 authored by Kai Chen's avatar Kai Chen Committed by GitHub
Browse files

Merge pull request #391 from hellock/master

allow specifying multi-scale random mode
parents 189d6097 4bb293dd
...@@ -40,6 +40,7 @@ class CustomDataset(Dataset): ...@@ -40,6 +40,7 @@ class CustomDataset(Dataset):
img_prefix, img_prefix,
img_scale, img_scale,
img_norm_cfg, img_norm_cfg,
multiscale_mode='value',
size_divisor=None, size_divisor=None,
proposal_file=None, proposal_file=None,
num_max_proposals=1000, num_max_proposals=1000,
...@@ -73,6 +74,10 @@ class CustomDataset(Dataset): ...@@ -73,6 +74,10 @@ class CustomDataset(Dataset):
# normalization configs # normalization configs
self.img_norm_cfg = img_norm_cfg 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 # max proposals per image
self.num_max_proposals = num_max_proposals self.num_max_proposals = num_max_proposals
# flip ratio # flip ratio
...@@ -196,7 +201,8 @@ class CustomDataset(Dataset): ...@@ -196,7 +201,8 @@ class CustomDataset(Dataset):
# apply transforms # apply transforms
flip = True if np.random.rand() < self.flip_ratio else False 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_shape, pad_shape, scale_factor = self.img_transform(
img, img_scale, flip, keep_ratio=self.resize_keep_ratio) img, img_scale, flip, keep_ratio=self.resize_keep_ratio)
img = img.copy() img = img.copy()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment