2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // See LICENSE file in the project root for full license information.
5 #include "../InferenceTest.hpp"
6 #include "../ImagePreprocessor.hpp"
7 #include "armnnOnnxParser/IOnnxParser.hpp"
9 int main(int argc, char* argv[])
11 int retVal = EXIT_FAILURE;
14 // Coverity fix: The following code may throw an exception of type std::length_error.
15 std::vector<ImageSet> imageSet =
22 armnn::TensorShape inputTensorShape({ 1, 3, 224, 224 });
24 using DataType = float;
25 using DatabaseType = ImagePreprocessor<float>;
26 using ParserType = armnnOnnxParser::IOnnxParser;
27 using ModelType = InferenceModel<ParserType, DataType>;
29 // Coverity fix: ClassifierInferenceTestMain() may throw uncaught exceptions.
30 retVal = armnn::test::ClassifierInferenceTestMain<DatabaseType, ParserType>(
32 "mobilenetv2-1.0.onnx", // model name
33 true, // model is binary
34 "data", "mobilenetv20_output_flatten0_reshape0", // input and output tensor names
35 { 0, 1, 2 }, // test images to test with as above
36 [&imageSet](const char* dataDir, const ModelType&) {
37 // This creates create a 1, 3, 224, 224 normalized input with mean and stddev to pass to Armnn
45 {{0.485f, 0.456f, 0.406f}}, // mean
46 {{0.229f, 0.224f, 0.225f}}, // stddev
47 DatabaseType::DataFormat::NCHW); // format
51 catch (const std::exception& e)
53 // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an
54 // exception of type std::length_error.
55 // Using stderr instead in this context as there is no point in nesting try-catch blocks here.
56 std::cerr << "WARNING: OnnxMobileNet-Armnn: An error has occurred when running "
57 "the classifier inference tests: " << e.what() << std::endl;