MaybeShewill-CV / CRNN_Tensorflow

Convolutional Recurrent Neural Networks(CRNN) for Scene Text Recognition
MIT License
1.03k stars 388 forks source link

When Training: [error] Invalid argument: Saw a non-null label(index >= num_classes -1 ) following a null label, batch: 8 num_classes: 562 labels #93

Closed wujiahao15 closed 5 years ago

wujiahao15 commented 6 years ago

My environment is as follows:

Ubuntu 17.04
python 3.6.3
tensorflow 1.7.0

When I am training on dataset of ICDAR15 Task4.3 whose tfrecords are generated by write_text_features.py, I encoutered this problem:

2018-06-05 03:08:22.133657: W tensorflow/core/framework/op_kernel.cc:1273] OP_REQUIRES failed at ctc_loss_op.cc:166 : Invalid argument: Saw a non-null label (index >= num_classes - 1) following a null label, batch: 26 num_classes: 562 labels: 
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 1327, in _do_call
    return fn(*args)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 1312, in _run_fn
    options, feed_dict, fetch_list, target_list, run_metadata)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 1420, in _call_tf_sessionrun
    status, run_metadata)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/errors_impl.py", line 516, in __exit__
    c_api.TF_GetCode(self.status.status))

This problem probably is caused by ctc loss in tf, but I don't know how to solve it.

MaybeShewill-CV commented 6 years ago

@framywhale You should check your sample file in my opinion

wujiahao15 commented 6 years ago

Thanks for your reply. I followed the sample style in your README, namely, path/to/img label. However, I did a little change when making the sample.txt, e.g. I change path/to/img label to path/to/img,label and adjust the split() to split(",") in data_provider.py:169 & 189. Here is my sample.txt. Are there any problems with it?

bluseking commented 6 years ago

@flamywhale I get the same problem as you , I use the ICDAR's dataset ,and i change the split() to split(“, ”),there is also comma in the lable,you can not split the dataset by comma, OP_REQUIRES failed at ctc_loss_op.cc:166 : Invalid argument: Saw a non-null label (index >= num_classes - 1) following a null label, batch: 11 num_classes: 37 labels: Traceback (most recent call last):

FannyDuan commented 6 years ago

@bluseking I have encountered the same problem. Have you solved the problem? My problem is that: Saw a non-null label (index >= num_classes - 1) following a null label, batch: 6 num_classes: 37 labels: 18,7,4,4,17

mdbenito commented 6 years ago

@flamywhale you should definitely check your labels for commas. If you want to have them in your character set, you can add maxplit=1 to your call to spit() as in line.strip().split(',', maxsplit=1)

bluseking commented 6 years ago

@FannyDuan you can find the answer to this issue in the following link: https://github.com/MaybeShewill-CV/CRNN_Tensorflow/issues/69#issuecomment-383992527