{"id":13578440,"url":"https://github.com/qubvel/tta_wrapper","last_synced_at":"2025-04-15T01:11:00.218Z","repository":{"id":46042375,"uuid":"146309454","full_name":"qubvel/tta_wrapper","owner":"qubvel","description":"Test Time image Augmentation (TTA) wrapper for Keras model.","archived":false,"fork":false,"pushed_at":"2022-01-06T07:10:28.000Z","size":26,"stargazers_count":112,"open_issues_count":5,"forks_count":18,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-28T13:05:43.094Z","etag":null,"topics":["augmentation","image-classification","image-segmentation","keras","tensorflow","tta","tta-wrapper"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qubvel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-27T14:32:03.000Z","updated_at":"2025-01-15T12:35:58.000Z","dependencies_parsed_at":"2022-08-30T21:21:00.831Z","dependency_job_id":null,"html_url":"https://github.com/qubvel/tta_wrapper","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qubvel%2Ftta_wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qubvel%2Ftta_wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qubvel%2Ftta_wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qubvel%2Ftta_wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qubvel","download_url":"https://codeload.github.com/qubvel/tta_wrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248986312,"owners_count":21194025,"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","image-classification","image-segmentation","keras","tensorflow","tta","tta-wrapper"],"created_at":"2024-08-01T15:01:30.669Z","updated_at":"2025-04-15T01:11:00.199Z","avatar_url":"https://github.com/qubvel.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"[![PyPI version](https://badge.fury.io/py/tta-wrapper.svg)](https://badge.fury.io/py/tta-wrapper)\n# TTA wrapper\nTest time augmnentation wrapper for keras image segmentation and classification models.\n\n## Description\n\n### How it works?\n\nWrapper add augmentation layers to your Keras model like this:\n\n```\n          Input\n            |           # input image; shape 1, H, W, C\n       / / / \\ \\ \\      # duplicate image for augmentation; shape N, H, W, C\n      | | |   | | |     # apply augmentations (flips, rotation, shifts)\n     your Keras model\n      | | |   | | |     # reverse transformations\n       \\ \\ \\ / / /      # merge predictions (mean, max, gmean)\n            |           # output mask; shape 1, H, W, C\n          Output\n```\n\n### Arguments\n\n  - `h_flip` - bool, horizontal flip augmentation\n  - `v_flip` - bool, vertical flip augmentation\n  - `rotataion` - list, allowable angles - 90, 180, 270\n  - `h_shift` - list of int, horizontal shift augmentation in pixels\n  - `v_shift` - list of int, vertical shift augmentation in pixels\n  - `add` - list of int/float, additive factor (aug_image = image + factor)\n  - `mul` - list of int/float, additive factor (aug_image = image * factor)\n  - `contrast` - list of int/float, contrast adjustment factor (aug_image = (image - mean) * factor + mean)\n  - `merge` - one of 'mean', 'gmean' and 'max' - mode of merging augmented predictions together\n  \n### Constraints\n  1) model has to have 1 `input` and 1 `output`\n  2) inference `batch_size == 1`\n  3) image `height == width` if `rotation` augmentation is used\n\n### Installation\n1) **PyPI package**:\n```bash\n$ pip install tta-wrapper\n```\n2) **Latest version**:\n```bash\n$ pip install git+https://github.com/qubvel/tta_wrapper/\n```\n\n## Example\n```python\nfrom keras.models import load_model\nfrom tta_wrapper import tta_segmentation\n\nmodel = load_model('path/to/model.h5')\ntta_model = tta_segmentation(model, h_flip=True, rotation=(90, 270), \n                             h_shift=(-5, 5), merge='mean')\ny = tta_model.predict(x)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqubvel%2Ftta_wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqubvel%2Ftta_wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqubvel%2Ftta_wrapper/lists"}