{"id":20585383,"url":"https://github.com/tillbeemelmanns/tfops-aug","last_synced_at":"2026-01-02T04:44:54.837Z","repository":{"id":64676211,"uuid":"257395646","full_name":"TillBeemelmanns/tfops-aug","owner":"TillBeemelmanns","description":"TFOps-Aug: Implementation of policy-based image augmentation techniques based on TF2 Operations. All augmentations as efficient Tensorflow 2.11.0 operations. Easy integration into a tf.data API pipeline.","archived":false,"fork":false,"pushed_at":"2022-12-12T18:58:04.000Z","size":57933,"stargazers_count":14,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-15T03:44:44.244Z","etag":null,"topics":["augmentation-libraries","augmentation-methods","augmentation-operation","augmentation-policy","google-autoaugment","keras","tf2"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TillBeemelmanns.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-20T20:26:33.000Z","updated_at":"2024-02-04T12:38:43.000Z","dependencies_parsed_at":"2022-12-13T23:37:07.551Z","dependency_job_id":null,"html_url":"https://github.com/TillBeemelmanns/tfops-aug","commit_stats":null,"previous_names":["tillbeemelmanns/auto-augment-tf2-operations"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TillBeemelmanns%2Ftfops-aug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TillBeemelmanns%2Ftfops-aug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TillBeemelmanns%2Ftfops-aug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TillBeemelmanns%2Ftfops-aug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TillBeemelmanns","download_url":"https://codeload.github.com/TillBeemelmanns/tfops-aug/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224885694,"owners_count":17386202,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["augmentation-libraries","augmentation-methods","augmentation-operation","augmentation-policy","google-autoaugment","keras","tf2"],"created_at":"2024-11-16T07:07:51.149Z","updated_at":"2026-01-02T04:44:54.775Z","avatar_url":"https://github.com/TillBeemelmanns.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TFOps-Aug: Implementation of policy-based image augmentation techniques based on TF2 Operations\n\nThe principle for the augmentation mechanism of __TFOps-Aug__ relies on Google's AutoAugment paper \"Learning\nAugmentation Policies from Data\" [1]. This repository implements the augmentation policy logic and many of the\naugmentation functions. Like in the original implementation, the augmentation procedure is defined as a policy,\nwhich consists of several subpolicies and operations.\n \nThe augmentation operations rely on Tensorflow 2 operations which allow scalability and high computational throughput\neven with large images. Furthermore, the augmentation pipeline can be easily integrated into the `tf.data` API, because\nall operations rely on Tensorflow operations and can be execute on image representations of type `tf.Tensor`. Currently,\nonly image representations of type `tf.uint8` are supported.\n\n\n### Installation\nThe package is available on [pypi.org](https://pypi.org/project/tfops-aug/) and can be installed with `pip`:\n\n```bash\npip install tfops-aug\n```\n\n\n### Example for an augmentation policy\n```python\npolicy = {'sub_policy0': {'op0': ['adjust_saturation', 0.2, 2],\n                          'op1': ['equalize', 0.1, 6],\n                          'op2': ['add_noise', 0.9, 6]},\n          'sub_policy1': {'op0': ['adjust_contrast', 0.1, 7],\n                          'op1': ['add_noise', 0.0, 10]},\n          'sub_policy2': {'op0': ['posterize', 0.9, 6],\n                          'op1': ['unbiased_gamma_sampling', 0.5, 1]},\n          'sub_policy3': {'op0': ['adjust_brightness', 0.3, 1],\n                          'op1': ['adjust_hue', 0.4, 5]},\n          'sub_policy4': {'op0': ['adjust_saturation', 0.2, 9],\n                          'op1': ['add_noise', 0.1, 0]},\n          'sub_policy5': {'op0': ['adjust_contrast', 1.0, 1],\n                          'op1': ['unbiased_gamma_sampling', 0.4, 9]},\n          'sub_policy6': {'op0': ['unbiased_gamma_sampling', 0.3, 0],\n                          'op1': ['adjust_hue', 0.1, 6]},\n          'sub_policy7': {'op0': ['solarize', 0.6, 0],\n                          'op1': ['adjust_gamma', 0.3, 6]},\n          'sub_policy8': {'op0': ['adjust_jpeg_quality', 0.7, 10],\n                          'op1': ['adjust_hue', 0.1, 2]},\n          'sub_policy9': {'op0': ['equalize', 0.6, 0],\n                          'op1': ['solarize', 0.0, 6]}}\n```\n\nSimilar to Google's AutoAugment, a single augmentation policy consists of several subpolicies, which in turn consists of\none or more augmentation operation. Each operation is defined as a tuple of **augmentation method**, \n**probability** and **intensity**. Several operations within one subpolicy are applied in sequence. \nThe augmentation policy from above would augment the [original image](assets/test_image.jpg) to the following output:\n \n![](assets/augmentation_policy.gif)\n\n### Usage\nA full example script for image classification can be found in [classification_example.py](utils/classification_example.py).\nThis excerpt demonstrates the simplicity for the usage of the augmentation methods:\n```python\nimport tensorflow as tf\n\nfrom tfops_aug.augmentation_utils import apply_augmentation_policy\n\ndef augmentor_func(img, label):\n    img = apply_augmentation_policy(img, policy)\n    return img, label\n\ntrain_dataset = tf.keras.preprocessing.image_dataset_from_directory(\n    \"PetImages\",\n    subset=\"training\",\n    image_size=(180, 180),\n    batch_size=1\n).unbatch()\n\ntrain_dataset = train_dataset.map(augmentor_func).batch(32).prefetch(32)\n```\n\n\n### Augmentation Methods\nA list of all implemented augmentation techniques is given here. Additional, methods will be implemented in the near \nfuture. Performance is measured with the `test_image.jpg` which has size `2048 x 1024`. All augmentation methods are \nexecuted with `level=5`. Averaged over 500 samples on the Intel Core i7 Prozessor 8665U.\n\n| Augmentation   |      Image      | Performance (per Image) |\n|----------|:-------------|:-----------------------:|\n| Additive Gaussian Noise | ![](assets/add_noise.gif) |         0.02 s          |\n| Adjust Brightness | ![](assets/adjust_brightness.gif) |         0.01 s          |\n| Adjust Contrast | ![](assets/adjust_contrast.gif) |         0.02 s          |\n| Adjust Gamma | ![](assets/adjust_gamma.gif) |         0.02 s          |\n| Adjust Hue | ![](assets/adjust_hue.gif) |         0.01 s          |\n| Adjust JPEG Quality | ![](assets/adjust_jpeg_quality.gif) |         0.035 s         |\n| Adjust Saturation | ![](assets/adjust_saturation.gif) |         0.02 s          |\n| Histogramm Equalization | ![](assets/equalize.gif) |         0.04 s          |\n| Invert | ![](assets/invert.gif) |         0.01 s          |\n| Posterize | ![](assets/posterize.gif) |         0.02 s          |\n| Solarize | ![](assets/solarize.gif) |         0.01 s          |\n| Unbiased Gamma Sampling | ![](assets/unbiased_gamma_sampling.gif) |         0.02 s          |\n| Gaussian Blur | ![](assets/gaussian_blur.gif) |         0.14 s          |\n| Sharpen | ![](assets/sharpen.gif) |         0.05 s          |\n| Shear X | ![](assets/shear_x.gif) |         0.04 s          |\n| Shear Y | ![](assets/shear_y.gif) |         0.04 s          |\n| Translate X | ![](assets/translate_x.gif) |         0.05 s          |\n| Translate Y | ![](assets/translate_y.gif) |         0.05 s          |\n\n### Reference\n\n```\n[1] AutoAugment: Learning Augmentation Policies from Data - 2019\n    Ekin Dogus Cubuk and Barret Zoph and Dandelion Mane and Vijay Vasudevan and Quoc V. Le\n    https://arxiv.org/pdf/1805.09501.pdf\n```\n\n### TODO\n- [ ] More Augmentation Methods\n    - [X] Shear X\n    - [X] Shear Y\n    - [X] Translate X\n    - [X] Translate Y\n    - [ ] Random Translation\n    - [ ] Random Rotation\n- [ ] Make augmentation min and max values configurable\n- [X] Implement Learning Pipeline\n- [ ] Implement augmentation policies identical to these in [1]\n- [ ] Implement augmentation policy search with Ray Tune\n- [ ] Clean up Code (Unified Docstrings)\n- [X] Create Python package\n- [ ] Support image representation types, other than `uint8`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftillbeemelmanns%2Ftfops-aug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftillbeemelmanns%2Ftfops-aug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftillbeemelmanns%2Ftfops-aug/lists"}