call method

Future<Float32List?> call(
  1. Float32List packed
)

Runs the model on a packed [1, 146, 2] landmark tensor and returns the 52 blendshape coefficients, each clamped to [0, 1].

packed must have length kBlendshapeInputFloats (use packBlendshapeInput). Returns null when the input is the wrong size or the model produces a NaN (delegate/fp16 quirk), so the caller leaves that face's scores null rather than surfacing garbage.

Implementation

Future<Float32List?> call(Float32List packed) async {
  if (packed.length != kBlendshapeInputFloats) return null;

  final CompiledModel? cm = _compiledModel;
  if (cm != null) {
    final List<Float32List> outputs = await cm.runAsync([packed]);
    if (outputs.isEmpty) return null;
    return _sanitize(outputs.first);
  }

  _views.inputs[0].setAll(0, packed);
  _itp!.invoke();
  return _sanitize(_views.outputs.first);
}