Almost ready

This commit is contained in:
2026-03-26 17:09:45 +01:00
parent 5bd8353242
commit 86018b4250
4 changed files with 316 additions and 223 deletions
+3 -2
View File
@@ -1,7 +1,7 @@
FROM debian:13.3
# Install system dependencies
RUN apt-get update && apt-get install -y wget libgl1 libglib2.0-0 patchelf
RUN apt-get update && apt-get install -y wget libgl1 libglib2.0-0 patchelf git
# Copy project files
COPY ./src /src
@@ -19,7 +19,8 @@ ENV PATH="/home/student/.local/bin:$PATH"
WORKDIR /src
RUN uv venv --python 3.11
ENV PATH="/src/.venv/bin:$PATH"
RUN uv pip install notebook open-iris
ENV IRIS_ENV="DEV"
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
# Launch Jupyter Notebook
+97 -207
View File
File diff suppressed because one or more lines are too long
+205
View File
@@ -0,0 +1,205 @@
pipeline_conf = {
"metadata": {"pipeline_name": "iris_pipeline", "iris_version": "1.11.0"},
"pipeline": [
{
"name": "segmentation",
"algorithm": {"class_name": "iris.MultilabelSegmentation.create_from_hugging_face", "params": {}},
"inputs": [{"name": "image", "source_node": "input"}],
"callbacks": None,
},
{
"name": "segmentation_binarization",
"algorithm": {"class_name": "iris.MultilabelSegmentationBinarization", "params": {
"eyeball_threshold": 0.1,
"iris_threshold": 0.1,
"pupil_threshold": 0.1,
"eyelashes_threshold": 0.1
}},
"inputs": [{"name": "segmentation_map", "source_node": "segmentation"}],
"callbacks": None,
},
{
"name": "vectorization",
"algorithm": {"class_name": "iris.ContouringAlgorithm", "params": {}},
"inputs": [{"name": "geometry_mask", "source_node": "segmentation_binarization", "index": 0}],
"callbacks": None,
},
{
"name": "specular_reflection_detection",
"algorithm": {"class_name": "iris.SpecularReflectionDetection", "params": {}},
"inputs": [{"name": "ir_image", "source_node": "input"}],
"callbacks": None,
},
{
"name": "interpolation",
"algorithm": {"class_name": "iris.ContourInterpolation", "params": {}},
"inputs": [{"name": "polygons", "source_node": "vectorization"}],
"callbacks": None,
},
{
"name": "distance_filter",
"algorithm": {"class_name": "iris.ContourPointNoiseEyeballDistanceFilter", "params": {}},
"inputs": [
{"name": "polygons", "source_node": "interpolation"},
{"name": "geometry_mask", "source_node": "segmentation_binarization", "index": 1},
],
"callbacks": None,
},
{
"name": "eye_orientation",
"algorithm": {"class_name": "iris.MomentOfArea", "params": {
"eccentricity_threshold": 0.05
}},
"inputs": [{"name": "geometries", "source_node": "distance_filter"}],
"callbacks": None,
},
{
"name": "eye_center_estimation",
"algorithm": {"class_name": "iris.BisectorsMethod", "params": {}},
"inputs": [{"name": "geometries", "source_node": "distance_filter"}],
"callbacks": None,
},
{
"name": "smoothing",
"algorithm": {"class_name": "iris.Smoothing", "params": {}},
"inputs": [
{"name": "polygons", "source_node": "distance_filter"},
{"name": "eye_centers", "source_node": "eye_center_estimation"},
],
"callbacks": None,
},
{
"name": "geometry_estimation",
"algorithm": {
"class_name": "iris.FusionExtrapolation",
"params": {
"circle_extrapolation": {"class_name": "iris.LinearExtrapolation", "params": {"dphi": 0.703125}},
"ellipse_fit": {"class_name": "iris.LSQEllipseFitWithRefinement", "params": {"dphi": 0.703125}},
"algorithm_switch_std_threshold": 3.5,
},
},
"inputs": [
{"name": "input_polygons", "source_node": "smoothing"},
{"name": "eye_center", "source_node": "eye_center_estimation"},
],
"callbacks": None,
},
{
"name": "pupil_to_iris_property_estimation",
"algorithm": {"class_name": "iris.PupilIrisPropertyCalculator", "params": {}},
"inputs": [
{"name": "geometries", "source_node": "geometry_estimation"},
{"name": "eye_centers", "source_node": "eye_center_estimation"},
],
"callbacks": None,
},
{
"name": "offgaze_estimation",
"algorithm": {"class_name": "iris.EccentricityOffgazeEstimation", "params": {}},
"inputs": [{"name": "geometries", "source_node": "geometry_estimation"}],
"callbacks": None,
},
{
"name": "occlusion90_calculator",
"algorithm": {"class_name": "iris.OcclusionCalculator", "params": {"quantile_angle": 90.0}},
"inputs": [
{"name": "noise_mask", "source_node": "segmentation_binarization", "index": 1},
{"name": "extrapolated_polygons", "source_node": "geometry_estimation"},
{"name": "eye_orientation", "source_node": "eye_orientation"},
{"name": "eye_centers", "source_node": "eye_center_estimation"},
],
"callbacks": None,
},
{
"name": "occlusion30_calculator",
"algorithm": {"class_name": "iris.OcclusionCalculator", "params": {"quantile_angle": 30.0}},
"inputs": [
{"name": "noise_mask", "source_node": "segmentation_binarization", "index": 1},
{"name": "extrapolated_polygons", "source_node": "geometry_estimation"},
{"name": "eye_orientation", "source_node": "eye_orientation"},
{"name": "eye_centers", "source_node": "eye_center_estimation"},
],
"callbacks": None,
},
{
"name": "noise_masks_aggregation",
"algorithm": {"class_name": "iris.NoiseMaskUnion", "params": {}},
"inputs": [
{
"name": "elements",
"source_node": [
{"name": "segmentation_binarization", "index": 1},
{"name": "specular_reflection_detection"},
],
}
],
"callbacks": None,
},
{
"name": "normalization",
"algorithm": {"class_name": "iris.PerspectiveNormalization", "params": {}},
"inputs": [
{"name": "image", "source_node": "input"},
{"name": "noise_mask", "source_node": "noise_masks_aggregation"},
{"name": "extrapolated_contours", "source_node": "geometry_estimation"},
{"name": "eye_orientation", "source_node": "eye_orientation"},
],
"callbacks": None,
},
{
"name": "filter_bank",
"algorithm": {
"class_name": "iris.ConvFilterBank",
"params": {
"filters": [
{
"class_name": "iris.GaborFilter",
"params": {
"kernel_size": [41, 21],
"sigma_phi": 7,
"sigma_rho": 6.13,
"theta_degrees": 90.0,
"lambda_phi": 28.0,
"dc_correction": True,
"to_fixpoints": True,
},
},
{
"class_name": "iris.GaborFilter",
"params": {
"kernel_size": [17, 21],
"sigma_phi": 2,
"sigma_rho": 5.86,
"theta_degrees": 90.0,
"lambda_phi": 8,
"dc_correction": True,
"to_fixpoints": True,
},
},
],
"probe_schemas": [
{"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"}],
"callbacks": None,
},
{
"name": "encoder",
"algorithm": {"class_name": "iris.IrisEncoder", "params": {}},
"inputs": [{"name": "response", "source_node": "filter_bank"}],
"callbacks": None,
},
{
"name": "bounding_box_estimation",
"algorithm": {"class_name": "iris.IrisBBoxCalculator", "params": {}},
"inputs": [
{"name": "ir_image", "source_node": "input"},
{"name": "geometry_polygons", "source_node": "geometry_estimation"},
],
"callbacks": None,
},
],
}
+11 -14
View File
@@ -5,16 +5,18 @@ import matplotlib.pyplot as plt
import iris
from pipeline import pipeline_conf
def process(path: str) -> None:
path = pathlib.Path(path)
iris_pipeline = iris.IRISPipeline(env=iris.IRISPipeline.DEBUGGING_ENVIRONMENT)
iris_pipeline = iris.IRISPipeline(env=iris.IRISPipeline.DEBUGGING_ENVIRONMENT, config=pipeline_conf)
iris_visualizer = iris.visualisation.IRISVisualizer()
outputs = []
for image_path in (path / "input").iterdir():
if image_path.suffix != ".png":
if image_path.suffix != ".jpg":
continue
print(f"Processing {image_path}...")
@@ -26,8 +28,7 @@ def process(path: str) -> None:
img_data=image_pixels,
eye_side=eye_side,
)
output = iris_pipeline(image_pixels, eye_side=eye_side)
output = iris_pipeline(iris.IRImage(img_data=image_pixels, image_id="image_id", eye_side="right"))
iris_visualizer.plot_segmentation_map(
ir_image=img,
@@ -35,7 +36,7 @@ def process(path: str) -> None:
)
(path / "segmentation").mkdir(parents=True, exist_ok=True)
plt.savefig(path / "segmentation" / f"{image_path.stem}.png")
iris_visualizer.plot_all_geometry(
ir_image=img,
geometry_polygons=iris_pipeline.call_trace["geometry_estimation"],
@@ -45,16 +46,12 @@ def process(path: str) -> None:
(path / "geometry").mkdir(parents=True, exist_ok=True)
plt.savefig(path / "geometry" / f"{image_path.stem}.png")
iris_visualizer.plot_normalized_iris(
normalized_iris=iris_pipeline.call_trace["normalization"],
)
(path / "normalized").mkdir(parents=True, exist_ok=True)
plt.savefig(path / "normalized" / f"{image_path.stem}.png")
iris_visualizer.plot_iris_template(
iris_template=iris_pipeline.call_trace["encoder"],
)
data = iris_pipeline.call_trace["normalization"].normalized_image
plt.imsave(path / "normalized" / f"{image_path.stem}.png", data, cmap='Greys_r')
(path / "template").mkdir(parents=True, exist_ok=True)
plt.savefig(path / "template" / f"{image_path.stem}.png")
data = output["iris_template"].iris_codes[0][:, :, 0]
plt.imsave(path / "template" / f"{image_path.stem}.png", data, cmap='binary')
outputs.append((image_path, img, output))