createFromFile static method

Future<IrisLandmark> createFromFile(
  1. String modelPath, {
  2. InterpreterOptions? options,
  3. PerformanceConfig? performanceConfig,
})

Creates and initializes an iris landmark model from a custom file path.

This factory method loads a TensorFlow Lite model from the specified modelPath on the filesystem instead of from package assets. This is useful for advanced users who want to use custom-trained or alternative iris tracking models.

The options parameter allows you to customize the TFLite interpreter configuration (e.g., number of threads, use of GPU delegate).

The performanceConfig parameter enables hardware acceleration delegates. Use PerformanceConfig.xnnpack() for 2-5x speedup on CPU. If both options and performanceConfig are provided, options takes precedence.

Returns a fully initialized IrisLandmark instance ready to detect irises.

Example:

// Default (auto mode)
final customModel = await IrisLandmark.createFromFile(
  '/path/to/custom_iris_model.tflite',
);
final irisPoints = await customModel(eyeCropImage);
customModel.dispose(); // Clean up when done

// With XNNPACK acceleration
final customModel = await IrisLandmark.createFromFile(
  '/path/to/custom_iris_model.tflite',
  performanceConfig: PerformanceConfig.xnnpack(),
);

See also:

  • create for loading the default bundled model from assets

Throws StateError if the model cannot be loaded or initialized.

Implementation

static Future<IrisLandmark> createFromFile(
  String modelPath, {
  InterpreterOptions? options,
  PerformanceConfig? performanceConfig,
}) => _createWithLoader(
  load: (opts) => Interpreter.fromFile(File(modelPath), options: opts),
  options: options,
  performanceConfig: performanceConfig,
);