tiwaridipak103 / Scene-Text-Recognition

9 stars 0 forks source link

shows images incompatible #2

Open watveabhi9 opened 2 years ago

watveabhi9 commented 2 years ago

Hi, I am trying to train the same model on my own images and got the following error. I am new to this field so I hope to get some detailed information. Executed the following code and got an error - Code - for epoch in range(EPOCHS): start = time.time()

train_loss.reset_states() train_accuracy.reset_states()

inp -> image, tar -> word character

for (batch, (inp, tar)) in enumerate(train_batches): train_step(inp, tar)

if (epoch + 1) % 5 == 0: ckpt_save_path = ckpt_manager.save() print(f'Saving checkpoint for epoch {epoch+1} at {ckpt_save_path}')

print(f'Epoch {epoch + 1} Loss {train_loss.result():.4f} Accuracy {train_accuracy.result():.4f}')

print(f'Time taken for 1 epoch: {time.time() - start:.2f} secs\n')

Error - ValueError: in user code:

File "<ipython-input-79-68f7fededc28>", line 14, in train_step  *
    predictions, _ = transformer(inp, tar_inp,
File "/usr/local/lib/python3.7/dist-packages/keras/utils/traceback_utils.py", line 67, in error_handler  **
    raise e.with_traceback(filtered_tb) from None

ValueError: Exception encountered when calling layer "transformer_1" (type Transformer).

in user code:

    File "<ipython-input-74-9f6b5777038a>", line 24, in call  *
        generated_images1 = modified(inp, training=True)
    File "/usr/local/lib/python3.7/dist-packages/keras/utils/traceback_utils.py", line 67, in error_handler  **
        raise e.with_traceback(filtered_tb) from None
    File "/usr/local/lib/python3.7/dist-packages/keras/engine/input_spec.py", line 264, in assert_input_compatibility
        raise ValueError(f'Input {input_index} of layer "{layer_name}" is '

    ValueError: Input 0 of layer "sequential" is incompatible with the layer: expected shape=(None, 48, 160, 3), found shape=(10, 360, 720, 3)

Call arguments received:
  • inp=tf.Tensor(shape=(10, 360, 720, 3), dtype=uint8)
  • tar=tf.Tensor(shape=(10, 23), dtype=int32)
  • training=True
  • enc_padding_mask=None
  • look_ahead_mask=tf.Tensor(shape=(10, 1, 24, 24), dtype=float32)
  • dec_padding_mask=None
Beethoven12138 commented 4 months ago

May I ask if you solved this problem, I had the same problem