getImagePredictionListFromBytesList method
Returns a list of predictions for an image as a bytes list.
The image are passed as a list of Uint8List objects.
The imageWidth
and imageHeight
parameters specify the dimensions of the image.
The optional mean
and std
parameters can be used to normalize the image.
Returns a Future that resolves to a list of double values representing the predictions.
Implementation
Future<List<double>> getImagePredictionListFromBytesList(
List<Uint8List> imageAsBytesList, int imageWidth, int imageHeight,
{List<double> mean = torchVisionNormMeanRGB,
List<double> std = torchVisionNormSTDRGB}) async {
// Assert mean std
assert(mean.length == 3, "Mean should have size of 3");
assert(std.length == 3, "STD should have size of 3");
// Call the getImagePredictionList method of the ModelApi class to get the predictions
final List<double> prediction = (await ModelApi().getImagePredictionList(
_index, null, imageAsBytesList, imageWidth, imageHeight, mean, std))
.whereNotNull()
.toList();
return prediction;
}