-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from gregstarr/develop
basic test + github action
- Loading branch information
Showing
4 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
||
name: Python package | ||
|
||
on: | ||
push: | ||
branches: [ "master", "develop" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.9", "3.10", "3.11"] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install poetry | ||
poetry install --with dev | ||
- name: Lint with flake8 | ||
run: | | ||
poetry run flake8 ./volumentations --count --select=E9,F63,F7,F82 --show-source --statistics | ||
- name: Test with pytest | ||
run: | | ||
poetry run pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[tool.poetry] | ||
name = "volumentations-3d" | ||
version = "1.0.4" | ||
description = "Library for 3D augmentations" | ||
authors = [ | ||
"Roman Sol (ZFTurbo)", | ||
"ashawkey", | ||
"qubvel", | ||
"muellerdo" | ||
] | ||
license = "MIT" | ||
readme = "README.md" | ||
packages = [{include = "volumentations"}] | ||
|
||
[tool.poetry.dependencies] | ||
python = ">=3.9, <3.12" | ||
scikit-image = "^0.20.0" | ||
opencv-python = "^4.7.0.72" | ||
numpy = "^1.24.3" | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
pytest = "^7.3.1" | ||
flake8 = "^6.0.0" | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import pytest | ||
import numpy as np | ||
|
||
from volumentations import * | ||
|
||
|
||
augmentations = [ | ||
CenterCrop, | ||
ColorJitter, | ||
Contiguous, | ||
# CropNonEmptyMaskIfExists, | ||
Downscale, | ||
ElasticTransform, | ||
ElasticTransformPseudo2D, | ||
Flip, | ||
Float, | ||
GaussianNoise, | ||
GlassBlur, | ||
GridDistortion, | ||
GridDropout, | ||
ImageCompression, | ||
Normalize, | ||
PadIfNeeded, | ||
RandomBrightnessContrast, | ||
RandomCrop, | ||
RandomCropFromBorders, | ||
RandomDropPlane, | ||
RandomGamma, | ||
RandomResizedCrop, | ||
RandomRotate90, | ||
RandomScale, | ||
RandomScale2, | ||
RemoveEmptyBorder, | ||
Resize, | ||
# ResizedCropNonEmptyMaskIfExists, | ||
Rotate, | ||
RotatePseudo2D, | ||
Transpose, | ||
] | ||
|
||
arg_required = [ | ||
CenterCrop, | ||
CropNonEmptyMaskIfExists, | ||
PadIfNeeded, | ||
RandomCrop, | ||
RandomResizedCrop, | ||
Resize, | ||
ResizedCropNonEmptyMaskIfExists, | ||
] | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def cube(): | ||
X, Y, Z = np.mgrid[-8:8:40j, -8:8:40j, -8:8:40j] | ||
values = np.sin(X*Y*Z) / (X*Y*Z) | ||
return values | ||
|
||
|
||
@pytest.mark.parametrize("aug_class", augmentations) | ||
def test_augmentations(aug_class, cube): | ||
if aug_class in arg_required: | ||
aug = aug_class(shape=(30, 30, 30)) | ||
else: | ||
aug = aug_class() | ||
new_cube = aug(True, "image", image=cube)["image"] | ||
print(aug_class.__name__, new_cube.shape) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters