GithubHelp home page GithubHelp logo

maybeshewill-cv / crnn_tensorflow Goto Github PK

View Code? Open in Web Editor NEW
1.0K 1.0K 390.0 557.42 MB

Convolutional Recurrent Neural Networks(CRNN) for Scene Text Recognition

License: MIT License

Python 99.48% Shell 0.52%
chinese-ocr crnn-tensorflow ctc-loss ocr-recognition sequence-recongnition tensorflow

crnn_tensorflow's Introduction

🏆 Github Trophy

trophy

👀 Lovely Snake

Contribution snake Light

👀 Active Repo

Lane_Detection segment-anything-u-specify

👀 Activity Graph

MaybeShewill-CV's github activity graph

🏆 Github Status

🏆 3D Status Profile

👨‍💻 Languages and Tools

CPP Python

Tensorflow Pytorch ONNX

LeetCode Docker

Git GitHub

☕ Get In Touch

visitors

visitors_new

⭐️ From Baidu.Inc

crnn_tensorflow's People

Contributors

dependabot[bot] avatar fhainzl avatar jackson-kang avatar ljxljxljx avatar maybeshewill-cv avatar mdbenito avatar once88 avatar ryanwcyin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

crnn_tensorflow's Issues

Load pre-trained model

Hi,
I clone the master branch and try to run the demo.
The model files seems changed to new format as i got this error
DataLossError (see above for traceback): Unable to open table file model/shadownet/shadownet_2017-10-17-11-47-46.ckpt-199999.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?

识别率

你好,原文在synth上的识别率应该是达到了90多的 但是我最高的识别率仅88%,网络已经收敛,但是最后的识别率一直稳定不下来,识别率也跟原文差距颇大,请问是哪里出错了吗

中文识别

请问有中文识别的数据库么,我搜索很久都搜索不到好的数据库@TJCVRS

I need number recogintion as well?

I am unable to find a data set on which i can train it for recognizing numbers as well.
Can some one suggest me data set for that.
If you have trained a model that can recognize both alphabets and numbers so let me know if you can provide me with your pre-trained model

About Chinese character recognition

I tried to train a model of Chiese character, at first, I made a dataset which only contains 5 characters, and the size of dataset is 200000. The loss is about 0 and accuracy is about 1, but when I test my real data, the recognition effect is terrible. Anyone can help me? Thank you very much.

生成模型

在生成自己模型的时候,使用了train_shadownet.py出现了以下错误:

INFO:tensorflow:Error reported to Coordinator: <class 'tensorflow.python.framework.errors_impl.InvalidArgumentError'>, Name: , Feature: imagenames (data type: string) is required but could not be found.
[[Node: ParseSingleExample/ParseExample/ParseExample = ParseExample[Ndense=2, Nsparse=1, Tdense=[DT_STRING, DT_STRING], dense_shapes=[[1], []], sparse_types=[DT_INT64], _device="/job:localhost/replica:0/task:0/cpu:0"](ParseSingleExample/ExpandDims, ParseSingleExample/ParseExample/ParseExample/names, ParseSingleExample/ParseExample/ParseExample/sparse_keys_0, ParseSingleExample/ParseExample/ParseExample/dense_keys_0, ParseSingleExample/ParseExample/ParseExample/dense_keys_1, ParseSingleExample/ParseExample/Const, ParseSingleExample/ParseExample/Const_1)]]
INFO: 11-06 15:56:13: tf_logging.py:82 * 140074667120384 Error reported to Coordinator: <class 'tensorflow.python.framework.errors_impl.InvalidArgumentError'>, Name: , Feature: imagenames (data type: string) is required but could not be found.
[[Node: ParseSingleExample/ParseExample/ParseExample = ParseExample[Ndense=2, Nsparse=1, Tdense=[DT_STRING, DT_STRING], dense_shapes=[[1], []], sparse_types=[DT_INT64], _device="/job:localhost/replica:0/task:0/cpu:0"](ParseSingleExample/ExpandDims, ParseSingleExample/ParseExample/ParseExample/names, ParseSingleExample/ParseExample/ParseExample/sparse_keys_0, ParseSingleExample/ParseExample/ParseExample/dense_keys_0, ParseSingleExample/ParseExample/ParseExample/dense_keys_1, ParseSingleExample/ParseExample/Const, ParseSingleExample/ParseExample/Const_1)]]
2017-11-06 15:56:14.055074: W tensorflow/core/framework/op_kernel.cc:1192] Out of range: RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
[[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_UINT8, DT_INT64, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]
2017-11-06 15:56:14.055217: W tensorflow/core/framework/op_kernel.cc:1192] Out of range: RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
[[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_UINT8, DT_INT64, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]
2017-11-06 15:56:14.055392: W tensorflow/core/framework/op_kernel.cc:1192] Out of range: RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
[[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_UINT8, DT_INT64, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]
2017-11-06 15:56:14.055432: W tensorflow/core/framework/op_kernel.cc:1192] Out of range: RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
[[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_UINT8, DT_INT64, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]
2017-11-06 15:56:14.055586: W tensorflow/core/framework/op_kernel.cc:1192] Out of range: RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
[[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_UINT8, DT_INT64, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]
2017-11-06 15:56:14.055619: W tensorflow/core/framework/op_kernel.cc:1192] Out of range: RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
[[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_UINT8, DT_INT64, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]
2017-11-06 15:56:14.055639: W tensorflow/core/framework/op_kernel.cc:1192] Out of range: RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
[[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_UINT8, DT_INT64, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]
2017-11-06 15:56:14.055660: W tensorflow/core/framework/op_kernel.cc:1192] Out of range: RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
[[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_UINT8, DT_INT64, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]
2017-11-06 15:56:14.055682: W tensorflow/core/framework/op_kernel.cc:1192] Out of range: RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
[[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_UINT8, DT_INT64, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]
2017-11-06 15:56:14.055712: W tensorflow/core/framework/op_kernel.cc:1192] Out of range: RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
[[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_UINT8, DT_INT64, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]
2017-11-06 15:56:14.055731: W tensorflow/core/framework/op_kernel.cc:1192] Out of range: RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
[[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_UINT8, DT_INT64, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]
2017-11-06 15:56:14.055748: W tensorflow/core/framework/op_kernel.cc:1192] Out of range: RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
[[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_UINT8, DT_INT64, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]
2017-11-06 15:56:14.055777: W tensorflow/core/framework/op_kernel.cc:1192] Out of range: RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
[[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_UINT8, DT_INT64, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]
Traceback (most recent call last):
File "/home/cxy/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1327, in _do_call
return fn(*args)
File "/home/cxy/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1306, in _run_fn
status, run_metadata)
File "/home/cxy/anaconda3/lib/python3.6/contextlib.py", line 88, in exit
next(self.gen)
File "/home/cxy/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.OutOfRangeError: RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
[[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_UINT8, DT_INT64, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "tools/train_shadownet.py", line 174, in
train_shadownet(args.dataset_dir, args.weights_path)
File "tools/train_shadownet.py", line 124, in train_shadownet
[optimizer, cost, sequence_dist, decoded, input_labels, merge_summary_op])
File "/home/cxy/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 895, in run
run_metadata_ptr)
File "/home/cxy/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1124, in _run
feed_dict_tensor, options, run_metadata)
File "/home/cxy/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1321, in _do_run
options, run_metadata)
File "/home/cxy/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1340, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.OutOfRangeError: RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
[[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_UINT8, DT_INT64, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]

Caused by op 'shuffle_batch', defined at:
File "tools/train_shadownet.py", line 174, in
train_shadownet(args.dataset_dir, args.weights_path)
File "tools/train_shadownet.py", line 51, in train_shadownet
tensors=[images, labels, imagenames], batch_size=32, capacity=120, min_after_dequeue=100, num_threads=1)
File "/home/cxy/anaconda3/lib/python3.6/site-packages/tensorflow/python/training/input.py", line 1220, in shuffle_batch
name=name)
File "/home/cxy/anaconda3/lib/python3.6/site-packages/tensorflow/python/training/input.py", line 791, in _shuffle_batch
dequeued = queue.dequeue_many(batch_size, name=name)
File "/home/cxy/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/data_flow_ops.py", line 457, in dequeue_many
self._queue_ref, n=n, component_types=self._dtypes, name=name)
File "/home/cxy/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/gen_data_flow_ops.py", line 1342, in _queue_dequeue_many_v2
timeout_ms=timeout_ms, name=name)
File "/home/cxy/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 767, in apply_op
op_def=op_def)
File "/home/cxy/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2630, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/home/cxy/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1204, in init
self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

OutOfRangeError (see above for traceback): RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
[[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_UINT8, DT_INT64, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]

有人知道怎么回事吗,看得我快崩溃了

批量测试不同大小的图片和sequence_length大小设置的问题

作者你好~麻烦请教两个问题:

1. 如何批量测试不同大小的图片?
1)因为测试图像大小比例均不同,转为tfrecords过程中resize造成图像变形会影响准确率,因而想直接拿图像测试。但不同大小的图像每次build_shadownet的网络都不同,测试第一张图像后已经创建了,却又不能reuse,而tf.variabel_scope是共享变量,如何释放啊?╮(╯_╰)╭
2)若tf.variabel_scope释放成功(或者用shell写循环调用demo_shadownet或者batch size=1的test_shadownet)每测试一张图像都要重新build网络,速度很慢啊,作者有啥好建议吗~
with tf.variable_scope('shadow'): net_out = net.build_shadownet(inputdata=inputdata)
image

  1. sequence_length=25*np.ones(32)
    对seqence_length应该怎么理解?

cnn输出512个大小为25的*1的特征图,可以理解为25个长度512的序列吗,经过rnn输出对应25帧长的预测序列(未合并)?为什么选择25呢,25和原图大小或者说cnn输出的特征图大小有关吗?我在训练中文行识别时,图像长宽比例较大,输入图像归一化为(280,32),cnn的输出应为70,当时没有改 sequence_length, 还是保持25为啥也没有报错啊?

cost一直下不去

@TJCVRS 我用crnn训练中文,5300类别。ctc_loss一直下不去,感觉就识别率在35%左右就不动了。。如何破?有什么好的建议么?

shadownet_2017-09-29-19-16-33.ckpt-39999 not found

excute "python tools/test_shadownet.py --dataset_dir data/ --weights_path model/shadownet/shadownet_2017-09-29-19-16-33.ckpt-39999"
however, it turns out "tensorflow.python.framework.errors_impl.NotFoundError: Unsuccessful TensorSliceReader constructor: Failed to find any matching files for model/shadownet/shadownet_2017-09-29-19-16-33.ckpt-39999"

shadownet_2017-09-29-19-16-33.ckpt-39999 is not in this repo.

ICDAR2013

请问谁用过ICDAR2013数据集,其中包含了特殊字符(),!,?等,导致CTC做loss的时候跟labels一直不匹配,因为输出类别只有37类,但是现在不止37类了,请问你们是怎么解决的

准确率公式 if len(pred) == 0: accuracy.append(1)

for index, gt_label in enumerate(gt_labels):
pred = preds[index]#预测的标签
totol_count = len(gt_label)#真是标签的长度
correct_count = 0
try:
for i, tmp in enumerate(gt_label):
if tmp == pred[i]:#计算预测的对的字符格式
correct_count += 1
except IndexError:
continue
finally:
try:
accuracy.append(correct_count / totol_count)
except ZeroDivisionError:
if len(pred) == 0:
accuracy.append(1)
else:
accuracy.append(0)
accuracy = np.mean(np.array(accuracy).astype(np.float32), axis=0)
##############################################################################
这是train_shadownet里面关于accuracy的计算,if len(pred) == 0: accuracy.append(1),这句话有问题把,pred是预测的标签,长度为0,为什么准确率的计算加了1??????预测为0,准确率应该加0啊。。。

Test model

Hello, when I intend to test model, I type 'python tools/test_shadownet.py --dataset_dir data/ --weights_path model/shadownet/shadownet_2017-09-29-19-16-33.ckpt-39999' and I encounter an error which said that
Traceback (most recent call last):
File "tools/test_shadownet.py", line 19, in
from local_utils import data_utils
ImportError: No module named 'local_utils'
Do you know how to solve it?

validating/saving model at every epoch

Hey, I want to validate the model at every epoch to avoid overfitting to training data. Presently it just gives training accuracy. Any suggestions how to validate model after each epoch? Or can I save all the models instead of last five?

Also does epoch in your model mean set of whole training data or a batch of 32 instances? I am asking this because training accuracy is changing abruptly after training for sufficient no. of epochs (observe variations from 0.87 to 0.98 in few consecutive epoch):-

INFO: 02-20 10:46:43: train_shadownet.py:152 * 140457240573696 Epoch: 73231 cost= 2.535266 seq distance= 0.079167 train accuracy= 0.917708
INFO: 02-20 10:46:44: train_shadownet.py:152 * 140457240573696 Epoch: 73232 cost= 2.426046 seq distance= 0.081250 train accuracy= 0.909028
INFO: 02-20 10:46:45: train_shadownet.py:152 * 140457240573696 Epoch: 73233 cost= 0.719452 seq distance= 0.015625 train accuracy= 0.984375
INFO: 02-20 10:46:45: train_shadownet.py:152 * 140457240573696 Epoch: 73234 cost= 1.353409 seq distance= 0.041667 train accuracy= 0.958333
INFO: 02-20 10:46:46: train_shadownet.py:152 * 140457240573696 Epoch: 73235 cost= 1.583038 seq distance= 0.050694 train accuracy= 0.945833
INFO: 02-20 10:46:47: train_shadownet.py:152 * 140457240573696 Epoch: 73236 cost= 3.420149 seq distance= 0.123611 train accuracy= 0.870139
INFO: 02-20 10:46:48: train_shadownet.py:152 * 140457240573696 Epoch: 73237 cost= 1.715354 seq distance= 0.054861 train accuracy= 0.945139
INFO: 02-20 10:46:49: train_shadownet.py:152 * 140457240573696 Epoch: 73238 cost= 1.695781 seq distance= 0.064931 train accuracy= 0.914583
INFO: 02-20 10:46:50: train_shadownet.py:152 * 140457240573696 Epoch: 73239 cost= 1.896924 seq distance= 0.056944 train accuracy= 0.913542
INFO: 02-20 10:46:50: train_shadownet.py:152 * 140457240573696 Epoch: 73240 cost= 1.916920 seq distance= 0.065278 train accuracy= 0.934722
INFO: 02-20 10:46:51: train_shadownet.py:152 * 140457240573696 Epoch: 73241 cost= 0.691025 seq distance= 0.020486 train accuracy= 0.979514
INFO: 02-20 10:46:52: train_shadownet.py:152 * 140457240573696 Epoch: 73242 cost= 0.412923 seq distance= 0.010417 train accuracy= 0.982639
INFO: 02-20 10:46:52: train_shadownet.py:152 * 140457240573696 Epoch: 73243 cost= 0.704129 seq distance= 0.026736 train accuracy= 0.973264

Thanks
Rohit

numpy import error

I am getting this error.
ImportError: numpy.core.multiarray failed to import
Failed to load the native TensorFlow runtime.

Text Extraction from Images

Hi,
Is it possible to extract all the text(all words) rather than a single word available in the image using this code?If it is so,please let me know whether I have to tune and change the layer stack available.

error: cv2.error: /io/opencv/modules/imgproc/src/imgwarp.cpp:3492: error: (-215) ssize.width > 0 && ssize.height > 0 in function resize

#comment: Although all images in test/ directory are of the same size i.e. (100, 32), still I am getting following error, any help?

error(detailed):

CRNN_Tensorflow$ python3 tools/write_text_features.py --dataset_dir test --save_dir newNPR/
Initialize the dataset provider ......
Dataset provider intialize complete
Start writing training tf records
OpenCV Error: Assertion failed (ssize.width > 0 && ssize.height > 0) in resize, file /io/opencv/modules/imgproc/src/imgwarp.cpp, line 3492
Traceback (most recent call last):
File "tools/write_text_features.py", line 104, in
write_features(dataset_dir=args.dataset_dir, save_dir=args.save_dir)
File "tools/write_text_features.py", line 59, in write_features
train_images = [cv2.resize(tmp, (100, 32)) for tmp in train_images]
File "tools/write_text_features.py", line 59, in
train_images = [cv2.resize(tmp, (100, 32)) for tmp in train_images]
cv2.error: /io/opencv/modules/imgproc/src/imgwarp.cpp:3492: error: (-215) ssize.width > 0 && ssize.height > 0 in function resize

跑train_shadownet.py 遇见这个问题有谁知道是什么原因么?

报错位置在这句代码中cost = tf.reduce_mean(tf.nn.ctc_loss(labels=input_labels, inputs=net_out, sequence_length=25*np.ones(32)))

报错信息:
self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): Saw a non-null label (index >= num_classes - 1) following a null label, batch: 1 num_classes: 37 labels:
[[Node: CTCLoss = CTCLoss[ctc_merge_repeated=true, ignore_longer_outputs_than_inputs=false, preprocess_collapse_repeated=fal

卷积

conv = self.conv2d(inputdata=inputdata, out_channel=out_dims, kernel_size=3, stride=1, use_bias=False, name=name)
这句话,为什么可以直接self.conv2d,self不是代表类吗,crnn中的,然后直接定义一个conv2d,不用调用tf.nn.conv2d来定义???
还有
conv1 = self.__conv_stage(inputdata=inputdata, out_dims=64, name='conv1') # batch165064
原本是32
100,池化后变成16*50是没问题,但是卷积之后大小不变应该是因为conv2d里面有一个padding='SAME'吧,但是你这里都没有padding参数,论文里好像是1×1

如何在训练的同时进行测试

你好,
请问如何在训练的同时进行测试呢,我本来打算利用placeholder,在Session里面feed_dict不同的数据(训练和测试),可是每个图片的标签好像是不一样大小。

为什么只能检测纯英文呢?

您好,我使用原作者的模型能检测字母加数字混合的字符串,但是使用您的模型检测字母加数字的字符串时预测的结果全是英文的。训练集都是synth的,为什么检测结果不一样呢?怎么样才能检测字母加数字的字符串呢?期待您的回复,谢谢。

Own Model Training with own dataset regarding

I downloaded the file under the folder named CRNN_Tensorflow-master
And I kept my dataset under the name CRNN_Tensorflow-master\imagesdataset
And I kept the sample.txt file in CRNN_Tensorflow-master but when I try to run the write_features.py code it shows an assetion error as " assert ops.exists(self.__train_dataset_dir)"

Please let me know and Thanks in Advance!

Also the steps are not described clearly please anyone describe the steps in clear!Thanks!

miss some thing when using CRNN_Tensorflow-chinese_version

I just clone the CRNN_Tensorflow-chinese_version, and excute the commands bellow just as master version
python tools/demo_shadownet.py --image_path data/test_images/test_01.jpg --weights_path model/shadownet/shadownet_2017-10-17-11-47-46.ckpt-199999
howevere i got problem bellow
NotFoundError (see above for traceback): Key shadow/cnn_subnetwork/conv7/W not found in checkpoint
[[Node: save/RestoreV2_23 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_arg_save/Const_0_0, save/RestoreV2_23/tensor_names, save/RestoreV2_23/shape_and_slices)]]

have i missed something?

what can i change in data_provider.py for a large dataset

Hi,

i want to train the model on a large set of data (184 000 images). My problem is that the write_text_features.py stop at

/*****************
train_images = np.array([cv2.imread(ops.join(self.__train_dataset_dir, tmp), cv2.IMREAD_COLOR)
for tmp in info[:, 0]])
/******************
on data_provider.py file because the out of memory ....

Do you have a solution that i can load all my dataset ?

Thank you,

poor accuracy on svt1 images

Dear author,

My test data set consists of text-localized images from the svt1 dataset (http://tc11.cvc.uab.es/datasets/SVT_1). The localization was done using Seglink (https://github.com/dengdan/seglink).

Here is the flow:
svt1 images -----> seglink ----> CRNN_Tensorflow

I utilized the checkpoint at step 19999 that you have provided under models directory for prediction. The prediction error turns out to be very bad.

Can you please share the log / plot of your loss and validation dataset accuracy (/distance) at each epoch during your training? I would like to see if there was overfitting. Also, can you please make your checkpoint 9999 and 29999 available?

thanks a lot!
Best,
Buvana

cpu version

i saw this"
This software has only been tested on ubuntu 16.04(x64), python3.5, cuda-8.0, cudnn-6.0 with a GTX-1070 GPU"
my question is "does it can be run without gpu?"

请教一下生成tfrecord的问题

您好,
我按照readme里的方法生成tfrecord用来测试,结果报错:
OutOfRangeError (see above for traceback): RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
然后我利用write_text_features.py生成的tfrecord,打开以后里面的图片格式为list.每个元素是0到255的像素值。而您在data里自带的tfrecord打开以后是乱码的,应该就是二进制文件。应该如何生成您这样的tfrecord文件呢,您的程序我没有做任何更改。
另外,您的tfrecord文件里面包含8568张图像的名字,但是利用test_shadoenet.py测试的时候输出32张图像的测试结果。这又是为什么呢?
期待您的指导,谢谢!

代码有一点问题

你好先生,最近在学习tensorflow。我使用了你上传你的代码,但是出现了一些问题,输出的prediction是一些乱码符号,而不是正常的预测。
2017-10-27 10-45-48

Train on more characters

Hi, I want to recognize more characters more than just English alphabet (numbers, special Unicode utf-8 characters, etc.). Suppose I have enough dataset, what is the modification I need to train/predict (full pipeline) more of these characters.

Some solutions I found on this repo:

  • README.md: Supply my supervised labels

Firstly you need to store all your image data in a root folder then you need to supply a txt file named sample.txt to specify the relative path to the image data dir and it's corresponding text label.

  • #31 Edit data/char_dict/char_dict.json

Is this enough? What about data/char_dict/ord_map.json

中文识别问题

@TJCVRS
您好,目前预训练的模型只是在英文合成字符的数据库上进行的吗?因为我试着用中文图片去测试,发现并不能识别。但是在您的README里,却有演示中文识别的例子。

Labelling Dataset

If I have the training dataset's annotation file (sample.txt) as follows:
./image1.jpg hi world
In above example there are 2 words for label,in-order to make it work what changes should I make,I tried out but it is showing the error as:
"Too many indices for an array!"

Thanks in advance!

Can not restore from your pretrained model....

I just download your entire project and run under tensorflow =1.1.0 , and want to train on other dataset .
I've created own dataset with the same format however load you pretrained model I got this key miss error.....
Key shadow/LSTMLayers/stack_bidirectional_rnn/cell_0/bidirectional_rnn/bw/basic_lstm_cell/biases/Adadelta not found in checkpoint

Other normalization scheme

Hi, i'm using your write_text_features.py script for storing my own data in tfrecords format. I'm trying to use a normalization scheme different from None ('divide_255' for example). The issue happens in this line of code:
train_images = [bytes(list(np.reshape(tmp, [100 * 32 * 3]))) for tmp in train_images]
and the error message is: 'numpy.float64' object cannot be interpreted as an integer

If i delete bytes form the instruction it works, but then I have problems with the encode function FeatureIO.bytes_feature in data_utils.py.
Any workaround for this issue? @TJCVRS
Probably a possible solution is to store the data as integer without performing normalization inside write_text_features.py and then applying a normalization in the train script

The accuracy of the trained model by own dataset is bad.

dear author,
I used your code in my dataset. In the training stage, the loss value keeps decreasing and the precision keeps rising. But, when I used tools/demo_shadownet.py to test picture, the result is so bad.
Could you give me some suggestions?
Some information:

  1. My dataset is OCR, consists of 10000 pictures.
  2. Base learning rate is 0.1, learning rate step is 30k, epoch is 100k, batchsize is 32.

bug with "python tools/write_text_features.py --dataset_dir data/crnn_dataset --save_dir data/tfrecords_dir"

@TJCVRS 您好,使用的是master版本,在执行“python tools/write_text_features.py --dataset_dir data/crnn_dataset --save_dir data/tfrecords_dir”的时候,跑出如下的错误:(数据集是自带的test_0*.jpg)

Initialize the dataset provider ......
data/crnn_dataset/Test/sample.txt
/home/aigo_/Desktop/CRNN_Tensorflow-master/data/crnn_dataset/test_01.jpg
shape (31, 116, 3)
/home/aigo_/Desktop/CRNN_Tensorflow-master/data/crnn_dataset/test_02.jpg
shape (31, 128, 3)
/home/aigo_/Desktop/CRNN_Tensorflow-master/data/crnn_dataset/test_03.jpg
shape (31, 83, 3)
Traceback (most recent call last):
File "tools/write_text_features.py", line 106, in
write_features(dataset_dir=args.dataset_dir, save_dir=args.save_dir)
File "tools/write_text_features.py", line 52, in write_features
normalization=None)
File "/home/aigo_/Desktop/CRNN_Tensorflow-master/data_provider/data_provider.py", line 181, in init
for tmp in info[:, 0]])
ValueError: could not broadcast input array from shape (31,116,3) into shape (31)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.