Aug volume
VolumeAugmentation
¤
The Volume Augmentation class performs diverse augmentation methods on given numpy array. The class acts as an easy to use function/interface for applying all types of augmentations with just one function call.
The class can be configured beforehand by selecting desired augmentation techniques and method ranges or strength. Afterwards, the class is passed to the DataGenerator which utilizes it during batch generation.
The specific configurations of selected methods can be adjusted by class variables.
Build on top of the library
Volumentations based on albumentations.
volumentations: Originally developed by @ashawkey and @ZFTurbo.
Initially inspired by albumentations library for augmentation of 2D images.
https://github.com/muellerdo/volumentations
https://github.com/ZFTurbo/volumentations
https://github.com/ashawkey/volumentations
albumentations: https://github.com/albumentations-team/albumentations
The Volumentations package was further continued by us to ensure ongoing development and support.
For more details, please read the README under: https://github.com/muellerdo/volumentations
Source code in aucmedi/data_processing/augmentation/aug_volume.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
|
__init__(flip=True, rotate=True, brightness=True, contrast=True, saturation=True, hue=True, scale=True, crop=False, grid_distortion=False, compression=False, gaussian_noise=False, gaussian_blur=False, downscaling=False, gamma=False, elastic_transform=False)
¤
Initialization function for the Volume Augmentation interface.
With boolean switches, it is possible to selected desired augmentation techniques. Recommended augmentation configurations are defined as class variables. Of course, these configs can be adjusted if needed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
flip |
bool
|
Boolean, whether flipping should be performed as data augmentation. |
True
|
rotate |
bool
|
Boolean, whether rotations should be performed as data augmentation. |
True
|
brightness |
bool
|
Boolean, whether brightness changes should be added as data augmentation. |
True
|
contrast |
bool
|
Boolean, whether contrast changes should be added as data augmentation. |
True
|
saturation |
bool
|
Boolean, whether saturation changes should be added as data augmentation. |
True
|
hue |
bool
|
Boolean, whether hue changes should be added as data augmentation. |
True
|
scale |
bool
|
Boolean, whether scaling should be performed as data augmentation. |
True
|
crop |
bool
|
Boolean, whether scaling cropping be performed as data augmentation. |
False
|
grid_distortion |
bool
|
Boolean, whether grid_distortion should be performed as data augmentation. |
False
|
compression |
bool
|
Boolean, whether compression should be performed as data augmentation. |
False
|
gaussian_noise |
bool
|
Boolean, whether gaussian noise should be added as data augmentation. |
False
|
gaussian_blur |
bool
|
Boolean, whether gaussian blur should be added as data augmentation. |
False
|
downscaling |
bool
|
Boolean, whether downscaling should be added as data augmentation. |
False
|
gamma |
bool
|
Boolean, whether gamma changes should be added as data augmentation. |
False
|
elastic_transform |
bool
|
Boolean, whether elastic deformation should be performed as data augmentation. |
False
|
Warning
If class variables (attributes) are modified, the internal augmentation operator has to be rebuild via the following call:
# initialize
aug = VolumeAugmentation(flip=True)
# set probability to 100% = always
aug.aug_flip_p = 1.0
# rebuild
aug.build()
Attributes:
Name | Type | Description |
---|---|---|
refine |
bool
|
Boolean, whether clipping to [0,255] and padding/cropping should be performed if outside of range. |
aug_flip_p |
float
|
Probability of flipping application if activated. Default=0.5. |
aug_rotate_p |
float
|
Probability of rotation application if activated. Default=0.5. |
aug_brightness_p |
float
|
Probability of brightness application if activated. Default=0.5. |
aug_contrast_p |
float
|
Probability of contrast application if activated. Default=0.5. |
aug_saturation_p |
float
|
Probability of saturation application if activated. Default=0.5. |
aug_hue_p |
float
|
Probability of hue application if activated. Default=0.5. |
aug_scale_p |
float
|
Probability of scaling application if activated. Default=0.5. |
aug_crop_p |
float
|
Probability of crop application if activated. Default=0.5. |
aug_grid_distortion_p |
float
|
Probability of grid_distortion application if activated. Default=0.5. |
aug_compression_p |
float
|
Probability of compression application if activated. Default=0.5. |
aug_gaussianNoise_p |
float
|
Probability of gaussian noise application if activated. Default=0.5. |
aug_gaussianBlur_p |
float
|
Probability of gaussian blur application if activated. Default=0.5. |
aug_downscaling_p |
float
|
Probability of downscaling application if activated. Default=0.5. |
aug_gamma_p |
float
|
Probability of gamma application if activated. Default=0.5. |
aug_elasticTransform_p |
float
|
Probability of elastic deformation application if activated. Default=0.5. |
Source code in aucmedi/data_processing/augmentation/aug_volume.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
build()
¤
Builds the albumenations augmentator by initializing all transformations.
The activated transformation and their configurations are defined as class variables.
-> Builds a new self.operator
Source code in aucmedi/data_processing/augmentation/aug_volume.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
|