createCompiledFromBuffer static method

Future<FaceBlendshapesModel> createCompiledFromBuffer(
  1. Uint8List modelBytes
)

Creates the model backed by a LiteRT CompiledModel, pinned to the CPU.

A 292-in / 52-out MLP is far below the size where GPU dispatch pays off, and CPU pinning sidesteps Metal tensor-format questions for a non-image input (mirrors IrisLandmark.createCompiledFromBuffer).

Implementation

static Future<FaceBlendshapesModel> createCompiledFromBuffer(
  Uint8List modelBytes,
) async {
  final CompiledModel compiledModel = CompiledModel.fromBuffer(
    modelBytes,
    accelerators: {Accelerator.cpu},
  );
  final obj = FaceBlendshapesModel._compiled(compiledModel);
  try {
    obj._initializeCompiledModel();
    return obj;
  } catch (_) {
    obj.dispose();
    rethrow;
  }
}