emedvedev/attention-ocr

Always get error with assert len(lex) < self.bucket_specs[-1][1] on Tensorflow 1.2.1

Closed this issue · 1 comments

Hi, I always get assertion error in assert len(lex) < self.bucket_specs[-1][1].
Could you help give me some clues on how to fix this?
Tensorflow Version: 1.2.1
I used to the training images from A Toy Example in https://github.com/da03/Attention-OCR/#a-toy-example
I also tried changing epoch size to 500 as well (total image is 1000) but still got the problem.

2019-10-25 08:53:22,868 root  INFO     phase: train
2019-10-25 08:53:22,869 root  INFO     model_dir: ./checkpoints
2019-10-25 08:53:22,869 root  INFO     load_model: True
2019-10-25 08:53:22,869 root  INFO     output_dir: ./results
2019-10-25 08:53:22,869 root  INFO     steps_per_checkpoint: 100
2019-10-25 08:53:22,869 root  INFO     batch_size: 65
2019-10-25 08:53:22,869 root  INFO     learning_rate: 1.000000
2019-10-25 08:53:22,870 root  INFO     reg_val: 0
2019-10-25 08:53:22,870 root  INFO     max_gradient_norm: 5.000000
2019-10-25 08:53:22,870 root  INFO     clip_gradients: True
2019-10-25 08:53:22,870 root  INFO     max_image_width 160.000000
2019-10-25 08:53:22,870 root  INFO     max_prediction_length 8.000000
2019-10-25 08:53:22,870 root  INFO     channels: 1
2019-10-25 08:53:22,870 root  INFO     target_embedding_size: 10.000000
2019-10-25 08:53:22,870 root  INFO     attn_num_hidden: 128
2019-10-25 08:53:22,871 root  INFO     attn_num_layers: 2
2019-10-25 08:53:22,871 root  INFO     visualize: False
2019-10-25 08:53:29,378 root  INFO     Created model with fresh parameters.
2019-10-25 08:53:30,143 root  INFO     num_epoch: 500
2019-10-25 08:53:31,446 root  INFO     Starting the training process.
Traceback (most recent call last):
  File "/root/anaconda3/envs/my_env/lib/python3.5/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/root/anaconda3/envs/my_env/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/root/attention-ocr/aocr/__main__.py", line 283, in <module>
    main()
  File "/root/attention-ocr/aocr/__main__.py", line 257, in main
    num_epoch=parameters.num_epoch
  File "/root/attention-ocr/aocr/model/model.py", line 376, in train
    for batch in s_gen.gen(self.batch_size):
  File "/root/attention-ocr/aocr/util/data_gen.py", line 71, in gen
    word = self.convert_lex(lex)
  File "/root/attention-ocr/aocr/util/data_gen.py", line 89, in convert_lex
    assert len(lex) < self.bucket_specs[-1][1]
AssertionError

Your max_prediction_length is 8, so if you have labels over 8 characters, you'll get this error. You should adjust it with the --max-prediction CLI parameter.