nanonets / number-plate-detection Goto Github PK
View Code? Open in Web Editor NEWAutomatic License Plate Reader using tensorflow attention OCR
Automatic License Plate Reader using tensorflow attention OCR
Greetings,
I have an issue with the training but first I would like to ask for clarification about the following:
"Having stored our cropped images of equal sizes in a different directory.."
Do you mean by "equal sizes" that all images should have the same width and height (Squares)? or is it okay to be rectangles but all images should have the same sizes?
What makes me confused is that all the images you are using in the example are squares (200x200). Also, after making my dataset with equal sizes rectangles (1900x17). I got the following error during the training step :
Traceback (most recent call last):
File "train.py", line 209, in <module>
app.run()
File "/opt/anaconda3/envs/tf2/lib/python2.7/site-packages/tensorflow_core/python/platform/app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/opt/anaconda3/envs/tf2/lib/python2.7/site-packages/absl/app.py", line 299, in run
_run_main(main, args)
File "/opt/anaconda3/envs/tf2/lib/python2.7/site-packages/absl/app.py", line 250, in _run_main
sys.exit(main(argv))
File "train.py", line 197, in main
endpoints = model.create_base(data.images, data.labels_one_hot)
File "/home/user/Projects/dlOCR/python/model.py", line 363, in create_base
for i, v in enumerate(views)
File "/home/user/Projects/dlOCR/python/model.py", line 208, in conv_tower_fn
images, final_endpoint=mparams.final_endpoint)
File "/opt/anaconda3/envs/tf2/lib/python2.7/site-packages/tensorflow_core/contrib/slim/python/slim/nets/inception_v3.py", line 143, in inception_v3_base
net = layers.conv2d(net, depth(192), [3, 3], scope=end_point)
File "/opt/anaconda3/envs/tf2/lib/python2.7/site-packages/tensorflow_core/contrib/framework/python/ops/arg_scope.py", line 182, in func_with_args
return func(*args, **current_args)
File "/opt/anaconda3/envs/tf2/lib/python2.7/site-packages/tensorflow_core/contrib/layers/python/layers/layers.py", line 1159, in convolution2d
conv_dims=2)
File "/opt/anaconda3/envs/tf2/lib/python2.7/site-packages/tensorflow_core/contrib/framework/python/ops/arg_scope.py", line 182, in func_with_args
return func(*args, **current_args)
File "/opt/anaconda3/envs/tf2/lib/python2.7/site-packages/tensorflow_core/contrib/layers/python/layers/layers.py", line 1057, in convolution
outputs = layer.apply(inputs)
File "/opt/anaconda3/envs/tf2/lib/python2.7/site-packages/tensorflow_core/python/util/deprecation.py", line 324, in new_func
return func(*args, **kwargs)
File "/opt/anaconda3/envs/tf2/lib/python2.7/site-packages/tensorflow_core/python/keras/engine/base_layer.py", line 1700, in apply
return self.__call__(inputs, *args, **kwargs)
File "/opt/anaconda3/envs/tf2/lib/python2.7/site-packages/tensorflow_core/python/layers/base.py", line 548, in __call__
outputs = super(Layer, self).__call__(inputs, *args, **kwargs)
File "/opt/anaconda3/envs/tf2/lib/python2.7/site-packages/tensorflow_core/python/keras/engine/base_layer.py", line 854, in __call__
outputs = call_fn(cast_inputs, *args, **kwargs)
File "/opt/anaconda3/envs/tf2/lib/python2.7/site-packages/tensorflow_core/python/autograph/impl/api.py", line 237, in wrapper
raise e.ag_error_metadata.to_exception(e)
ValueError: in converted code:
relative to /opt/anaconda3/envs/tf2/lib/python2.7/site-packages/tensorflow_core/python:
keras/layers/convolutional.py:197 call
outputs = self._convolution_op(inputs, self.kernel)
ops/nn_ops.py:1134 __call__
return self.conv_op(inp, filter)
ops/nn_ops.py:639 __call__
return self.call(inp, filter)
ops/nn_ops.py:238 __call__
name=self.name)
ops/nn_ops.py:2010 conv2d
name=name)
ops/gen_nn_ops.py:1071 conv2d
data_format=data_format, dilations=dilations, name=name)
framework/op_def_library.py:794 _apply_op_helper
op_def=op_def)
util/deprecation.py:507 new_func
return func(*args, **kwargs)
framework/ops.py:3357 create_op
attrs, op_def, compute_device)
framework/ops.py:3426 _create_op_internal
op_def=op_def)
framework/ops.py:1770 __init__
control_input_ops)
framework/ops.py:1610 _create_c_op
raise ValueError(str(e))
ValueError: Negative dimension size caused by subtracting 3 from 2 for 'AttentionOcr_v1/conv_tower_fn/INCE/InceptionV3/Conv2d_4a_3x3/Conv2D' (op: 'Conv2D') with input shapes: [32,473,2,80], [3,3,80,192].
Please help me to solve this issue.
Thank you
Update1:
The error is coming from this line in model.py:
net, _ = inception.inception_v3_base(images, final_endpoint=mparams.final_endpoint)
I tried to debug the object images and got:
print images
print type(images)
Output:
Tensor("AttentionOcr_v1/split:0", shape=(32, 1900, 17, 3), dtype=float32)
<class 'tensorflow.python.framework.ops.Tensor'>
Update2:
I just realized that my issue because the height in number_plates.py is less than 26. I tried 26 and more but I don't get the same error. In my case, the height is 17 and mostly will be less than 26. Any idea how to change the limit?
Use tf.where in 2.0, which has the same broadcast rule as np.where
Traceback (most recent call last):
File "demo_inference.py", line 97, in
tf.app.run()
File "/home/parth/anaconda3/envs/ocr/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/home/parth/.local/lib/python3.6/site-packages/absl/app.py", line 299, in run
_run_main(main, args)
File "/home/parth/.local/lib/python3.6/site-packages/absl/app.py", line 250, in _run_main
sys.exit(main(argv))
File "demo_inference.py", line 91, in main
FLAGS.image_path_pattern)
File "demo_inference.py", line 78, in run
dataset_name)
File "demo_inference.py", line 53, in load_images
pil_image = PIL.Image.open(tf.gfile.GFile(file_pattern))
File "/home/parth/.local/lib/python3.6/site-packages/PIL/Image.py", line 2775, in open
prefix = fp.read(16)
File "/home/parth/anaconda3/envs/ocr/lib/python3.6/site-packages/tensorflow/python/lib/io/file_io.py", line 128, in read
pywrap_tensorflow.ReadFromStream(self._read_buf, length))
File "/home/parth/anaconda3/envs/ocr/lib/python3.6/site-packages/tensorflow/python/lib/io/file_io.py", line 98, in _prepare_value
return compat.as_str_any(val)
File "/home/parth/anaconda3/envs/ocr/lib/python3.6/site-packages/tensorflow/python/util/compat.py", line 117, in as_str_any
return as_str(value)
File "/home/parth/anaconda3/envs/ocr/lib/python3.6/site-packages/tensorflow/python/util/compat.py", line 87, in as_text
return bytes_or_text.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte
I have succesfully trained the model using train.py and now using the saved model to use demo_inference.py but its throwing this error again and again.
First of all the training on CPU is very slow.
training script is running properly. But I am not able to get the correct detections at all.
I am getting something like ๐
b'NRRRRRRRRRRRRRRRRRRRR'
b'M99999RRRRRRRRRRRRRRR'
Something like this..
Where do I need to the give the pretrained models and start detection process??
Could you please help me out with this??
Thank you
Hello, as described in the title, the link is broken.
INFO:tensorflow:Starting Session.
I1223 18:10:23.516401 140558669547392 learning.py:754] Starting Session.
INFO:tensorflow:Saving checkpoint to path /content/aocr-logs/model.ckpt
I1223 18:10:23.721935 140554274965248 supervisor.py:1117] Saving checkpoint to path /content/aocr-logs/model.ckpt
INFO:tensorflow:Starting Queues.
I1223 18:10:23.727193 140558669547392 learning.py:768] Starting Queues.
INFO:tensorflow:global_step/sec: 0
I1223 18:10:30.392521 140554266572544 supervisor.py:1099] global_step/sec: 0
2019-12-23 18:10:36.825400: W tensorflow/core/framework/op_kernel.cc:1651] OP_REQUIRES failed at example_parsing_ops.cc:240 : Invalid argument: Key: image/class. Can't parse serialized Example.
2019-12-23 18:10:36.825561: W tensorflow/core/framework/op_kernel.cc:1651] OP_REQUIRES failed at example_parsing_ops.cc:240 : Invalid argument: Key: image/class. Can't parse serialized Example.
2019-12-23 18:10:36.825581: W tensorflow/core/framework/op_kernel.cc:1651] OP_REQUIRES failed at example_parsing_ops.cc:240 : Invalid argument: Key: image/class. Can't parse serialized Example.
2019-12-23 18:10:36.825996: W tensorflow/core/framework/op_kernel.cc:1651] OP_REQUIRES failed at example_parsing_ops.cc:240 : Invalid argument: Key: image/class. Can't parse serialized Example.
INFO:tensorflow:Error reported to Coordinator: <class 'tensorflow.python.framework.errors_impl.InvalidArgumentError'>, Key: image/class. Can't parse serialized Example.
[[{{node ParseSingleExample/ParseSingleExample}}]]
2019-12-23 18:10:36.826406: W tensorflow/core/framework/op_kernel.cc:1651] OP_REQUIRES failed at example_parsing_ops.cc:240 : Invalid argument: Key: image/class. Can't parse serialized Example.
I1223 18:10:36.826037 140554241394432 coordinator.py:224] Error reported to Coordinator: <class 'tensorflow.python.framework.errors_impl.InvalidArgumentError'>, Key: image/class. Can't parse serialized Example.
[[{{node ParseSingleExample/ParseSingleExample}}]]
2019-12-23 18:10:36.826698: W tensorflow/core/framework/op_kernel.cc:1651] OP_REQUIRES failed at example_parsing_ops.cc:240 : Invalid argument: Key: image/class. Can't parse serialized Example.
INFO:tensorflow:Caught OutOfRangeError. Stopping Training. RandomShuffleQueue '_0_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
[[node shuffle_batch (defined at /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/ops.py:1748) ]]
how to convert .json file that downloaded from dataturks into .csv file
I tried to execute the code bby following the mentionned steps, but while execution this script get_tf_records.py an error is generated: FileNotFoundError: [Errno 2] No such file or directory: 'charset-labels.txt'
How can I generated this file?
Thanks.
TypeError: Fetch argument dict_values([<tf.Tensor 'CharAccuracy/mean/update_op:0' shape=() dtype=float32>, <tf.Tensor 'SequenceAccuracy/mean/update_op:0' shape=() dtype=float32>]) has invalid type <class 'dict_values'>, must be a string or Tensor. (Can not convert a dict_values into a Tensor or Operation.)
Not able to understand how did you get the model.ckpt-3000 even before training in common_flags.py
why training loss increasing so high, just for a second training?
from:
INFO:tensorflow:global step 0: loss = 37.9278 (9.969 sec/step) I0401 14:10:33.120939 139834940118848 learning.py:507] global step 0: loss = 37.9278 (9.969 sec/step) INFO:tensorflow:global step 1: loss = 38.2249 (0.345 sec/step) I0401 14:10:33.577449 139834940118848 learning.py:507] global step 1: loss = 38.2249 (0.345 sec/step) INFO:tensorflow:global step 2: loss = 38.1697 (0.359 sec/step) I0401 14:10:33.938303 139834940118848 learning.py:507] global step 2: loss = 38.1697 (0.359 sec/step) INFO:tensorflow:global step 3: loss = 37.3754 (0.355 sec/step) I0401 14:10:34.296173 139834940118848 learning.py:507] global step 3: loss = 37.3754 (0.355 sec/step) INFO:tensorflow:global step 4: loss = 36.9365 (0.374 sec/step) I0401 14:10:34.675701 139834940118848 learning.py:507] global step 4: loss = 36.9365 (0.374 sec/step) INFO:tensorflow:global step 5: loss = 36.6026 (0.367 sec/step) I0401 14:10:35.044912 139834940118848 learning.py:507] global step 5: loss = 36.6026 (0.367 sec/step) INFO:tensorflow:global step 6: loss = 36.3448 (0.374 sec/step) I0401 14:10:35.422319 139834940118848 learning.py:507] global step 6: loss = 36.3448 (0.374 sec/step) INFO:tensorflow:global step 7: loss = 35.3725 (0.370 sec/step) I0401 14:10:35.796007 139834940118848 learning.py:507] global step 7: loss = 35.3725 (0.370 sec/step)
to:
INFO:tensorflow:global step 772: loss = 2422.3994 (0.362 sec/step) I0401 14:15:17.393121 139834940118848 learning.py:507] global step 772: loss = 2422.3994 (0.362 sec/step) INFO:tensorflow:global step 773: loss = 2591.4863 (0.362 sec/step) I0401 14:15:17.757555 139834940118848 learning.py:507] global step 773: loss = 2591.4863 (0.362 sec/step) INFO:tensorflow:global step 774: loss = 2726.2822 (0.361 sec/step) I0401 14:15:18.120915 139834940118848 learning.py:507] global step 774: loss = 2726.2822 (0.361 sec/step) INFO:tensorflow:global step 775: loss = 2463.8806 (0.358 sec/step) I0401 14:15:18.481991 139834940118848 learning.py:507] global step 775: loss = 2463.8806 (0.358 sec/step) INFO:tensorflow:global step 776: loss = 1594.3793 (0.358 sec/step) I0401 14:15:18.841962 139834940118848 learning.py:507] global step 776: loss = 1594.3793 (0.358 sec/step) INFO:tensorflow:global step 777: loss = 1444.8801 (0.359 sec/step) I0401 14:15:19.203997 139834940118848 learning.py:507] global step 777: loss = 1444.8801 (0.359 sec/step)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.