Low Accuracy with static image on TFLite demo model

♀尐吖头ヾ 提交于 2019-12-08 03:34:47

问题


I'm trying the TFLite implementation for Image Classification using Mobile Net Transfer Learning example from TensorFlow for Poets 2

I'm able to succesfully complete the transfer learning using the four flower samples in the code lab and got the below screen

This is a continuous stream of images that's being classified.

I need to classify the image after taking the picture instead of stream and then take some action based on the result. Below is my approach for this.

  1. Create a basic camera app
  2. Take a picture and save it to storage
  3. The uri of the image is saved and then a drawable is created from the URI.
  4. This drawable is then converted to a bitmap.
  5. The bitmap size transformed to 224 x 224 to match the input of the Mobile Net model
  6. I'm receiving the accuracy in the ranges of 0.05 and 0.06 against the continuous stream sample from the Code Labs which gives accuracy in the range of 0.80 - 0.90 in the trained flower classes

Below is the code where I transform the bitmap to 224 x 224 size

private static Bitmap getResizedBitmap(Bitmap bm, int newWidth, int newHeight, boolean isNecessaryToKeepOrig) {
    int width = bm.getWidth();
    int height = bm.getHeight();
    float scaleWidth = ((float) newWidth) / width;
    float scaleHeight = ((float) newHeight) / height;
    // CREATE A MATRIX FOR THE MANIPULATION
    Matrix matrix = new Matrix();
    // RESIZE THE BIT MAP
    matrix.postScale(scaleWidth, scaleHeight);

    // "RECREATE" THE NEW BITMAP
    Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false);
    if(!isNecessaryToKeepOrig){
        bm.recycle();
    }
    return resizedBitmap;
}

The results turn out to be same even when I pass down the original bitmap to classifier which itself is converting the image to 224 x 224. Should I be doing some more additional processing on the images or do I need to change any configuration in the model ?


回答1:


I think the problem is applyFilter() which smooth the probability. Just remove it then the probability should be showed as normal.

String classifyFrame(Bitmap bitmap) {
...
// smooth the results
//applyFilter(); <--remove it

...
}



回答2:


I have the same problem and I want to sort a picture .I've found multiple calls to call the classification function. The results will tend to be correct. It's just a bad solution. enter image description here



来源:https://stackoverflow.com/questions/49954439/low-accuracy-with-static-image-on-tflite-demo-model

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!