flutter_tflite icon indicating copy to clipboard operation
flutter_tflite copied to clipboard

Is it possible to get prediction detail for each label in RunModelOnImage method?

Open Alfyu07 opened this issue 3 years ago • 3 comments

is it possible to get prediction detail for each label in RunModelOnImage ? for example output like: { output : [ { index: 0, label: "person", confidence: 0.65 }, { index: 1, label: "car", confidence:0.15, }, { index: 2, label: "bicycle", confidence: 0.2" } ] }

Thanks

Alfyu07 avatar Sep 03 '21 10:09 Alfyu07

Hello!

You could try to ask for as many results as labels you have. For example, if you have 3 labels ask for 3 results: var recognitions = await Tflite.runModelOnImage( path: image.path, numResults: 3, threshold: 0.05, imageMean: 127.5, imageStd: 127.5, );

Hope it works!

erikbg7 avatar Sep 24 '21 16:09 erikbg7

Hello!

You could try to ask for as many results as labels you have. For example, if you have 3 labels ask for 3 results: var recognitions = await Tflite.runModelOnImage( path: image.path, numResults: 3, threshold: 0.05, imageMean: 127.5, imageStd: 127.5, );

Hope it works!

Thanks for answering, apreciate it,

I already ask for 3 result but still get the same output, which not resulting output like in my question. here's my code : static Future classifyImage(File image) async { final output = await Tflite.runModelOnImage( path: image.path, numResults: 3, threshold: 0.5, imageMean: 127.5, imageStd: 125.5, ); return output; }

and the output : [{confidence: 1.0, index: 2, label: pneumonia}]

Alfyu07 avatar Sep 24 '21 19:09 Alfyu07

You can lower your minimal confidence/threshold, 0.0 will return everything.