Skip to content

Commit

Permalink
Remove imgaug from requieres (#894)
Browse files Browse the repository at this point in the history
* Rollback IAAEmboss

* Rollback IAASharpen

* Rollback IAAPerspective

* Deprecation warnings

* Remove imgaug from install requires and add extra extra requires imgaug

* Ddd extra develop extra requires

* update deprecation warnings

* Update deprecation warnings and update README.md

* Change CI extra packages from tests to develop

* Add develop extra packages for CI docs tests
  • Loading branch information
Dipet authored May 19, 2021
1 parent b527fa9 commit cc8fbb6
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
if: matrix.operating-system == 'macos-latest'
run: pip install torch==1.7.1 torchvision==0.8.2
- name: Install dependencies
run: pip install .[tests]
run: pip install .[develop]
- name: Install linters
run: pip install flake8==3.8.4 flake8-docstrings==1.5.0 mypy==0.800
- name: Run PyTest
Expand Down Expand Up @@ -96,6 +96,6 @@ jobs:
- name: Update pip
run: python -m pip install --upgrade pip
- name: Install dependencies
run: pip install .
run: pip install .[develop]
- name: Run checks
run: python tools/make_transforms_docs.py check README.md
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@ Spatial-level transforms will simultaneously change both an input image as well
| [GridDistortion](https://albumentations.ai/docs/api_reference/augmentations/transforms/#albumentations.augmentations.transforms.GridDistortion) ||| | |
| [GridDropout](https://albumentations.ai/docs/api_reference/augmentations/transforms/#albumentations.augmentations.transforms.GridDropout) ||| | |
| [HorizontalFlip](https://albumentations.ai/docs/api_reference/augmentations/transforms/#albumentations.augmentations.transforms.HorizontalFlip) |||||
| [IAAAffine](https://albumentations.ai/docs/api_reference/imgaug/transforms/#albumentations.imgaug.transforms.IAAAffine) |||||
| [IAAPiecewiseAffine](https://albumentations.ai/docs/api_reference/imgaug/transforms/#albumentations.imgaug.transforms.IAAPiecewiseAffine) |||||
| [Lambda](https://albumentations.ai/docs/api_reference/augmentations/transforms/#albumentations.augmentations.transforms.Lambda) |||||
| [LongestMaxSize](https://albumentations.ai/docs/api_reference/augmentations/geometric/resize/#albumentations.augmentations.geometric.resize.LongestMaxSize) |||||
| [MaskDropout](https://albumentations.ai/docs/api_reference/augmentations/transforms/#albumentations.augmentations.transforms.MaskDropout) ||| | |
Expand Down
57 changes: 49 additions & 8 deletions albumentations/imgaug/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ def get_transform_init_args_names(self):


class IAAFliplr(DualIAATransform):
"""This augmentation is deprecated. Please use HorizontalFlip instead."""

def __init__(self, always_apply=False, p=0.5):
super().__init__(always_apply, p)
warnings.warn("IAAFliplr is deprecated. Please use HorizontalFlip instead.", FutureWarning)
Expand All @@ -122,6 +124,8 @@ def get_transform_init_args_names(self):


class IAAFlipud(DualIAATransform):
"""This augmentation is deprecated. Please use VerticalFlip instead."""

def __init__(self, always_apply=False, p=0.5):
super().__init__(always_apply, p)
warnings.warn("IAAFlipud is deprecated. Please use VerticalFlip instead.", FutureWarning)
Expand All @@ -134,7 +138,7 @@ def get_transform_init_args_names(self):
return ()


class IAAEmboss(Emboss):
class IAAEmboss(ImageOnlyIAATransform):
"""Emboss the input image and overlays the result with the original image.
This augmentation is deprecated. Please use Emboss instead.
Expand All @@ -149,14 +153,25 @@ class IAAEmboss(Emboss):
"""

def __init__(self, alpha=(0.2, 0.5), strength=(0.2, 0.7), always_apply=False, p=0.5):
warnings.warn("IAAEmboss is deprecated. Please use Emboss instead", FutureWarning)
super().__init__(alpha=alpha, strength=strength, always_apply=always_apply, p=p)
super(IAAEmboss, self).__init__(always_apply, p)
self.alpha = to_tuple(alpha, 0.0)
self.strength = to_tuple(strength, 0.0)
warnings.warn("This augmentation is deprecated. Please use Emboss instead", FutureWarning)

@property
def processor(self):
return iaa.Emboss(self.alpha, self.strength)

def get_transform_init_args_names(self):
return ("alpha", "strength")


class IAASuperpixels(ImageOnlyIAATransform):
"""Completely or partially transform the input image to its superpixel representation. Uses skimage's version
of the SLIC algorithm. May be slow.
This augmentation is deprecated. Please use Superpixels instead.
Args:
p_replace (float): defines the probability of any superpixel area being replaced by the superpixel, i.e. by
the average pixel color within its area. Default: 0.1.
Expand All @@ -181,7 +196,7 @@ def get_transform_init_args_names(self):
return ("p_replace", "n_segments")


class IAASharpen(Sharpen):
class IAASharpen(ImageOnlyIAATransform):
"""Sharpen the input image and overlays the result with the original image.
This augmentation is deprecated. Please use Sharpen instead
Args:
Expand All @@ -195,13 +210,24 @@ class IAASharpen(Sharpen):
"""

def __init__(self, alpha=(0.2, 0.5), lightness=(0.5, 1.0), always_apply=False, p=0.5):
super(IAASharpen, self).__init__(always_apply, p)
self.alpha = to_tuple(alpha, 0)
self.lightness = to_tuple(lightness, 0)
warnings.warn("IAASharpen is deprecated. Please use Sharpen instead", FutureWarning)
super().__init__(alpha=alpha, lightness=lightness, always_apply=always_apply, p=p)

@property
def processor(self):
return iaa.Sharpen(self.alpha, self.lightness)

def get_transform_init_args_names(self):
return ("alpha", "lightness")


class IAAAdditiveGaussianNoise(ImageOnlyIAATransform):
"""Add gaussian noise to the input image.
This augmentation is deprecated. Please use GaussNoise instead.
Args:
loc (int): mean of the normal distribution that generates the noise. Default: 0.
scale ((float, float)): standard deviation of the normal distribution that generates the noise.
Expand Down Expand Up @@ -231,6 +257,8 @@ class IAAPiecewiseAffine(DualIAATransform):
"""Place a regular grid of points on the input and randomly move the neighbourhood of these point around
via affine transformations.
This augmentation is deprecated. Please use PiecewiseAffine instead.
Note: This class introduce interpolation artifacts to mask if it has values other than {0;1}
Args:
Expand All @@ -253,6 +281,7 @@ def __init__(
self.order = order
self.cval = cval
self.mode = mode
warnings.warn("This IAAPiecewiseAffine is deprecated. Please use PiecewiseAffine instead", FutureWarning)

@property
def processor(self):
Expand All @@ -266,6 +295,8 @@ class IAAAffine(DualIAATransform):
"""Place a regular grid of points on the input and randomly move the neighbourhood of these point around
via affine transformations.
This augmentation is deprecated. Please use Affine instead.
Note: This class introduce interpolation artifacts to mask if it has values other than {0;1}
Args:
Expand Down Expand Up @@ -297,6 +328,7 @@ def __init__(
self.order = order
self.cval = cval
self.mode = mode
warnings.warn("This IAAAffine is deprecated. Please use Affine instead", FutureWarning)

@property
def processor(self):
Expand Down Expand Up @@ -330,6 +362,15 @@ class IAAPerspective(Perspective):
image, mask
"""

def __init__(self, scale=(0.05, 0.1), keep_size=True, always_apply=False, p=0.5, **kwargs):
warnings.warn("IAAPerspective is deprecated. Please use Perspective instead", FutureWarning)
super().__init__(scale=scale, keep_size=keep_size, always_apply=always_apply, p=p, **kwargs)
def __init__(self, scale=(0.05, 0.1), keep_size=True, always_apply=False, p=0.5):
super(IAAPerspective, self).__init__(always_apply, p)
self.scale = to_tuple(scale, 1.0)
self.keep_size = keep_size
warnings.warn("This IAAPerspective is deprecated. Please use Perspective instead", FutureWarning)

@property
def processor(self):
return iaa.PerspectiveTransform(self.scale, keep_size=self.keep_size)

def get_transform_init_args_names(self):
return ("scale", "keep_size")
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pkg_resources import DistributionNotFound, get_distribution


INSTALL_REQUIRES = ["numpy>=1.11.1", "scipy", "scikit-image>=0.16.1", "imgaug>=0.4.0", "PyYAML"]
INSTALL_REQUIRES = ["numpy>=1.11.1", "scipy", "scikit-image>=0.16.1", "PyYAML"]

# If none of packages in first installed, install second package
CHOOSE_INSTALL_REQUIRES = [
Expand Down Expand Up @@ -66,7 +66,7 @@ def get_install_requirements(install_requires, choose_install_requires):
packages=find_packages(exclude=["tests"]),
python_requires=">=3.6",
install_requires=get_install_requirements(INSTALL_REQUIRES, CHOOSE_INSTALL_REQUIRES),
extras_require={"tests": ["pytest"]},
extras_require={"tests": ["pytest"], "imgaug": ["imgaug>=0.4.0"], "develop": ["pytest", "imgaug>=0.4.0"]},
classifiers=[
"Development Status :: 4 - Beta",
"License :: OSI Approved :: MIT License",
Expand Down

0 comments on commit cc8fbb6

Please sign in to comment.