TFLite model TransposeConv layer converter only supports same padding with equal kernel and stride.

forwARdgame
forwARdgame Posts: 41 🔥

We are trying to integrate a model and Studio shows an error that we don't think reflects the reality.

it says: TFLite model TransposeConv layer converter only supports same padding with equal kernel and stride.

However, according to the code kernel size and strides both equal 2 — they ARE the same and the padding IS according to the requirements.

We will greatly appreciate any help with this issue.

In this folder is the description of the issue with screens and the ML model.
(please request access)

https://drive.google.com/drive/folders/16etEngieyP5-MlXnUDA5C8d2lQl4mQyq?usp=share_link

Answers

  • Tariq B
    Tariq B Posts: 96 🔥🔥

    Hi @forwARdgame I can't access the file it says: You need access

  • forwARdgame
    forwARdgame Posts: 41 🔥

    That's what I meant in the post by "request access" 😅
    You just requested, I just granted it. Hope you can solve the issue for us.

  • Tariq B
    Tariq B Posts: 96 🔥🔥

    Sorry I didn't see it, okay hopefully I will take a look.

  • Tariq B
    Tariq B Posts: 96 🔥🔥

    Try to replace the Conv2DTranspose with UpSampling2D and Conv2D, and convert it to TFLIte it should fix the issue.

    def upsample(filters, size, apply_dropout=False):
    initializer = tf.random_normal_initializer(0., 0.02)

    result = tf.keras.Sequential()
    
    # Replace Conv2DTranspose with UpSampling2D and Conv2D
    result.add(
        tf.keras.layers.UpSampling2D(size=(2, 2), interpolation='nearest'))
    
    result.add(
        tf.keras.layers.Conv2D(filters,
                               size,
                               strides=1,
                               padding='same',
                               kernel_initializer=initializer,
                               use_bias=False))
    
    result.add(tf.keras.layers.BatchNormalization())
    
    if apply_dropout:
        result.add(tf.keras.layers.Dropout(0.5))
    
    result.add(tf.keras.layers.ReLU())
    
    return result