loadModel method

Future<void> loadModel()

Implementation

Future<void> loadModel() async {
  try {
    print('[Liveness] 🔍 Try load model manually from asset...');

    final byteData = await rootBundle.load('packages/face_checkin_library/assets/models/mobilenet_liveness_v3.tflite');
    final tempDir = await getTemporaryDirectory();
    final modelPath = '${tempDir.path}/mobilenet_liveness_v3.tflite';

    final modelFile = File(modelPath);
    await modelFile.writeAsBytes(byteData.buffer.asUint8List());

    _interpreter = await Interpreter.fromFile(modelFile);
    _modelLoaded = true;

    print('[Liveness] ✅ Model loaded from temp file: $modelPath');
  } catch (e) {
    print('[Liveness] ❌ Failed to load model manually: $e');
  }
}