MaybeShewill-CV / CRNN_Tensorflow

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

請問訓練繁體中文 #397

Closed tingggggg closed 4 years ago

tingggggg commented 4 years ago

一樣使用 char_dict_cn.json ord_map_cn.json 可行嗎?

目前使用自己的數據集, 遇上問題

2020-04-14 15:45:32.475062: W tensorflow/core/framework/op_kernel.cc:1502] OP_REQUIRES failed at ctc_loss_op.cc:168 : Invalid argument: Saw a non-null label (index >= num_classes - 1) following a null label, batch: 3 num_classes: 37 labels: 323,642,4,20,250,682 labels seen so far: 2020-04-14 15:45:33.259486: W tensorflow/core/framework/op_kernel.cc:1502] OP_REQUIRES failed at ctc_loss_op.cc:168 : Invalid argument: Saw a non-null label (index >= num_classes - 1) following a null label, batch: 1 num_classes: 37 labels: 354,897,25,5,944,241,250,515,537 labels seen so far: Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1356, in _do_call return fn(*args) File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1341, in _run_fn options, feed_dict, fetch_list, target_list, run_metadata) File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1429, in _call_tf_sessionrun run_metadata) tensorflow.python.framework.errors_impl.InvalidArgumentError: Saw a non-null label (index >= num_classes - 1) following a null label, batch: 3 num_classes: 37 labels: 323,642,4,20,250,682 labels seen so far: [[{{node CTCLoss_1}}]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "train_shadownet.py", line 575, in need_decode=args.decode_outputs File "train_shadownet.py", line 319, in train_shadownet [optimizer, train_ctc_loss, merge_summary_op]) File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 950, in run run_metadata_ptr) File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1173, in _run feed_dict_tensor, options, run_metadata) File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1350, in _do_run run_metadata) File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1370, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InvalidArgumentError: Saw a non-null label (index >= num_classes - 1) following a null label, batch: 3 num_classes: 37 labels: 323,642,4,20,250,682 labels seen so far: [[node CTCLoss_1 (defined at /workspace/handwritten/CRNN_Tensorflow/crnn_model/crnn_net.py:253) ]]

Errors may have originated from an input operation. Input Source operations connected to node CTCLoss_1: shadow_net_1/sequence_rnn_module/transpose_time_major (defined at /workspace/handwritten/CRNN_Tensorflow/crnn_model/crnn_net.py:207)
DeserializeSparse_1 (defined at /workspace/handwritten/CRNN_Tensorflow/data_provider/tf_io_pipline_fast_tools.py:406)

Original stack trace for 'CTCLoss_1': File "train_shadownet.py", line 575, in need_decode=args.decode_outputs File "train_shadownet.py", line 190, in train_shadownet reuse=True File "/workspace/handwritten/CRNN_Tensorflow/crnn_model/crnn_net.py", line 253, in compute_loss sequence_length=CFG.ARCH.SEQ_LENGTH np.ones(CFG.TRAIN.BATCH_SIZE) File "/usr/local/lib/python3.6/site-packages/tensorflow/python/ops/ctc_ops.py", line 176, in ctc_loss ignore_longer_outputs_than_inputs=ignore_longer_outputs_than_inputs) File "/usr/local/lib/python3.6/site-packages/tensorflow/python/ops/gen_ctc_ops.py", line 335, in ctc_loss name=name) File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper op_def=op_def) File "/usr/local/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func return func(args, **kwargs) File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3616, in create_op op_def=op_def) File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2005, in init self._traceback = tf_stack.extract_stack()

不知是否為 char_dict 問題

MaybeShewill-CV commented 4 years ago

@tingggggg 繁体中文要自己重建char dict文件 具体可以参考 https://github.com/MaybeShewill-CV/CRNN_Tensorflow/blob/0c352335471088714586a0b11cf0d7818226dcf0/data_provider/shadownet_data_feed_pipline.py#L201

tingggggg commented 4 years ago

thanks~ char dict 已經使用我自己的數據集產生的了

但還是有同樣問題 有可能是什麼問題?!

2020-04-15 04:11:18.496389: W tensorflow/core/framework/op_kernel.cc:1502] OP_REQUIRES failed at ctc_loss_op.cc:168 : Invalid argument: Saw a non-null label (index >= num_classes - 1) following a null label, batch: 0 num_classes: 37 labels: 788,892,846,124,865,451,421,208,29,647,513 labels seen so far: 2020-04-15 04:11:18.496436: W tensorflow/core/framework/op_kernel.cc:1502] OP_REQUIRES failed at ctc_loss_op.cc:168 : Invalid argument: Saw a non-null label (index >= num_classes - 1) following a null label, batch: 5 num_classes: 37 labels: 634,304,17,713,582 labels seen so far: Traceback (most recent call last): File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1356, in _do_call return fn(*args) File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1341, in _run_fn options, feed_dict, fetch_list, target_list, run_metadata) File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1429, in _call_tf_sessionrun run_metadata) tensorflow.python.framework.errors_impl.InvalidArgumentError: Saw a non-null label (index >= num_classes - 1) following a null label, batch: 0 num_classes: 37 labels: 788,892,846,124,865,451,421,208,29,647,513 labels seen so far: [[{{node CTCLoss_1}}]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "train_shadownet.py", line 575, in need_decode=args.decode_outputs File "train_shadownet.py", line 319, in train_shadownet [optimizer, train_ctc_loss, merge_summary_op]) File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 950, in run run_metadata_ptr) File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1173, in _run feed_dict_tensor, options, run_metadata) File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1350, in _do_run run_metadata) File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1370, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InvalidArgumentError: Saw a non-null label (index >= num_classes - 1) following a null label, batch: 0 num_classes: 37 labels: 788,892,846,124,865,451,421,208,29,647,513 labels seen so far: [[node CTCLoss_1 (defined at /workspace/CRNN_Tensorflow/crnn_model/crnn_net.py:253) ]]

Errors may have originated from an input operation. Input Source operations connected to node CTCLoss_1: shadow_net_1/sequence_rnn_module/transpose_time_major (defined at /workspace/CRNN_Tensorflow/crnn_model/crnn_net.py:207)
DeserializeSparse_1 (defined at /workspace/CRNN_Tensorflow/data_provider/tf_io_pipline_fast_tools.py:406)

Original stack trace for 'CTCLoss_1': File "train_shadownet.py", line 575, in need_decode=args.decode_outputs File "train_shadownet.py", line 190, in train_shadownet reuse=True File "/workspace/CRNN_Tensorflow/crnn_model/crnn_net.py", line 253, in compute_loss sequence_length=CFG.ARCH.SEQ_LENGTH np.ones(CFG.TRAIN.BATCH_SIZE) File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/ctc_ops.py", line 176, in ctc_loss ignore_longer_outputs_than_inputs=ignore_longer_outputs_than_inputs) File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/gen_ctc_ops.py", line 335, in ctc_loss name=name) File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper op_def=op_def) File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func return func(args, **kwargs) File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 3616, in create_op op_def=op_def) File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 2005, in init self._traceback = tf_stack.extract_stack()

tingggggg commented 4 years ago

config 修改 NUM_CLASSES 可以正常訓練了 謝謝

MaybeShewill-CV commented 4 years ago

@tingggggg 好的 也欢迎分享模型训练结果:)