android – Picture Normalization Previous to Pytorch_Mobile Prediction in Dart/Flutter?


I’m trying to run a picture by a pytorch mannequin I’ve created and included right into a cellular flutter app. Within the Coaching course of, previous to shifting the mannequin to my cellular dev surroundings, I normalize my coaching photos in python utilizing Pytorch Transforms with the next line of code:

transforms.Normalize(imply=[0.75107294, 0.51543763, 0.52209598], std=[0.13829332, 0.15216838, 0.16517265]),

I’ve tried to determine this out from the documentation for the Pytorch_Mobile bundle for Dart/Flutter however I’m uncertain as to wether I’ve to normalize my picture previous to passing it to the community for a prediction, my code at present appears as follows (filePath being the Path to the Picture):

File resizedFile = await FlutterNativeImage.compressImage(filePath,
    high quality: 100, targetWidth: 224, targetHeight: 224);

Record? classificationPrediction =
    await classificationModel.getImagePredictionList(resizedFile, 224, 224);

Nonetheless, when passing photos to the mannequin by my flutter app I’m receiving outcomes that simply do not appear to replicate the accuracy that was achieved by the take a look at dataset utilized in Coaching in Pytorch in Python.

Might the difficulty be that I have to normalize the picture previous to passing it to the mannequin in Flutter, and if that’s the case, how would I greatest obtain this?

Leave a Reply