createCompiledFromBuffer static method

Future<FaceLandmark> createCompiledFromBuffer(
  1. Uint8List modelBytes, {
  2. Set<Accelerator> accelerators = const {Accelerator.gpu, Accelerator.cpu},
  3. Precision precision = Precision.fp16,
})

Creates a face landmark model backed by LiteRT CompiledModel.

Implementation

static Future<FaceLandmark> createCompiledFromBuffer(
  Uint8List modelBytes, {
  Set<Accelerator> accelerators = const {Accelerator.gpu, Accelerator.cpu},
  Precision precision = Precision.fp16,
}) async {
  final CompiledModel compiledModel = compiledModelFromBufferAuto(
    modelBytes,
    accelerators: accelerators,
    precision: precision,
    onGpuFallback: _onGpuFallback,
  );
  final int side;
  try {
    side = compiledSquareInputSide(
      compiledModel,
      label: 'Compiled face landmark',
    );
  } catch (_) {
    compiledModel.close();
    rethrow;
  }
  final obj = FaceLandmark._compiled(compiledModel, side, side);
  try {
    obj._initializeCompiledModel();
    return obj;
  } catch (_) {
    obj.dispose();
    rethrow;
  }
}