blob: c676cd7355fc5b2d132db443f95e8333cfd02d6d [file] [log] [blame]
Bruno Goncalves61980d42018-12-28 10:08:26 -02001//
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", 209},
20 {"Cat.jpg", 283},
21 {"shark.jpg", 3},
22 };
23
24 armnn::TensorShape inputTensorShape({ 2, 224, 224, 3 });
25
26 using DataType = float;
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 "mnasnet_1.3_224.tflite", // model name
36 true, // model is binary
37 "input", // input tensor name
38 "output", // output tensor name
39 { 0, 1, 2 }, // test images to test with as above
40 [&imageSet](const char* dataDir, const ModelType & model) {
41 return DatabaseType(
42 dataDir,
43 224,
44 224,
45 imageSet);
46 },
47 &inputTensorShape);
48 }
49 catch (const std::exception& e)
50 {
51 // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an
52 // exception of type std::length_error.
53 // Using stderr instead in this context as there is no point in nesting try-catch blocks here.
54 std::cerr << "WARNING: " << *argv << ": An error has occurred when running "
55 "the classifier inference tests: " << e.what() << std::endl;
56 }
57 return retVal;
58}