@@ -83,6 +83,7 @@ def transforms_imagenet_train(
8383
8484 Args:
8585 img_size: Target image size.
86+ train_crop_mode: Training random crop mode ('rrc', 'rkrc', 'rkrr').
8687 scale: Random resize scale range (crop area, < 1.0 => zoom in).
8788 ratio: Random aspect ratio range (crop ratio for RRC, ratio adjustment factor for RKR).
8889 hflip: Horizontal flip probability.
@@ -112,6 +113,7 @@ def transforms_imagenet_train(
112113 * normalizes and converts the branches above with the third, final transform
113114 """
114115 train_crop_mode = train_crop_mode or 'rrc'
116+ assert train_crop_mode in {'rrc' , 'rkrc' , 'rkrr' }
115117 if train_crop_mode in ('rkrc' , 'rkrr' ):
116118 # FIXME integration of RKR is a WIP
117119 scale = tuple (scale or (0.8 , 1.00 ))
@@ -318,6 +320,7 @@ def create_transform(
318320 input_size : Union [int , Tuple [int , int ], Tuple [int , int , int ]] = 224 ,
319321 is_training : bool = False ,
320322 no_aug : bool = False ,
323+ train_crop_mode : Optional [str ] = None ,
321324 scale : Optional [Tuple [float , float ]] = None ,
322325 ratio : Optional [Tuple [float , float ]] = None ,
323326 hflip : float = 0.5 ,
@@ -347,6 +350,7 @@ def create_transform(
347350 input_size: Target input size (channels, height, width) tuple or size scalar.
348351 is_training: Return training (random) transforms.
349352 no_aug: Disable augmentation for training (useful for debug).
353+ train_crop_mode: Training random crop mode ('rrc', 'rkrc', 'rkrr').
350354 scale: Random resize scale range (crop area, < 1.0 => zoom in).
351355 ratio: Random aspect ratio range (crop ratio for RRC, ratio adjustment factor for RKR).
352356 hflip: Horizontal flip probability.
@@ -400,6 +404,7 @@ def create_transform(
400404 elif is_training :
401405 transform = transforms_imagenet_train (
402406 img_size ,
407+ train_crop_mode = train_crop_mode ,
403408 scale = scale ,
404409 ratio = ratio ,
405410 hflip = hflip ,
0 commit comments