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 "armnnTfLiteParser/ITfLiteParser.hpp"
9 using namespace armnnTfLiteParser;
11 int main(int argc, char* argv[])
13 int retVal = EXIT_FAILURE;
16 // Coverity fix: The following code may throw an exception of type std::length_error.
17 std::vector<ImageSet> imageSet =
20 // top five predictions in tensorflow:
21 // -----------------------------------
22 // 209:Labrador retriever 0.949995
23 // 160:Rhodesian ridgeback 0.0270182
24 // 208:golden retriever 0.0192866
25 // 853:tennis ball 0.000470382
26 // 239:Greater Swiss Mountain dog 0.000464451
28 // top five predictions in tensorflow:
29 // -----------------------------------
30 // 283:tiger cat 0.579016
31 // 286:Egyptian cat 0.319676
32 // 282:tabby, tabby cat 0.0873346
33 // 288:lynx, catamount 0.011163
34 // 289:leopard, Panthera pardus 0.000856755
36 // top five predictions in tensorflow:
37 // -----------------------------------
38 // 3:great white shark, white shark, ... 0.996926
39 // 4:tiger shark, Galeocerdo cuvieri 0.00270528
40 // 149:killer whale, killer, orca, ... 0.000121848
41 // 395:sturgeon 7.78977e-05
42 // 5:hammerhead, hammerhead shark 6.44127e-055
45 armnn::TensorShape inputTensorShape({ 1, 224, 224, 3 });
47 using DataType = uint8_t;
48 using DatabaseType = ImagePreprocessor<DataType>;
49 using ParserType = armnnTfLiteParser::ITfLiteParser;
50 using ModelType = InferenceModel<ParserType, DataType>;
52 // Coverity fix: ClassifierInferenceTestMain() may throw uncaught exceptions.
53 retVal = armnn::test::ClassifierInferenceTestMain<DatabaseType,
56 "mobilenet_v1_1.0_224_quant.tflite", // model name
57 true, // model is binary
58 "input", // input tensor name
59 "MobilenetV1/Predictions/Reshape_1", // output tensor name
60 { 0, 1, 2 }, // test images to test with as above
61 [&imageSet](const char* dataDir, const ModelType & model) {
62 // we need to get the input quantization parameters from
64 auto inputBinding = model.GetInputBindingInfo();
70 inputBinding.second.GetQuantizationScale(),
71 inputBinding.second.GetQuantizationOffset());
75 catch (const std::exception& e)
77 // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an
78 // exception of type std::length_error.
79 // Using stderr instead in this context as there is no point in nesting try-catch blocks here.
80 std::cerr << "WARNING: " << *argv << ": An error has occurred when running "
81 "the classifier inference tests: " << e.what() << std::endl;