I need to convert a given tensorflow model into a tflite model. Unfortunately I am not allowed to share the model. I also have not created it myself. However, I know it is a "ssdmobilenet_v2_320x320" model and the object detection api was used to train the model. Right now the model is used to detect a single class.
When I run the original model the results are very good. However, when I use the tflite model, the results feel kinda random. All the scores of the ten detected objects are nearly zero.
I used this google colab notebook for converting the model. I experimented with converter.experimental_new_converter = True and converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS,.lite.OpsSet.SELECT_TF_OPS] but it didn't help.
Here is the meta data output of the tflite model.
Metadata populated:
{
"name": "ObjectDetector",
"description": "Identify which of a known set of objects might be present and provide information about their positions within the given image or a video stream.",
"subgraph_metadata": [
{
"input_tensor_metadata": [
{
"name": "image",
"description": "Input image to be detected.",
"content": {
"content_properties_type": "ImageProperties",
"content_properties": {
"color_space": "RGB"
}
},
"process_units": [
{
"options_type": "NormalizationOptions",
"options": {
"mean": [
127.5
],
"std": [
127.5
]
}
}
],
"stats": {
"max": [
1.0
],
"min": [
-1.0
]
}
}
],
"output_tensor_metadata": [
{
"name": "location",
"description": "The locations of the detected boxes.",
"content": {
"content_properties_type": "BoundingBoxProperties",
"content_properties": {
"index": [
1,
0,
3,
2
],
"type": "BOUNDARIES"
},
"range": {
"min": 2,
"max": 2
}
},
"stats": {
}
},
{
"name": "category",
"description": "The categories of the detected boxes.",
"content": {
"content_properties_type": "FeatureProperties",
"content_properties": {
},
"range": {
"min": 2,
"max": 2
}
},
"stats": {
},
"associated_files": [
{
"name": "tflite_label_map.txt",
"description": "Labels for categories that the model can recognize.",
"type": "TENSOR_VALUE_LABELS"
}
]
},
{
"name": "score",
"description": "The scores of the detected boxes.",
"content": {
"content_properties_type": "FeatureProperties",
"content_properties": {
},
"range": {
"min": 2,
"max": 2
}
},
"stats": {
}
},
{
"name": "number of detections",
"description": "The number of the detected boxes.",
"content": {
"content_properties_type": "FeatureProperties",
"content_properties": {
}
},
"stats": {
}
}
],
"output_tensor_groups": [
{
"name": "detection_result",
"tensor_names": [
"location",
"category",
"score"
]
}
]
}
],
"min_parser_version": "1.2.0"
}
=============================
Associated file(s) populated:
['tflite_label_map.txt']
I actually don't really know how to interpret most of it since I didn't find any documentation for the metadata. But the lines
"range": {
"min": 2,
"max": 2
}
feel wrong. Which ranges are those and why should the min and the max be 2?