### Verify open-iris installation (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Imports the `iris` package and prints its version to confirm successful installation. This step ensures the package is correctly installed and accessible. Requires the `iris` package to be installed. ```python import iris print(iris.__version__) ``` -------------------------------- ### Install open-iris package (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Installs the `open-iris` package using pip. This is the first step to set up the environment for using the IRIS pipeline. Requires a Python environment with pip. ```python !pip install open-iris ``` -------------------------------- ### Initializing the IRISVisualizer Source: https://github.com/worldcoin/open-iris/blob/main/docs/source/examples/getting_started.rst Shows the simple step of creating an instance of the IRISVisualizer class, which is the prerequisite for using its methods to plot intermediate results from the IRIS pipeline. ```python iris_visualizer = iris.visualisation.IRISVisualizer() ``` -------------------------------- ### Using IRISPipeline with DEBUGGING_ENVIRONMENT Source: https://github.com/worldcoin/open-iris/blob/main/docs/source/examples/getting_started.rst Demonstrates how to instantiate the IRISPipeline using the predefined DEBUGGING_ENVIRONMENT and execute it with sample image data and eye side, capturing the detailed output provided by this environment. ```python iris_pipeline = iris.IRISPipeline(env=iris.IRISPipeline.DEBUGGING_ENVIRONMENT) output = iris_pipeline(img_data=img_pixels, eye_side="right") ``` -------------------------------- ### Plotting Intermediate Results with IRISVisualizer Source: https://github.com/worldcoin/open-iris/blob/main/docs/source/examples/getting_started.rst Provides examples of using the initialized IRISVisualizer to plot specific data structures like IRImage and iris_template, demonstrating how to generate visualization canvases and display them using Matplotlib. ```python import matplotlib.pyplot as plt canvas = iris_visualizer.plot_ir_image(iris.IRImage(img_data=img_pixels, eye_side="right")) plt.show() canvas = iris_visualizer.plot_iris_template(output["iris_template"]) plt.show() ``` -------------------------------- ### Install open-iris (Server) from GitHub Source: https://github.com/worldcoin/open-iris/blob/main/docs/source/quickstart/installation.rst Installs the open-iris package for server environments directly from the GitHub repository using pip, explicitly setting the IRIS_ENV flag to SERVER. ```bash IRIS_ENV=SERVER pip install git+https://github.com/worldcoin/open-iris.git ``` -------------------------------- ### Install open-iris (Development) from GitHub Source: https://github.com/worldcoin/open-iris/blob/main/docs/source/quickstart/installation.rst Installs the open-iris package along with necessary development dependencies directly from the GitHub repository using pip and setting the IRIS_ENV flag to DEV. ```bash IRIS_ENV=DEV pip install git+https://github.com/worldcoin/open-iris.git ``` -------------------------------- ### Install open-iris (Server) from PyPI Source: https://github.com/worldcoin/open-iris/blob/main/docs/source/quickstart/installation.rst Installs the open-iris package for server environments from the Python Package Index using pip. This is the default installation method when the IRIS_ENV flag is omitted. ```bash pip install open-iris ``` -------------------------------- ### Defining the DEBUGGING_ENVIRONMENT Source: https://github.com/worldcoin/open-iris/blob/main/docs/source/examples/getting_started.rst Shows the definition of the predefined DEBUGGING_ENVIRONMENT within IRISPipeline, which is configured with specific output builders, error managers, and a list of disabled QA validators useful for debugging. ```python DEBUGGING_ENVIRONMENT = Environment( pipeline_output_builder=build_debugging_output, error_manager=store_error_manager, disabled_qa=[ iris.nodes.validators.object_validators.Pupil2IrisPropertyValidator, iris.nodes.validators.object_validators.OffgazeValidator, iris.nodes.validators.object_validators.OcclusionValidator, iris.nodes.validators.object_validators.IsPupilInsideIrisValidator, iris.nodes.validators.object_validators.IsMaskTooSmallValidator, iris.nodes.validators.cross_object_validators.EyeCentersInsideImageValidator, iris.nodes.validators.cross_object_validators.ExtrapolatedPolygonsInsideImageValidator, ], call_trace_initialiser=PipelineCallTraceStorage.initialise, ) ``` -------------------------------- ### Verify open-iris Installation Source: https://github.com/worldcoin/open-iris/blob/main/docs/source/quickstart/installation.rst Verifies the successful installation of the iris package by attempting to import it in Python and printing its version using a bash command. ```bash python3 -c "import iris; print(iris.__version__)" ``` -------------------------------- ### Instantiating and Running IRISPipeline with DEBUGGING_ENVIRONMENT in Python Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Demonstrates how to create an instance of `IRISPipeline` using the predefined `DEBUGGING_ENVIRONMENT` and then execute the pipeline by calling the instance with input data (`img_data`, `eye_side`). ```python iris_pipeline = iris.IRISPipeline(env=iris.IRISPipeline.DEBUGGING_ENVIRONMENT) output = iris_pipeline(img_data=img_pixels, eye_side="right") ``` -------------------------------- ### Install open-iris (Orb) from GitHub Source: https://github.com/worldcoin/open-iris/blob/main/docs/source/quickstart/installation.rst Installs the open-iris package with dependencies required for running inference on the Orb, directly from the GitHub repository using pip and setting the IRIS_ENV flag to ORB. ```bash IRIS_ENV=ORB pip install git+https://github.com/worldcoin/open-iris.git ``` -------------------------------- ### Plotting IR Image and Iris Template (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Shows examples of using the `iris_visualizer` to plot an infrared image (`plot_ir_image`) and an iris template (`plot_iris_template`). It requires importing `matplotlib.pyplot` and uses `plt.show()` to display the generated plots. ```python import matplotlib.pyplot as plt canvas = iris_visualizer.plot_ir_image(iris.IRImage(img_data=img_pixels, eye_side="right")) plt.show() canvas = iris_visualizer.plot_iris_template(output["iris_template"]) plt.show() ``` -------------------------------- ### Initializing IRISPipeline in Python Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Shows the constructor signature for the `IRISPipeline` class, highlighting the `config` and `env` parameters used for configuring the pipeline graph and runtime environment, respectively. ```python def __init__( self, config: Union[Dict[str, Any], Optional[str]] = None, env: Environment = Environment( pipeline_output_builder=build_orb_output, error_manager=store_error_manager, call_trace_initialiser=PipelineCallTraceStorage.initialise, ), ) -> None: ``` -------------------------------- ### Example IRISPipeline Error Dictionary (Python) Source: https://github.com/worldcoin/open-iris/blob/main/docs/source/examples/getting_started.rst Shows the structure of the dictionary returned in the 'error' key of the pipeline output when an exception occurs during inference. It includes keys for 'error_type', 'message', and 'traceback'. ```python { 'error_type': 'TypeError', 'message': "run() got an unexpected keyword argument 'segmentation_map2'", 'traceback': 'Very long exception traceback' } ``` -------------------------------- ### IRISPipeline Constructor Signature (Python) Source: https://github.com/worldcoin/open-iris/blob/main/docs/source/examples/getting_started.rst Displays the method signature for the `IRISPipeline` constructor (`__init__`). It highlights the `config` and `env` parameters which allow customization of the pipeline's graph and runtime environment. ```python def __init__( self, config: Union[Dict[str, Any], Optional[str]] = None, env: Environment = Environment( pipeline_output_builder=build_orb_output, error_manager=store_error_manager, call_trace_initialiser=PipelineCallTraceStorage.initialise, ), ) -> None: ``` -------------------------------- ### Download sample IR image (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Downloads a sample infrared image (`example_orb_image_1.png`) from a public S3 bucket using `wget` and saves it locally as `sample_ir_image.png`. This image is used as input for the IRIS pipeline. Requires `wget` to be available in the environment. ```python !wget https://wld-ml-ai-data-public.s3.amazonaws.com/public-iris-images/example_orb_image_1.png -O ./sample_ir_image.png ``` -------------------------------- ### Running IRISPipeline Inference (Python) Source: https://github.com/worldcoin/open-iris/blob/main/docs/source/examples/getting_started.rst Demonstrates the three equivalent methods (`__call__`, `run`, `estimate`) for performing inference with the `IRISPipeline` object. It shows how to pass the image data (`img_data`) and specify the eye side (`eye_side`). ```python # Options for the `eye_side` argument are: ["left", "right"] output = iris_pipeline(img_data=img_pixels, eye_side="right") output = iris_pipeline.run(img_data=img_pixels, eye_side="right") output = iris_pipeline.estimate(img_data=img_pixels, eye_side="right") ``` -------------------------------- ### Setup Development Environment with Conda (Bash) Source: https://github.com/worldcoin/open-iris/blob/main/docs/source/quickstart/setup_for_development.rst This bash script provides the commands to set up the development environment for the 'iris' project. It includes cloning the repository, navigating into the directory, creating and activating a dedicated conda environment using the provided environment file, and optionally installing pre-commit hooks to maintain code formatting standards. ```bash # Clone the iris repo git clone https://github.com/worldcoin/open-iris # Go to the repo directory cd open-iris # Create and activate conda environment IRIS_ENV=DEV conda env create -f ./conda/environment_dev.yml conda activate iris_dev # (Optional, but recommended) Install git hooks to preserve code format consistency pre-commit install nb-clean add-filter --remove-empty-cells ``` -------------------------------- ### Creating IRISPipeline Object (Python) Source: https://github.com/worldcoin/open-iris/blob/main/docs/source/examples/getting_started.rst Imports the `iris` package and instantiates the `IRISPipeline` class. This object is the main entry point for performing iris recognition tasks. ```python import iris iris_pipeline = iris.IRISPipeline() ``` -------------------------------- ### Create IRISPipeline object (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Instantiates the `IRISPipeline` class from the `iris` package. This creates the main object used to perform iris inference on images. Requires the `iris` package. ```python iris_pipeline = iris.IRISPipeline() ``` -------------------------------- ### Loading IR Image with OpenCV (Python) Source: https://github.com/worldcoin/open-iris/blob/main/docs/source/examples/getting_started.rst Loads an infrared image from a file using OpenCV. The image is read in grayscale format and stored in the `img_pixels` variable for subsequent processing. ```python import cv2 img_pixels = cv2.imread("./sample_ir_image.png", cv2.IMREAD_GRAYSCALE) ``` -------------------------------- ### Defining the IRISPipeline Environment Class Source: https://github.com/worldcoin/open-iris/blob/main/docs/source/examples/getting_started.rst Defines the structure of the Environment class used to configure IRISPipeline's behavior, including call trace initialization, output building, error management, and disabling quality assurance nodes. ```python class Environment(ImmutableModel): call_trace_initialiser: Callable[[Dict[str, Algorithm], List[PipelineNode]], PipelineCallTraceStorage] pipeline_output_builder: Callable[[PipelineCallTraceStorage], Any] error_manager: Callable[[PipelineCallTraceStorage, Exception], None] disabled_qa: List[type] = [] ``` -------------------------------- ### Setup Development Environment with Conda - Bash Source: https://github.com/worldcoin/open-iris/blob/main/README.md Steps to set up a development environment for the iris package using conda. This involves cloning the repository, creating and activating a dedicated conda environment, and optionally installing git hooks. ```bash # Clone the iris repo git clone https://github.com/worldcoin/open-iris # Go to the repo directory cd open-iris # Create and activate conda environment IRIS_ENV=DEV conda env create -f ./conda/environment_dev.yml conda activate iris_dev # (Optional, but recommended) Install git hooks to preserve code format consistency pre-commit install nb-clean add-filter --remove-empty-cells ``` -------------------------------- ### Load and display sample IR image (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Loads the downloaded sample infrared image (`sample_ir_image.png`) using OpenCV (`cv2`) in grayscale mode and displays it using Matplotlib (`plt`). This visualizes the input image before processing. Requires `opencv-python` and `matplotlib` packages. ```python import cv2 import matplotlib.pyplot as plt img_pixels = cv2.imread("./sample_ir_image.png", cv2.IMREAD_GRAYSCALE) plt.imshow(img_pixels, cmap='gray') ``` -------------------------------- ### Defining the DEBUGGING_ENVIRONMENT for IRISPipeline in Python Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Shows the definition of a predefined `Environment` instance, `DEBUGGING_ENVIRONMENT`, configured with specific output builders and a list of disabled quality assurance validators, useful for debugging the pipeline execution. ```python DEBUGGING_ENVIRONMENT = Environment( pipeline_output_builder=build_debugging_output, error_manager=store_error_manager, disabled_qa=[ iris.nodes.validators.object_validators.Pupil2IrisPropertyValidator, iris.nodes.validators.object_validators.OffgazeValidator, iris.nodes.validators.object_validators.OcclusionValidator, iris.nodes.validators.object_validators.IsPupilInsideIrisValidator, iris.nodes.validators.object_validators.IsMaskTooSmallValidator, iris.nodes.validators.cross_object_validators.EyeCentersInsideImageValidator, iris.nodes.validators.cross_object_validators.ExtrapolatedPolygonsInsideImageValidator, ], call_trace_initialiser=PipelineCallTraceStorage.initialise, ) ``` -------------------------------- ### Inspecting IRISPipeline Output Keys in Python Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Shows how to access the keys of the dictionary returned by the `IRISPipeline` execution, allowing inspection of the available intermediate results and final output, particularly useful when using environments like `DEBUGGING_ENVIRONMENT`. ```python output.keys() ``` -------------------------------- ### Get IrisTemplate code dimensions (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Calculates and prints the number of iris codes and the shape of the first iris code stored in the `IrisTemplate` object. This provides information about the dimensions and quantity of the generated iris features. Requires the `output` dictionary from a pipeline run. ```python num_codes = len(output["iris_template"].iris_codes) code_shape = output["iris_template"].iris_codes[0].shape f"""Number of returned iris codes is equal to {num_codes} and each code shape is {code_shape}""" ``` -------------------------------- ### Plotting Iris Template (Encoder) (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Plots the final iris template using the `iris_visualizer`. It takes the output of the 'encoder' step from the pipeline's `call_trace` as input. ```python canvas = iris_visualizer.plot_iris_template( iris_template=iris_pipeline.call_trace['encoder'], ) plt.show() ``` -------------------------------- ### Verifying iris Installation Python Source: https://github.com/worldcoin/open-iris/blob/main/colab/MatchingEntities.ipynb Imports the installed `iris` package and prints its version to confirm successful installation. ```python import iris print(iris.__version__) ``` -------------------------------- ### Instantiating IRIS Visualizer (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Creates an instance of the `IRISVisualizer` class from the `iris.visualisation` module. This object is used to call various plotting methods to visualize intermediate results from the iris processing pipeline. ```python iris_visualizer = iris.visualisation.IRISVisualizer() ``` -------------------------------- ### Installing iris package Python Source: https://github.com/worldcoin/open-iris/blob/main/colab/MatchingEntities.ipynb Installs the `open-iris` package using pip, typically executed in a notebook or server environment. ```python !pip install open-iris ``` -------------------------------- ### Plotting Normalized Iris (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Plots the normalized iris image using the `iris_visualizer`. It takes the result of the 'normalization' step from the pipeline's `call_trace` as input. ```python canvas = iris_visualizer.plot_normalized_iris( normalized_iris=iris_pipeline.call_trace['normalization'], ) plt.show() ``` -------------------------------- ### Inspect IRISPipeline metadata (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Prints the content of the "metadata" key in the `output` dictionary. This dictionary contains additional information generated during the pipeline run that can be useful for analysis or quality assessment. Requires the `output` dictionary from a pipeline run. ```python output["metadata"] ``` -------------------------------- ### Plotting Segmentation Map (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Uses the `iris_visualizer` to plot the segmentation map obtained from the pipeline's `call_trace`. It requires the original IR image data and the segmentation map result. ```python canvas = iris_visualizer.plot_segmentation_map( ir_image=iris.IRImage(img_data=img_pixels, eye_side="right"), segmap=iris_pipeline.call_trace['segmentation'], ) plt.show() ``` -------------------------------- ### Run IRISPipeline inference methods (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Demonstrates the different methods available to run the `IRISPipeline` inference: using the `__call__` operator, the `run` method, and the `estimate` method. All methods perform the same core inference process. Requires an `IRISPipeline` object and image data (`img_pixels`). The `eye_side` argument specifies which eye is being processed. ```python # Options for the `eye_side` argument are: ["left", "right"] output = iris_pipeline(img_data=img_pixels, eye_side="right") output = iris_pipeline.run(img_data=img_pixels, eye_side="right") output = iris_pipeline.estimate(img_data=img_pixels, eye_side="right") ``` -------------------------------- ### Accessing Eye Side Metadata (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Demonstrates how to access the 'eye_side' information stored within the 'metadata' dictionary of the `output` object, which typically contains results from the iris processing pipeline. ```python output['metadata']['eye_side'] ``` -------------------------------- ### Accessing IRIS Pipeline Configuration (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Shows how to access the `pipeline` attribute within the `params` object of an `iris_pipeline` instance. This attribute typically holds the configuration or graph defining the sequence of algorithms used in the pipeline. ```python iris_pipeline.params.pipeline ``` -------------------------------- ### Defining the IRISPipeline Environment Class in Python Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Defines the `Environment` class, an `ImmutableModel`, which encapsulates callable functions for managing call trace initialization, pipeline output building, error handling, and a list of disabled quality assurance steps. ```python class Environment(ImmutableModel): call_trace_initialiser: Callable[[Dict[str, Algorithm], List[PipelineNode]], PipelineCallTraceStorage] pipeline_output_builder: Callable[[PipelineCallTraceStorage], Any] error_manager: Callable[[PipelineCallTraceStorage, Exception], None] disabled_qa: List[type] = [] ``` -------------------------------- ### Inspect IrisTemplate fields (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Accesses the `iris_template` object within the `output` and prints its available fields using `__fields__`. This reveals the structure of the `IrisTemplate` object, which holds the generated iris and mask codes. Requires the `output` dictionary from a pipeline run. ```python """Available fields in `output["iris_template"]` are: """ + str(output["iris_template"].__fields__) ``` -------------------------------- ### Defining the Canvas Type for Visualization Source: https://github.com/worldcoin/open-iris/blob/main/docs/source/examples/getting_started.rst Specifies the expected type hint for the output of visualization functions in the iris.visualisation module, indicating it returns a tuple containing a Matplotlib Figure and Axes (or an array of Axes). ```python Canvas = Tuple[matplotlib.figure.Figure, Union[matplotlib.axes._axes.Axes, np.ndarray]] ``` -------------------------------- ### Plotting All Geometry (Geometry Estimation) (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Similar to the previous snippet, this plots geometric features using the `iris_visualizer`, but it uses the results from the 'geometry_estimation' step instead of 'vectorization', along with 'eye_orientation' and 'eye_center_estimation'. ```python canvas = iris_visualizer.plot_all_geometry( ir_image=iris.IRImage(img_data=img_pixels, eye_side="right"), geometry_polygons=iris_pipeline.call_trace['geometry_estimation'], eye_orientation=iris_pipeline.call_trace['eye_orientation'], eye_center=iris_pipeline.call_trace['eye_center_estimation'], ) plt.show() ``` -------------------------------- ### Inspect IRISPipeline output keys (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Prints the keys of the dictionary returned by the `IRISPipeline` inference call. This shows the top-level structure of the output, which typically includes keys like "error", "iris_template", and "metadata". Requires the `output` dictionary from a pipeline run. ```python output.keys() ``` -------------------------------- ### Accessing Segmentation Result from Call Trace (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Demonstrates accessing the result of the 'segmentation' step from the `call_trace` attribute of the `iris_pipeline` object. The `call_trace` stores intermediate results from the latest pipeline execution. ```python iris_pipeline.call_trace['segmentation'] ``` -------------------------------- ### Verifying open-iris Installation (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/ConfiguringCustomPipeline.ipynb Imports the `iris` library and prints its version to confirm successful installation. Requires the `iris` package to be installed. ```python import iris print(iris.__version__) ``` -------------------------------- ### Plotting All Geometry (Vectorization) (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Plots various geometric features (polygons, orientation, center) using the `iris_visualizer`, specifically using the results from the 'vectorization', 'eye_orientation', and 'eye_center_estimation' steps stored in the pipeline's `call_trace`. ```python canvas = iris_visualizer.plot_all_geometry( ir_image=iris.IRImage(img_data=img_pixels, eye_side="right"), geometry_polygons=iris_pipeline.call_trace['vectorization'], eye_orientation=iris_pipeline.call_trace['eye_orientation'], eye_center=iris_pipeline.call_trace['eye_center_estimation'], ) plt.show() ``` -------------------------------- ### Run Simple Iris Inference - Python Source: https://github.com/worldcoin/open-iris/blob/main/README.md Example Python code to perform a simple iris inference using the IRISPipeline. It demonstrates creating the pipeline object, loading an image, and calling the pipeline with image data and eye side. ```python import cv2 import iris # 1. Create IRISPipeline object iris_pipeline = iris.IRISPipeline() # 2. Load IR image of an eye img_pixels = cv2.imread("/path/to/ir/image", cv2.IMREAD_GRAYSCALE) # 3. Perform inference # Options for the `eye_side` argument are: ["left", "right"] output = iris_pipeline(img_data=img_pixels, eye_side="left") ``` -------------------------------- ### Install open-iris for Server (Local) - Bash Source: https://github.com/worldcoin/open-iris/blob/main/README.md Install the open-iris package for running inference on a local machine. This uses the SERVER environment configuration. You can install from PyPI or directly from the GitHub repository. ```bash # On a local machine pip install open-iris # or directly from GitHub IRIS_ENV=SERVER pip install git+https://github.com/worldcoin/open-iris.git ``` -------------------------------- ### Installing open-iris Package (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/ConfiguringCustomPipeline.ipynb Installs the `open-iris` Python package using pip. This is the first step to use the IRIS library. Requires an environment with pip installed. ```python !pip install open-iris ``` -------------------------------- ### Verify iris Installation - Bash Source: https://github.com/worldcoin/open-iris/blob/main/README.md Verify that the iris package has been successfully installed and is importable by running a simple Python command from the terminal. ```bash python3 -c "import iris; print(iris.__version__)" ``` -------------------------------- ### Verify IRISPipeline error status (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Checks if the "error" key in the `output` dictionary is `None`. A `None` value indicates that the `IRISPipeline` inference completed successfully without raising any exceptions. Requires the `output` dictionary from a pipeline run. ```python # Verify IRISPipeline inference call finished without any exception being raised output["error"] is None ``` -------------------------------- ### Install open-iris for Development - Bash Source: https://github.com/worldcoin/open-iris/blob/main/README.md Install the open-iris package along with necessary dependencies for developing the package itself. This uses the DEV environment configuration. ```bash # For development IRIS_ENV=DEV pip install git+https://github.com/worldcoin/open-iris.git ``` -------------------------------- ### IRIS Algorithm Class Signature Example (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/ConfiguringCustomPipeline.ipynb Shows the beginning of the '__init__' method signature for an IRIS 'Algorithm' class ('MultilabelSegmentationBinarization'). This illustrates where parameters defined in the YAML configuration's 'params' section are received by the algorithm implementation. ```python class MultilabelSegmentationBinarization(Algorithm): def __init__( self, ``` -------------------------------- ### Citing the Worldcoin Open-IRIS Project Source: https://github.com/worldcoin/open-iris/blob/main/README.md Provides the standard BibTeX entry for citing the Worldcoin Open-IRIS project in academic or research contexts. ```BibTeX @misc{wldiris, author = {Worldcoin AI}, title = {IRIS: Iris Recognition Inference System of the Worldcoin project}, year = {2023}, url = {https://github.com/worldcoin/open-iris} } ``` -------------------------------- ### Install open-iris for Orb - Bash Source: https://github.com/worldcoin/open-iris/blob/main/README.md Install the open-iris package with dependencies required for running inference on the Orb. This uses the ORB environment configuration. ```bash # On the Orb IRIS_ENV=ORB pip install git+https://github.com/worldcoin/open-iris.git ``` -------------------------------- ### Run IRISPipeline inference using call operator (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Executes the `IRISPipeline` inference using the `__call__` operator with the loaded image data and specifying the eye side as "right". This is one of the standard ways to trigger the pipeline's processing. Requires an `IRISPipeline` object and image data (`img_pixels`). The output is a dictionary containing results and metadata. ```python output = iris_pipeline(img_data=img_pixels, eye_side="right") ``` -------------------------------- ### Instantiating and Running IRIS Pipeline (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/ConfiguringCustomPipeline.ipynb Demonstrates how to create an instance of the IRISPipeline class using a configuration dictionary and execute it with image data and eye side information. Includes an assertion to check for errors. ```python iris_pipeline = iris.IRISPipeline(config=new_pipeline_conf) assert iris_pipeline(img_data=img_pixels, eye_side="left")["error"] is None ``` -------------------------------- ### Downloading Sample IR Images Python Source: https://github.com/worldcoin/open-iris/blob/main/colab/MatchingEntities.ipynb Downloads three sample infrared iris images from a public S3 bucket using `wget` for use as input data in the tutorial. ```python !wget https://wld-ml-ai-data-public.s3.amazonaws.com/public-iris-images/example_orb_image_1.png -O ./subject1_first_image.png !wget https://wld-ml-ai-data-public.s3.amazonaws.com/public-iris-images/example_orb_image_2.png -O ./subject1_second_image.png !wget https://wld-ml-ai-data-public.s3.amazonaws.com/public-iris-images/example_orb_image_3.png -O ./subject2_image.png ``` -------------------------------- ### Instantiating and Running IRIS Pipeline (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/ConfiguringCustomPipeline.ipynb Demonstrates how to instantiate the `IRISPipeline` object with a configuration and execute it with image data and eye side information, asserting that the execution completes without errors. ```python iris_pipeline = iris.IRISPipeline(config=default_pipeline_conf) assert iris_pipeline(img_data=img_pixels, eye_side="left")["error"] is None ``` -------------------------------- ### Instantiating and Running IRISPipeline - Python Source: https://github.com/worldcoin/open-iris/blob/main/colab/ConfiguringCustomPipeline.ipynb Demonstrates how to reinstantiate the IRISPipeline with a new configuration and execute it with image data, asserting that no error occurred. ```python iris_pipeline = iris.IRISPipeline(config=new_pipeline_conf) assert iris_pipeline(img_data=img_pixels, eye_side="left")["error"] is None ``` -------------------------------- ### Defining IRIS Visualizer Canvas Type (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/GettingStarted.ipynb Defines the `Canvas` type alias used by the `IRISVisualizer` module, representing a tuple containing a Matplotlib Figure and an Axes object or a NumPy array. This type is used for the output of plotting functions. ```python Canvas = Tuple[matplotlib.figure.Figure, Union[matplotlib.axes._axes.Axes, np.ndarray]] ``` -------------------------------- ### Downloading Sample IR Image (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/ConfiguringCustomPipeline.ipynb Downloads a sample infrared image file from a public S3 bucket using the `wget` command. The image is saved as `./sample_ir_image.png`. Requires `wget` to be available in the environment. ```python !wget https://wld-ml-ai-data-public.s3.amazonaws.com/public-iris-images/example_orb_image_1.png -O ./sample_ir_image.png ``` -------------------------------- ### Instantiate and Run IRIS Pipeline (Python) Source: https://github.com/worldcoin/open-iris/blob/main/colab/ConfiguringCustomPipeline.ipynb Creates an instance of the IRISPipeline using a default configuration dictionary and runs it with sample image data ('img_pixels') for the 'left' eye side, asserting that the execution completed without errors. ```python iris_pipeline = iris.IRISPipeline(config=default_pipeline_conf) assert iris_pipeline(img_data=img_pixels, eye_side="left")["error"] is None ``` -------------------------------- ### IRIS Pipeline YAML Node Input with Index (YAML) Source: https://github.com/worldcoin/open-iris/blob/main/colab/ConfiguringCustomPipeline.ipynb Provides an example of defining a node input in the IRIS configuration YAML that uses the 'index' key. This is necessary when the source node outputs a list or tuple and a specific element needs to be selected as input. ```yaml - name: vectorization algorithm: class_name: iris.ContouringAlgorithm params: {} inputs: - name: geometry_mask source_node: segmentation_binarization index: 0 callbacks: ``` -------------------------------- ### Instantiating IRIS Pipeline Object - Python Source: https://github.com/worldcoin/open-iris/blob/main/docs/source/examples/custom_pipeline.rst This snippet demonstrates how to create an instance of the `iris.IRISPipeline` class, passing a configuration dictionary (`default_pipeline_conf`) to its constructor. This initializes the pipeline with the specified nodes and algorithms. ```python iris_pipeline = iris.IRISPipeline(config=default_pipeline_conf) ``` -------------------------------- ### Loading Images with OpenCV Source: https://github.com/worldcoin/open-iris/blob/main/docs/source/examples/matching_entities.rst Loads grayscale IR images from files using the `cv2.imread` function from the `opencv-python` package. Requires image files named 'subject1_first_image.png', 'subject1_second_image.png', and 'subject2_image.png' in the current directory. ```python import cv2 subject1_first_image = cv2.imread("./subject1_first_image.png", cv2.IMREAD_GRAYSCALE) subject1_second_image = cv2.imread("./subject1_second_image.png", cv2.IMREAD_GRAYSCALE) subject2_image = cv2.imread("./subject2_image.png", cv2.IMREAD_GRAYSCALE) ``` -------------------------------- ### Running Inference with IRISPipeline in Python Source: https://github.com/worldcoin/open-iris/blob/main/docs/source/quickstart/running_inference.rst This snippet shows the basic steps to run inference using the iris package. It requires the cv2 and iris libraries. It initializes the IRISPipeline, loads a grayscale eye image using OpenCV, and then calls the pipeline with the image data and eye side ('left' or 'right') to get the inference output. ```python import cv2 import iris # 1. Create IRISPipeline object iris_pipeline = iris.IRISPipeline() # 2. Load IR image of an eye img_pixels = cv2.imread("/path/to/ir/image", cv2.IMREAD_GRAYSCALE) # 3. Perform inference # Options for the `eye_side` argument are: ["left", "right"] output = iris_pipeline(img_data=img_pixels, eye_side="left") ``` -------------------------------- ### Instantiating IRIS Pipeline (Python) Source: https://github.com/worldcoin/open-iris/blob/main/docs/source/examples/custom_pipeline.rst Creates an instance of the IRISPipeline class, passing a configuration dictionary (new_pipeline_conf) that defines the structure and nodes of the pipeline. ```python iris_pipeline = iris.IRISPipeline(config=new_pipeline_conf) ``` -------------------------------- ### Generating Iris Templates with IRISPipeline Python Source: https://github.com/worldcoin/open-iris/blob/main/colab/MatchingEntities.ipynb Initializes an `IRISPipeline` object and processes each loaded image to extract and generate an `IrisTemplate`, which is a binary representation of the iris pattern. ```python import iris iris_pipeline = iris.IRISPipeline() output_1 = iris_pipeline(subject1_first_image, eye_side="left") subject1_first_code = output_1['iris_template'] output_2 = iris_pipeline(subject1_second_image, eye_side="left") subject1_second_code = output_2['iris_template'] output_3 = iris_pipeline(subject2_image, eye_side="left") subject2_code = output_3['iris_template'] ``` -------------------------------- ### Processing Images with IRISPipeline Source: https://github.com/worldcoin/open-iris/blob/main/docs/source/examples/matching_entities.rst Creates an `iris.IRISPipeline` object and processes the loaded images to compute iris templates using the `eye_side="left"` parameter. Stores the resulting templates in variables `subject1_first_code`, `subject1_second_code`, and `subject2_code`. ```python import iris iris_pipeline = iris.IRISPipeline() output_1 = iris_pipeline(subject1_first_image, eye_side="left") subject1_first_code = output_1["iris_template"] output_2 = iris_pipeline(subject1_second_image, eye_side="left") subject1_second_code = output_2["iris_template"] output_3 = iris_pipeline(subject2_image, eye_side="left") subject2_code = output_3["iris_template"] ``` -------------------------------- ### Instantiating IRISPipeline in Python Source: https://github.com/worldcoin/open-iris/blob/main/docs/source/examples/custom_pipeline.rst Initializes an IRISPipeline object using a predefined configuration dictionary. This sets up the processing pipeline with its specified nodes and algorithms. ```python iris_pipeline = iris.IRISPipeline(config=default_pipeline_conf) ``` -------------------------------- ### Loading IR Images with OpenCV Python Source: https://github.com/worldcoin/open-iris/blob/main/colab/MatchingEntities.ipynb Uses the `opencv-python` library (`cv2`) to load the downloaded infrared iris images into memory as grayscale images. ```python import cv2 subject1_first_image = cv2.imread("./subject1_first_image.png", cv2.IMREAD_GRAYSCALE) subject1_second_image = cv2.imread("./subject1_second_image.png", cv2.IMREAD_GRAYSCALE) subject2_image = cv2.imread("./subject2_image.png", cv2.IMREAD_GRAYSCALE) ```