rishigami / Swin-Transformer-TF

Tensorflow implementation of Swin Transformer model.
Apache License 2.0
198 stars 46 forks source link

Please run in eager mode or implement the `compute_output_shape` method on your layer (SwinTransformerModel) #20

Open atelili opened 1 year ago

atelili commented 1 year ago

Has anyone tried to use the pretrained model with TimeDistributed layer ?

model = tf.keras.Sequential([ tf.keras.layers.Lambda(lambda data: tf.keras.applications.imagenet_utils.preprocess_input(tf.cast(data, tf.float32), mode="torch"), 
input_shape=[224,224, 3]), SwinTransformer('swin_base_224', include_top=False, pretrained=True)])

model_f = models.Sequential()
    model.add(TimeDistributed(model, input_shape= (8,224,224,3)) 

I get the following error:

NotImplementedError: Exception encountered when calling layer "time_distributed" (type TimeDistributed).

Please run in eager mode or implement the `compute_output_shape` method on your layer (SwinTransformerModel).

Call arguments received by layer "time_distributed" (type TimeDistributed):
  • inputs=tf.Tensor(shape=(None, 8, 224, 224, 3), dtype=float32)
  • training=False