Skip to content

Commit

Permalink
Merge branch 'feature/v0.2.1' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Oct 12, 2024
2 parents a50651b + 1435566 commit b0493fe
Show file tree
Hide file tree
Showing 21 changed files with 574 additions and 471 deletions.
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ is available to guide the process: https://www.colour-science.org/contributing/.
- [ ] Pyright static checking has been run and passed.
- [ ] Pre-commit hooks have been run and passed.

<!-- The unit tests can be invoked with `poetry run invoke tests` -->
<!-- Pyright can be started with `pyright --skipunannotated` -->
<!-- The unit tests can be invoked with `uv run invoke tests` -->
<!-- Pyright can be started with `pyright --threads --skipunannotated` -->

**Documentation**

Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/continuous-integration-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.12]
python-version: [3.13]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -22,25 +22,23 @@ jobs:
echo "COLOUR_SCIENCE__DOCUMENTATION_BUILD=True" >> $GITHUB_ENV
shell: bash
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get --yes install latexmk texlive-full
- name: Install Poetry
- name: Install uv
run: |
curl -sSL https://install.python-poetry.org | POETRY_HOME=$HOME/.poetry python3 -
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
pip install uv
shell: bash
- name: Install Package Dependencies
run: |
poetry run python -m pip install --upgrade pip
poetry install
poetry run python -c "import imageio;imageio.plugins.freeimage.download()"
uv sync --all-extras --no-dev
uv run python -c "import imageio;imageio.plugins.freeimage.download()"
shell: bash
- name: Build Documentation
run: |
poetry run invoke docs
uv run invoke docs
shell: bash
34 changes: 19 additions & 15 deletions .github/workflows/continuous-integration-quality-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [macOS-latest, ubuntu-latest, windows-2019]
python-version: [3.9, "3.10", 3.11, 3.12]
python-version: ["3.10", 3.11, 3.12, 3.13]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -22,39 +22,43 @@ 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@v4
- name: Set up Python 3.10 for Pre-Commit
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: "3.10"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
- name: Install Dependencies (macOS)
if: matrix.os == 'macOS-latest'
run: |
curl -sSL https://install.python-poetry.org | POETRY_HOME=$HOME/.poetry python3 -
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
brew install freeimage
# TODO: Drop when https://github.com/imageio/imageio/issues/628 is addressed
echo "IMAGEIO_FREEIMAGE_LIB=/opt/homebrew/Cellar/freeimage/3.18.0/lib/libfreeimage.3.18.0.dylib" >> $GITHUB_ENV
- name: Install uv
run: |
pip install uv
shell: bash
- name: Install Package Dependencies
run: |
poetry run python -m pip install --upgrade pip
poetry install
poetry run python -c "import imageio;imageio.plugins.freeimage.download()"
uv sync --all-extras --no-dev
uv run python -c "import imageio;imageio.plugins.freeimage.download()"
shell: bash
- name: Pre-Commit (All Files)
run: |
poetry run pre-commit run --all-files
uv run pre-commit run --all-files
shell: bash
- name: Test Optimised Python Execution
run: |
poetry run python -OO -c "import $CI_PACKAGE"
uv run python -OO -c "import $CI_PACKAGE"
shell: bash
- name: Test with Pytest
run: |
poetry run python -W ignore -m pytest --doctest-modules --ignore=$CI_PACKAGE/examples --ignore=$CI_PACKAGE/scripts/inference.py --cov=$CI_PACKAGE $CI_PACKAGE
uv run python -W ignore -m pytest --doctest-modules --ignore=$CI_PACKAGE/examples --cov=$CI_PACKAGE $CI_PACKAGE
shell: bash
- name: Upload Coverage to coveralls.io
if: matrix.os == 'macOS-latest' && matrix.python-version == '3.12'
run: |
if [ -z "$COVERALLS_REPO_TOKEN" ]; then echo \"COVERALLS_REPO_TOKEN\" secret is undefined!; else poetry run coveralls; fi
if [ -z "$COVERALLS_REPO_TOKEN" ]; then echo \"COVERALLS_REPO_TOKEN\" secret is undefined!; else uv run coveralls; fi
shell: bash
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ jobs:
echo "CI_PACKAGE=colour_checker_detection" >> $GITHUB_ENV
shell: bash
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Package Dependencies
run: |
pip install -r requirements.txt
cat requirements.txt | grep -Eo '(^[^#]+)' | xargs -n 1 pip install || true
- name: Static Type Checking
run: |
pyright --skipunannotated
pyright --threads --skipunannotated
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
.fleet
.idea
.ipynb_checkpoints
.python-version
.sandbox
.vs
.vscode
Expand All @@ -17,4 +18,4 @@ colour_checker_detection.egg-info
dist
docs/_build
docs/generated
poetry.lock
uv.lock
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**, *Technology Supervisor @ Wētā FX*
- **Thomas Mansencal**, *Principal Pipeline Programmer @ Epic Games*

Project coordination, overall development.

Expand Down
9 changes: 5 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,17 @@ Primary Dependencies

**Colour - Checker Detection** requires various dependencies in order to run:

- `python >= 3.9, < 4 <https://www.python.org/download/releases>`__
- `colour-science >= 4.3 <https://pypi.org/project/colour-science>`__
- `python >= 3.10, < 3.14 <https://www.python.org/download/releases>`__
- `colour-science >= 4.5 <https://pypi.org/project/colour-science>`__
- `imageio >= 2, < 3 <https://imageio.github.io>`__
- `numpy >= 1.22, < 2 <https://pypi.org/project/numpy>`__
- `numpy >= 1.24, < 3 <https://pypi.org/project/numpy>`__
- `opencv-python >= 4, < 5 <https://pypi.org/project/opencv-python>`__
- `scipy >= 1.8, < 2 <https://pypi.org/project/scipy>`__
- `scipy >= 1.10, < 2 <https://pypi.org/project/scipy>`__

Secondary Dependencies
~~~~~~~~~~~~~~~~~~~~~~

- `click >= 8, < 9 <https://pypi.org/project/click>`__
- `ultralytics >= 8, < 9 <https://pypi.org/project/ultralytics>`__

Pypi
Expand Down
16 changes: 8 additions & 8 deletions TODO.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ TODO

- colour_checker_detection/__init__.py

- Line 92 : # TODO: Remove legacy printing support when deemed appropriate.
- Line 90 : # TODO: Remove legacy printing support when deemed appropriate.


- colour_checker_detection/detection/common.py

- Line 126 : # TODO: Update when "Colour" 0.4.5 is released.
- Line 1131 : # TODO: Update when "Colour" 0.4.5 is released.
- Line 1120 : # TODO: Update when "Colour" 0.4.5 is released.


- colour_checker_detection/detection/tests/test_inference.py

- Line 62 : # TODO: Unit test is only reproducible on "macOs", skipping other OSes.
- Line 66 : # TODO: Enable when "torch" is available on Python 3.12.
- Line 101 : # TODO: Unit test is only reproducible on "macOs", skipping other OSes.
- Line 105 : # TODO: Enable when "torch" is available on Python 3.12.
- Line 58 : # TODO: Unit test is only reproducible on "macOs", skipping other OSes.
- Line 62 : # TODO: Enable when "torch" is available on Python 3.12.
- Line 97 : # TODO: Unit test is only reproducible on "macOs", skipping other OSes.
- Line 101 : # TODO: Enable when "torch" is available on Python 3.12.


- colour_checker_detection/detection/tests/test_segmentation.py

- Line 59 : # TODO: Unit test is only reproducible on "macOs", skipping other OSes.
- Line 151 : # TODO: Unit test is only reproducible on "macOs", skipping other OSes.
- Line 57 : # TODO: Unit test is only reproducible on "macOs", skipping other OSes.
- Line 147 : # TODO: Unit test is only reproducible on "macOs", skipping other OSes.

About
-----
Expand Down
2 changes: 2 additions & 0 deletions colour_checker_detection/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
ROOT_RESOURCES, "colour-checker-detection-tests-datasets"
)

__all__ += ["ROOT_RESOURCES", "ROOT_RESOURCES_EXAMPLES", "ROOT_RESOURCES_TESTS"]

__application_name__ = "Colour - Checker Detection"

__major_version__ = "0"
Expand Down
2 changes: 1 addition & 1 deletion colour_checker_detection/detection/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ def sample_colour_checker(
image: ArrayLike, quadrilateral, rectangle, samples=32, **kwargs
) -> DataDetectionColourChecker:
"""
Sample the colour checker using the given source quadrilateral, i.e.
Sample the colour checker using the given source quadrilateral, i.e.,
detected colour checker in the image, and the given target rectangle.
Parameters
Expand Down
9 changes: 4 additions & 5 deletions colour_checker_detection/detection/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
from colour.utilities import (
Structure,
as_int_scalar,
is_string,
)
from colour.utilities.documentation import (
DocstringDict,
Expand Down Expand Up @@ -193,7 +192,7 @@ def inferencer_default(
temp_directory = tempfile.mkdtemp()

try:
if not is_string(image):
if not isinstance(image, str):
input_image = os.path.join(temp_directory, "input-image.png")

if apply_cctf_encoding:
Expand Down Expand Up @@ -267,7 +266,7 @@ def detect_colour_checkers_inference(
Other Parameters
----------------
aspect_ratio
Colour checker aspect ratio, e.g. 1.5.
Colour checker aspect ratio, e.g., 1.5.
aspect_ratio_minimum
Minimum colour checker aspect ratio for detection: projective geometry
might reduce the colour checker aspect ratio.
Expand Down Expand Up @@ -366,8 +365,8 @@ def detect_colour_checkers_inference(

results = inferencer(image, **inferencer_kwargs)

if is_string(image):
image = read_image(cast(str, image))
if isinstance(image, str):
image = read_image(image)
else:
image = convert_bit_depth(
image,
Expand Down
9 changes: 4 additions & 5 deletions colour_checker_detection/detection/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
from colour.utilities import (
MixinDataclassIterable,
Structure,
is_string,
)
from colour.utilities.documentation import (
DocstringDict,
Expand Down Expand Up @@ -218,7 +217,7 @@ def segmenter_default(
adaptive_threshold_kwargs
Keyword arguments for :func:`cv2.adaptiveThreshold` definition.
aspect_ratio
Colour checker aspect ratio, e.g. 1.5.
Colour checker aspect ratio, e.g., 1.5.
aspect_ratio_minimum
Minimum colour checker aspect ratio for detection: projective geometry
might reduce the colour checker aspect ratio.
Expand Down Expand Up @@ -433,7 +432,7 @@ def detect_colour_checkers_segmentation(
adaptive_threshold_kwargs
Keyword arguments for :func:`cv2.adaptiveThreshold` definition.
aspect_ratio
Colour checker aspect ratio, e.g. 1.5.
Colour checker aspect ratio, e.g., 1.5.
aspect_ratio_minimum
Minimum colour checker aspect ratio for detection: projective geometry
might reduce the colour checker aspect ratio.
Expand Down Expand Up @@ -541,8 +540,8 @@ def detect_colour_checkers_segmentation(
working_width = settings.working_width
working_height = int(working_width / settings.aspect_ratio)

if is_string(image):
image = read_image(cast(str, image))
if isinstance(image, str):
image = read_image(image)
else:
image = convert_bit_depth(
image,
Expand Down
4 changes: 2 additions & 2 deletions colour_checker_detection/detection/tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def test_reformat_image(self):
definition unit tests methods.
"""

# Skipping unit test when "png" files are missing, e.g. when testing
# Skipping unit test when "png" files are missing, e.g., when testing
# the distributed "Python" package.
if len(PNG_FILES) == 0:
return
Expand Down Expand Up @@ -392,7 +392,7 @@ def test_sample_colour_checker(self):
sample_colour_checker` definition unit tests methods.
"""

# Skipping unit test when "png" files are missing, e.g. when testing
# Skipping unit test when "png" files are missing, e.g., when testing
# the distributed "Python" package.
if len(PNG_FILES) == 0:
return
Expand Down
Loading

0 comments on commit b0493fe

Please sign in to comment.