create static method
Future<FaceEmbedding>
create({
- InterpreterOptions? options,
- PerformanceConfig? performanceConfig,
Creates and initializes a face embedding model instance.
This factory method loads the MobileFaceNet TensorFlow Lite model from package assets and prepares it for inference.
The performanceConfig parameter enables hardware acceleration delegates.
Use PerformanceConfig.xnnpack() for 2-5x speedup on CPU.
Returns a fully initialized FaceEmbedding instance ready to generate face embeddings.
Example:
// Default (XNNPACK enabled)
final embedding = await FaceEmbedding.create();
// With custom configuration
final embedding = await FaceEmbedding.create(
performanceConfig: PerformanceConfig.xnnpack(numThreads: 4),
);
Throws StateError if the model cannot be loaded or initialized.
Implementation
static Future<FaceEmbedding> create({
InterpreterOptions? options,
PerformanceConfig? performanceConfig,
}) => _createWithLoader(
load: (opts) => Interpreter.fromAsset(
'packages/face_detection_tflite/assets/models/$kEmbeddingModel',
options: opts,
),
options: options,
performanceConfig: performanceConfig,
);