Skip to content

Conversation

@swarmidentity
Copy link

@swarmidentity swarmidentity commented Jan 9, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant