blob: 70828498df379300ff949eb18af680e67c066ca6 [file] [log] [blame]
David Monahana820e022019-04-23 11:03:38 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5#include "../InferenceTest.hpp"
6#include "../ImagePreprocessor.hpp"
7#include "armnnTfLiteParser/ITfLiteParser.hpp"
8
9using namespace armnnTfLiteParser;
10
11int main(int argc, char* argv[])
12{
13 int retVal = EXIT_FAILURE;
14 try
15 {
16 // Coverity fix: The following code may throw an exception of type std::length_error.
17 std::vector<ImageSet> imageSet =
18 {
19 {"Dog.jpg", 795},
20 {"Cat.jpg", 592},
21 {"shark.jpg", 436},
22 };
23
24 armnn::TensorShape inputTensorShape({ 1, 128, 128, 3 });
25
26 using DataType = uint8_t;
27 using DatabaseType = ImagePreprocessor<DataType>;
28 using ParserType = armnnTfLiteParser::ITfLiteParser;
29 using ModelType = InferenceModel<ParserType, DataType>;
30
31 // Coverity fix: ClassifierInferenceTestMain() may throw uncaught exceptions.
32 retVal = armnn::test::ClassifierInferenceTestMain<DatabaseType,
33 ParserType>(
34 argc, argv,
35 "mobilenet_v1_0.25_128_quant.tflite", // model name
36 true, // model is binary
37 "input", // input tensor name
38 "MobilenetV1/Predictions/Reshape_1", // output tensor name
39 { 0, 1, 2 }, // test images to test with as above
40 [&imageSet](const char* dataDir, const ModelType & model) {
41 // we need to get the input quantization parameters from
42 // the parsed model
David Monahana820e022019-04-23 11:03:38 +010043 return DatabaseType(
44 dataDir,
45 128,
46 128,
47 imageSet,
FinnWilliamsArma723ec52019-05-22 14:50:55 +010048 1,
David Monahana820e022019-04-23 11:03:38 +010049 {{0, 0, 0}},
50 {{1, 1, 1}},
51 DatabaseType::DataFormat::NCHW,
52 1);
53 },
54 &inputTensorShape);
55 }
56 catch (const std::exception& e)
57 {
58 // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an
59 // exception of type std::length_error.
60 // Using stderr instead in this context as there is no point in nesting try-catch blocks here.
61 std::cerr << "WARNING: " << *argv << ": An error has occurred when running "
62 "the classifier inference tests: " << e.what() << std::endl;
63 }
64 return retVal;
65}