@@ -63,11 +63,15 @@ def imgaug_transform(params_dict: dict | DictConfig) -> iaa.Sequential:
63
63
transform_args = args .get ("args" , ())
64
64
transform_kwargs = args .get ("kwargs" , {})
65
65
66
- # make sure any lists are converted to tuples; DictConfig cannot load tuples from yaml
67
- # files, but no iaa args are lists
66
+ # DictConfig cannot load tuples from yaml files
67
+ # make sure any lists are converted to tuples
68
+ # unless the list contains a single item, then pass through the item (hack for Rot90)
68
69
for kw , arg in transform_kwargs .items ():
69
70
if isinstance (arg , list ) or isinstance (arg , ListConfig ):
70
- transform_kwargs [kw ] = tuple (arg )
71
+ if len (arg ) == 1 :
72
+ transform_kwargs [kw ] = arg [0 ]
73
+ else :
74
+ transform_kwargs [kw ] = tuple (arg )
71
75
72
76
# add transform to pipeline
73
77
if apply_prob == 0.0 :
@@ -91,13 +95,13 @@ def expand_imgaug_str_to_dict(params: str) -> dict[str, Any]:
91
95
pass # no augmentations
92
96
elif params in ["dlc" , "dlc-lr" , "dlc-top-down" ]:
93
97
94
- # flip horizontally
95
- if params in ["dlc-lr" , "dlc-top-down" ]:
96
- params_dict ["Fliplr " ] = {"p" : 1.0 , "kwargs" : {"p " : 0.5 }}
98
+ # rotate 0 or 180 degrees
99
+ if params in ["dlc-lr" ]:
100
+ params_dict ["Rot90 " ] = {"p" : 1.0 , "kwargs" : {"k " : [[ 0 , 2 ]] }}
97
101
98
- # flip vertically
102
+ # rotate 0, 90, 180, or 270 degrees
99
103
if params in ["dlc-top-down" ]:
100
- params_dict ["Flipud " ] = {"p" : 1.0 , "kwargs" : {"p " : 0.5 }}
104
+ params_dict ["Rot90 " ] = {"p" : 1.0 , "kwargs" : {"k " : [[ 0 , 1 , 2 , 3 ]] }}
101
105
102
106
# rotate
103
107
rotation = 25 # rotation uniformly sampled from (-rotation, +rotation)
0 commit comments