Package: tfops-aug
TFOps-Aug: Implementation of policy-based image augmentation techniques based on TF2 OperationsThe principle for the augmentation mechanism ofTFOps-Augrelies on Google's AutoAugment paper "Learning
Augmentation Policies from Data" [1]. This repository implements the augmentation policy logic and many of the
augmentation functions. Like in the original implementation, the augmentation procedure is defined as a policy,
which consists of several subpolicies and operations.The augmentation operations rely on Tensorflow 2 operations which allow scalability and high computational throughput
even with large images. Furthermore, the augmentation pipeline can be easily integrated into thetf.dataAPI, because
all operations rely on Tensorflow operations and can be execute on image representations of typetf.Tensor. Currently,
only image representations of typetf.uint8are supported.InstallationThe package is available onpypi.organd can be installed withpip:pipinstalltfops-augExample for an augmentation policypolicy={'sub_policy0':{'op0':['adjust_saturation',0.2,2],'op1':['equalize',0.1,6],'op2':['add_noise',0.9,6]},'sub_policy1':{'op0':['adjust_contrast',0.1,7],'op1':['add_noise',0.0,10]},'sub_policy2':{'op0':['posterize',0.9,6],'op1':['unbiased_gamma_sampling',0.5,1]},'sub_policy3':{'op0':['adjust_brightness',0.3,1],'op1':['adjust_hue',0.4,5]},'sub_policy4':{'op0':['adjust_saturation',0.2,9],'op1':['add_noise',0.1,0]},'sub_policy5':{'op0':['adjust_contrast',1.0,1],'op1':['unbiased_gamma_sampling',0.4,9]},'sub_policy6':{'op0':['unbiased_gamma_sampling',0.3,0],'op1':['adjust_hue',0.1,6]},'sub_policy7':{'op0':['solarize',0.6,0],'op1':['adjust_gamma',0.3,6]},'sub_policy8':{'op0':['adjust_jpeg_quality',0.7,10],'op1':['adjust_hue',0.1,2]},'sub_policy9':{'op0':['equalize',0.6,0],'op1':['solarize',0.0,6]}}Similar to Google's AutoAugment, a single augmentation policy consists of several subpolicies, which in turn consists of
one or more augmentation operation. Each operation is defined as a tuple ofaugmentation method,probabilityandintensity. Several operations within one subpolicy are applied in sequence.
The augmentation policy from above would augment theoriginal imageto the following output:UsageA full example script for image classification can be found inclassification_example.py.
This excerpt demonstrates the simplicity for the usage of the augmentation methods:importtensorflowastffromtfops_aug.augmentation_utilsimportapply_augmentation_policydefaugmentor_func(img,label):img=apply_augmentation_policy(img,policy)returnimg,labeltrain_dataset=tf.keras.preprocessing.image_dataset_from_directory("PetImages",subset="training",image_size=(180,180),batch_size=1).unbatch()train_dataset=train_dataset.map(augmentor_func).batch(32).prefetch(32)Augmentation MethodsA list of all implemented augmentation techniques is given here. Additional, methods will be implemented in the near
future. Performance is measured with thetest_image.jpgwhich has size2048 x 1024. All augmentation methods are
executed withlevel=5. Averaged over 500 samples on the Intel Core i7 Prozessor 8665U.AugmentationImagePerformance (per Image)Additive Gaussian Noise0.02 sAdjust Brightness0.01 sAdjust Contrast0.02 sAdjust Gamma0.02 sAdjust Hue0.01 sAdjust JPEG Quality0.035 sAdjust Saturation0.02 sHistogramm Equalization0.04 sInvert0.01 sPosterize0.02 sSolarize0.01 sUnbiased Gamma Sampling0.02 sGaussian Blur0.14 sSharpen0.05 sShear X0.04 sShear Y0.04 sTranslate X0.05 sTranslate Y0.05 sReference[1] AutoAugment: Learning Augmentation Policies from Data - 2019
    Ekin Dogus Cubuk and Barret Zoph and Dandelion Mane and Vijay Vasudevan and Quoc V. Le
    https://arxiv.org/pdf/1805.09501.pdfTODOMore Augmentation MethodsShear XShear YTranslate XTranslate YRandom TranslationRandom RotationMake augmentation min and max values configurableImplement Learning PipelineImplement augmentation policies identical to these in [1]Implement augmentation policy search with Ray TuneClean up Code (Unified Docstrings)Create Python packageSupport image representation types, other thanuint8