MCPcopy Create free account
hub / github.com/OpenPPL/ppl.nn / main

Function main

samples/cpp/run_model/classification.cpp:223–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221}
222
223int main(int argc, char* argv[]) {
224 if (argc != 3) {
225 fprintf(stderr, "Usage: %s <image_file> <onnx_model_file>\n", argv[0]);
226 return -1;
227 }
228
229 const char* img_path = argv[1];
230 Mat src_img = imread(img_path);
231 if (src_img.empty()) {
232 fprintf(stderr, "read image file %s failed!\n", img_path);
233 return -1;
234 }
235
236 const bool resize_input = false; // pplnn can adapt dynamic input size even if onnx model has static input size
237 if (resize_input) {
238 resize(src_img, src_img, Size(224, 224));
239 }
240
241 const char* onnx_model_path = argv[2];
242 int32_t ret = RunClassificationModel(src_img, onnx_model_path);
243 if (ret != 0) {
244 fprintf(stderr, "run classification model failed!\n");
245 return -1;
246 }
247
248 return 0;
249}

Callers

nothing calls this directly

Calls 1

RunClassificationModelFunction · 0.85

Tested by

no test coverage detected