Kshitijpawar / License_Plate_Detection

License Plate Detection and OCR
Other
1 stars 7 forks source link

Error while Training the model from parameters defined earlier #3

Closed pendex900x closed 4 years ago

pendex900x commented 4 years ago

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?

Kshitijpawar commented 4 years ago

I think you're passing string for num_steps and batch_size when it should be int type(1 instead of '1', and 1000 instead of '1000')

pendex900x commented 4 years ago

I think you're passing string for num_steps and batch_size when it should be int type(1 instead of '1', and 1000 instead of '1000')

I thought the same thing, but if I take out the quotes it gives the same error:/ The colab does it work for you without any problem?

Kshitijpawar commented 4 years ago

Yes I just tried my notebook it trains the model.

pendex900x commented 4 years ago

Yes I just tried my notebook it trains the model.

could you share the link?

Kshitijpawar commented 4 years ago

https://colab.research.google.com/drive/1B-u6-uj5LFhqeCelBxuN-auImiHqKU_R

pendex900x commented 4 years ago

It worked, It was my mistake because I declared some variables in previous steps, thank you very much for your help, it is a great job