I am recently trying out darkflow, a Tensorflow implementation of Darknet written by Joseph Redmon. Looking at the configuration files, I noticed a section called region as shown below.

anchors = 1.08,1.19,  3.42,4.41,  6.63,11.38,  9.42,5.11,  16.62,10.52

The anchor box values are pre-calculated. Are the anchor values used universally for all trained data sets? If not, how does one calculate the anchor box values from their own image annotations?


The anchor boxes are generated by clustering the dimensions of the ground truth boxes from the original dataset, to find the most common shapes/sizes. See section 2 (Dimension Clusters) in the original paper for more details.

You can generate you own dataset-specific anchors by following the instructions in this darknet repo.


So let's take an example of a simple binary image classification model. The goal of this model is to predict if the given image is of a dog or cat. So it is assumed that the output softmax layer of this model has 2 neurons. In YOLO we add 4 more neurons at the input as well as on the output layer. These 4 new neurons are the coordinates of the object present in the image, so the model also predicts the bounding boxes in such a way.

Output Layer:

Class1, Class2, X_min, y_min, X_max, y_max,

We annotate the image and pass it to the network along with the bounding box's original coordinates. The model then is able to predict the class along with the coordinates for the location of that image.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.