Displaying Class Names in 'examples/ssd/ssd_detect.cpp'

38 views
Skip to first unread message

K.M

unread,
Sep 6, 2017, 4:06:08 AM9/6/17
to Caffe Users
Hi,

I'm running the ssd_detect.cpp example in my Eclipse IDE and I have noticed that the output just returns the class index and does not display the class name (like in the cpp_classifcation/classification.cpp example)

I have noticed that plot_detections.py uses the function LabelMap() to retrieve the class names. But I want to accomplish this in C++.

So, is there any way to read '/data/VOC0712/labelmap_voc.prototxt' and map the class_index against the names in the Caffe C++ API? I just want the class names to be displayed in the output too.

Any help would be greatly appreciated! 

Tian Jin

unread,
Oct 19, 2018, 4:43:43 AM10/19/18
to Caffe Users
I am also try doing this, here is what I currently do:


vector<string> get_label_names(const string labelmap_f){
// return a vector of label names with certain order
// file = open(labelmap_file, 'r')
// labelmap = caffe_pb2.LabelMap()
// text_format.Merge(str(file.read()), labelmap)

LabelMap labelMap;
fstream input(labelmap_f, ios::in | ios::binary);
labelMap.ParseFromIstream(&input);

cout << "dd " << labelMap.item(0) << endl;
cout << "dd " << labelMap.item(1) << endl;
cout << "dd " << labelMap.item(2) << endl;
cout << labelMap.item_size() << endl;


// vector<string> label_names;
// for (int j = 0; j < labelMap.item_size(); ++j) {
// label_names.push_back(labelMap.item().)
// }



}
Reply all
Reply to author
Forward
0 new messages