Are the object detection evaluation scripts still working for coco dataset?
Are the evaluation scripts still working for coco dataset, say on model ssd_inception_v2? https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/oid_inference_and_evaluation.md
I tried the flow above with tfrecord generated by create_coco_tf_record. But it looks like it's quite bumpy, that I have to fix several typo-looking issues in the source code to make it through.
object_detection/inference/detection_inference.py:65
- with tf.gfile.Open(inference_graph_path, 'r') as graph_def_file:
+ with tf.gfile.Open(inference_graph_path, 'rb') as graph_def_file:
object_detection/metrics/offline_eval_map_corloc.py:159
- input_config = configs['eval_input_config']
+ input_config = configs['eval_input_configs'][0]
Finally all image got skipped when computing evaluation measures from tfrecord, because some 'groundtruth_classes' can't be found in annotations.
So how can I evaluate ssd_inception_v2 in model zoo on coco dataset exactly? Do I need to try on Python2? Do I need to try object_detection/legacy/eval.py?
the commands. I'm using my local paths for 'MY_PATH's below.
tfrecord gen:
# From tensorflow/models/research/oid
SPLIT=validation # Set SPLIT to "test" to create TFRecords for the test split
mkdir ${SPLIT}_tfrecords
PYTHONPATH=$PYTHONPATH:$(readlink -f ..) \
python -m object_detection.dataset_tools.create_coco_tf_record \
--output_dir=${SPLIT}_tfrecords \
--val_annotations_file=instances_val2014.json \
--val_image_dir=val2014
run eval:
#From tensorflow/models/research/oid
SPLIT=validation # or test
TF_RECORD_FILES=$(ls -1 ${SPLIT}_tfrecords/* | tr '\n' ',')
PYTHONPATH=$PYTHONPATH:$(readlink -f ..) \
python -m object_detection.inference.infer_detections \
--input_tfrecord_paths=$TF_RECORD_FILES \
--output_tfrecord_path=${SPLIT}_detections.tfrecord-00000-of-00001 \
--inference_graph=<MY_PATH>/mask_rcnn_inception_v2/mask_rcnn_inception_v2_coco_2018_01_28/frozen_inference_graph.pb \
--discard_image_pixels
# From tensorflow/models/research/oid
SPLIT=validation # or test
NUM_SHARDS=1 # Set to NUM_GPUS if using the parallel evaluation script above
mkdir -p ${SPLIT}_eval_metrics
echo "
label_map_path: '<MY_PATH>/object_detection/data/mscoco_complete_label_map.pbtxt'
tf_record_input_reader: { input_path: '${SPLIT}_detections.tfrecord@${NUM_SHARDS}' }
" > ${SPLIT}_eval_metrics/${SPLIT}_input_config.pbtxt
echo "
metrics_set: 'coco_detection_metrics'
" > ${SPLIT}_eval_metrics/${SPLIT}_eval_config.pbtxt
run result:
# From tensorflow/models/research/oid
SPLIT=validation # or test
PYTHONPATH=$PYTHONPATH:$(readlink -f ..) \
python -m object_detection.metrics.offline_eval_map_corloc \
--eval_dir=${SPLIT}_eval_metrics \
--eval_config_path=${SPLIT}_eval_metrics/${SPLIT}_eval_config.pbtxt \
--input_config_path=${SPLIT}_eval_metrics/${SPLIT}_input_config.pbtxt
I have the exact same issue on Python 2
@lbingbing did you get it working?
I had the same issue too. The problem is in create_coco_tf_record, it doesn't add the key for 'image/object/class/label' which should contain the label id (category_id in the case of COCO). In my case, I've added it in the feature dictionary like in the following picture :

Hi There, We are checking to see if you still need help on this, as this seems to be an old issue. Please update this issue with the latest information, code snippet to reproduce your issue and error you are seeing. If we don't hear from you in the next 7 days, this issue will be closed automatically. If you don't need help on this issue any more, please consider closing this.