TensorFlow step by step training custom Object-detection classifier
[ad_1]
In this part and few in the future, we’re going to cover how we can track and detect our own custom objects with this API.
I am doing this by using the pre-built model to add custom detection objects to it. That’s a decent jump from my findings, and it’s quite hard to locate any full step-by-step tutorials, so hopefully, I can help you with that. Once you finish this tutorial you will have the ability to train for any custom object you can think of (and create data for) – that’s an awesome skill to have in my opinion.
Text tutorial: http://pylessons.com/Tensorflow-object-detection-step-by-step-custom-object-detection/
GitHub tutorial: https://github.com/pythonlessons/TensorFlow-object-detection-tutorial/tree/master/5_part%20step%20by%20step%20custom%20object%20detection
LabelImg utility: https://github.com/tzutalin/labelImg#installation
Pretrained models: https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md/
Full playlist: https://www.youtube.com/watch?v=HX2yXajg8Ts&list=PLbMO9c_jUD46x-d4pIj_STGK6CWWkw0Vv
✅ Support My Channel Through Patreon:
https://www.patreon.com/PyLessons
✅ One-Time Contribution Through PayPal:
https://www.paypal.com/paypalme/PyLessons
Source
[ad_2]
what is the backbone this TensorFlow custom Object-detection
Could anyone help me please ? this error occurs in the last command when executing the train.py
(tf115) C:tensorflow1modelsresearchobject_detection>python train.py –logtostderr –train_dir=training/ –pipeline_config_path=training/faster_rcnn_inception_v2_pets.config
2020-10-12 20:36:56.352514: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_100.dll
Traceback (most recent call last):
File "train.py", line 46, in <module>
from object_detection.builders import dataset_builder
File "C:tensorflow1modelsresearchobject_detectionbuildersdataset_builder.py", line 32, in <module>
from object_detection.builders import decoder_builder
File "C:tensorflow1modelsresearchobject_detectionbuildersdecoder_builder.py", line 25, in <module>
from object_detection.data_decoders import tf_example_decoder
File "C:tensorflow1modelsresearchobject_detectiondata_decoderstf_example_decoder.py", line 28, in <module>
from tf_slim import tfexample_decoder as slim_example_decoder
ModuleNotFoundError: No module named 'tf_slim'
ModuleNotFoundError: No module named 'official'
can you do the same with Tensorflow2?
how you are getting loss very less? and for transfer learning what you have change. Do you freeze any layer ?
in class_text_to_int function . if we have lot of different labels what we have to do we can not assign all of them id's manually.
Are you using tensorflow_gpu or just tensorflow ?
I am running on tensorflow with intel i5 cpu and speed is 15 second per step for training and 5 seconds per frame in detection. Using faster Rcnn coco weights and config.
will it increase if I try on Linux machine? or I have to use GPU ?
also mobilenet ssd is not giving much accuracy. But faster rcnn coco is much better accuracy.
Thanks in advance.
thank you for this , but i have this problem from tensorflow.contrib import framework as contrib_framework
ModuleNotFoundError: No module named 'tensorflow.contrib' how i can fix it in tensorflow 2.0
is it okay if the tfrecoed file generated is of 0 bytes
even in your training.record generated it was shown to be of 0 bytes
@Python Lessons
Hi, very nice tutorial I have a query which is I am unable to dealt with
I am getting this below error, would you help me
Failed to get matching files on faster_rcnn_inception_v2_coco/model.ckpt:
Hello i m trying to complete this tutorial , but when i m trying to run this command
python train.py –logtostderr –train_dir=Training/ –pipeline_config_path=C:/Users/David/Desktop/models-master/research/object_detection/Training/faster_rcnn_resnet101_coco.config
i receive the error :
File "train.py", line 49, in <module>
from object_detection.builders import dataset_builder
File "C:UsersDavidDesktopmodels-masterresearchobject_detectionbuildersdataset_builder.py", line 27, in <module>
from object_detection.data_decoders import tf_example_decoder
File "C:UsersDavidDesktopmodels-masterresearchobject_detectiondata_decoderstf_example_decoder.py", line 29, in <module>
from object_detection.protos import input_reader_pb2
ValueError: source code string cannot contain null bytes
Sir I am working on smoke detection.
will you give me any suggestion for smoke detection.
I am getting below error
File "/usr/local/lib/python2.7/dist-packages/object_detection-0.1-py2.7.egg/object_detection/core/anchor_generator.py", line 108, in generate
anchors_list = self._generate(feature_map_shape_list, **params)
File "/usr/local/lib/python2.7/dist-packages/object_detection-0.1-py2.7.egg/object_detection/anchor_generators/grid_anchor_generator.py", line 111, in _generate
with tf.init_scope():
AttributeError: 'module' object has no attribute 'init_scope'
help, brother.
https://youtu.be/bYqvx_DM45U?list=PL7SlzVEU48Kh-NHJW9FWaLItZ5RvDoJ45&t=982
error line 20 generate_tfrecord.py
File "generate_tfrecord.py", line 20, in <module>
from object_detection.utils import dataset_util
ModuleNotFoundError: No module named 'object_detection'
Hello! Could you understood, how to make confusion matrix for obtained model?
wonderful tutorial
For detecting more than 4 characters, what changes we have to do in xml_to_csv.py file?
How many training steps/epochs will this methodology run for by default?
12:40 – Wrong row_label condition. CH instead of TH
BE CAREFUL LINUX USERS CHANGE THE DIRECTROY DIRECETION FROM '' TO '/' OTHERWISE U GET ERROR
Thank you sir
please help me in this error…
python generate_tfrecord.py –csv_input=CSGO_imagestrain_labels.csv –image_dir=CSGO_imagestrain –output_path=CSGO_imagestrain.record
Traceback (most recent call last):
File "generate_tfrecord.py", line 101, in <module>
tf.compat.v1.app.run()
File "/home/sid/.local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/home/sid/.local/lib/python2.7/site-packages/absl/app.py", line 300, in run
_run_main(main, args)
File "/home/sid/.local/lib/python2.7/site-packages/absl/app.py", line 251, in _run_main
sys.exit(main(argv))
File "generate_tfrecord.py", line 89, in main
examples = pd.read_csv(FLAGS.csv_input)
File "/usr/local/lib/python2.7/dist-packages/pandas/io/parsers.py", line 678, in parser_f
return _read(filepath_or_buffer, kwds)
File "/usr/local/lib/python2.7/dist-packages/pandas/io/parsers.py", line 440, in _read
parser = TextFileReader(filepath_or_buffer, **kwds)
File "/usr/local/lib/python2.7/dist-packages/pandas/io/parsers.py", line 787, in _init_
self._make_engine(self.engine)
File "/usr/local/lib/python2.7/dist-packages/pandas/io/parsers.py", line 1014, in _make_engine
self._engine = CParserWrapper(self.f, **self.options)
File "/usr/local/lib/python2.7/dist-packages/pandas/io/parsers.py", line 1708, in _init_
self._reader = parsers.TextReader(src, **kwds)
File "pandas/_libs/parsers.pyx", line 384, in pandas._libs.parsers.TextReader._cinit_
File "pandas/_libs/parsers.pyx", line 695, in pandas._libs.parsers.TextReader._setup_parser_source
IOError: File CSGO_imagestrain_labels.csv does not exist
Hello, very nice tutorial. I have a question. How can I make the training process in Ubuntu (the steps in the video after 21:38 time)? I am using Ubuntu 18, with tensorflow and all software installed in it already.
the training steps go longer when am i stop the training
Thanks for the episode
when i use this command :- python train.py –logtostderr –train_dir=training/ –pipeline_config_path=training/faster_rcnn_inception_v2_coco.config
following error occur
Traceback (most recent call last):
File "train.py", line 51, in <module>
from object_detection.builders import model_builder
File "C:UsersAsusAnaconda3envstensorflowlibsite-packagesobject_detection-0.1-py3.5.eggobject_detectionbuildersmodel_builder.py", line 35, in <module>
from object_detection.models import faster_rcnn_inception_resnet_v2_feature_extractor as frcnn_inc_res
File "C:UsersAsusAnaconda3envstensorflowlibsite-packagesobject_detection-0.1-py3.5.eggobject_detectionmodelsfaster_rcnn_inception_resnet_v2_feature_extractor.py", line 28, in <module>
from nets import inception_resnet_v2
ImportError: No module named 'nets'
plz help!
Why are u labelling the test image also
i cant find my images with label ! help
getting this wierd error can you help?
tensorflow.python.framework.errors_impl.InvalidArgumentError: Unsuccessful TensorSliceReader constructor: Failed to get matching files on faster_rcnn_inception_v2_coco_2018_01_28/model.ckpt: Not found: FindFirstFile failed for: faster_rcnn_inception_v2_coco_2018_01_28 : The system cannot find the path specified.
; No such process
its looking for a checkpoint file but there is nothing htere for it to find? did you get the checkpoint from ZOO?
Hi sir! I want to ask, in the configuration file, the yours with me is not the same, should we change this setting as well? Thanks!
eval_config: {
num_examples: 8000
# Note: The below line limits the evaluation process to 10 evaluations.
# Remove the below line to evaluate indefinitely.
max_evals: 10
}
Thank you for the amazing tutorial =)
+1 for custom training for CSGO! 🙂
My Error!
WARNING:tensorflow:From C:UsersaadisAnaconda3libsite-packagestensorflowpy thonplatformapp.py:125: main (from __main__) is deprecated and will be removed in a future version.
Instructions for updating:
Use object_detection/model_main.py.
W1122 17:05:42.650600 8768 tf_logging.py:125] From C:UsersaadisAnaconda3lib site-packagestensorflowpythonplatformapp.py:125: main (from __main__) is de precated and will be removed in a future version.
Instructions for updating:
Use object_detection/model_main.py.
WARNING:tensorflow:From C:UsersaadisDocumentsAnaconda WorkSpaceTensorFlowC ustom_Object_Detectionmodelsresearchobject_detectionlegacytrainer.py:265: c reate_global_step (from tensorflow.contrib.framework.python.ops.variables) is de precated and will be removed in a future version.
Instructions for updating:
Please switch to tf.train.create_global_step
W1122 17:05:42.962524 8768 tf_logging.py:125] From C:UsersaadisDocumentsAna conda WorkSpaceTensorFlowCustom_Object_Detectionmodelsresearchobject_detect ionlegacytrainer.py:265: create_global_step (from tensorflow.contrib.framework .python.ops.variables) is deprecated and will be removed in a future version.
Instructions for updating:
Please switch to tf.train.create_global_step
Traceback (most recent call last):
File "C:UsersaadisDocumentsAnaconda WorkSpaceTensorFlowCustom_Object_Det ectionmodelsresearchobject_detectionutilslabel_map_util.py", line 136, in l oad_labelmap
text_format.Merge(label_map_string, label_map)
File "C:UsersaadisAnaconda3libsite-packagesgoogleprotobuftext_format.p y", line 536, in Merge
descriptor_pool=descriptor_pool)
File "C:UsersaadisAnaconda3libsite-packagesgoogleprotobuftext_format.p y", line 590, in MergeLines
return parser.MergeLines(lines, message)
File "C:UsersaadisAnaconda3libsite-packagesgoogleprotobuftext_format.p y", line 623, in MergeLines
self._ParseOrMerge(lines, message)
File "C:UsersaadisAnaconda3libsite-packagesgoogleprotobuftext_format.p y", line 638, in _ParseOrMerge
self._MergeField(tokenizer, message)
File "C:UsersaadisAnaconda3libsite-packagesgoogleprotobuftext_format.p y", line 706, in _MergeField
name = tokenizer.ConsumeIdentifierOrNumber()
File "C:UsersaadisAnaconda3libsite-packagesgoogleprotobuftext_format.p y", line 1166, in ConsumeIdentifierOrNumber
raise self.ParseError('Expected identifier or number, got %s.' % result)
google.protobuf.text_format.ParseError: 1:1 : Expected identifier or number, got ufeff.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "train.py", line 184, in <module>
tf.app.run()
File "C:UsersaadisAnaconda3libsite-packagestensorflowpythonplatformap p.py", line 125, in run
_sys.exit(main(argv))
File "C:UsersaadisAnaconda3libsite-packagestensorflowpythonutildeprec ation.py", line 250, in new_func
return func(*args, **kwargs)
File "train.py", line 180, in main
graph_hook_fn=graph_rewriter_fn)
File "C:UsersaadisDocumentsAnaconda WorkSpaceTensorFlowCustom_Object_Det ectionmodelsresearchobject_detectionlegacytrainer.py", line 279, in train
train_config.prefetch_queue_capacity, data_augmentation_options)
File "C:UsersaadisDocumentsAnaconda WorkSpaceTensorFlowCustom_Object_Det ectionmodelsresearchobject_detectionlegacytrainer.py", line 59, in create_i nput_queue
tensor_dict = create_tensor_dict_fn()
File "train.py", line 121, in get_next
dataset_builder.build(config)).get_next()
File "C:UsersaadisDocumentsAnaconda WorkSpaceTensorFlowCustom_Object_Det ectionmodelsresearchobject_detectionbuildersdataset_builder.py", line 123, in build
num_additional_channels=input_reader_config.num_additional_channels)
File "C:UsersaadisDocumentsAnaconda WorkSpaceTensorFlowCustom_Object_Det ectionmodelsresearchobject_detectiondata_decoderstf_example_decoder.py", li ne 297, in _init_
default_value=''),
File "C:UsersaadisDocumentsAnaconda WorkSpaceTensorFlowCustom_Object_Det ectionmodelsresearchobject_detectiondata_decoderstf_example_decoder.py", li ne 59, in _init_
label_map_proto_file, use_display_name=False)
File "C:UsersaadisDocumentsAnaconda WorkSpaceTensorFlowCustom_Object_Det ectionmodelsresearchobject_detectionutilslabel_map_util.py", line 164, in g et_label_map_dict
label_map = load_labelmap(label_map_path)
File "C:UsersaadisDocumentsAnaconda WorkSpaceTensorFlowCustom_Object_Det ectionmodelsresearchobject_detectionutilslabel_map_util.py", line 138, in l oad_labelmap
label_map.ParseFromString(label_map_string)
TypeError: a bytes-like object is required, not 'str'
Hi. Great video! However i am getting this error
TypeError: a bytes-like object is required, not 'str'