GithubHelp home page GithubHelp logo

kshitijpawar / license_plate_detection Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 6.0 87.18 MB

License Plate Detection and OCR

License: Other

Jupyter Notebook 98.83% Python 1.17%
object-detection plate-detection ocr detection-api tesseract google-colab tensorflow

license_plate_detection's People

Contributors

kshitijpawar avatar

Stargazers

 avatar

Watchers

 avatar  avatar

license_plate_detection's Issues

Error while Training the model from parameters defined earlier

In License_Plate_Detection.ipynb file,

when I try to compile this:

!python /content/models/research/object_detection/model_main.py \
    --pipeline_config_path={pipeline_fname} \
    --model_dir={model_dir} \
    --alsologtostderr \
    --num_train_steps={num_steps} \
    --num_eval_steps={num_eval_steps}

Output this error:

WARNING:tensorflow:
The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:
  * https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
  * https://github.com/tensorflow/addons
  * https://github.com/tensorflow/io (for I/O related ops)
If you depend on functionality not listed there, please file an issue.

WARNING:tensorflow:From /content/models/research/slim/nets/inception_resnet_v2.py:374: The name tf.GraphKeys is deprecated. Please use tf.compat.v1.GraphKeys instead.

WARNING:tensorflow:From /content/models/research/slim/nets/mobilenet/mobilenet.py:397: The name tf.nn.avg_pool is deprecated. Please use tf.nn.avg_pool2d instead.

WARNING:tensorflow:From /content/models/research/object_detection/model_main.py:109: The name tf.app.run is deprecated. Please use tf.compat.v1.app.run instead.

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/absl/flags/_flag.py", line 181, in _parse
    return self.parser.parse(argument)
  File "/usr/local/lib/python3.6/dist-packages/absl/flags/_argument_parser.py", line 152, in parse
    val = self.convert(argument)
  File "/usr/local/lib/python3.6/dist-packages/absl/flags/_argument_parser.py", line 265, in convert
    return int(argument, base)
ValueError: invalid literal for int() with base 10: '{num_steps}'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/content/models/research/object_detection/model_main.py", line 109, in <module>
    tf.app.run()
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/platform/app.py", line 40, in run
    _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
  File "/usr/local/lib/python3.6/dist-packages/absl/app.py", line 293, in run
    flags_parser,
  File "/usr/local/lib/python3.6/dist-packages/absl/app.py", line 362, in _run_init
    flags_parser=flags_parser,
  File "/usr/local/lib/python3.6/dist-packages/absl/app.py", line 212, in _register_and_parse_flags_with_usage
    args_to_main = flags_parser(original_argv)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/platform/app.py", line 31, in _parse_flags_tolerate_undef
    return flags.FLAGS(_sys.argv if argv is None else argv, known_only=True)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/platform/flags.py", line 112, in __call__
    return self.__dict__['__wrapped'].__call__(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/absl/flags/_flagvalues.py", line 626, in __call__
    unknown_flags, unparsed_args = self._parse_args(args, known_only)
  File "/usr/local/lib/python3.6/dist-packages/absl/flags/_flagvalues.py", line 774, in _parse_args
    flag.parse(value)
  File "/usr/local/lib/python3.6/dist-packages/absl/flags/_flag.py", line 166, in parse
    self.value = self._parse(argument)
  File "/usr/local/lib/python3.6/dist-packages/absl/flags/_flag.py", line 184, in _parse
    'flag --%s=%s: %s' % (self.name, argument, e))
absl.flags._exceptions.IllegalFlagValueError: flag --num_train_steps={num_steps}: invalid literal for int() with base 10: '{num_steps}'

This is pipeline_fname:

import re

num_classes = get_num_classes(label_map_pbtxt_fname)

batch_size = '12'
num_steps = '1000'
num_classes = '1'


with open(pipeline_fname) as f:
    s = f.read()
with open(pipeline_fname, 'w') as f:
    
    # fine_tune_checkpoint
    s = re.sub('fine_tune_checkpoint: ".*?"',
               'fine_tune_checkpoint: "{}"'.format(fine_tune_checkpoint), s)
    
    # tfrecord files train and test.
    s = re.sub(
        '(input_path: ".*?)(train.record)(.*?")', 'input_path: "{}"'.format(train_record_fname), s)
    s = re.sub(
        '(input_path: ".*?)(val.record)(.*?")', 'input_path: "{}"'.format(test_record_fname), s)

    # label_map_path
    s = re.sub(
        'label_map_path: ".*?"', 'label_map_path: "{}"'.format(label_map_pbtxt_fname), s)

    # Set training batch_size.
    s = re.sub('batch_size: [0-9]+',
               'batch_size: {}'.format(batch_size), s)

    # Set training steps, num_steps
    s = re.sub('num_steps: [0-9]+',
               'num_steps: {}'.format(num_steps), s)
    
    # Set number of classes num_classes.
    s = re.sub('num_classes: [0-9]+',
               'num_classes: {}'.format(num_classes), s)
    f.write(s)

It is not enough to train because that error comes out

Someone know how can I fix this?

Little and basic question

On the file "License_Plate_Detection.ipynb" in the part of "Downloading the model"

What should i put in the MODEL part?

Here:

MODEL_FILE = MODEL + '.tar.gz'

Which model for example?

thanks!

Arranging a training pipeline to work on problem

In the part of Arranging a training pipeline to work on, specifically in this part:

import re

num_classes = get_num_classes(label_map_pbtxt_fname)
with open(pipeline_fname) as f:
    s = f.read()
with open(pipeline_fname, 'w') as f:
    
    # fine_tune_checkpoint
    s = re.sub('fine_tune_checkpoint: ".*?"',
               'fine_tune_checkpoint: "{}"'.format(fine_tune_checkpoint), s)
    
    # tfrecord files train and test.
    s = re.sub(
        '(input_path: ".*?)(train.record)(.*?")', 'input_path: "{}"'.format(train_record_fname), s)
    s = re.sub(
        '(input_path: ".*?)(val.record)(.*?")', 'input_path: "{}"'.format(test_record_fname), s)

    # label_map_path
    s = re.sub(
        'label_map_path: ".*?"', 'label_map_path: "{}"'.format(label_map_pbtxt_fname), s)

    # Set training batch_size.
    s = re.sub('batch_size: [0-9]+',
               'batch_size: {}'.format(batch_size), s)

    # Set training steps, num_steps
    s = re.sub('num_steps: [0-9]+',
               'num_steps: {}'.format(num_steps), s)
    
    # Set number of classes num_classes.
    s = re.sub('num_classes: [0-9]+',
               'num_classes: {}'.format(num_classes), s)
    f.write(s)

The output:

 ---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-33-ff0f87d0a47b> in <module>()
     22     # Set training batch_size.
     23     s = re.sub('batch_size: [0-9]+',
---> 24                'batch_size: {}'.format(batch_size), s)
     25 
     26     # Set training steps, num_steps

NameError: name 'batch_size' is not defined

Should I define batch_size variable?

So, how many batch_size, num_steps do you use?
num_classes=1 ?

Attempt to get argmax of an empty sequence

I was running License Plate Detection notebook in colab and after running this cell:

`# Exporting the freezed training .pb file
#This model will be used later on to perform inference

import re
import numpy as np

output_directory = './fine_tuned_model'

lst = os.listdir(model_dir)
lst = [l for l in lst if 'model.ckpt-' in l and '.meta' in l]
steps=np.array([int(re.findall('\d+', l)[0]) for l in lst])
last_model = lst[steps.argmax()].replace('.meta', '')

last_model_path = os.path.join(model_dir, last_model)
print(last_model_path)
!python /content/models/research/object_detection/export_inference_graph.py
--input_type=image_tensor
--pipeline_config_path={pipeline_fname}
--output_directory={output_directory}
--trained_checkpoint_prefix={last_model_path}`

Got this error:

`ValueError Traceback (most recent call last)
in ()
10 lst = [l for l in lst if 'model.ckpt-' in l and '.meta' in l]
11 steps=np.array([int(re.findall('\d+', l)[0]) for l in lst])
---> 12 last_model = lst[steps.argmax()].replace('.meta', '')
13
14 last_model_path = os.path.join(model_dir, last_model)

ValueError: attempt to get argmax of an empty sequence`

What should I do?

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.