PROBLEM ENCOUNTERED:
E/AndroidRuntime: FATAL EXCEPTION: main Process: org.tensorflow.lite.examples.detection, PID: 14719 java.lang.AssertionError: Error occurred when initializing ObjectDetector: Mobile SSD models are expected to have exactly 4 outputs, found 8
Problem Description
- Android Application Source: TensorFlow Lite Object Detection Example from Google
- Error shown when starting the Example Application
Model Description
Custom Model Used? YES
Pre-trained Model Used: ssd_mobilenet_v2_fpnlite_640x640_coco17_tpu-8
Inference type: FLOAT
Number of classes: 4
System Information
- OS Platform and Distribution: ( Linux Ubuntu 20.14)
- TensorFlow Version: 2.4.1
- TensorFlow installed from: Pip
Saved Model conversion commands used:
1. Saved_Model.pb export:
python ./exporter_main_v2.py
--input_type image_tensor
--pipeline_config_path ./models/ssd_mobilenet_v2_fpnlite_640x640_coco17_tpu-8/pipeline.config
--trained_checkpoint_dir ./models/ssd_mobilenet_v2_fpnlite_640x640_coco17_tpu-8
--output_directory exported_models/tflite
2. Convert saved model (.pb) to tflite
toco
--saved_model_dir ./exported-models/tflite/saved_model
--emit-select-tf-ops true
--allow_custom_ops
--graph_def_file ./exported-models/tflite/saved_model/saved_model.pb
--output_file ./exported-models/tflite/tflite/detect.tflite
--input_shapes 1,300,300,3
--input_arrays normalized_input_image_tensor
--output_arrays 'TFLite_Detection_PostProcess’,’TFLite_Detection_PostProcess:1','TFLite_Detection_PostProcess:2','TFLite_Detection_PostProcess:3'
--inference_type=FLOAT
--allow_custom_ops
Remarks I am trying to use a trained custom model on the Google TensorFlow lite provided example. Just that every time I open the application, it returns such an error, Mobile SSD models are expected to have exactly 4 outputs, found 8. The model is trained to identify 4 classes, all stated in the labelmap.txt and pipeline config.
Does anybody have any clue about this error?