Ready I think

This commit is contained in:
2026-04-08 12:14:12 +02:00
parent 86018b4250
commit ffc0e923dc
8 changed files with 172 additions and 145 deletions
+3
View File
@@ -23,6 +23,9 @@ ENV IRIS_ENV="DEV"
RUN uv pip install notebook git+https://github.com/worldcoin/open-iris.git@v1.11.0 RUN uv pip install notebook git+https://github.com/worldcoin/open-iris.git@v1.11.0
RUN patchelf --clear-execstack /src/.venv/lib/python3.11/site-packages/onnxruntime/capi/*.so RUN patchelf --clear-execstack /src/.venv/lib/python3.11/site-packages/onnxruntime/capi/*.so
# Run initialize to download the model
RUN python ./initialize.py
# Launch Jupyter Notebook # Launch Jupyter Notebook
EXPOSE 8888 EXPOSE 8888
CMD ["python", "-m", "jupyter", "notebook", "--ip=0.0.0.0", "--port=8888", "--no-browser", "--IdentityProvider.token=''"] CMD ["python", "-m", "jupyter", "notebook", "--ip=0.0.0.0", "--port=8888", "--no-browser", "--IdentityProvider.token=''"]
Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 855 KiB

+3
View File
@@ -0,0 +1,3 @@
import iris
iris_pipeline = iris.IRISPipeline()
+21 -86
View File
File diff suppressed because one or more lines are too long
+82 -25
View File
@@ -3,30 +3,45 @@ pipeline_conf = {
"pipeline": [ "pipeline": [
{ {
"name": "segmentation", "name": "segmentation",
"algorithm": {"class_name": "iris.MultilabelSegmentation.create_from_hugging_face", "params": {}}, "algorithm": {
"class_name": "iris.MultilabelSegmentation.create_from_hugging_face",
"params": {},
},
"inputs": [{"name": "image", "source_node": "input"}], "inputs": [{"name": "image", "source_node": "input"}],
"callbacks": None, "callbacks": None,
}, },
{ {
"name": "segmentation_binarization", "name": "segmentation_binarization",
"algorithm": {"class_name": "iris.MultilabelSegmentationBinarization", "params": { "algorithm": {
"eyeball_threshold": 0.1, "class_name": "iris.MultilabelSegmentationBinarization",
"iris_threshold": 0.1, "params": {
"pupil_threshold": 0.1, "eyeball_threshold": 0.5,
"eyelashes_threshold": 0.1 "iris_threshold": 0.5,
}}, "pupil_threshold": 0.5,
"eyelashes_threshold": 0.5,
},
},
"inputs": [{"name": "segmentation_map", "source_node": "segmentation"}], "inputs": [{"name": "segmentation_map", "source_node": "segmentation"}],
"callbacks": None, "callbacks": None,
}, },
{ {
"name": "vectorization", "name": "vectorization",
"algorithm": {"class_name": "iris.ContouringAlgorithm", "params": {}}, "algorithm": {"class_name": "iris.ContouringAlgorithm", "params": {}},
"inputs": [{"name": "geometry_mask", "source_node": "segmentation_binarization", "index": 0}], "inputs": [
{
"name": "geometry_mask",
"source_node": "segmentation_binarization",
"index": 0,
}
],
"callbacks": None, "callbacks": None,
}, },
{ {
"name": "specular_reflection_detection", "name": "specular_reflection_detection",
"algorithm": {"class_name": "iris.SpecularReflectionDetection", "params": {}}, "algorithm": {
"class_name": "iris.SpecularReflectionDetection",
"params": {},
},
"inputs": [{"name": "ir_image", "source_node": "input"}], "inputs": [{"name": "ir_image", "source_node": "input"}],
"callbacks": None, "callbacks": None,
}, },
@@ -38,18 +53,26 @@ pipeline_conf = {
}, },
{ {
"name": "distance_filter", "name": "distance_filter",
"algorithm": {"class_name": "iris.ContourPointNoiseEyeballDistanceFilter", "params": {}}, "algorithm": {
"class_name": "iris.ContourPointNoiseEyeballDistanceFilter",
"params": {},
},
"inputs": [ "inputs": [
{"name": "polygons", "source_node": "interpolation"}, {"name": "polygons", "source_node": "interpolation"},
{"name": "geometry_mask", "source_node": "segmentation_binarization", "index": 1}, {
"name": "geometry_mask",
"source_node": "segmentation_binarization",
"index": 1,
},
], ],
"callbacks": None, "callbacks": None,
}, },
{ {
"name": "eye_orientation", "name": "eye_orientation",
"algorithm": {"class_name": "iris.MomentOfArea", "params": { "algorithm": {
"eccentricity_threshold": 0.05 "class_name": "iris.MomentOfArea",
}}, "params": {"eccentricity_threshold": 0.05},
},
"inputs": [{"name": "geometries", "source_node": "distance_filter"}], "inputs": [{"name": "geometries", "source_node": "distance_filter"}],
"callbacks": None, "callbacks": None,
}, },
@@ -73,8 +96,14 @@ pipeline_conf = {
"algorithm": { "algorithm": {
"class_name": "iris.FusionExtrapolation", "class_name": "iris.FusionExtrapolation",
"params": { "params": {
"circle_extrapolation": {"class_name": "iris.LinearExtrapolation", "params": {"dphi": 0.703125}}, "circle_extrapolation": {
"ellipse_fit": {"class_name": "iris.LSQEllipseFitWithRefinement", "params": {"dphi": 0.703125}}, "class_name": "iris.LinearExtrapolation",
"params": {"dphi": 0.703125},
},
"ellipse_fit": {
"class_name": "iris.LSQEllipseFitWithRefinement",
"params": {"dphi": 0.703125},
},
"algorithm_switch_std_threshold": 3.5, "algorithm_switch_std_threshold": 3.5,
}, },
}, },
@@ -86,7 +115,10 @@ pipeline_conf = {
}, },
{ {
"name": "pupil_to_iris_property_estimation", "name": "pupil_to_iris_property_estimation",
"algorithm": {"class_name": "iris.PupilIrisPropertyCalculator", "params": {}}, "algorithm": {
"class_name": "iris.PupilIrisPropertyCalculator",
"params": {},
},
"inputs": [ "inputs": [
{"name": "geometries", "source_node": "geometry_estimation"}, {"name": "geometries", "source_node": "geometry_estimation"},
{"name": "eye_centers", "source_node": "eye_center_estimation"}, {"name": "eye_centers", "source_node": "eye_center_estimation"},
@@ -95,15 +127,25 @@ pipeline_conf = {
}, },
{ {
"name": "offgaze_estimation", "name": "offgaze_estimation",
"algorithm": {"class_name": "iris.EccentricityOffgazeEstimation", "params": {}}, "algorithm": {
"class_name": "iris.EccentricityOffgazeEstimation",
"params": {},
},
"inputs": [{"name": "geometries", "source_node": "geometry_estimation"}], "inputs": [{"name": "geometries", "source_node": "geometry_estimation"}],
"callbacks": None, "callbacks": None,
}, },
{ {
"name": "occlusion90_calculator", "name": "occlusion90_calculator",
"algorithm": {"class_name": "iris.OcclusionCalculator", "params": {"quantile_angle": 90.0}}, "algorithm": {
"class_name": "iris.OcclusionCalculator",
"params": {"quantile_angle": 90.0},
},
"inputs": [ "inputs": [
{"name": "noise_mask", "source_node": "segmentation_binarization", "index": 1}, {
"name": "noise_mask",
"source_node": "segmentation_binarization",
"index": 1,
},
{"name": "extrapolated_polygons", "source_node": "geometry_estimation"}, {"name": "extrapolated_polygons", "source_node": "geometry_estimation"},
{"name": "eye_orientation", "source_node": "eye_orientation"}, {"name": "eye_orientation", "source_node": "eye_orientation"},
{"name": "eye_centers", "source_node": "eye_center_estimation"}, {"name": "eye_centers", "source_node": "eye_center_estimation"},
@@ -112,9 +154,16 @@ pipeline_conf = {
}, },
{ {
"name": "occlusion30_calculator", "name": "occlusion30_calculator",
"algorithm": {"class_name": "iris.OcclusionCalculator", "params": {"quantile_angle": 30.0}}, "algorithm": {
"class_name": "iris.OcclusionCalculator",
"params": {"quantile_angle": 30.0},
},
"inputs": [ "inputs": [
{"name": "noise_mask", "source_node": "segmentation_binarization", "index": 1}, {
"name": "noise_mask",
"source_node": "segmentation_binarization",
"index": 1,
},
{"name": "extrapolated_polygons", "source_node": "geometry_estimation"}, {"name": "extrapolated_polygons", "source_node": "geometry_estimation"},
{"name": "eye_orientation", "source_node": "eye_orientation"}, {"name": "eye_orientation", "source_node": "eye_orientation"},
{"name": "eye_centers", "source_node": "eye_center_estimation"}, {"name": "eye_centers", "source_node": "eye_center_estimation"},
@@ -178,12 +227,20 @@ pipeline_conf = {
}, },
], ],
"probe_schemas": [ "probe_schemas": [
{"class_name": "iris.RegularProbeSchema", "params": {"n_rows": 16, "n_cols": 256}}, {
{"class_name": "iris.RegularProbeSchema", "params": {"n_rows": 16, "n_cols": 256}}, "class_name": "iris.RegularProbeSchema",
"params": {"n_rows": 16, "n_cols": 256},
},
{
"class_name": "iris.RegularProbeSchema",
"params": {"n_rows": 16, "n_cols": 256},
},
], ],
}, },
}, },
"inputs": [{"name": "normalization_output", "source_node": "normalization"}], "inputs": [
{"name": "normalization_output", "source_node": "normalization"}
],
"callbacks": None, "callbacks": None,
}, },
{ {
+37 -8
View File
@@ -1,18 +1,24 @@
import copy
import pathlib import pathlib
import cv2 import cv2
import matplotlib as mpl
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np
from pipeline import pipeline_conf
import iris import iris
from pipeline import pipeline_conf
def process(path: str) -> None: def process(path: str) -> None:
path = pathlib.Path(path) path = pathlib.Path(path)
iris_pipeline = iris.IRISPipeline(env=iris.IRISPipeline.DEBUGGING_ENVIRONMENT, config=pipeline_conf) print("Loading pipeline...")
iris_pipeline = iris.IRISPipeline(
env=iris.IRISPipeline.DEBUGGING_ENVIRONMENT, config=pipeline_conf
)
iris_visualizer = iris.visualisation.IRISVisualizer() iris_visualizer = iris.visualisation.IRISVisualizer()
print("Pipeline loaded")
outputs = [] outputs = []
for image_path in (path / "input").iterdir(): for image_path in (path / "input").iterdir():
@@ -20,7 +26,7 @@ def process(path: str) -> None:
continue continue
print(f"Processing {image_path}...") print(f"Processing {image_path}...")
try:
eye_side = "right" if "left" not in image_path.stem else "left" eye_side = "right" if "left" not in image_path.stem else "left"
image_pixels = cv2.imread(str(image_path), cv2.IMREAD_GRAYSCALE) image_pixels = cv2.imread(str(image_path), cv2.IMREAD_GRAYSCALE)
@@ -28,7 +34,11 @@ def process(path: str) -> None:
img_data=image_pixels, img_data=image_pixels,
eye_side=eye_side, eye_side=eye_side,
) )
output = iris_pipeline(iris.IRImage(img_data=image_pixels, image_id="image_id", eye_side="right")) output = iris_pipeline(
iris.IRImage(
img_data=image_pixels, image_id="image_id", eye_side="right"
)
)
iris_visualizer.plot_segmentation_map( iris_visualizer.plot_segmentation_map(
ir_image=img, ir_image=img,
@@ -36,6 +46,7 @@ def process(path: str) -> None:
) )
(path / "segmentation").mkdir(parents=True, exist_ok=True) (path / "segmentation").mkdir(parents=True, exist_ok=True)
plt.savefig(path / "segmentation" / f"{image_path.stem}.png") plt.savefig(path / "segmentation" / f"{image_path.stem}.png")
plt.close()
iris_visualizer.plot_all_geometry( iris_visualizer.plot_all_geometry(
ir_image=img, ir_image=img,
@@ -45,13 +56,31 @@ def process(path: str) -> None:
) )
(path / "geometry").mkdir(parents=True, exist_ok=True) (path / "geometry").mkdir(parents=True, exist_ok=True)
plt.savefig(path / "geometry" / f"{image_path.stem}.png") plt.savefig(path / "geometry" / f"{image_path.stem}.png")
plt.close()
(path / "normalized").mkdir(parents=True, exist_ok=True) (path / "normalized").mkdir(parents=True, exist_ok=True)
data = iris_pipeline.call_trace["normalization"].normalized_image data = iris_pipeline.call_trace["normalization"].normalized_image
plt.imsave(path / "normalized" / f"{image_path.stem}.png", data, cmap='Greys_r') plt.imsave(
path / "normalized" / f"{image_path.stem}.png", data, cmap="Greys_r"
)
cm = copy.copy(mpl.colormaps["binary"])
cm.set_bad("red")
data = output["iris_template"].iris_codes[0][:, :, 0]
mask = np.invert(output["iris_template"].mask_codes[0][:, :, 0])
data = np.ma.masked_array(data, mask=mask)
(path / "template").mkdir(parents=True, exist_ok=True) (path / "template").mkdir(parents=True, exist_ok=True)
data = output["iris_template"].iris_codes[0][:, :, 0] plt.imsave(path / "template" / f"{image_path.stem}.png", data, cmap=cm)
plt.imsave(path / "template" / f"{image_path.stem}.png", data, cmap='binary')
outputs.append((image_path, img, output)) outputs.append((image_path, img, output))
print(f"Finished processing: {image_path}")
except:
print(
f"Failed to process: {image_path}. Most likely not centered, out of focus, or eye not opened enough"
)
print("Done")