Skip to content

Commit

Permalink
Update used by (#1556)
Browse files Browse the repository at this point in the history
* Authomatically update used by

* Authomatically update used by

* Cleaup in CI

* Fixes from Sourcery

* Updated requirements

* Fix in readme

* Updated reacme

* Updated reacme

* Removed updsate for Readme from pre-commit

* Fix in generating transform docs

* Fix in generating docstrings docs

* Debugging

* Debugging

* Fix in CI
  • Loading branch information
ternaus authored Mar 2, 2024
1 parent 4e47867 commit 9b2863b
Show file tree
Hide file tree
Showing 14 changed files with 170 additions and 78 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
run: pytest

check_code_formatting_types:
name: Check code formatting with ruff and mypy
name: Check code formatting with ruff and mypy + tests
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -70,7 +70,7 @@ jobs:
run: pre-commit run --files $(find albumentations -type f)

check_transforms_docs:
name: Check that transforms docs are not outdated
name: Check Readme is not outdated
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -82,11 +82,12 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Update pip
run: python -m pip install --upgrade pip
- name: Install dependencies
- name: Install requirements
run: |
python -m pip install --upgrade pip
pip install requests
pip install .
pip install pytest
- name: Run checks
- name: Run checks for documentation
run: python tools/make_transforms_docs.py check README.md
- name: Run checks for used by documentation
run: python tools/make_used_by_docs.py check
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ repos:
- id: requirements-txt-fixer
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.2.2
rev: v0.3.0
hooks:
# Run the linter.
- id: ruff
Expand Down
37 changes: 18 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Here is an example of how you can apply some [pixel-level](#pixel-level-transfor
- [List of augmentations](#list-of-augmentations)
- [Pixel-level transforms](#pixel-level-transforms)
- [Spatial-level transforms](#spatial-level-transforms)
- [A few more examples of augmentations](#a-few-more-examples-of-augmentations)
- [A few more examples of **augmentations**](#a-few-more-examples-of-augmentations)
- [Semantic segmentation on the Inria dataset](#semantic-segmentation-on-the-inria-dataset)
- [Medical imaging](#medical-imaging)
- [Object detection and semantic segmentation on the Mapillary Vistas dataset](#object-detection-and-semantic-segmentation-on-the-mapillary-vistas-dataset)
Expand Down Expand Up @@ -120,27 +120,26 @@ Check the [online demo of the library](https://albumentations-demo.herokuapp.com

## Who is using Albumentations

<a href="https://www.lyft.com/" target="_blank"><img src="https://habrastorage.org/webt/ce/bs/sa/cebssajf_5asst5yshmyykqjhcg.png" width="100"/></a>
<a href="https://imedhub.org/" target="_blank"><img src="https://habrastorage.org/webt/eq/8x/m-/eq8xm-fjfx_uqkka4_ekxsdwtiq.png" width="100"/></a>
<a href="https://recursionpharma.com" target="_blank"><img src="https://pbs.twimg.com/profile_images/925897897165639683/jI8YvBfC_400x400.jpg" width="100"/></a>
<a href="https://www.everypixel.com/" target="_blank"><img src="https://www.everypixel.com/i/logo_sq.png" width="100"/></a>
<a href="https://neuromation.io/" target="_blank"><img src="https://habrastorage.org/webt/yd/_4/xa/yd_4xauvggn1tuz5xgrtkif6lya.png" width="100"/></a>
<a href="https://ultralytics.com/" target="_blank"><img src="https://albumentations.ai/assets/img/industry/ultralytics.png" width="100"/></a>
<a href="https://www.cft.ru/" target="_blank"><img src="https://habrastorage.org/webt/dv/fa/uq/dvfauqyl5cor5yzrfrpthjzm0mi.jpeg" width="100"/></a>
<a href="https://www.pinatafarm.com/" target="_blank"><img src="https://www.pinatafarm.com/pfLogo.png" width="100"/></a>
<a href="https://incode.com/" target="_blank"><img src="https://habrastorage.org/webt/sh/eg/bs/shegbsyzy-0lebwqxkgl_rkkx3m.png" width="100"/></a>
<a href="https://sharpershape.com/" target="_blank"><img src="https://lh3.googleusercontent.com/pw/AM-JKLWe2-aRXcZMqZOnL67Gw8v46LTwJw5a6RyufgAiLCKncxSI4U7wzHopt5Lacbc4wpDF7uJYMrWcVXPK-3Z3cxopV9jmtriuWSdzNpAO6gDC963nPd3BrWlE6eFwstLCb4il6lYXT49BbamdUipZrLk=w1870-h1574-no?authuser=0" width="100"/></a>
<a href="https://vitechlab.com/" target="_blank"><img src="https://res2.weblium.site/res/5f842a47d2077f0022e59f1d/5f842ba81ff15b00214a447f_optimized_389.webp" width="100"/></a>
<a href="https://borzodelivery.com/" target="_blank"><img src="https://borzodelivery.com/img/global/big-logo.svg" width="100"/></a>
<a href="https://anadea.info/" target="_blank"><img src="https://habrastorage.org/webt/oc/lt/8u/oclt8uwyyc-vgmwwcgcsk5cw7wy.png" width="100"/></a>
<a href="https://www.idrnd.ai/" target="_blank"><img src="https://www.idrnd.ai/wp-content/uploads/2019/09/Logo-IDRND.png.webp" width="100"/></a>
<a href="https://openface.me/" target="_blank"><img src="https://drive.google.com/uc?export=view&id=1mC8B55CPFlpUC69Wnli2vitp6pImIfz7" width="100"/></a>
<a href="https://www.apple.com/" target="_blank"><img src="https://raw.githubusercontent.com/albumentations-team/albumentations.ai/main/html/assets/img/industry/apple.jpeg" width="100"/></a>
<a href="https://research.google/" target="_blank"><img src="https://raw.githubusercontent.com/albumentations-team/albumentations.ai/main/html/assets/img/industry/google.png" width="100"/></a>
<a href="https://opensource.fb.com/" target="_blank"><img src="https://raw.githubusercontent.com/albumentations-team/albumentations.ai/main/html/assets/img/industry/meta_research.png" width="100"/></a>
<a href="https: //www.nvidia.com/en-us/research/" target="_blank"><img src="https://raw.githubusercontent.com/albumentations-team/albumentations.ai/main/html/assets/img/industry/nvidia_research.jpeg" width="100"/></a>
<a href="https://www.amazon.science/" target="_blank"><img src="https://raw.githubusercontent.com/albumentations-team/albumentations.ai/main/html/assets/img/industry/amazon_science.png" width="100"/></a>
<a href="https://opensource.microsoft.com/" target="_blank"><img src="https://raw.githubusercontent.com/albumentations-team/albumentations.ai/main/html/assets/img/industry/microsoft.png" width="100"/></a>
<a href="https://engineering.salesforce.com/open-source/" target="_blank"><img src="https://raw.githubusercontent.com/albumentations-team/albumentations.ai/main/html/assets/img/industry/salesforce_open_source.png" width="100"/></a>
<a href="https://stability.ai/" target="_blank"><img src="https://raw.githubusercontent.com/albumentations-team/albumentations.ai/main/html/assets/img/industry/stability.png" width="100"/></a>
<a href="https://www.ibm.com/opensource/" target="_blank"><img src="https://raw.githubusercontent.com/albumentations-team/albumentations.ai/main/html/assets/img/industry/ibm.jpeg" width="100"/></a>
<a href="https://huggingface.co/" target="_blank"><img src="https://raw.githubusercontent.com/albumentations-team/albumentations.ai/main/html/assets/img/industry/hugging_face.png" width="100"/></a>
<a href="https://www.sony.com/en/" target="_blank"><img src="https://raw.githubusercontent.com/albumentations-team/albumentations.ai/main/html/assets/img/industry/sony.png" width="100"/></a>
<a href="https://opensource.alibaba.com/" target="_blank"><img src="https://raw.githubusercontent.com/albumentations-team/albumentations.ai/main/html/assets/img/industry/alibaba.png" width="100"/></a>
<a href="https://opensource.tencent.com/" target="_blank"><img src="https://raw.githubusercontent.com/albumentations-team/albumentations.ai/main/html/assets/img/industry/tencent.png" width="100"/></a>
<a href="https://h2o.ai/" target="_blank"><img src="https://raw.githubusercontent.com/albumentations-team/albumentations.ai/main/html/assets/img/industry/h2o_ai.png" width="100"/></a>

### See also

- [A list of papers that cite Albumentations](https://albumentations.ai/whos_using#research).
- [A list of papers that cite Albumentations](https://scholar.google.com/citations?view_op=view_citation&citation_for_view=vkjh9X0AAAAJ:r0BpntZqJG4C).
- [A list of teams that were using Albumentations and took high places in machine learning competitions](https://albumentations.ai/whos_using#competitions).
- [Open source projects that use Albumentations](https://albumentations.ai/whos_using#open-source).
- [Open source projects that use Albumentations](https://github.com/albumentations-team/albumentations/network/dependents?dependent_type=PACKAGE).

## List of augmentations

Expand Down Expand Up @@ -243,7 +242,7 @@ Spatial-level transforms will simultaneously change both an input image as well
| [VerticalFlip](https://albumentations.ai/docs/api_reference/augmentations/geometric/transforms/#albumentations.augmentations.geometric.transforms.VerticalFlip) |||||
| [XYMasking](https://albumentations.ai/docs/api_reference/augmentations/dropout/xy_masking/#albumentations.augmentations.dropout.xy_masking.XYMasking) ||| ||

## A few more examples of augmentations
## A few more examples of **augmentations**

### Semantic segmentation on the Inria dataset

Expand Down
4 changes: 2 additions & 2 deletions albumentations/augmentations/blur/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,10 @@ class AdvancedBlur(ImageOnlyTransform):
available at https://arxiv.org/abs/2107.10833
Targets:
This transformation is applied to images only.
image
Image types:
This transform supports uint8 and float32 image types.
uint8, float32
"""

Expand Down
2 changes: 1 addition & 1 deletion albumentations/augmentations/crops/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def crop_keypoint_by_coords(
"""
x, y, angle, scale = keypoint[:4]
x1, y1, _, _ = crop_coords
x1, y1 = crop_coords[:2]
return x - x1, y - y1, angle, scale


Expand Down
9 changes: 3 additions & 6 deletions albumentations/augmentations/domain_adaptation_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,13 @@

class TransformerInterface(Protocol):
@abc.abstractmethod
def inverse_transform(self, x: np.ndarray) -> np.ndarray:
...
def inverse_transform(self, x: np.ndarray) -> np.ndarray: ...

@abc.abstractmethod
def fit(self, x: np.ndarray, y: Optional[np.ndarray] = None) -> np.ndarray:
...
def fit(self, x: np.ndarray, y: Optional[np.ndarray] = None) -> np.ndarray: ...

@abc.abstractmethod
def transform(self, x: np.ndarray, y: Optional[np.ndarray] = None) -> np.ndarray:
...
def transform(self, x: np.ndarray, y: Optional[np.ndarray] = None) -> np.ndarray: ...


class DomainAdapter:
Expand Down
2 changes: 1 addition & 1 deletion albumentations/augmentations/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ def multiply(img: np.ndarray, multiplier: np.ndarray) -> np.ndarray:
img: Image.
multiplier: Multiplier coefficient.
Returns
Returns:
-------
Image multiplied by `multiplier` coefficient.
Expand Down
2 changes: 1 addition & 1 deletion albumentations/augmentations/geometric/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ class PositionType(Enum):
assume relative to a container. It's particularly useful in image processing, UI layout,
and graphic design to specify the alignment and positioning of elements.
Attributes
Attributes:
----------
CENTER (str): Specifies that the object should be placed at the center.
TOP_LEFT (str): Specifies that the object should be placed at the top-left corner.
Expand Down
4 changes: 2 additions & 2 deletions albumentations/augmentations/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class ImageCompressionType(IntEnum):
This Enum class is used to specify the image compression format.
Attributes
Attributes:
----------
JPEG (int): Represents the JPEG image compression format.
WEBP (int): Represents the WEBP image compression format.
Expand Down Expand Up @@ -1515,7 +1515,7 @@ class RandomGamma(ImageOnlyTransform):
conditions, potentially enhancing model generalization. For more details on gamma correction,
see: https://en.wikipedia.org/wiki/Gamma_correction
Attributes
Attributes:
----------
gamma_limit (Union[int, Tuple[int, int]]): The range for gamma adjustment. If `gamma_limit` is a single
int, the range will be interpreted as (-gamma_limit, gamma_limit), defining how much
Expand Down
3 changes: 1 addition & 2 deletions albumentations/pytorch/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ class ToTensorV2(BasicTransform):
"""Converts images/masks to PyTorch Tensors, inheriting from BasicTransform. Supports images in numpy `HWC` format
and converts them to PyTorch `CHW` format. If the image is in `HW` format, it will be converted to PyTorch `HW`.
Attributes
----------
Attributes:
transpose_mask (bool): If True, transposes 3D input mask dimensions from `[height, width, num_channels]` to
`[num_channels, height, width]`.
always_apply (bool): Indicates if this transformation should be always applied. Default: True.
Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ exclude = [
"venv",
"tests",
"benchmark",
"setup.py"
"setup.py",
"tools"
]

# Same as Black.
Expand All @@ -62,7 +63,7 @@ target-version = "py38"
explicit-preview-rules = true

select = ["F", "E", "W", "C90", "I", "N", "D", "UP", "YTT", "ANN", "ASYNC", "TRIO", "S", "BLE", "FBT", "B", "A", "COM", "CPY", "C4", "DTZ", "T10", "DJ", "EM", "EXE", "ISC", "ICN", "G", "INP", "PIE", "T20", "PYI", "PT", "Q", "RSE", "RET", "SLF", "SLOT", "SIM", "TID", "TCH", "INT", "ARG", "PTH", "TD", "FIX", "ERA", "PD", "PGH", "PL", "TRY", "FLY", "NPY", "PERF", "FURB", "LOG", "RUF"]
ignore = ["D211", "D213", "ANN101", "D107", "ANN401", "D102", "D103", "ANN204", "ARG002", "D104", "S311", "F403", "PLR0913", "FBT001", "FBT002", "ISC001", "COM812", "ANN102", "D100", "D205", "D101", "EM102", "TRY003", "D401", "A002", "D105", "D415", "D400", "D202", "D203", "PTH123", "D203", "B028", "ARG001", "ARG005", "B028", "N812", "FBT003", "D417", "B027"]
ignore = [ "ANN101", "D107", "ANN401", "ANN204", "ARG002", "S311", "F403", "PLR0913", "FBT001", "FBT002", "ISC001", "COM812", "ANN102", "EM102", "TRY003", "D401", "A002", "PTH123", "B028", "ARG001", "ARG005", "B028", "N812", "FBT003", "B027", "D104", "D100", "D103", "D102", "D415", "D101", "D205", "D105", "D417"]

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
Expand All @@ -83,3 +84,6 @@ skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"

[tool.ruff.lint.pydocstyle]
convention = "google"
10 changes: 6 additions & 4 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
deepdiff==6.7.1
mypy==1.8.0
deepdiff>=6.7.1
mypy>=1.8.0
pre_commit>=3.5.0
pytest==8.0.2
ruff==0.2.2
pytest>=8.0.2
requests>=2.31.0
ruff>=0.3.0
tomli>=2.0.1
types-pkg-resources
types-PyYAML
types-setuptools
Loading

0 comments on commit 9b2863b

Please sign in to comment.