我已经根据以下信息训练了自定义对象检测模型:
配置:ssd_mobilenet_v2_fullyconv_coco.config
选择此特定配置的原因是,它是唯一支持ssd_mobilenet_*
的{{1}}类型,该类型在调整输入图像的大小以进行训练时会尊重输入图像的长宽比。我在配置keep_aspect_ratio_resizer
而非默认max_dimension: 1014
中所做的唯一更改。
一旦成功训练了模型超过50K个时间段,并进行了合理的训练和定位损失,我将使用以下命令冻结模型:
max_dimension: 640
返回奇怪的错误(链接到export_inference_graph.py):
python export_inference_graph.py --input_type image_tensor --write_inference_graph True --pipeline_config_path training/ssd_mobilenet_v2_fullyconv_coco.config --trained_checkpoint_prefix training/model.ckpt-XXXXX --output_directory inference_graph
请注意,当使用faster_rcnn_inception_v2_coco_2018_01_28 checpoint(config)时,相同的设置也可以正常工作。我可以轻松地将冻结的图和SavedModel转换。首次切换到I1007 12:32:59.855752 1896 convolutional_box_predictor.py:151] depth of additional conv before box predictor: 0
I1007 12:32:59.910747 1896 convolutional_box_predictor.py:151] depth of additional conv before box predictor: 0
I1007 12:32:59.965748 1896 convolutional_box_predictor.py:151] depth of additional conv before box predictor: 0
I1007 12:33:00.015746 1896 convolutional_box_predictor.py:151] depth of additional conv before box predictor: 0
I1007 12:33:00.065742 1896 convolutional_box_predictor.py:151] depth of additional conv before box predictor: 0
I1007 12:33:00.115744 1896 convolutional_box_predictor.py:151] depth of additional conv before box predictor: 0
Traceback (most recent call last):
File "export_inference_graph.py", line 162, in <module>
tf.app.run()
File "C:\ProgramData\Miniconda3\envs\tensorflow1\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:\ProgramData\Miniconda3\envs\tensorflow1\lib\site-packages\absl\app.py", line 300, in run
_run_main(main, args)
File "C:\ProgramData\Miniconda3\envs\tensorflow1\lib\site-packages\absl\app.py", line 251, in _run_main
sys.exit(main(argv))
File "export_inference_graph.py", line 158, in main
write_inference_graph=FLAGS.write_inference_graph)
File "C:\tensorflow1\models\research\object_detection\exporter.py", line 489, in export_inference_graph
write_inference_graph=write_inference_graph)
File "C:\tensorflow1\models\research\object_detection\exporter.py", line 392, in _export_inference_graph
graph_hook_fn=graph_hook_fn)
File "C:\tensorflow1\models\research\object_detection\exporter.py", line 359, in build_detection_graph
output_collection_name=output_collection_name)
File "C:\tensorflow1\models\research\object_detection\exporter.py", line 338, in _get_outputs_from_inputs
output_tensors, true_image_shapes)
File "C:\tensorflow1\models\research\object_detection\meta_architectures\ssd_meta_arch.py", line 722, in postprocess
anchor_indices = tf.range(self._anchors.num_boxes_static())
File "C:\ProgramData\Miniconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\ops\math_ops.py", line 1305, in range
limit = ops.convert_to_tensor(limit, dtype=dtype, name="limit")
File "C:\ProgramData\Miniconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\framework\ops.py", line 1087, in convert_to_tensor
return convert_to_tensor_v2(value, dtype, preferred_dtype, name)
File "C:\ProgramData\Miniconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\framework\ops.py", line 1145, in convert_to_tensor_v2
as_ref=False)
File "C:\ProgramData\Miniconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\framework\ops.py", line 1224, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "C:\ProgramData\Miniconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\framework\constant_op.py", line 305, in _constant_tensor_conversion_function
return constant(v, dtype=dtype, name=name)
File "C:\ProgramData\Miniconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\framework\constant_op.py", line 246, in constant
allow_broadcast=True)
File "C:\ProgramData\Miniconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\framework\constant_op.py", line 284, in _constant_impl
allow_broadcast=allow_broadcast))
File "C:\ProgramData\Miniconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\framework\tensor_util.py", line 454, in make_tensor_proto
raise ValueError("None values not supported.")
ValueError: None values not supported.
时,问题会浮出水面。某人here似乎已成功将这些模型转换为冻结图,但是它是一年前的,基于Tensorflow 1.10.0