flutter-tflite icon indicating copy to clipboard operation
flutter-tflite copied to clipboard

Wrong face embeddings when called multiple times in a row

Open rafaelmaia8384 opened this issue 1 year ago • 0 comments

I'm trying to obtain the Face Embeddings of two faces to perform the calculation of the Euclidean distance. I manage to get the List of 192 points, however, this list is not returning consistent results.

I am using the model mobilefacenet.tflite

Future<List<double>?> _getEmbeddingsFromFace(
    imglib.Image convertedImage, Face face) async {
    List? input = await _preProcess(convertedImage, face);
    if (input == null) return null;
    input = input.reshape([1, 112, 112, 3]);
    List output = List.generate(1, (index) => List.filled(192, 0));
    _interpreter?.run(input, output);
    final result = output.reshape([192]);
    print(result);
    return List<double>.from(result);
}

If I put a 1-second delay between the calls to the function, the result becomes consistent. Any idea on how could I solve this? Thanks!

rafaelmaia8384 avatar Nov 05 '23 20:11 rafaelmaia8384