In the moment I am doing some research with the object detection API from tensorflow. For this I followed this tutorial:
https://www.oreilly.com/ideas/object-detection-with-tensorflow
This tutorial describes how to generate tfrecord from images and also PASCAL VOC xml label files. As well as getting started with the object detection API.
To generate those tfrecords I modified some code from the referenced raccoon repository on github:
https://github.com/datitran/raccoon_dataset
I labeled my images with LabelImg (https://github.com/tzutalin/labelImg) there you have the possibility to save in PASCAL VOC format.
So now I followed the tutorial and did a first test (training) with 60 images and after an hour (574 steps) I did an interrupt to save the checkpoint. After this I did an export "graph for inference.py" and saved the frozen model (correct me if I'm saying something stupid, this stuff is also new to me...)
And after this I modified the jupyter notebook from the tutorial for my desires and tada there is some recognition in test images.
So far so good, but now I want to see how good (accuracy) the object detection is and for this I wanted to add some ground truth boxes from my test PASCAL VOC dataset. But I am having some troubles to acquire my goal.
The first thing I was doing is to manually add boxes which I read from my VOC dataset and add them to the image, which I made with https://matplotlib.org/devdocs/api/_as_gen/matplotlib.patches.Rectangle.html
But in my solution this is getting different plots/figures....
So then I thought maybe the object detection API provides some functions to add boxes/ground truth boxes and evaluates the accuracy from my detection with my test VOC dataset.
So I thought I take a look at https://github.com/tensorflow/models/tree/master/research/object_detection/utils and I thought I did found a function (def draw_bounding_box_on_image_array ) to make some boxes to my image_np, but nothings happens so this is what the API uses to do some visualization:
vis_util.visualize_boxes_and_labels_on_image_array(
image_np,
np.squeeze(boxes),
np.squeeze(classes).astype(np.int32),
np.squeeze(scores),
category_index,
use_normalized_coordinates=True,
line_thickness=2)
and this what I have tried to use:
vis_util.draw_bounding_box_on_image(
image_np,
bndbox_coordinates[0][1],
bndbox_coordinates[0][0],
bndbox_coordinates[0][3],
bndbox_coordinates[0][2])
but there arent boxes if I try to plot this numpy array image
Am I missing something? And question 2 is there some class in the API which is doing the evaluation for accuracy? I don't see with my dried eyes... And if does this class/function use PASCAL VOC to determine? Mybe I can use this: https://github.com/tensorflow/models/blob/master/research/object_detection/utils/object_detection_evaluation.py but I'm not confident because I am also new to python and some code/comments are hard for me to understand...
Maybe you professional guys out there can help me.
EDIT:
I have read a little bit from this article: https://www.pyimagesearch.com/2016/11/07/intersection-over-union-iou-for-object-detection/
and now I know that I need an IoU (Intersection over Union) - so does anyone know if the object detection API provides a function for this? I will look again into the API...