Skip to content

Commit

Permalink
Merge branch 'feature/v0.1.4' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Dec 4, 2022
2 parents fd346a1 + be0ef32 commit 07b9a7b
Show file tree
Hide file tree
Showing 16 changed files with 231 additions and 205 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/continuous-integration-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ jobs:
name: ${{ matrix.os }} - Python ${{ matrix.python-version }}
strategy:
matrix:
os: [ubuntu-20.04]
python-version: [3.8]
os: [ubuntu-22.04]
python-version: [3.11]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
- name: Environment Variables
run: |
echo "CI_PYTHON_VERSION=${{ matrix.python-version }}" >> $GITHUB_ENV
echo "CI_PACKAGE=colour" >> $GITHUB_ENV
echo "CI_PACKAGE=colour_checker_detection" >> $GITHUB_ENV
echo "CI_SHA=${{ github.sha }}" >> $GITHUB_ENV
echo "MPLBACKEND=AGG" >> $GITHUB_ENV
echo "COLOUR_SCIENCE__DOCUMENTATION_BUILD=True" >> $GITHUB_ENV
Expand All @@ -31,8 +31,7 @@ jobs:
sudo apt-get --yes install latexmk texlive-full
- name: Install Poetry
run: |
curl -L https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py -o get-poetry.py
python get-poetry.py
curl -sSL https://install.python-poetry.org | POETRY_HOME=$HOME/.poetry python3 -
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
shell: bash
- name: Install Package Dependencies
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/continuous-integration-quality-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ jobs:
name: ${{ matrix.os }} - Python ${{ matrix.python-version }}
strategy:
matrix:
os: [macOS-latest, ubuntu-20.04, windows-2019]
python-version: [3.8, 3.9, '3.10']
os: [macOS-latest, ubuntu-22.04, windows-2019]
python-version: [3.9, '3.10', 3.11]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -22,14 +22,17 @@ jobs:
echo "CI_SHA=${{ github.sha }}" >> $GITHUB_ENV
echo "COVERALLS_REPO_TOKEN=${{ secrets.COVERALLS_REPO_TOKEN }}" >> $GITHUB_ENV
shell: bash
- name: Set up Python 3.9 for Pre-Commit
uses: actions/setup-python@v1
with:
python-version: 3.9
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
run: |
curl -L https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py -o get-poetry.py
python get-poetry.py --version 1.1.12
curl -sSL https://install.python-poetry.org | POETRY_HOME=$HOME/.poetry python3 -
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
shell: bash
- name: Install Package Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,22 @@ jobs:
strategy:
matrix:
os: [macOS-latest]
python-version: [3.9]
python-version: [3.11]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
- name: Environment Variables
run: |
echo "CI_PACKAGE=colour" >> $GITHUB_ENV
echo "CI_PACKAGE=colour_checker_detection" >> $GITHUB_ENV
shell: bash
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Static Type Checking
- name: Install Package Dependencies
run: |
pip install -r requirements.txt
mypy --install-types --non-interactive --show-error-codes --warn-unused-ignores --warn-redundant-casts -p $CI_PACKAGE
- name: Static Type Checking
run: |
mypy --install-types --non-interactive --show-error-codes --warn-unused-ignores --warn-redundant-casts $CI_PACKAGE
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
*.egg-info
*.pyc
*.pyo
.DS_Store
.coverage
.dmypy.json
.fleet
.idea
.ipynb_checkpoints/
.ipynb_checkpoints
.mypy_cache
.vscode
.sandbox
.vs
.vscode

__pycache__

Expand Down
19 changes: 12 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.37.3
rev: v3.2.2
hooks:
- id: pyupgrade
args: [--py38-plus]
args: [--py39-plus]
- repo: https://github.com/ikamensh/flynt/
rev: '0.76'
rev: '0.77'
hooks:
- id: flynt
- repo: https://github.com/psf/black
rev: 22.6.0
rev: 22.10.0
hooks:
- id: black
language_version: python3.8
language_version: python3.9
- repo: https://github.com/keewis/blackdoc
rev: v0.3.8
hooks:
- id: blackdoc
language_version: python3.9
- repo: https://github.com/PyCQA/flake8
rev: 5.0.3
rev: 6.0.0
hooks:
- id: flake8
- repo: https://github.com/pycqa/pydocstyle
Expand All @@ -23,4 +28,4 @@ repos:
- id: pydocstyle
args:
- --convention=numpy
- --add-ignore=D104,D200,D202,D205,D301,D400
- --add-ignore=D104,D200,D202,D205,D301,D400
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
build:
os: ubuntu-20.04
tools:
python: "3.8"
python: "3.11"

sphinx:
configuration: docs/conf.py
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Contributors
Development & Technical Support
-------------------------------

- **Thomas Mansencal**, *Lead Pipeline Developer @ WetaFX*
- **Thomas Mansencal**, *Technology Supervisor @ Wētā FX*

Project coordination, overall development.

Expand Down
12 changes: 6 additions & 6 deletions colour_checker_detection/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@
"detect_colour_checkers_segmentation",
]

RESOURCES_DIRECTORY: str = os.path.join(os.path.dirname(__file__), "resources")
EXAMPLES_RESOURCES_DIRECTORY: str = os.path.join(
RESOURCES_DIRECTORY, "colour-checker-detection-examples-datasets"
ROOT_RESOURCES: str = os.path.join(os.path.dirname(__file__), "resources")
ROOT_RESOURCES_EXAMPLES: str = os.path.join(
ROOT_RESOURCES, "colour-checker-detection-examples-datasets"
)
TESTS_RESOURCES_DIRECTORY: str = os.path.join(
RESOURCES_DIRECTORY, "colour-checker-detection-tests-datasets"
ROOT_RESOURCES_TESTS: str = os.path.join(
ROOT_RESOURCES, "colour-checker-detection-tests-datasets"
)

__application_name__ = "Colour - Checker Detection"

__major_version__ = "0"
__minor_version__ = "1"
__change_version__ = "3"
__change_version__ = "4"
__version__ = ".".join(
(__major_version__, __minor_version__, __change_version__)
)
Expand Down
50 changes: 31 additions & 19 deletions colour_checker_detection/detection/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def as_8_bit_BGR_image(image: ArrayLike) -> NDArray:
def adjust_image(
image: ArrayLike,
target_width: Integer,
interpolation_method: Literal[ # type: ignore[misc]
interpolation_method: Literal[ # type: ignore[valid-type]
cv2.INTER_AREA,
cv2.INTER_BITS,
cv2.INTER_BITS2,
Expand Down Expand Up @@ -465,7 +465,7 @@ def scale_contour(contour: ArrayLike, factor: Floating) -> NDArray:
def crop_and_level_image_with_rectangle(
image: ArrayLike,
rectangle: Tuple[Tuple, Tuple, Floating],
interpolation_method: Literal[ # type: ignore[misc]
interpolation_method: Literal[ # type: ignore[valid-type]
cv2.INTER_AREA,
cv2.INTER_BITS,
cv2.INTER_BITS2,
Expand Down Expand Up @@ -499,10 +499,13 @@ def crop_and_level_image_with_rectangle(
--------
>>> import os
>>> from colour import read_image
>>> from colour_checker_detection import TESTS_RESOURCES_DIRECTORY
>>> path = os.path.join(TESTS_RESOURCES_DIRECTORY,
... 'colour_checker_detection', 'detection',
... 'IMG_1967.png')
>>> from colour_checker_detection import ROOT_RESOURCES_TESTS
>>> path = os.path.join(
... ROOT_RESOURCES_TESTS,
... "colour_checker_detection",
... "detection",
... "IMG_1967.png",
... )
>>> image = adjust_image(read_image(path), 1440)
>>> rectangle = (
... (723.29608154, 465.50939941),
Expand Down Expand Up @@ -661,10 +664,13 @@ def colour_checkers_coordinates_segmentation(
--------
>>> import os
>>> from colour import read_image
>>> from colour_checker_detection import TESTS_RESOURCES_DIRECTORY
>>> path = os.path.join(TESTS_RESOURCES_DIRECTORY,
... 'colour_checker_detection', 'detection',
... 'IMG_1967.png')
>>> from colour_checker_detection import ROOT_RESOURCES_TESTS
>>> path = os.path.join(
... ROOT_RESOURCES_TESTS,
... "colour_checker_detection",
... "detection",
... "IMG_1967.png",
... )
>>> image = read_image(path)
>>> colour_checkers_coordinates_segmentation(image) # doctest: +ELLIPSIS
(array([[ 369, 688],
Expand Down Expand Up @@ -856,10 +862,13 @@ def extract_colour_checkers_segmentation(
--------
>>> import os
>>> from colour import read_image
>>> from colour_checker_detection import TESTS_RESOURCES_DIRECTORY
>>> path = os.path.join(TESTS_RESOURCES_DIRECTORY,
... 'colour_checker_detection', 'detection',
... 'IMG_1967.png')
>>> from colour_checker_detection import ROOT_RESOURCES_TESTS
>>> path = os.path.join(
... ROOT_RESOURCES_TESTS,
... "colour_checker_detection",
... "detection",
... "IMG_1967.png",
... )
>>> image = read_image(path)
>>> extract_colour_checkers_segmentation(image)
... # doctest: +SKIP
Expand Down Expand Up @@ -1042,10 +1051,13 @@ def detect_colour_checkers_segmentation(
--------
>>> import os
>>> from colour import read_image
>>> from colour_checker_detection import TESTS_RESOURCES_DIRECTORY
>>> path = os.path.join(TESTS_RESOURCES_DIRECTORY,
... 'colour_checker_detection', 'detection',
... 'IMG_1967.png')
>>> from colour_checker_detection import ROOT_RESOURCES_TESTS
>>> path = os.path.join(
... ROOT_RESOURCES_TESTS,
... "colour_checker_detection",
... "detection",
... "IMG_1967.png",
... )
>>> image = read_image(path)
>>> detect_colour_checkers_segmentation(image) # doctest: +SKIP
(array([[ 0.361626... , 0.2241066..., 0.1187837...],
Expand Down Expand Up @@ -1115,7 +1127,7 @@ def detect_colour_checkers_segmentation(
settings.swatches_achromatic_slice,
]:
swatch_std_mean = as_float_array(swatch_colours[slice_])
swatch_std_mean /= swatch_std_mean[..., 1][..., np.newaxis]
swatch_std_mean /= swatch_std_mean[..., 1][..., None]
std_means.append(np.mean(np.std(swatch_std_mean, 0)))
if std_means[0] < std_means[1]:
usage_warning(
Expand Down
4 changes: 2 additions & 2 deletions colour_checker_detection/detection/tests/test_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from colour import read_image
from colour.models import cctf_encoding

from colour_checker_detection import TESTS_RESOURCES_DIRECTORY
from colour_checker_detection import ROOT_RESOURCES_TESTS
from colour_checker_detection.detection.segmentation import (
SETTINGS_SEGMENTATION_COLORCHECKER_CLASSIC,
swatch_masks,
Expand Down Expand Up @@ -53,7 +53,7 @@
]

DETECTION_DIRECTORY = os.path.join(
TESTS_RESOURCES_DIRECTORY, "colour_checker_detection", "detection"
ROOT_RESOURCES_TESTS, "colour_checker_detection", "detection"
)

PNG_FILES = glob.glob(os.path.join(DETECTION_DIRECTORY, "*.png"))
Expand Down
4 changes: 2 additions & 2 deletions colour_checker_detection/examples/examples_detection.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"import colour\n",
"\n",
"from colour_checker_detection import (\n",
" EXAMPLES_RESOURCES_DIRECTORY,\n",
" ROOT_RESOURCES_EXAMPLES,\n",
" SETTINGS_SEGMENTATION_COLORCHECKER_CLASSIC,\n",
" colour_checkers_coordinates_segmentation,\n",
" detect_colour_checkers_segmentation)\n",
Expand Down Expand Up @@ -120,7 +120,7 @@
],
"source": [
"COLOUR_CHECKER_IMAGE_PATHS = glob.glob(\n",
" os.path.join(EXAMPLES_RESOURCES_DIRECTORY, 'detection', '*.png'))\n",
" os.path.join(ROOT_RESOURCES_EXAMPLES, 'detection', '*.png'))\n",
"\n",
"COLOUR_CHECKER_IMAGES = [\n",
" colour.cctf_decoding(colour.io.read_image(path))\n",
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
]

intersphinx_mapping = {
"python": ("https://docs.python.org/3.8", None),
"python": ("https://docs.python.org/3.11", None),
"matplotlib": ("https://matplotlib.org/stable", None),
"numpy": ("https://numpy.org/doc/stable", None),
"pandas": ("https://pandas.pydata.org/pandas-docs/dev", None),
"scipy": ("https://docs.scipy.org/doc/scipy-1.8.0/html-scipyorg", None),
"scipy": ("https://docs.scipy.org/doc/scipy-1.8.0/", None),
}

autodoc_member_order = "bysource"
Expand Down
17 changes: 10 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "colour-checker-detection"
version = "0.1.3"
version = "0.1.4"
description = "Colour checker detection with Python"
license = "BSD-3-Clause"
authors = [ "Colour Developers <[email protected]>" ]
Expand Down Expand Up @@ -44,18 +44,19 @@ exclude = [
]

[tool.poetry.dependencies]
python = ">= 3.8, < 3.11"
colour-science = ">= 0.4.0"
python = ">= 3.9, < 3.12"
colour-science = ">= 0.4.2"
imageio = ">= 2, < 3"
numpy = ">= 1.19, < 2"
numpy = ">= 1.20, < 2"
opencv-python = ">= 4, < 5"
scipy = ">= 1.5, < 2"
scipy = ">= 1.7, < 2"
typing-extensions = ">= 4, < 5" # Convenience for Google Colab.

matplotlib = { version = ">= 3.2, != 3.5.0, != 3.5.1", optional = true }
matplotlib = { version = ">= 3.4, != 3.5.0, != 3.5.1", optional = true }

biblib-simple = { version = "*", optional = true } # Development dependency.
black = { version = "*", optional = true } # Development dependency.
blackdoc = { version = "*", optional = true } # Development dependency.
coverage = { version = "*", optional = true } # Development dependency.
coveralls = { version = "*", optional = true } # Development dependency.
flake8 = { version = "*", optional = true } # Development dependency.
Expand All @@ -79,6 +80,7 @@ twine = { version = "*", optional = true } # Development dependency.
[tool.poetry.dev-dependencies]
biblib-simple = "*"
black = "*"
blackdoc = "*"
coverage = "!= 6.3"
coveralls = "*"
flake8 = "*"
Expand All @@ -103,6 +105,7 @@ twine = "*"
development = [
"biblib-simple",
"black",
"blackdoc",
"coverage",
"coveralls",
"flake8",
Expand Down Expand Up @@ -148,7 +151,7 @@ convention = "numpy"
add-ignore = "D104,D200,D202,D205,D301,D400"

[tool.pytest.ini_options]
addopts = "-n auto --durations=5"
addopts = "-n auto --dist=loadscope --durations=5"

[build-system]
requires = [ "poetry_core>=1.0.0" ]
Expand Down
Loading

0 comments on commit 07b9a7b

Please sign in to comment.