semantic-segmentation-augmentations


Namesemantic-segmentation-augmentations JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://github.com/ruescog/semantic_segmentation_augmentations
SummaryA library to apply some data augmentations in semantic segmentation problems
upload_time2023-01-11 09:03:22
maintainer
docs_urlNone
authorruescog
requires_python>=3.7
licenseApache Software License 2.0
keywords nbdev jupyter notebook python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            semantic_segmentation_augmentations
================

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

Data augmentation is a regularisation technique that generates new
training samples from the original dataset by applying colour or
geometric transformations. Although this technique has been applied in
other computer vision fields, such as image classification or object
detection, the application of this technique in semantic segmentation is
not yet widespread.

This library groups some data augmentation techniques for semantic
augmentation, such as `CutOut` or `CutMix`.

# Install

To install the library, run:

``` sh
pip install semantic_segmentation_augmentations
```

# How it works

This data augmentation techniques are defined as `fastai` `callbacks`.
Given this fact, you need to train your models using `fastai`’s API to
use them.

As these techniques modifies the input image changing some pixels
regions for something else, those callbacks have been defined as the
union of two subcomponents: the
[`HoleMakerTechnique`](https://ruescog.github.io/semantic_segmentation_augmentations/iholemakertechnique.html#holemakertechnique),
that defines how to make the hole (how to select the region to replace)
and the
[`HolesFilling`](https://ruescog.github.io/semantic_segmentation_augmentations/iholesfilling.html#holesfilling),
that defines how to fill the region defined below (the way to fill the
region gives the name to the technique used).

The
[`HoleMakerTechnique`](https://ruescog.github.io/semantic_segmentation_augmentations/iholemakertechnique.html#holemakertechnique)
can be replaced in order to change the behavior of the selection of the
region to replace. Doing so, you can use a CutOut technique that select
the region randomly or based on the information bounded in that region.

You can also define your custom techniques defining how to fill a hole.
You just need to extend the
[`HolesFilling`](https://ruescog.github.io/semantic_segmentation_augmentations/iholesfilling.html#holesfilling)
class and define the `before_bacth` (remember: we are using `callbacks`
from `fastai`) abstract method. You will have two methods to simplify
the process: the `make_hole` function, that uses the selected
[`HoleMakerTechnique`](https://ruescog.github.io/semantic_segmentation_augmentations/iholemakertechnique.html#holemakertechnique)
to make the hole and returns two slices (the region boundaries) and the
`fill_hole` function, that fills the hole with something.

# How to use it

In order to use these techniques, you just need to define the `Learner`
from `fastai` with the `Callbacks` that represent the techniques that
you want to use.

For example, if you want to create an `U-net` `Leaner` with `resnet18`
backbone and use the CutOut technique with
[`HoleMakerRandom`](https://ruescog.github.io/semantic_segmentation_augmentations/holemakerrandom.html#holemakerrandom)
as region selection techinique (which is the default one), you just need
to import it:

``` sh
from semantic_segmentation_augmentations.holesfilling import CutOutRandom
```

And add it to your learner:

``` sh
learner = unet_learner(dls, resnet18, cbs = CutOutRandom(hole_maker = HoleMakerRandom()))
```

If you want to change the default behaviour of the CutOutRandom
technique (i. e. to select the region with a
[`HoleMakerAttention`](https://ruescog.github.io/semantic_segmentation_augmentations/holemakerattention.html#holemakerattention)
technique), you just need to define the technique as follows:

``` sh
learner = unet_learner(dls, resnet18, cbs = CutOutRandom(hole_maker = HoleMakerAttention(attention_threshold = 0.25, hole_size = (150, 150))))
```

Finally, you can apply geometrical augments to the selected regions
(using the `Albumentations` augments). Maybe this augmnets are not
useful with the `CutOut` techniques, but with the `CutMix` ones. In
order to do so, you just need to implement a
[`RegionModifier`](https://ruescog.github.io/semantic_segmentation_augmentations/regionmodifier.html#regionmodifier)
with a list with the augments to apply:

``` sh
learner = unet_learner( dls,
                        resnet18,
                        cbs = CutMixRandom( holes_num = 1,
                                            modifier = RegionModifier(A.Compose([A.Blur(), A.GaussNoise()])),
                                            hole_maker = HoleMakerRandom((250, 250)),
                                            p = 1
                        )
                      )
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ruescog/semantic_segmentation_augmentations",
    "name": "semantic-segmentation-augmentations",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "nbdev jupyter notebook python",
    "author": "ruescog",
    "author_email": "ruescog@unirioja.es",
    "download_url": "https://files.pythonhosted.org/packages/03/28/a9e3a3fb4012144632508db29250c2fdb7fdbd49d63fe82de44f19eb8daf/semantic_segmentation_augmentations-1.1.0.tar.gz",
    "platform": null,
    "description": "semantic_segmentation_augmentations\n================\n\n<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->\n\nData augmentation is a regularisation technique that generates new\ntraining samples from the original dataset by applying colour or\ngeometric transformations. Although this technique has been applied in\nother computer vision fields, such as image classification or object\ndetection, the application of this technique in semantic segmentation is\nnot yet widespread.\n\nThis library groups some data augmentation techniques for semantic\naugmentation, such as `CutOut` or `CutMix`.\n\n# Install\n\nTo install the library, run:\n\n``` sh\npip install semantic_segmentation_augmentations\n```\n\n# How it works\n\nThis data augmentation techniques are defined as `fastai` `callbacks`.\nGiven this fact, you need to train your models using `fastai`\u2019s API to\nuse them.\n\nAs these techniques modifies the input image changing some pixels\nregions for something else, those callbacks have been defined as the\nunion of two subcomponents: the\n[`HoleMakerTechnique`](https://ruescog.github.io/semantic_segmentation_augmentations/iholemakertechnique.html#holemakertechnique),\nthat defines how to make the hole (how to select the region to replace)\nand the\n[`HolesFilling`](https://ruescog.github.io/semantic_segmentation_augmentations/iholesfilling.html#holesfilling),\nthat defines how to fill the region defined below (the way to fill the\nregion gives the name to the technique used).\n\nThe\n[`HoleMakerTechnique`](https://ruescog.github.io/semantic_segmentation_augmentations/iholemakertechnique.html#holemakertechnique)\ncan be replaced in order to change the behavior of the selection of the\nregion to replace. Doing so, you can use a CutOut technique that select\nthe region randomly or based on the information bounded in that region.\n\nYou can also define your custom techniques defining how to fill a hole.\nYou just need to extend the\n[`HolesFilling`](https://ruescog.github.io/semantic_segmentation_augmentations/iholesfilling.html#holesfilling)\nclass and define the `before_bacth` (remember: we are using `callbacks`\nfrom `fastai`) abstract method. You will have two methods to simplify\nthe process: the `make_hole` function, that uses the selected\n[`HoleMakerTechnique`](https://ruescog.github.io/semantic_segmentation_augmentations/iholemakertechnique.html#holemakertechnique)\nto make the hole and returns two slices (the region boundaries) and the\n`fill_hole` function, that fills the hole with something.\n\n# How to use it\n\nIn order to use these techniques, you just need to define the `Learner`\nfrom `fastai` with the `Callbacks` that represent the techniques that\nyou want to use.\n\nFor example, if you want to create an `U-net` `Leaner` with `resnet18`\nbackbone and use the CutOut technique with\n[`HoleMakerRandom`](https://ruescog.github.io/semantic_segmentation_augmentations/holemakerrandom.html#holemakerrandom)\nas region selection techinique (which is the default one), you just need\nto import it:\n\n``` sh\nfrom semantic_segmentation_augmentations.holesfilling import CutOutRandom\n```\n\nAnd add it to your learner:\n\n``` sh\nlearner = unet_learner(dls, resnet18, cbs = CutOutRandom(hole_maker = HoleMakerRandom()))\n```\n\nIf you want to change the default behaviour of the CutOutRandom\ntechnique (i. e. to select the region with a\n[`HoleMakerAttention`](https://ruescog.github.io/semantic_segmentation_augmentations/holemakerattention.html#holemakerattention)\ntechnique), you just need to define the technique as follows:\n\n``` sh\nlearner = unet_learner(dls, resnet18, cbs = CutOutRandom(hole_maker = HoleMakerAttention(attention_threshold = 0.25, hole_size = (150, 150))))\n```\n\nFinally, you can apply geometrical augments to the selected regions\n(using the `Albumentations` augments). Maybe this augmnets are not\nuseful with the `CutOut` techniques, but with the `CutMix` ones. In\norder to do so, you just need to implement a\n[`RegionModifier`](https://ruescog.github.io/semantic_segmentation_augmentations/regionmodifier.html#regionmodifier)\nwith a list with the augments to apply:\n\n``` sh\nlearner = unet_learner( dls,\n                        resnet18,\n                        cbs = CutMixRandom( holes_num = 1,\n                                            modifier = RegionModifier(A.Compose([A.Blur(), A.GaussNoise()])),\n                                            hole_maker = HoleMakerRandom((250, 250)),\n                                            p = 1\n                        )\n                      )\n```\n",
    "bugtrack_url": null,
    "license": "Apache Software License 2.0",
    "summary": "A library to apply some data augmentations in semantic segmentation problems",
    "version": "1.1.0",
    "split_keywords": [
        "nbdev",
        "jupyter",
        "notebook",
        "python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "acf922e63c512703240fd15787e2b15133e6158afa55048acfabaae1442465ec",
                "md5": "a7a25456114975ec08a2c79a5561b4a3",
                "sha256": "da3815320bb57707183a88f3dd36129359513cd1124e4e06f55d3162bb3d0fa6"
            },
            "downloads": -1,
            "filename": "semantic_segmentation_augmentations-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a7a25456114975ec08a2c79a5561b4a3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 31999,
            "upload_time": "2023-01-11T09:03:20",
            "upload_time_iso_8601": "2023-01-11T09:03:20.731309Z",
            "url": "https://files.pythonhosted.org/packages/ac/f9/22e63c512703240fd15787e2b15133e6158afa55048acfabaae1442465ec/semantic_segmentation_augmentations-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0328a9e3a3fb4012144632508db29250c2fdb7fdbd49d63fe82de44f19eb8daf",
                "md5": "01e428ccd49a19ffc92d0d0e311e6e9c",
                "sha256": "e00140317a8f2ba958a65a5a7be6f0fc19581bdf9927da508ce19c053f19a47b"
            },
            "downloads": -1,
            "filename": "semantic_segmentation_augmentations-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "01e428ccd49a19ffc92d0d0e311e6e9c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 18275,
            "upload_time": "2023-01-11T09:03:22",
            "upload_time_iso_8601": "2023-01-11T09:03:22.578727Z",
            "url": "https://files.pythonhosted.org/packages/03/28/a9e3a3fb4012144632508db29250c2fdb7fdbd49d63fe82de44f19eb8daf/semantic_segmentation_augmentations-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-11 09:03:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "ruescog",
    "github_project": "semantic_segmentation_augmentations",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "semantic-segmentation-augmentations"
}
        
Elapsed time: 0.32194s