ilovin / lstm_ctc_ocr

Use CTC + tensorflow to OCR
https://ilovin.github.io/2017-04-06/tensorflow-lstm-ctc-ocr/
354 stars 140 forks source link

test.sh出错 #55

Open yangjx54 opened 5 years ago

yangjx54 commented 5 years ago

你好,我在训练完成后在网上找了一张图进行测试,但是出现了如下的问题: `tensorflow.python.framework.errors_impl.FailedPreconditionError: sequence_length(0) <= 21 [[Node: CTCBeamSearchDecoder = CTCBeamSearchDecoder[beam_width=100, merge_repeated=true, top_paths=1, _device="/job:localhost/replica:0/task:0/device:CPU:0"](logits/transpose/_105, _arg_time_step_len_0_2)]] [[Node: SparseToDense/_107 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_399_SparseToDense", tensor_type=DT_INT64, _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "./lstm/test_net.py", line 73, in restore=bool(int(args.restore))) File "./lstm/../lib/lstm/test.py", line 99, in test_net sw.test_model(sess, testDir=testDir, restore=restore) File "./lstm/../lib/lstm/test.py", line 77, in test_model res = sess.run(fetches=dense_decoded[0], feed_dict=feed_dict) File "/home/yangjx513/tensorflow3/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 895, in run run_metadata_ptr) File "/home/yangjx513/tensorflow3/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 1128, in _run feed_dict_tensor, options, run_metadata) File "/home/yangjx513/tensorflow3/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 1344, in _do_run options, run_metadata) File "/home/yangjx513/tensorflow3/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 1363, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.FailedPreconditionError: sequence_length(0) <= 21 [[Node: CTCBeamSearchDecoder = CTCBeamSearchDecoder[beam_width=100, merge_repeated=true, top_paths=1, _device="/job:localhost/replica:0/task:0/device:CPU:0"](logits/transpose/_105, _arg_time_step_len_0_2)]] [[Node: SparseToDense/_107 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_399_SparseToDense", tensor_type=DT_INT64, _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]]

Caused by op 'CTCBeamSearchDecoder', defined at: File "./lstm/test_net.py", line 73, in restore=bool(int(args.restore))) File "./lstm/../lib/lstm/test.py", line 99, in test_net sw.test_model(sess, testDir=testDir, restore=restore) File "./lstm/../lib/lstm/test.py", line 30, in test_model decoded, log_prob = tf.nn.ctc_beam_search_decoder(logits, time_step_batch, merge_repeated=True) File "/home/yangjx513/tensorflow3/lib/python3.4/site-packages/tensorflow/python/ops/ctc_ops.py", line 273, in ctc_beam_search_decoder merge_repeated=merge_repeated)) File "/home/yangjx513/tensorflow3/lib/python3.4/site-packages/tensorflow/python/ops/gen_ctc_ops.py", line 77, in _ctc_beam_search_decoder top_paths=top_paths, merge_repeated=merge_repeated, name=name) File "/home/yangjx513/tensorflow3/lib/python3.4/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "/home/yangjx513/tensorflow3/lib/python3.4/site-packages/tensorflow/python/framework/ops.py", line 3160, in create_op op_def=op_def) File "/home/yangjx513/tensorflow3/lib/python3.4/site-packages/tensorflow/python/framework/ops.py", line 1625, in init self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

FailedPreconditionError (see above for traceback): sequence_length(0) <= 21 [[Node: CTCBeamSearchDecoder = CTCBeamSearchDecoder[beam_width=100, merge_repeated=true, top_paths=1, _device="/job:localhost/replica:0/task:0/device:CPU:0"](logits/transpose/_105, _arg_time_step_len_0_2)]] [[Node: SparseToDense/_107 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_399_SparseToDense", tensor_type=DT_INT64, _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]] ` 请问,这个是什么原因造成的?是因为对测试的图片有什么要求吗?我如果不修改图像的大小会出现cannot reshape array of size 3200 into shape(1,32,32)的问题,调整大小后会出现上面这个问题。因为我是刚接触,遇到了很多问题,这个问题我实在不知道怎么解决,希望您能提供一下方法,谢谢了。