Search code examples
pythontensorflowobject-detection

Running export_inference_graph.py throws value error


I am new to StackOverflow.I am trying to export a model by using export_inference_graph.py. I trained my model locally using faster_rcnn_inception_v2.I am following this tutorial.

When in command prompt I type

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 

All with correct paths I get following error.

  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

I am using Python 3.8.5 and tensorflow version 2.4.1 Thanks in advance


Solution

  • Looks like a Tensorflow version problem according to error. Looking into source faster_rcnn_inception_v2 exists under if tf_version.is_tf1():. Try using to 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 exists here in Tensorflow 1 Detection model zoo.

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