'How to improve the accuracy of Yolov4-tiny.tflite in flutter
I have trained the yolov4-tiny file and successfully converted it to tflite. There were no problems during the computer test, but I encountered difficulties in installing it on the phone.
As I put my tflite into the flutter, I had different test results from my computer. And the result is not good, the accuracy is much lower, and the recognition error is often. I think the problem appear at classierYOLOv4, but i'm not sure where is wrong.
Is there any suggestion for me to fix this problem?
Thanks a lot for your help!
Here is the code:https://github.com/piggychu0w0/flutter-yolov4tiny-tflite
Solution 1:[1]
I think the problem here is your input not being scaled to (0,1). You have to add a normalize layer into your model or scale your input first.
Edit: Using this code to normalize image
TensorImage getProcessedImage(TensorImage inputImage) {
padSize = max(inputImage.height, inputImage.width);
if (imageProcessor == null) {
imageProcessor = ImageProcessorBuilder()
.add(ResizeWithCropOrPadOp(padSize, padSize))
.add(ResizeOp(INPUT_SIZE, INPUT_SIZE, ResizeMethod.BILINEAR))
.add(DequantizeOp(0, 255.0))
.build();
}
inputImage = imageProcessor.process(inputImage);
return inputImage;
}
and load the input image
TensorImage inputImage = TensorImage(TfLiteType.float32);
inputImage.loadImage(image);
inputImage = getProcessedImage(inputImage);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |