AlexanderLutsenko / nobuco

Pytorch to Keras/Tensorflow/TFLite conversion made intuitive
MIT License
263 stars 17 forks source link

Signature output names #51

Closed johan-sightic closed 4 months ago

johan-sightic commented 4 months ago

I have a pytorch model that returns a dict[str, torch.Tensor] type with 5 keys and tensors and I use nobuco to convert it to tflite. Conversion works fine, however, the output of the tflite model is now a dict with different keys. The signature of the tflite model is:

Signature#0 key: 'serving_default'
- Subgraph: Subgraph#0
- Inputs: 
    'args_0' : T#0
- Outputs: 
    'tf.identity' : T#206
    'tf.identity_1' : T#208
    'tf.identity_2' : T#210
    'tf.identity_3' : T#212
    'tf.identity_4' : T#214

How can I change the output keys to match my original model? Thanks!

AlexanderLutsenko commented 4 months ago

Hi! Signatures are supported since v0.15.0, see example. Note: you'll have to use TFLiteConverterV2, not the old TFLiteConverter.

johan-sightic commented 4 months ago

Perfect, thank you!

johan-sightic commented 4 months ago

tensorflow.lite.TFLiteConverter points to TFLiteConverterV2 in my tensorflow version (2.15.0)