Skip to content

Commit 09ce331

Browse files
Merge pull request #151 from worldcoin/dev
v1.9.3 release
2 parents f0a39cd + 407a092 commit 09ce331

31 files changed

Lines changed: 183 additions & 142 deletions

.github/workflows/deploy-docs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ jobs:
6767
- name: Checkout gh-pages branch
6868
run: |
6969
git fetch origin gh-pages:gh-pages || git checkout --orphan gh-pages
70+
git stash
7071
git checkout gh-pages
7172
7273
- name: Preserve existing .nojekyll from root

scripts/common/run_iris_pipeline.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44

55
import cv2
6+
from iris.io.dataclasses import IRImage
67
from iris.pipelines.iris_pipeline import IRISPipeline
78

89
if __name__ == "__main__":
@@ -22,6 +23,6 @@
2223

2324
img_data = cv2.imread(args.in_img, cv2.IMREAD_GRAYSCALE)
2425

25-
out = iris_pipeline(img_data, "right")
26+
out = iris_pipeline.estimate(IRImage(img_data=img_data, image_id="image_id1", eye_side="right"))
2627

2728
logging.info("Run iris pipeline inference script FINISHED")

src/iris/_version.py

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

src/iris/io/dataclasses.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from functools import cached_property
4-
from typing import Any, Callable, Dict, List, Literal, Tuple, Union
4+
from typing import Any, Callable, Dict, List, Literal, Optional, Tuple, Union
55

66
import numpy as np
77
from pydantic import BaseModel, Field, NonNegativeInt, root_validator, validator
@@ -22,6 +22,7 @@ class IRImage(ImmutableModel):
2222
"""Data holder for input IR image."""
2323

2424
img_data: np.ndarray
25+
image_id: Optional[str]
2526
eye_side: Literal["left", "right"]
2627

2728
@property

src/iris/nodes/iris_response/conv_filter_bank.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,12 @@ def __init__(
9494
filters (List[ImageFilter]): List of image filters.
9595
probe_schemas (List[ProbeSchema]): List of corresponding probe schemas.
9696
"""
97-
super().__init__(iris_code_version=iris_code_version, maskisduplicated=maskisduplicated, filters=filters, probe_schemas=probe_schemas)
97+
super().__init__(
98+
iris_code_version=iris_code_version,
99+
maskisduplicated=maskisduplicated,
100+
filters=filters,
101+
probe_schemas=probe_schemas,
102+
)
98103

99104
def run(self, normalization_output: NormalizedIris) -> IrisFilterResponse:
100105
"""Apply filters to a normalized iris image.
@@ -160,15 +165,30 @@ def _convolve(
160165

161166
# Perform convolution at [i,j] probed pixel position.
162167
iris_response[i][j] = (iris_patch * filter_patch).sum() / iris_patch.shape[0] / k_cols
163-
if iris_response[i][j] == 0:
168+
if iris_response[i][j] == 0:
164169
mask_response[i][j] = 0
165170
else:
166171
if self.params.maskisduplicated:
167-
val = 1 if mask_patch.all() else np.abs(filter_patch[mask_patch.astype(bool)].imag).sum() / np.abs(filter_patch.imag).sum()
172+
val = (
173+
1
174+
if mask_patch.all()
175+
else np.abs(filter_patch[mask_patch.astype(bool)].imag).sum()
176+
/ np.abs(filter_patch.imag).sum()
177+
)
168178
mask_response[i][j] = np.complex64(val + 1j * val)
169179
else:
170-
val_real = 1 if mask_patch.all() else np.abs(filter_patch[mask_patch.astype(bool)].real).sum() / np.abs(filter_patch.real).sum()
171-
val_imag = 1 if mask_patch.all() else np.abs(filter_patch[mask_patch.astype(bool)].imag).sum() / np.abs(filter_patch.imag).sum()
180+
val_real = (
181+
1
182+
if mask_patch.all()
183+
else np.abs(filter_patch[mask_patch.astype(bool)].real).sum()
184+
/ np.abs(filter_patch.real).sum()
185+
)
186+
val_imag = (
187+
1
188+
if mask_patch.all()
189+
else np.abs(filter_patch[mask_patch.astype(bool)].imag).sum()
190+
/ np.abs(filter_patch.imag).sum()
191+
)
172192
mask_response[i][j] = np.complex64(val_real + 1j * val_imag)
173193

174194
iris_response.real = iris_response.real / img_filter.kernel_norm.real

src/iris/nodes/iris_response_refinement/fragile_bits_refinement.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,13 @@ def __init__(
5151
maskisduplicated (bool, optional): If True, the mask is duplicated for both real and imaginary parts.
5252
callbacks(List[Callback]): List of callbacks. Defaults to [].
5353
"""
54-
super().__init__(value_threshold=value_threshold, fragile_type=fragile_type, maskisduplicated=maskisduplicated, callbacks=callbacks)
55-
54+
super().__init__(
55+
value_threshold=value_threshold,
56+
fragile_type=fragile_type,
57+
maskisduplicated=maskisduplicated,
58+
callbacks=callbacks,
59+
)
60+
5661
def run(self, response: IrisFilterResponse) -> IrisFilterResponse:
5762
"""Generate refined IrisFilterResponse.
5863
@@ -97,7 +102,7 @@ def run(self, response: IrisFilterResponse) -> IrisFilterResponse:
97102
iris_response_r >= self.params.value_threshold[0], iris_response_r <= self.params.value_threshold[1]
98103
)
99104
# min angle away from the coordinate lines
100-
105+
101106
if self.params.maskisduplicated:
102107
mask_value = mask_value_r * iris_mask.imag
103108
fragile_masks.append(mask_value + 1j * mask_value)

src/iris/nodes/matcher/hamming_distance_matcher_interface.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import abc
22
from typing import Any, List
3-
import numpy as np
43

4+
import numpy as np
55
from pydantic import conint
66

77
from iris.io.class_configs import ImmutableModel
@@ -25,7 +25,7 @@ def __init__(self, **kwargs) -> None:
2525
rotation_shift (int = 15): rotation allowed in matching, converted to columns. Defaults to 15.
2626
"""
2727
self.params = self.__parameters_type__(**kwargs)
28-
28+
2929
def load_weights(self, weights_path: str) -> List[np.array]:
3030
"""Load weights from a file.
3131
@@ -35,7 +35,7 @@ def load_weights(self, weights_path: str) -> List[np.array]:
3535
Returns:
3636
List[Any]: Loaded weights.
3737
"""
38-
with open(weights_path, 'rb') as f:
38+
with open(weights_path, "rb") as f:
3939
try:
4040
weights = np.load(f, allow_pickle=True)
4141
if isinstance(weights, np.ndarray):

src/iris/nodes/matcher/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ def count_nonmatchbits(
7272

7373
if half_width:
7474
totalirisbitcount = np.sum(
75-
[[np.sum(x[hw:, ...])*2, np.sum(x[:hw, ...])*2] for x, hw in zip(irisbitcount, half_width)], axis=0
75+
[[np.sum(x[hw:, ...]) * 2, np.sum(x[:hw, ...]) * 2] for x, hw in zip(irisbitcount, half_width)], axis=0
7676
)
7777
totalmaskbitcount = np.sum(
78-
[[np.sum(y[hw:, ...])*2, np.sum(y[:hw, ...])*2] for y, hw in zip(maskbitcount, half_width)], axis=0
78+
[[np.sum(y[hw:, ...]) * 2, np.sum(y[:hw, ...]) * 2] for y, hw in zip(maskbitcount, half_width)], axis=0
7979
)
8080
else:
8181
totalirisbitcount = np.sum(irisbitcount)

src/iris/orchestration/output_builders.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def __get_iris_pipeline_metadata(call_trace: PipelineCallTraceStorage) -> Dict[s
8989

9090
return {
9191
"iris_version": __version__,
92+
"image_id": ir_image.image_id,
9293
"image_size": (ir_image.width, ir_image.height),
9394
"eye_side": ir_image.eye_side,
9495
"eye_centers": __safe_serialize(call_trace.get("eye_center_estimation")),
@@ -144,9 +145,9 @@ def __get_templates_aggregation_metadata(call_trace: PipelineCallTraceStorage) -
144145
"reference_template_id": aligned_templates.reference_template_id if aligned_templates is not None else None,
145146
"distances": __safe_serialize(aligned_templates.distances) if aligned_templates is not None else None,
146147
},
147-
"post_identity_filter_templates_count": len(identity_filtered_templates)
148-
if identity_filtered_templates is not None
149-
else None,
148+
"post_identity_filter_templates_count": (
149+
len(identity_filtered_templates) if identity_filtered_templates is not None else None
150+
),
150151
}
151152

152153

@@ -216,9 +217,9 @@ def __get_multiframe_iris_pipeline_metadata(call_trace: PipelineCallTraceStorage
216217
OutputFieldSpec(key="error", extractor=__get_error, safe_serialize=False),
217218
OutputFieldSpec(
218219
key="iris_template",
219-
extractor=lambda ct: ct.get("templates_aggregation").as_iris_template()
220-
if ct.get("templates_aggregation") is not None
221-
else None,
220+
extractor=lambda ct: (
221+
ct.get("templates_aggregation").as_iris_template() if ct.get("templates_aggregation") is not None else None
222+
),
222223
safe_serialize=True,
223224
),
224225
OutputFieldSpec(key="metadata", extractor=__get_templates_aggregation_metadata, safe_serialize=False),
@@ -228,9 +229,9 @@ def __get_multiframe_iris_pipeline_metadata(call_trace: PipelineCallTraceStorage
228229
OutputFieldSpec(key="error", extractor=__get_error, safe_serialize=False),
229230
OutputFieldSpec(
230231
key="iris_template",
231-
extractor=lambda ct: ct.get("templates_aggregation").as_iris_template()
232-
if ct.get("templates_aggregation") is not None
233-
else None,
232+
extractor=lambda ct: (
233+
ct.get("templates_aggregation").as_iris_template() if ct.get("templates_aggregation") is not None else None
234+
),
234235
safe_serialize=False,
235236
),
236237
OutputFieldSpec(key="metadata", extractor=__get_templates_aggregation_metadata, safe_serialize=False),
@@ -242,9 +243,9 @@ def __get_multiframe_iris_pipeline_metadata(call_trace: PipelineCallTraceStorage
242243
OutputFieldSpec(key="error", extractor=__get_error, safe_serialize=False),
243244
OutputFieldSpec(
244245
key="iris_template",
245-
extractor=lambda ct: ct.get("aggregation_result", {}).get("iris_template")
246-
if ct.get("aggregation_result")
247-
else None,
246+
extractor=lambda ct: (
247+
ct.get("aggregation_result", {}).get("iris_template") if ct.get("aggregation_result") else None
248+
),
248249
safe_serialize=True,
249250
),
250251
OutputFieldSpec(key="metadata", extractor=__get_multiframe_iris_pipeline_metadata, safe_serialize=False),
@@ -267,9 +268,9 @@ def __get_multiframe_iris_pipeline_metadata(call_trace: PipelineCallTraceStorage
267268
OutputFieldSpec(key="error", extractor=__get_error, safe_serialize=False),
268269
OutputFieldSpec(
269270
key="iris_template",
270-
extractor=lambda ct: ct.get("aggregation_result", {}).get("iris_template")
271-
if ct.get("aggregation_result")
272-
else None,
271+
extractor=lambda ct: (
272+
ct.get("aggregation_result", {}).get("iris_template") if ct.get("aggregation_result") else None
273+
),
273274
safe_serialize=False,
274275
),
275276
OutputFieldSpec(key="metadata", extractor=__get_multiframe_iris_pipeline_metadata, safe_serialize=False),

src/iris/pipelines/confs/multiframe_iris_pipeline.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
metadata:
22
pipeline_name: multiframe_iris_pipeline
3-
iris_version: 1.9.2
3+
iris_version: 1.9.3
44

55
# Configuration for individual image processing (IRISPipeline)
66
iris_pipeline:
77
metadata:
88
pipeline_name: iris_pipeline
9-
iris_version: 1.9.2
9+
iris_version: 1.9.3
1010

1111
pipeline:
1212
- name: segmentation
@@ -314,7 +314,7 @@ iris_pipeline:
314314
# Configuration for template aggregation (TemplatesAggregationPipeline)
315315
templates_aggregation_pipeline:
316316
metadata:
317-
iris_version: 1.9.2
317+
iris_version: 1.9.3
318318
pipeline_name: templates_aggregation
319319

320320
pipeline:

0 commit comments

Comments
 (0)