运行 export_inference_graph.py 抛出值错误

Running export_inference_graph.py throws value error

我是 Whosebug.I 的新手,正在尝试使用 export_inference_graph.py 导出模型。 我在本地使用 faster_rcnn_inception_v2.I 训练了我的模型,我遵循这个 tutorial

当我在命令提示符下输入时

python export_inference_graph.py --input_type image_tensor --pipeline_config_path CAPTCHA_training/faster_rcnn_inception_v2_coco.config --trained_checkpoint_prefix "CAPTCHA_training_dir/model.ckpt-51272" --output_directory CAPTCHA_inference_graph 

所有路径都正确我得到以下错误。

  File "export_inference_graph.py", line 206, in <module>
    tf.app.run()
  File "C:\Users\Jatin\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\Jatin\anaconda3\lib\site-packages\absl\app.py", line 303, in run
    _run_main(main, args)
  File "C:\Users\Jatin\anaconda3\lib\site-packages\absl\app.py", line 251, in _run_main
    sys.exit(main(argv))
  File "export_inference_graph.py", line 194, in main
    exporter.export_inference_graph(
  File "C:\Users\Jatin\anaconda3\lib\site-packages\object_detection\exporter.py", line 604, in export_inference_graph
    detection_model = model_builder.build(pipeline_config.model,
  File "C:\Users\Jatin\anaconda3\lib\site-packages\object_detection\builders\model_builder.py", line 1116, in build
    return build_func(getattr(model_config, meta_architecture), is_training,
  File "C:\Users\Jatin\anaconda3\lib\site-packages\object_detection\builders\model_builder.py", line 583, in _build_faster_rcnn_model
    _check_feature_extractor_exists(frcnn_config.feature_extractor.type)
  File "C:\Users\Jatin\anaconda3\lib\site-packages\object_detection\builders\model_builder.py", line 249, in _check_feature_extractor_exists
    raise ValueError('{} is not supported. See `model_builder.py` for features '
ValueError: faster_rcnn_inception_v2 is not supported. See `model_builder.py` for features extractors compatible with different versions of Tensorflow

我正在使用 Python 3.8.5 和 tensorflow 版本 2.4.1 提前致谢

根据报错看来是Tensorflow版本问题。查看来源 faster_rcnn_inception_v2 存在于 if tf_version.is_tf1(): 下。尝试使用 TF 1.

https://github.com/tensorflow/models/blob/5a89897396aa8ecc7b3ef8919f987e96fc8d74db/research/object_detection/builders/model_builder.py#L70

https://github.com/tensorflow/models/blob/5a89897396aa8ecc7b3ef8919f987e96fc8d74db/research/object_detection/models/faster_rcnn_inception_resnet_v2_feature_extractor.py#L33

faster_rcnn_inception_v2_coco 存在于 Tensorflow 1 检测模型动物园中。

https://github.com/tensorflow/models/blob/5a89897396aa8ecc7b3ef8919f987e96fc8d74db/research/object_detection/g3doc/tf1_detection_zoo.md#coco-trained-models