Skip to content

Commit b76cdeb

Browse files
authored
Merge pull request #87 from worldcoin/dev
1.5.0 release
2 parents d4c9a46 + b9a7794 commit b76cdeb

8 files changed

Lines changed: 18 additions & 17 deletions

File tree

src/iris/_version.py

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

src/iris/nodes/encoder/iris_encoder.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ class Parameters(Algorithm.Parameters):
2626

2727
__parameters_type__ = Parameters
2828

29-
def __init__(self, mask_threshold: float = 0.9, callbacks: List[Callback] = []) -> None:
29+
def __init__(self, mask_threshold: float = 0.93, callbacks: List[Callback] = []) -> None:
3030
"""Assign parameters.
3131
3232
Args:
33-
mask_threshold (float): threshold to binarize mask_responses, in the range of [0,1]. Defaults to 0.9.
33+
mask_threshold (float): threshold to binarize mask_responses, in the range of [0,1]. Defaults to 0.93.
3434
callbacks (List[Callback]): callbacks list. Defaults to [].
3535
"""
3636
super().__init__(mask_threshold=mask_threshold, callbacks=callbacks)
@@ -48,7 +48,6 @@ def run(self, response: IrisFilterResponse) -> IrisTemplate:
4848
mask_codes: List[np.ndarray] = []
4949

5050
for iris_response, mask_response in zip(response.iris_responses, response.mask_responses):
51-
5251
iris_code = np.stack([iris_response.real > 0, iris_response.imag > 0], axis=-1)
5352
mask_code = np.stack(
5453
[mask_response.real >= self.params.mask_threshold, mask_response.imag >= self.params.mask_threshold],

src/iris/nodes/iris_response/conv_filter_bank.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,19 @@ def _convolve(
152152
rbot = min(r_probe + p_rows + 1, i_rows - 1)
153153
iris_patch = padded_iris[rtop:rbot, c_probe : c_probe + k_cols]
154154
mask_patch = padded_mask[rtop:rbot, c_probe : c_probe + k_cols]
155+
ktop = p_rows - iris_patch.shape[0] // 2
156+
filter_patch = img_filter.kernel_values[ktop : ktop + iris_patch.shape[0], :]
155157

156158
# Perform convolution at [i,j] probed pixel position.
157-
ktop = p_rows - iris_patch.shape[0] // 2
158-
iris_response[i][j] = (
159-
(iris_patch * img_filter.kernel_values[ktop : ktop + iris_patch.shape[0], :]).sum()
160-
/ iris_patch.shape[0]
161-
/ k_cols
162-
)
163-
mask_response[i][j] = (
164-
0 if iris_response[i][j] == 0 else (mask_patch.sum() / iris_patch.shape[0] / k_cols)
165-
)
159+
iris_response[i][j] = (iris_patch * filter_patch).sum() / iris_patch.shape[0] / k_cols
160+
if iris_response[i][j] == 0:
161+
mask_response[i][j] = 0
162+
else:
163+
mask_response[i][j] = (
164+
1
165+
if mask_patch.all()
166+
else np.abs(filter_patch[mask_patch.astype(bool)].imag).sum() / np.abs(filter_patch.imag).sum()
167+
)
166168

167169
iris_response.real = iris_response.real / img_filter.kernel_norm.real
168170
iris_response.imag = iris_response.imag / img_filter.kernel_norm.imag

src/iris/pipelines/confs/pipeline.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
metadata:
22
pipeline_name: iris_pipeline
3-
iris_version: 1.4.0
3+
iris_version: 1.5.0
44

55
pipeline:
66
- name: segmentation

src/iris/utils/visualisation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ def plot_iris_filter_response(
389389
iris_filter_response: Union[iris_dc.IrisFilterResponse, Dict[str, List[np.ndarray]]],
390390
space: Literal["cartesian", "polar"] = "cartesian",
391391
plot_mask: bool = True,
392-
mask_threshold: float = 0.9,
392+
mask_threshold: float = 0.93,
393393
vlim: float = 1e-3,
394394
ax: Optional[matplotlib.axes._axes.Axes] = None,
395395
) -> Canvas:
@@ -399,7 +399,7 @@ def plot_iris_filter_response(
399399
iris_filter_response (Union[iris_dc.IrisFilterResponse, Dict[str, List[np.ndarray]]]): iris filter response to visualise.
400400
space (Literal["cartesian", "polar"], optional): Wether to plot the response in cartesian or polar coordinates. Defaults to cartesian.
401401
plot_mask (bool, optional): Wether to overlay the mask response in transparency. Defaults to True.
402-
mask_threshold (float, optional): Wether to overlay the mask in transparency. Defaults to 0.9.
402+
mask_threshold (float, optional): Wether to overlay the mask in transparency. Defaults to 0.93.
403403
vlim (float, optional): The maximal value displayed in real, imaginary and amplitude graphs. Defaults to 1e-3
404404
ax (Optional[matplotlib.axes._axes.Axes]): ax to plot the figure at. Defaults to None.
405405
@@ -525,7 +525,7 @@ def plot_iris_template_and_normalized_iris(
525525
array=mask_code[:, :, 1],
526526
target_shape=normalized_iris.normalized_image.shape[::-1],
527527
)
528-
mask_resized[mask_resized > 0.9] = np.nan
528+
mask_resized[mask_resized > 0.93] = np.nan
529529
axs[2 * i + j].imshow(mask_resized, alpha=0.8, cmap="gray", vmin=0, vmax=1)
530530

531531
return fig, axs
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)