You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

151 lines
7.5 KiB

6 years ago
  1. # Open Images Challenge Evaluation
  2. The Object Detection API is currently supporting several evaluation metrics used in the [Open Images Challenge 2018](https://storage.googleapis.com/openimages/web/challenge.html).
  3. In addition, several data processing tools are available. Detailed instructions on using the tools for each track are available below.
  4. **NOTE**: links to the external website in this tutorial may change after the Open Images Challenge 2018 is finished.
  5. ## Object Detection Track
  6. The [Object Detection metric](https://storage.googleapis.com/openimages/web/object_detection_metric.html) protocol requires a pre-processing of the released data to ensure correct evaluation. The released data contains only leaf-most bounding box annotations and image-level labels.
  7. The evaluation metric implementation is available in the class `OpenImagesDetectionChallengeEvaluator`.
  8. 1. Download class hierarchy of Open Images Challenge 2018 in JSON format from [here](https://storage.googleapis.com/openimages/challenge_2018/bbox_labels_500_hierarchy.json).
  9. 2. Download ground-truth [boundling boxes](https://storage.googleapis.com/openimages/challenge_2018/train/challenge-2018-train-annotations-bbox.csv) and [image-level labels](https://storage.googleapis.com/openimages/challenge_2018/train/challenge-2018-train-annotations-human-imagelabels.csv).
  10. 3. Filter the rows corresponding to the validation set images you want to use and store the results in the same CSV format.
  11. 4. Run the following command to create hierarchical expansion of the bounding boxes annotations:
  12. ```
  13. HIERARCHY_FILE=/path/to/bbox_labels_500_hierarchy.json
  14. BOUNDING_BOXES=/path/to/challenge-2018-train-annotations-bbox
  15. IMAGE_LABELS=/path/to/challenge-2018-train-annotations-human-imagelabels
  16. python object_detection/dataset_tools/oid_hierarchical_labels_expansion.py \
  17. --json_hierarchy_file=${HIERARCHY_FILE} \
  18. --input_annotations=${BOUNDING_BOXES}.csv \
  19. --output_annotations=${BOUNDING_BOXES}_expanded.csv \
  20. --annotation_type=1
  21. python object_detection/dataset_tools/oid_hierarchical_labels_expansion.py \
  22. --json_hierarchy_file=${HIERARCHY_FILE} \
  23. --input_annotations=${IMAGE_LABELS}.csv \
  24. --output_annotations=${IMAGE_LABELS}_expanded.csv \
  25. --annotation_type=2
  26. ```
  27. After step 4 you will have produced the ground-truth files suitable for running 'OID Challenge Object Detection Metric 2018' evaluation.
  28. ```
  29. INPUT_PREDICTIONS=/path/to/detection_predictions.csv
  30. OUTPUT_METRICS=/path/to/output/metrics/file
  31. python models/research/object_detection/metrics/oid_od_challenge_evaluation.py \
  32. --input_annotations_boxes=${BOUNDING_BOXES}_expanded.csv \
  33. --input_annotations_labels=${IMAGE_LABELS}_expanded.csv \
  34. --input_class_labelmap=object_detection/data/oid_object_detection_challenge_500_label_map.pbtxt \
  35. --input_predictions=${INPUT_PREDICTIONS} \
  36. --output_metrics=${OUTPUT_METRICS} \
  37. ```
  38. ### Running evaluation on CSV files directly
  39. 5. If you are not using Tensorflow, you can run evaluation directly using your algorithm's output and generated ground-truth files. {value=5}
  40. ### Running evaluation using TF Object Detection API
  41. 5. Produce tf.Example files suitable for running inference: {value=5}
  42. ```
  43. RAW_IMAGES_DIR=/path/to/raw_images_location
  44. OUTPUT_DIR=/path/to/output_tfrecords
  45. python object_detection/dataset_tools/create_oid_tf_record.py \
  46. --input_box_annotations_csv ${BOUNDING_BOXES}_expanded.csv \
  47. --input_image_label_annotations_csv ${IMAGE_LABELS}_expanded.csv \
  48. --input_images_directory ${RAW_IMAGES_DIR} \
  49. --input_label_map object_detection/data/oid_object_detection_challenge_500_label_map.pbtxt \
  50. --output_tf_record_path_prefix ${OUTPUT_DIR} \
  51. --num_shards=100
  52. ```
  53. 6. Run inference of your model and fill corresponding fields in tf.Example: see [this tutorial](object_detection/g3doc/oid_inference_and_evaluation.md) on running the inference with Tensorflow Object Detection API models. {value=6}
  54. 7. Finally, run the evaluation script to produce the final evaluation result.
  55. ```
  56. INPUT_TFRECORDS_WITH_DETECTIONS=/path/to/tf_records_with_detections
  57. OUTPUT_CONFIG_DIR=/path/to/configs
  58. echo "
  59. label_map_path: 'object_detection/data/oid_object_detection_challenge_500_label_map.pbtxt'
  60. tf_record_input_reader: { input_path: '${INPUT_TFRECORDS_WITH_DETECTIONS}' }
  61. " > ${OUTPUT_CONFIG_DIR}/input_config.pbtxt
  62. echo "
  63. metrics_set: 'oid_challenge_detection_metrics'
  64. " > ${OUTPUT_CONFIG_DIR}/eval_config.pbtxt
  65. OUTPUT_METRICS_DIR=/path/to/metrics_csv
  66. python object_detection/metrics/offline_eval_map_corloc.py \
  67. --eval_dir=${OUTPUT_METRICS_DIR} \
  68. --eval_config_path=${OUTPUT_CONFIG_DIR}/eval_config.pbtxt \
  69. --input_config_path=${OUTPUT_CONFIG_DIR}/input_config.pbtxt
  70. ```
  71. The result of the evaluation will be stored in `${OUTPUT_METRICS_DIR}/metrics.csv`
  72. For the Object Detection Track, the participants will be ranked on:
  73. - "OpenImagesChallenge2018_Precision/mAP@0.5IOU"
  74. ## Visual Relationships Detection Track
  75. The [Visual Relationships Detection metrics](https://storage.googleapis.com/openimages/web/vrd_detection_metric.html) can be directly evaluated using the ground-truth data and model predictions. The evaluation metric implementation is available in the class `VRDRelationDetectionEvaluator`,`VRDPhraseDetectionEvaluator`.
  76. 1. Download the ground-truth [visual relationships annotations](https://storage.googleapis.com/openimages/challenge_2018/train/challenge-2018-train-vrd.csv) and [image-level labels](https://storage.googleapis.com/openimages/challenge_2018/train/challenge-2018-train-vrd-labels.csv).
  77. 2. Filter the rows corresponding to the validation set images you want to use and store the results in the same CSV format.
  78. 3. Run the follwing command to produce final metrics:
  79. ```
  80. INPUT_ANNOTATIONS_BOXES=/path/to/challenge-2018-train-vrd.csv
  81. INPUT_ANNOTATIONS_LABELS=/path/to/challenge-2018-train-vrd-labels.csv
  82. INPUT_PREDICTIONS=/path/to/predictions.csv
  83. INPUT_CLASS_LABELMAP=/path/to/oid_object_detection_challenge_500_label_map.pbtxt
  84. INPUT_RELATIONSHIP_LABELMAP=/path/to/relationships_labelmap.pbtxt
  85. OUTPUT_METRICS=/path/to/output/metrics/file
  86. echo "item { name: '/m/02gy9n' id: 602 display_name: 'Transparent' }
  87. item { name: '/m/05z87' id: 603 display_name: 'Plastic' }
  88. item { name: '/m/0dnr7' id: 604 display_name: '(made of)Textile' }
  89. item { name: '/m/04lbp' id: 605 display_name: '(made of)Leather' }
  90. item { name: '/m/083vt' id: 606 display_name: 'Wooden'}
  91. ">>${INPUT_CLASS_LABELMAP}
  92. echo "item { name: 'at' id: 1 display_name: 'at' }
  93. item { name: 'on' id: 2 display_name: 'on (top of)' }
  94. item { name: 'holds' id: 3 display_name: 'holds' }
  95. item { name: 'plays' id: 4 display_name: 'plays' }
  96. item { name: 'interacts_with' id: 5 display_name: 'interacts with' }
  97. item { name: 'wears' id: 6 display_name: 'wears' }
  98. item { name: 'is' id: 7 display_name: 'is' }
  99. item { name: 'inside_of' id: 8 display_name: 'inside of' }
  100. item { name: 'under' id: 9 display_name: 'under' }
  101. item { name: 'hits' id: 10 display_name: 'hits' }
  102. "> ${INPUT_RELATIONSHIP_LABELMAP}
  103. python object_detection/metrics/oid_vrd_challenge_evaluation.py \
  104. --input_annotations_boxes=${INPUT_ANNOTATIONS_BOXES} \
  105. --input_annotations_labels=${INPUT_ANNOTATIONS_LABELS} \
  106. --input_predictions=${INPUT_PREDICTIONS} \
  107. --input_class_labelmap=${INPUT_CLASS_LABELMAP} \
  108. --input_relationship_labelmap=${INPUT_RELATIONSHIP_LABELMAP} \
  109. --output_metrics=${OUTPUT_METRICS}
  110. ```
  111. The participants of the challenge will be evaluated by weighted average of the following three metrics:
  112. - "VRDMetric_Relationships_mAP@0.5IOU"
  113. - "VRDMetric_Relationships_Recall@50@0.5IOU"
  114. - "VRDMetric_Phrases_mAP@0.5IOU"