Add fix for MobileNetSSD Bug on Android #235
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Seems like TFLite conversion on TensorFlow 2.7.0 acts differently than previous versions - when I run the python script:
`
num_classes=1
tflite_interpreter.resize_tensor_input(input_details[0]['index'], (1, 320, 320, 3))
tflite_interpreter.resize_tensor_input(output_details[0]['index'], (1, num_classes))
tflite_interpreter.allocate_tensors()
input_details = tflite_interpreter.get_input_details()
output_details = tflite_interpreter.get_output_details()
print("== Input details ==")
print("shape:", input_details[0]['shape'])
print("\n== Output details ==")
print("shape:", output_details[0]['shape'])
print("shape:", output_details[1]['shape'])
print("shape:", output_details[2]['shape'])
print("shape:", output_details[3]['shape'])
print("name:", output_details[0]['name'])
print("name:", output_details[1]['name'])
print("name:", output_details[2]['name'])
print("name:", output_details[3]['name'])
`
on a TFLite file generated a few months ago, I get:
`
== Input details ==
shape: [ 1 320 320 3]
== Output details ==
shape: [ 1 10 4]
shape: [ 1 10]
shape: [ 1 10]
shape: [1]
name: StatefulPartitionedCall:3
name: StatefulPartitionedCall:2
name: StatefulPartitionedCall:1
name: StatefulPartitionedCall:0
`
On a TFLite file generated with 2.7.0, I get:
`
== Input details ==
shape: [ 1 320 320 3]
== Output details ==
shape: [ 1 10]
shape: [ 1 10 4]
shape: [1]
shape: [ 1 10]
name: StatefulPartitionedCall:1
name: StatefulPartitionedCall:3
name: StatefulPartitionedCall:0
name: StatefulPartitionedCall:2
`
This patch fixes the specific error I'm running into on Android for MobileNetSSD models, there may be other cases that have similar issues like #223