tensorflow / flutter-tflite

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong face embeddings when called multiple times in a row

rafaelmaia8384 opened this issue · 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!