swalkner
swalkner

Reputation: 17359

convert .caffemodel to yolo/object detection

I do have a .caffemodel file, converted it to a .coreml file which I'm using in an app to recognize special types of bottles. It works, but it only shows if a bottle is in the picture or not.

Now I would like to know WHERE the bottle is and stumbled upon https://github.com/hollance/YOLO-CoreML-MPSNNGraph and https://github.com/r4ghu/iOS-CoreML-Yolo but I don't know how I can convert my .caffemodel to such files; is such a conversion even possible or does the training have to be completely different?

Upvotes: 0

Views: 627

Answers (1)

Matthijs Hollemans
Matthijs Hollemans

Reputation: 7892

If your current model is a classifier then you cannot use it to detect where the objects are in the picture, since it was not trained to do this.

You will have to train a model that does not just do classification but also object detection. The detection part will tell you where the objects are in the image (it gives you zero or more bounding boxes), while the classification part will tell you what the objects are in those bounding boxes.

A very simple way to do this is to add a "regression" layer to the model that outputs 4 numbers in addition to the classification (so the model now has two outputs instead of just one). Then you train it to make these 4 numbers the coordinates of the bounding box for the thing in the image. (This model can only detect a single object in the image since it only returns the coordinates for a single bounding box.)

To train this model you need not just images but also the coordinates of the bounding box for the thing inside the image. In other words, you'll need to annotate your training images with bounding box info.

YOLO, SSD, R-CNN, and similar models build on this idea and allow for multiple detections per image.

Upvotes: 3

Related Questions