Skip to content

Commit baea011

Browse files
Release 1.9.4 (#158)
* replace DistanceMatrix serialization (#155) * replace DistanceMatrix serialization * add more tests for json serialization of the metadata * Merge pull request #156 from worldcoin/wiktorlazarski/fix-colabs Fix README.md, tutorials in doc, and Google Colabs. * 1.9.3 -> 1.9.4 (#157) * 1.9.3 -> 1.9.4 * upd * update the version * bump version in the doc * Main to dev (#159) Co-authored-by: Wiktor Łazarski <wjlazarski@gmail.com> --------- Co-authored-by: Wiktor Łazarski <wjlazarski@gmail.com>
1 parent 09ce331 commit baea011

16 files changed

Lines changed: 170 additions & 58 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ img_pixels = cv2.imread("/path/to/ir/image", cv2.IMREAD_GRAYSCALE)
133133

134134
# 3. Perform inference
135135
# Options for the `eye_side` argument are: ["left", "right"]
136-
output = iris_pipeline(img_data=img_pixels, eye_side="left")
136+
output = iris_pipeline(iris.IRImage(img_data=img_pixels, image_id="image_id", eye_side="left"))
137137
```
138138

139139
To fully explore and understand the extensive capabilities of the iris package, visit the [Example notebooks](#example-notebooks) section. Here, you'll find a collection of Jupyter Notebooks that serve as valuable resources, offering practical guides and real-world examples to provide a comprehensive insight into the rich functionalities and potential applications of the `iris` package.

colab/ConfiguringCustomPipeline.ipynb

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
"metadata": {},
4545
"outputs": [],
4646
"source": [
47-
"!pip install open-iris"
47+
"!pip install onnx onnxruntime pydantic==1.10.16 huggingface-hub pyyaml\n",
48+
"!pip install --no-deps open-iris"
4849
]
4950
},
5051
{
@@ -125,7 +126,7 @@
125126
"```yaml\n",
126127
"metadata:\n",
127128
" pipeline_name: iris_pipeline\n",
128-
" iris_version: 1.1.1\n",
129+
" iris_version: 1.9.4\n",
129130
"```\n",
130131
"\n",
131132
"The top YAML file contains `IRISPipeline` metadata, used to both describe `IRISPipeline` and specify package parameters that are later used to verify compatibility between `iris` package version/release and later, specified in the `pipeline` YAML file section, pipeline's graph.\n",
@@ -205,7 +206,7 @@
205206
"outputs": [],
206207
"source": [
207208
"default_pipeline_conf = {\n",
208-
" \"metadata\": {\"pipeline_name\": \"iris_pipeline\", \"iris_version\": \"1.1.1\"},\n",
209+
" \"metadata\": {\"pipeline_name\": \"iris_pipeline\", \"iris_version\": \"1.9.4\"},\n",
209210
" \"pipeline\": [\n",
210211
" {\n",
211212
" \"name\": \"segmentation\",\n",
@@ -423,7 +424,7 @@
423424
"source": [
424425
"iris_pipeline = iris.IRISPipeline(config=default_pipeline_conf)\n",
425426
"\n",
426-
"assert iris_pipeline(img_data=img_pixels, eye_side=\"left\")[\"error\"] is None"
427+
"assert iris_pipeline(iris.IRImage(img_data=img_pixels, image_id=\"image_id\", eye_side=\"left\"))[\"error\"] is None"
427428
]
428429
},
429430
{
@@ -480,7 +481,7 @@
480481
"outputs": [],
481482
"source": [
482483
"new_pipeline_conf = {\n",
483-
" \"metadata\": {\"pipeline_name\": \"iris_pipeline\", \"iris_version\": \"1.1.1\"},\n",
484+
" \"metadata\": {\"pipeline_name\": \"iris_pipeline\", \"iris_version\": \"1.9.4\"},\n",
484485
" \"pipeline\": [\n",
485486
" {\n",
486487
" \"name\": \"segmentation\",\n",
@@ -702,7 +703,7 @@
702703
"source": [
703704
"iris_pipeline = iris.IRISPipeline(config=new_pipeline_conf)\n",
704705
"\n",
705-
"assert iris_pipeline(img_data=img_pixels, eye_side=\"left\")[\"error\"] is None"
706+
"assert iris_pipeline(iris.IRImage(img_data=img_pixels, image_id=\"image_id\", eye_side=\"left\"))[\"error\"] is None"
706707
]
707708
},
708709
{
@@ -759,7 +760,7 @@
759760
"outputs": [],
760761
"source": [
761762
"default_pipeline_conf = {\n",
762-
" \"metadata\": {\"pipeline_name\": \"iris_pipeline\", \"iris_version\": \"1.1.1\"},\n",
763+
" \"metadata\": {\"pipeline_name\": \"iris_pipeline\", \"iris_version\": \"1.9.4\"},\n",
763764
" \"pipeline\": [\n",
764765
" {\n",
765766
" \"name\": \"segmentation\",\n",
@@ -981,7 +982,7 @@
981982
"source": [
982983
"iris_pipeline = iris.IRISPipeline(config=default_pipeline_conf)\n",
983984
"\n",
984-
"assert iris_pipeline(img_data=img_pixels, eye_side=\"left\")[\"error\"] is None"
985+
"assert iris_pipeline(iris.IRImage(img_data=img_pixels, image_id=\"image_id\", eye_side=\"left\"))[\"error\"] is None"
985986
]
986987
},
987988
{
@@ -1034,7 +1035,7 @@
10341035
"outputs": [],
10351036
"source": [
10361037
"new_pipeline_conf = {\n",
1037-
" \"metadata\": {\"pipeline_name\": \"iris_pipeline\", \"iris_version\": \"1.1.1\"},\n",
1038+
" \"metadata\": {\"pipeline_name\": \"iris_pipeline\", \"iris_version\": \"1.9.4\"},\n",
10381039
" \"pipeline\": [\n",
10391040
" {\n",
10401041
" \"name\": \"segmentation\",\n",
@@ -1256,7 +1257,7 @@
12561257
"source": [
12571258
"iris_pipeline = iris.IRISPipeline(config=new_pipeline_conf)\n",
12581259
"\n",
1259-
"assert iris_pipeline(img_data=img_pixels, eye_side=\"left\")[\"error\"] is None"
1260+
"assert iris_pipeline(iris.IRImage(img_data=img_pixels, image_id=\"image_id\", eye_side=\"left\"))[\"error\"] is None"
12601261
]
12611262
},
12621263
{
@@ -1371,7 +1372,7 @@
13711372
],
13721373
"metadata": {
13731374
"kernelspec": {
1374-
"display_name": "Python 3 (ipykernel)",
1375+
"display_name": "open_iris_dev",
13751376
"language": "python",
13761377
"name": "python3"
13771378
},

colab/GettingStarted.ipynb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
},
4747
"outputs": [],
4848
"source": [
49-
"!pip install open-iris"
49+
"!pip install onnx onnxruntime pydantic==1.10.16 huggingface-hub pyyaml\n",
50+
"!pip install --no-deps open-iris"
5051
]
5152
},
5253
{
@@ -148,9 +149,9 @@
148149
"\n",
149150
"```python\n",
150151
"# Options for the `eye_side` argument are: [\"left\", \"right\"]\n",
151-
"output = iris_pipeline(img_data=img_pixels, eye_side=\"right\")\n",
152-
"output = iris_pipeline.run(img_data=img_pixels, eye_side=\"right\")\n",
153-
"output = iris_pipeline.estimate(img_data=img_pixels, eye_side=\"right\")\n",
152+
"output = iris_pipeline(iris.IRImage(img_data=img_pixels, image_id=\"image_id\", eye_side=\"right\"))\n",
153+
"output = iris_pipeline.run(iris.IRImage(img_data=img_pixels, image_id=\"image_id\", eye_side=\"right\"))\n",
154+
"output = iris_pipeline.estimate(iris.IRImage(img_data=img_pixels, image_id=\"image_id\", eye_side=\"right\"))\n",
154155
"```"
155156
]
156157
},
@@ -161,7 +162,7 @@
161162
"metadata": {},
162163
"outputs": [],
163164
"source": [
164-
"output = iris_pipeline(img_data=img_pixels, eye_side=\"right\")"
165+
"output = iris_pipeline(iris.IRImage(img_data=img_pixels, image_id=\"image_id\", eye_side=\"right\"))"
165166
]
166167
},
167168
{
@@ -351,7 +352,7 @@
351352
"source": [
352353
"iris_pipeline = iris.IRISPipeline(env=iris.IRISPipeline.DEBUGGING_ENVIRONMENT)\n",
353354
"\n",
354-
"output = iris_pipeline(img_data=img_pixels, eye_side=\"right\")"
355+
"output = iris_pipeline(iris.IRImage(img_data=img_pixels, image_id=\"image_id\", eye_side=\"right\"))"
355356
]
356357
},
357358
{
@@ -583,7 +584,7 @@
583584
],
584585
"metadata": {
585586
"kernelspec": {
586-
"display_name": "Python 3 (ipykernel)",
587+
"display_name": "open_iris_dev",
587588
"language": "python",
588589
"name": "python3"
589590
},

colab/MatchingEntities.ipynb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
"metadata": {},
3838
"outputs": [],
3939
"source": [
40-
"!pip install open-iris"
40+
"!pip install onnx onnxruntime pydantic==1.10.16 huggingface-hub pyyaml\n",
41+
"!pip install --no-deps open-iris"
4142
]
4243
},
4344
{
@@ -141,13 +142,13 @@
141142
"\n",
142143
"iris_pipeline = iris.IRISPipeline()\n",
143144
"\n",
144-
"output_1 = iris_pipeline(subject1_first_image, eye_side=\"left\")\n",
145+
"output_1 = iris_pipeline(iris.IRImage(img_data=subject1_first_image, image_id=\"subject1_first_image\", eye_side=\"left\"))\n",
145146
"subject1_first_code = output_1['iris_template']\n",
146147
"\n",
147-
"output_2 = iris_pipeline(subject1_second_image, eye_side=\"left\")\n",
148+
"output_2 = iris_pipeline(iris.IRImage(img_data=subject1_second_image, image_id=\"subject1_second_image\", eye_side=\"left\"))\n",
148149
"subject1_second_code = output_2['iris_template']\n",
149150
"\n",
150-
"output_3 = iris_pipeline(subject2_image, eye_side=\"left\")\n",
151+
"output_3 = iris_pipeline(iris.IRImage(img_data=subject2_image, image_id=\"subject2_image\", eye_side=\"left\"))\n",
151152
"subject2_code = output_3['iris_template']"
152153
]
153154
},
@@ -221,7 +222,7 @@
221222
],
222223
"metadata": {
223224
"kernelspec": {
224-
"display_name": "Python 3 (ipykernel)",
225+
"display_name": "open_iris_dev",
225226
"language": "python",
226227
"name": "python3"
227228
},
@@ -235,7 +236,7 @@
235236
"name": "python",
236237
"nbconvert_exporter": "python",
237238
"pygments_lexer": "ipython3",
238-
"version": "3.8.0"
239+
"version": "3.9.0"
239240
}
240241
},
241242
"nbformat": 4,

docs/source/examples/custom_pipeline.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ When the ``IRISPipeline`` pipeline is created with default parameters, it's grap
1818
1919
metadata:
2020
pipeline_name: iris_pipeline
21-
iris_version: 1.1.1
21+
iris_version: 1.9.4
2222
2323
The top YAML file contains ``IRISPipeline`` metadata, used to both describe ``IRISPipeline`` and specify package parameters that are later used to verify compatibility between ``iris`` package version/release and later, specified in the ``pipeline`` YAML file section, pipeline's graph.
2424

@@ -93,7 +93,7 @@ First let's intantiate ``IRISPipeline`` with default configuration and see ``iri
9393
.. code-block:: python
9494
9595
default_pipeline_conf = {
96-
"metadata": {"pipeline_name": "iris_pipeline", "iris_version": "1.1.1"},
96+
"metadata": {"pipeline_name": "iris_pipeline", "iris_version": "1.9.4"},
9797
"pipeline": [
9898
{
9999
"name": "segmentation",
@@ -320,7 +320,7 @@ As expected all threshold values are set to default ``0.5`` value. Now, let's mo
320320
.. code-block:: python
321321
322322
new_pipeline_conf = {
323-
"metadata": {"pipeline_name": "iris_pipeline", "iris_version": "1.1.1"},
323+
"metadata": {"pipeline_name": "iris_pipeline", "iris_version": "1.9.4"},
324324
"pipeline": [
325325
{
326326
"name": "segmentation",
@@ -552,7 +552,7 @@ First let's instantiate ``IRISPipeline`` with default configuration and see node
552552
.. code-block:: python
553553
554554
default_pipeline_conf = {
555-
"metadata": {"pipeline_name": "iris_pipeline", "iris_version": "1.1.1"},
555+
"metadata": {"pipeline_name": "iris_pipeline", "iris_version": "1.9.4"},
556556
"pipeline": [
557557
{
558558
"name": "segmentation",
@@ -783,7 +783,7 @@ As expected, ``input_polygons`` argument of the ``run`` method is taken from the
783783
.. code-block:: python
784784
785785
new_pipeline_conf = {
786-
"metadata": {"pipeline_name": "iris_pipeline", "iris_version": "1.1.1"},
786+
"metadata": {"pipeline_name": "iris_pipeline", "iris_version": "1.9.4"},
787787
"pipeline": [
788788
{
789789
"name": "segmentation",

docs/source/examples/getting_started.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ There are several methods that wraps ``IRISPipeline`` inference call. Each one o
3434
.. code-block:: python
3535
3636
# Options for the `eye_side` argument are: ["left", "right"]
37-
output = iris_pipeline(img_data=img_pixels, eye_side="right")
38-
output = iris_pipeline.run(img_data=img_pixels, eye_side="right")
39-
output = iris_pipeline.estimate(img_data=img_pixels, eye_side="right")
37+
output = iris_pipeline(iris.IRImage(img_data=img_pixels, image_id="image_id", eye_side="right"))
38+
output = iris_pipeline.run(iris.IRImage(img_data=img_pixels, image_id="image_id", eye_side="right"))
39+
output = iris_pipeline.estimate(iris.IRImage(img_data=img_pixels, image_id="image_id", eye_side="right"))
4040
4141
The output of ``IRISPipeline`` is a dictionary with following keys: ``["error", "iris_template", "metadata"]``.
4242

@@ -126,7 +126,7 @@ Let's test it and see the output of the ``IRISPipeline`` with ``DEBUGGING_ENVIRO
126126
.. code-block:: python
127127
128128
iris_pipeline = iris.IRISPipeline(env=iris.IRISPipeline.DEBUGGING_ENVIRONMENT)
129-
output = iris_pipeline(img_data=img_pixels, eye_side="right")
129+
output = iris_pipeline(iris.IRImage(img_data=img_pixels, image_id="image_id", eye_side="right"))
130130
131131
In the same manner, we can investigate what has been returned from ``DEBUGGING_ENVIRONMENT`` and we can see that more intermediate result are available for us in the ``output`` dictionary.
132132

docs/source/examples/matching_entities.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ Create ``IRISPipeline`` object and compute ``IrisTemplates`` for all images.
2525
2626
iris_pipeline = iris.IRISPipeline()
2727
28-
output_1 = iris_pipeline(subject1_first_image, eye_side="left")
28+
output_1 = iris_pipeline(iris.IRImage(img_data=subject1_first_image, image_id="subject1_first_image", eye_side="left"))
2929
subject1_first_code = output_1["iris_template"]
3030
31-
output_2 = iris_pipeline(subject1_second_image, eye_side="left")
31+
output_2 = iris_pipeline(iris.IRImage(img_data=subject1_second_image, image_id="subject1_second_image", eye_side="left"))
3232
subject1_second_code = output_2["iris_template"]
3333
34-
output_3 = iris_pipeline(subject2_image, eye_side="left")
34+
output_3 = iris_pipeline(iris.IRImage(img_data=subject2_image, image_id="subject2_image", eye_side="left"))
3535
subject2_code = output_3["iris_template"]
3636
3737
Create a ``HammingDistanceMatcher`` matcher object.

docs/source/quickstart/running_inference.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ A simple inference run can be achieved by running source code below.
1616
1717
# 3. Perform inference
1818
# Options for the `eye_side` argument are: ["left", "right"]
19-
output = iris_pipeline(img_data=img_pixels, eye_side="left")
19+
output = iris_pipeline(iris.IRImage(img_data=img_pixels, image_id="image_id", eye_side="left")
2020
2121
To fully explore and understand the extensive capabilities of the iris package, visit the `Examples` subpages. Here, you'll find a collection of Jupyter Notebooks that serve as valuable resources, offering practical guides and real-world examples to provide a comprehensive insight into the rich functionalities and potential applications of the ``iris`` package.
2222

src/iris/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.9.3"
1+
__version__ = "1.9.4"

src/iris/io/dataclasses.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -928,22 +928,35 @@ def nb_templates(self) -> int:
928928
indices.add(j)
929929
return len(indices)
930930

931-
def serialize(self) -> Dict[Tuple[int, int], float]:
931+
def serialize(self) -> Dict[str, float]:
932932
"""Serialize DistanceMatrix object.
933933
934934
Returns:
935-
Dict[Tuple[int, int], float]: Serialized object.
935+
Dict[str, float]: Serialized object with keys as "i_j" strings.
936936
"""
937-
return self.data
937+
return {f"{i}_{j}": value for (i, j), value in self.data.items()}
938938

939939
@staticmethod
940-
def deserialize(data: Dict[Tuple[int, int], float]) -> DistanceMatrix:
941-
"""Deserialize DistanceMatrix object.
940+
def deserialize(data: Dict[str, float]) -> DistanceMatrix:
941+
"""Deserialize DistanceMatrix object from "i_j" string keys only.
942942
943943
Returns:
944944
DistanceMatrix: Deserialized object.
945945
"""
946-
return DistanceMatrix(data=data)
946+
tuple_keyed: Dict[Tuple[int, int], float] = {}
947+
for key_str, value in data.items():
948+
s = str(key_str).strip()
949+
parts = s.split("_", 1)
950+
if len(parts) != 2:
951+
raise ValueError(f"Invalid distance matrix key format: {key_str}, expected format: 'i_j'")
952+
try:
953+
i = int(parts[0])
954+
j = int(parts[1])
955+
except ValueError:
956+
raise ValueError(f"Invalid distance matrix key format: {key_str}, expected format: 'i_j'")
957+
tuple_keyed[(i, j)] = value
958+
959+
return DistanceMatrix(data=tuple_keyed)
947960

948961

949962
class AlignedTemplates(ImmutableModel):

0 commit comments

Comments
 (0)