Tried doing training object detection from the below link
https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html#training-the-model
In the last part of the page you can see the training part where i am getting the below error
(base) C:\Users\Admin\Desktop\tensorflow\workspace\training_demo>python train.py --logtostderr --train_dir=training\ --pipeline_config_path=C:\Users\Admin\Desktop\tensorflow\workspace\training_demo\training\ssd_inception_v2_coco.config
WARNING: Logging before flag parsing goes to stderr.
W0808 19:36:44.690053 9896 lazy_loader.py:50]
The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:
W0808 19:36:44.971286 9896 deprecation_wrapper.py:119] From C:\Users\Admin\Desktop\tensorflow\workspace\training_demo\nets\inception_resnet_v2.py:373: The name tf.GraphKeys is deprecated. Please use tf.compat.v1.GraphKeys instead.
W0808 19:36:44.986923 9896 deprecation_wrapper.py:119] From C:\Users\Admin\Desktop\tensorflow\workspace\training_demo\nets\mobilenet\mobilenet.py:397: The name tf.nn.avg_pool is deprecated. Please use tf.nn.avg_pool2d instead.
W0808 19:36:45.002547 9896 deprecation_wrapper.py:119] From train.py:55: The name tf.logging.set_verbosity is deprecated. Please use tf.compat.v1.logging.set_verbosity instead.
W0808 19:36:45.002547 9896 deprecation_wrapper.py:119] From train.py:55: The name tf.logging.INFO is deprecated. Please use tf.compat.v1.logging.INFO instead.
W0808 19:36:45.002547 9896 deprecation_wrapper.py:119] From train.py:184: The name tf.app.run is deprecated. Please use tf.compat.v1.app.run instead.
W0808 19:36:45.018155 9896 deprecation.py:323] From C:\Users\Admin\Anaconda3\lib\site-packages\absl\app.py:251: main (from __main__) is deprecated and will be removed in a future version.
Instructions for updating:
Use object_detection/model_main.py.
W0808 19:36:45.018155 9896 deprecation_wrapper.py:119] From train.py:90: The name tf.gfile.MakeDirs is deprecated. Please use tf.io.gfile.makedirs instead.
W0808 19:36:45.018155 9896 deprecation_wrapper.py:119] From C:\Users\Admin\Desktop\tensorflow\workspace\training_demo\object_detection\utils\config_util.py:102: The name tf.gfile.GFile is deprecated. Please use tf.io.gfile.GFile instead.
W0808 19:36:45.018155 9896 deprecation_wrapper.py:119] From train.py:95: The name tf.gfile.Copy is deprecated. Please use tf.io.gfile.copy instead.
Traceback (most recent call last):
File "train.py", line 184, in
tf.app.run()
File "C:\Users\Admin\Anaconda3\lib\site-packages\tensorflow\python\platform\app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "C:\Users\Admin\Anaconda3\lib\site-packages\absl\app.py", line 300, in run
_run_main(main, args)
File "C:\Users\Admin\Anaconda3\lib\site-packages\absl\app.py", line 251, in _run_main
sys.exit(main(argv))
File "C:\Users\Admin\Anaconda3\lib\site-packages\tensorflow\python\util\deprecation.py", line 324, in new_func
return func(*args, kwargs)
File "train.py", line 180, in main
graph_hook_fn=graph_rewriter_fn)
File "C:\Users\Admin\Desktop\tensorflow\workspace\training_demo\object_detection\legacy\trainer.py", line 249, in train
detection_model = create_model_fn()
File "C:\Users\Admin\Desktop\tensorflow\workspace\training_demo\object_detection\builders\model_builder.py", line 132, in build
return _build_ssd_model(model_config.ssd, is_training, add_summaries)
File "C:\Users\Admin\Desktop\tensorflow\workspace\training_demo\object_detection\builders\model_builder.py", line 258, in _build_ssd_model
is_training=is_training)
File "C:\Users\Admin\Desktop\tensorflow\workspace\training_demo\object_detection\builders\model_builder.py", line 234, in _build_ssd_feature_extractor
return feature_extractor_class(kwargs)
File "C:\Users\Admin\Desktop\tensorflow\workspace\training_demo\object_detection\models\ssd_inception_v2_feature_extractor.py", line 78, in __init__
raise ValueError('SSD Inception V2 feature extractor always uses'
ValueError: SSD Inception V2 feature extractor always usesscope returned by conv_hyperparams_fn
for both the base feature extractor and the additional layers added since there is no arg_scope defined for the base feature extractor.
Check this config file
Also, try to train your model using _model_main.py_ which is in _models/research/object_detection_ folder.
It's very similar.
run model_main.py with --logtostderr --model_dir=
You can see the additional possible flags by inspecting all flags.DEFINE_xxx()
in model_main.py or by running model_main.py with -h flag.
@TheCaffeineDev I tried using model_main.py , but also I am getting the same error.
I have a similar problem. Any clue?
@samudralaz @Msmhasani
Go to your pipeline.config
and under feature_extractor
right after conv_hyperparameters
closing bracket paste the line
override_base_feature_extractor_hyperparams: true
.
So the block looks like this
activation: RELU_6
batch_norm {
decay: 0.999700009823
center: true
scale: true
epsilon: 0.0010000000475
train: true
}
}
override_base_feature_extractor_hyperparams: true
}
box_coder {
faster_rcnn_box_coder {
y_scale: 10.0
x_scale: 10.0
height_scale: 5.0
width_scale: 5.0
}
I have same problem too. Thanks @sebastian-sz 's method. I worked it well.
Thank you for answer. I got that we will be using pre-trained feature extractor's weights. and we can also freeze feature extractor layers. but if we freeze then in that case, why it is necessary to define conv_hyperparams under feature extractor in pipeline.config. over there we need to define initializer, regularizer etc, . if we don't define, it will give error of """ ValueError: SSD Inception V2 feature extractor always usesscope returned by conv_hyperparams_fn for both the base feature extractor and the additional layers added since there is no arg_scope defined for the base feature extractor """ and on defining, what will be effect on feature extractor, since we don't want to change pre-trained weights. Thank you
Most helpful comment
@samudralaz @Msmhasani
Go to your
pipeline.config
and underfeature_extractor
right afterconv_hyperparameters
closing bracket paste the lineoverride_base_feature_extractor_hyperparams: true
.So the block looks like this