MCPcopy Create free account
hub / github.com/OAID/Tengine / check_params

Function check_params

internal/bin/classification.cpp:323–373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321}
322
323static bool check_params(const std::string model_format, int& model_fnum, const std::string proto_file,
324 const std::string model_file, const std::string label_file, const std::string image_file,
325 const int img_h, const int img_w, const float scale, const int repeat_count)
326{
327 // check model format
328 if(model_format.empty())
329 {
330 std::cerr << "Model format not specified.\n";
331 return false;
332 }
333 else if(model_format == "caffe" || model_format == "mxnet")
334 {
335 model_fnum = 2;
336 if(proto_file.empty() || model_file.empty())
337 {
338 std::cerr << "Both proto file and model file should be specified.\n";
339 return false;
340 }
341 }
342 else if(model_format == "caffe_single" || model_format == "onnx" || model_format == "tensorflow" ||
343 model_format == "tflite")
344 {
345 model_fnum = 1;
346 if(model_file.empty())
347 {
348 std::cerr << "Model file should be specified.\n";
349 return false;
350 }
351 }
352 else
353 {
354 std::cerr << "Model format not supported: " << model_format << "\n";
355 return false;
356 }
357
358 // check input files
359 if((model_fnum == 2 && !check_file_exist(proto_file)) || !check_file_exist(model_file) ||
360 !check_file_exist(label_file) || !check_file_exist(image_file))
361 {
362 return false;
363 }
364
365 // check other params
366 if(img_h <= 0 || img_w <= 0 || scale <= 0 || repeat_count <= 0)
367 {
368 std::cerr << "Invalid input params.\n";
369 return false;
370 }
371
372 return true;
373}
374
375int main(int argc, char* argv[])
376{

Callers 1

mainFunction · 0.85

Calls 2

emptyMethod · 0.80
check_file_existFunction · 0.70

Tested by

no test coverage detected