Skip to content

Commit b0d1d35

Browse files
committed
Implement support for machine learning inference.
Overhaul segmentation method implementation.
1 parent 0f4e8f8 commit b0d1d35

17 files changed

+3532
-1595
lines changed

README.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,16 @@ Features
3939

4040
The following colour checker detection algorithms are implemented:
4141

42-
- Segmentation
42+
- Segmentation
43+
- Machine learning inference via `Ultralytics YOLOv8 <https://github.com/ultralytics/ultralytics>`__
44+
45+
- The model is published on `HuggingFace <https://huggingface.co/colour-science/colour-checker-detection-models>`__,
46+
and was trained on a purposely constructed `dataset <https://huggingface.co/datasets/colour-science/colour-checker-detection-dataset>`__.
47+
- The model has only been trained on *ColorChecker Classic 24* images and will not work with *ColorChecker Nano* or *ColorChecker SG* images.
48+
- Inference is performed by a script licensed under the terms of the
49+
*GNU Affero General Public License v3.0* as it uses the
50+
*Ultralytics YOLOv8* API which is incompatible with the
51+
*BSD-3-Clause*.
4352

4453
Examples
4554
^^^^^^^^
@@ -72,6 +81,11 @@ Primary Dependencies
7281
- `opencv-python >= 4, < 5 <https://pypi.org/project/opencv-python>`__
7382
- `scipy >= 1.8, < 2 <https://pypi.org/project/scipy>`__
7483

84+
Secondary Dependencies
85+
~~~~~~~~~~~~~~~~~~~~~~
86+
87+
- `ultralytics >= 8, < 9 <https://pypi.org/project/ultralytics>`__
88+
7589
Pypi
7690
~~~~
7791

colour_checker_detection/__init__.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@
2020
import numpy as np
2121

2222
from .detection import (
23+
SETTINGS_INFERENCE_COLORCHECKER_CLASSIC,
24+
SETTINGS_INFERENCE_COLORCHECKER_CLASSIC_MINI,
2325
SETTINGS_SEGMENTATION_COLORCHECKER_CLASSIC,
26+
SETTINGS_SEGMENTATION_COLORCHECKER_NANO,
2427
SETTINGS_SEGMENTATION_COLORCHECKER_SG,
25-
colour_checkers_coordinates_segmentation,
28+
detect_colour_checkers_inference,
2629
detect_colour_checkers_segmentation,
27-
extract_colour_checkers_segmentation,
30+
inferencer_default,
31+
segmenter_default,
2832
)
2933

3034
__author__ = "Colour Developers"
@@ -35,11 +39,15 @@
3539
__status__ = "Production"
3640

3741
__all__ = [
42+
"SETTINGS_INFERENCE_COLORCHECKER_CLASSIC",
43+
"SETTINGS_INFERENCE_COLORCHECKER_CLASSIC_MINI",
3844
"SETTINGS_SEGMENTATION_COLORCHECKER_CLASSIC",
45+
"SETTINGS_SEGMENTATION_COLORCHECKER_NANO",
3946
"SETTINGS_SEGMENTATION_COLORCHECKER_SG",
40-
"colour_checkers_coordinates_segmentation",
41-
"extract_colour_checkers_segmentation",
47+
"detect_colour_checkers_inference",
4248
"detect_colour_checkers_segmentation",
49+
"inferencer_default",
50+
"segmenter_default",
4351
]
4452

4553
ROOT_RESOURCES: str = os.path.join(os.path.dirname(__file__), "resources")
Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,73 @@
11
from .common import (
2-
FLOAT_DTYPE_DEFAULT,
2+
DTYPE_INT_DEFAULT,
3+
DTYPE_FLOAT_DEFAULT,
4+
SETTINGS_DETECTION_COLORCHECKER_CLASSIC,
5+
SETTINGS_DETECTION_COLORCHECKER_SG,
6+
SETTINGS_CONTOUR_DETECTION_DEFAULT,
7+
as_int32_array,
8+
as_float32_array,
39
swatch_masks,
4-
adjust_image,
5-
crop_with_rectangle,
10+
swatch_colours,
11+
reformat_image,
12+
transform_image,
13+
detect_contours,
614
is_square,
715
contour_centroid,
816
scale_contour,
917
approximate_contour,
18+
quadrilateralise_contours,
19+
remove_stacked_contours,
20+
DataDetectionColourChecker,
21+
sample_colour_checker,
1022
)
23+
from .inference import (
24+
SETTINGS_INFERENCE_COLORCHECKER_CLASSIC,
25+
SETTINGS_INFERENCE_COLORCHECKER_CLASSIC_MINI,
26+
inferencer_default,
27+
detect_colour_checkers_inference,
28+
)
29+
1130
from .segmentation import (
1231
SETTINGS_SEGMENTATION_COLORCHECKER_CLASSIC,
1332
SETTINGS_SEGMENTATION_COLORCHECKER_SG,
14-
colour_checkers_coordinates_segmentation,
15-
extract_colour_checkers_segmentation,
33+
SETTINGS_SEGMENTATION_COLORCHECKER_NANO,
34+
segmenter_default,
1635
detect_colour_checkers_segmentation,
1736
)
1837

1938
__all__ = [
20-
"FLOAT_DTYPE_DEFAULT",
39+
"DTYPE_INT_DEFAULT",
40+
"DTYPE_FLOAT_DEFAULT",
41+
"SETTINGS_DETECTION_COLORCHECKER_CLASSIC",
42+
"SETTINGS_DETECTION_COLORCHECKER_SG",
43+
"SETTINGS_CONTOUR_DETECTION_DEFAULT",
44+
"as_int32_array",
45+
"as_float32_array",
2146
"swatch_masks",
22-
"adjust_image",
23-
"crop_with_rectangle",
47+
"swatch_colours",
48+
"reformat_image",
49+
"transform_image",
50+
"detect_contours",
2451
"is_square",
2552
"contour_centroid",
2653
"scale_contour",
2754
"approximate_contour",
55+
"quadrilateralise_contours",
56+
"remove_stacked_contours",
57+
"DataDetectionColourChecker",
58+
"sample_colour_checker",
2859
]
2960
__all__ += [
3061
"SETTINGS_SEGMENTATION_COLORCHECKER_CLASSIC",
3162
"SETTINGS_SEGMENTATION_COLORCHECKER_SG",
32-
"colour_checkers_coordinates_segmentation",
63+
"SETTINGS_SEGMENTATION_COLORCHECKER_NANO",
64+
"segmenter_default",
3365
"extract_colour_checkers_segmentation",
3466
"detect_colour_checkers_segmentation",
3567
]
68+
__all__ += [
69+
"SETTINGS_INFERENCE_COLORCHECKER_CLASSIC",
70+
"SETTINGS_INFERENCE_COLORCHECKER_CLASSIC_MINI",
71+
"inferencer_default",
72+
"detect_colour_checkers_inference",
73+
]

0 commit comments

Comments
 (0)