experiencor / keras-yolo2

Easy training on custom dataset. Various backends (MobileNet and SqueezeNet) supported. A YOLO demo to detect raccoon run entirely in brower is accessible at https://git.io/vF7vI (not on Windows).
MIT License
1.73k stars 785 forks source link

Use yolo anchor boxes with retina net #371

Open baljit92 opened 5 years ago

baljit92 commented 5 years ago

Is there a way to use the anchor boxes generated using kMeans in Yolo with retina net. Retinanet takes into account the ratio and scales and then generates the anchor boxes based on that

So is there a way I can print out the ratios and scales for the generated anchor boxes?

robertlugg commented 5 years ago

Look in the file gen_anchors.py for the line:

centroids = run_kmeans(annotation_dims, num_anchors)

right after this line, do the math to compute what you need. In numpy syntax (which is the type of data centroids is), do something like this:

centroids[:,0] / centroids[:,1]

That will give you the ratio for each box. Then you must also know the scaling factor. A size in the centroids array relates to the grid size in the network, so multiply by that number. Let's pretend it is "43", then type

centroids * 43

You will need to learn a bit about numpy to do what I suggest.