MCPcopy Create free account
hub / github.com/BVLC/caffe / main

Function main

examples/cpp_classification/classification.cpp:229–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227}
228
229int main(int argc, char** argv) {
230 if (argc != 6) {
231 std::cerr << "Usage: " << argv[0]
232 << " deploy.prototxt network.caffemodel"
233 << " mean.binaryproto labels.txt img.jpg" << std::endl;
234 return 1;
235 }
236
237 ::google::InitGoogleLogging(argv[0]);
238
239 string model_file = argv[1];
240 string trained_file = argv[2];
241 string mean_file = argv[3];
242 string label_file = argv[4];
243 Classifier classifier(model_file, trained_file, mean_file, label_file);
244
245 string file = argv[5];
246
247 std::cout << "---------- Prediction for "
248 << file << " ----------" << std::endl;
249
250 cv::Mat img = cv::imread(file, -1);
251 CHECK(!img.empty()) << "Unable to decode image " << file;
252 std::vector<Prediction> predictions = classifier.Classify(img);
253
254 /* Print the top N predictions. */
255 for (size_t i = 0; i < predictions.size(); ++i) {
256 Prediction p = predictions[i];
257 std::cout << std::fixed << std::setprecision(4) << p.second << " - \""
258 << p.first << "\"" << std::endl;
259 }
260}
261#else
262int main(int argc, char** argv) {
263 LOG(FATAL) << "This example requires OpenCV; compile with USE_OPENCV.";

Callers

nothing calls this directly

Calls 2

ClassifyMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected