tensorflow / models

Models and examples built with TensorFlow
Other
77.04k stars 45.77k forks source link

Problem with Inference/Exporting Graph: ValueError Attempted to map inputs that were not found in grah_def[image_tensor:0] #6687

Open paviddavid opened 5 years ago

paviddavid commented 5 years ago

System information

Error Description

I created a custom tfrecord file for the object detection task and fine-tuned a pre-trained Kitti Resnet101 Faster RCNN network with "my" data. I exported the graph by using the following code:

python object_detection/export_inference_graph.py \
    --input_type=tf_record \
    --pipeline_config_path= {Path_to_Config_File_Used_In_Training} \
    --trained_checkpoint_prefix={Path_To_CKPT_FIle} \
    --output_directory=${Export_Directory}

The Model Analysis Reports starts with Incomplete Shape followed by a large list of output statements.

I executed the inference with following command:

python -m object_detection/inference/infer_detections \
  --input_tfrecord_paths={Path_To_TfRecord_File} \
  --output_tfrecord_path={Path_To_Output_TfRecord_File}.tfrecord-00000-of-00001 \
  --inference_graph={Path_To_Exported_Directory_See_Above}/frozen_inference_graph.pb \
  --discard_image_pixels

However, I got the following error code:

Traceback (most recent call last):
  File "infer_detections.py", line 96, in <module>
    tf.app.run()
  File "/home/user/.local/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 125, in run
    _sys.exit(main(argv))
  File "infer_detections.py", line 74, in main
    image_tensor, FLAGS.inference_graph)
  File "/home/user/tensorflow/models/research/object_detection/inference/detection_inference.py", line 74, in build_inference_graph
    graph_def, name='', input_map={'image_tensor': image_tensor})
  File "/home/user/.local/lib/python3.5/site-packages/tensorflow/python/util/deprecation.py", line 488, in new_func
    return func(*args, **kwargs)
  File "/home/user/.local/lib/python3.5/site-packages/tensorflow/python/framework/importer.py", line 455, in import_graph_def
    ', '.join(missing_unused_input_keys))
ValueError: Attempted to map inputs that were not found in graph_def: [image_tensor:0]

I am struggling with this error for some days and do not know what is wrong. Does anybody know why this error appear? I only work with tfrecord data.

I appreciate every hint/remark/solution.

Thanks a lot in advance.

mwessley commented 4 years ago

Probably already solved, but for other people. Had a similar problem which was solved by double checking the dstNodeName... if that one is not set correctly or there is no connection to the input Node, this error can occur.

dnth commented 3 years ago

Probably already solved, but for other people. Had a similar problem which was solved by double checking the dstNodeName... if that one is not set correctly or there is no connection to the input Node, this error can occur.

Thank you for the solution there! I am relatively new to this framework. Could you point me to any resources to double check dstNodeName and to fix that?