blob: 36fc72cdf47f63aa0a8e0b4c152ba11775e51fba [file] [log] [blame]
Bruno Goncalves8f293382018-12-27 16:15:38 -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
25 armnn::TensorShape inputTensorShape({ 1, 299, 299, 3 });
26
27 using DataType = float;
28 using DatabaseType = ImagePreprocessor<DataType>;
29 using ParserType = armnnTfLiteParser::ITfLiteParser;
30 using ModelType = InferenceModel<ParserType, DataType>;
31
32 // Coverity fix: ClassifierInferenceTestMain() may throw uncaught exceptions.
33 retVal = armnn::test::ClassifierInferenceTestMain<DatabaseType,
34 ParserType>(
35 argc, argv,
36 "resnet_v2_101_299.tflite", // model name
37 true, // model is binary
38 "input", // input tensor name
39 "output", // output tensor name
40 { 0, 1, 2 }, // test images to test with as above
41 [&imageSet](const char* dataDir, const ModelType & model) {
42 return DatabaseType(
43 dataDir,
44 299,
45 299,
46 imageSet);
47 },
48 &inputTensorShape);
49 }
50 catch (const std::exception& e)
51 {
52 // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an
53 // exception of type std::length_error.
54 // Using stderr instead in this context as there is no point in nesting try-catch blocks here.
55 std::cerr << "WARNING: " << *argv << ": An error has occurred when running "
56 "the classifier inference tests: " << e.what() << std::endl;
57 }
58 return retVal;
59}