Search code examples
androidtensorflowyologoogle-mlkit

it requires specifying NormalizationOptions metadata to preprocess input images


Yolov3-tiny-416.tflite is a tflite model for yolov3 tiny model created from yolov3-tiny.weights I had tried to use this from ML kit Vision module provided by google in android. In repo: https://github.com/googlesamples/mlkit/tree/master/android/vision-quickstart

This is the way I have load and and choose detection options for yolo v3 tiny tflite model.

LocalModel localModel = new LocalModel.Builder()
              .setAssetFilePath("yolov3-tiny-416.tflite")
              .build();
CustomObjectDetectorOptions customObjectDetectorOptions = PreferenceUtils.getCustomObjectDetectorOptionsForLivePreview(this,localModel);
cameraSource.setMachineLearningFrameProcessor(new ObjectDetectorProcessor(this,customObjectDetectorOptions));

Now, I have encounterd a error that says:

E/MobileVisionBase: Error preloading model resource
b.a.d.a.a: Failed to initialize detector. Input tensor has type kTfLiteFloat32: it requires specifying NormalizationOptions metadata to preprocess input images. 

As I know from error, I need to specify NormalizationOptions Metadata to process Image. So, How the problem can be solved? any Suggestion?


Solution

  • Here is the custom model requirements for ML Kit custom object detection&tracking. https://developers.google.com/ml-kit/custom-models If you check the Metadata section at the bottom of the page, it has some instructions about adding NormalizationOptions Metadata.

    However, the very basic requirement for ML Kit custom object detection&tracking is that the model needs to be an image classification model, while yolov3 is not.

    If you want to classify more object with ML Kit, you can try one of the custom image classifier models with ML Kit tag on TFHub. https://tfhub.dev/ml-kit/collections/image-classification/1 or train your own classifier using AutoML or TFLite ModelMaker (see https://developers.google.com/ml-kit/custom-models#automl_vision_edge).

    Best,