blob: 48e63211a3ca2b8e231cdf64a3baad952e7e89df [file] [log] [blame]
nikraj01647aab32019-04-05 11:42:45 +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 std::vector<ImageSet> imageSet =
17 {
18 {"Dog.jpg", 209},
19 {"Cat.jpg", 283},
20 {"shark.jpg", 3},
21
22 };
23
nikraj01b1390fc2019-04-15 09:55:15 +010024 armnn::TensorShape inputTensorShape({ 1, 224, 224, 3 });
nikraj01647aab32019-04-05 11:42:45 +010025
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,
nikraj01b1390fc2019-04-15 09:55:15 +010035 "resnet_v2_50_default_minmax.tflite", // model name
nikraj01647aab32019-04-05 11:42:45 +010036 true, // model is binary
37 "input", // input tensor name
Nina Drozdaab6aff2019-04-16 10:28:19 +010038 "resnet_v2_50/predictions/Reshape_1", // output tensor name
nikraj01647aab32019-04-05 11:42:45 +010039 { 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
43 auto inputBinding = model.GetInputBindingInfo();
44 return DatabaseType(
45 dataDir,
nikraj01b1390fc2019-04-15 09:55:15 +010046 224,
47 224,
nikraj01647aab32019-04-05 11:42:45 +010048 imageSet,
49 inputBinding.second.GetQuantizationScale(),
50 inputBinding.second.GetQuantizationOffset());
51 },
52 &inputTensorShape);
53 }
54 catch (const std::exception& e)
55 {
56 // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an
57 // exception of type std::length_error.
58 // Using stderr instead in this context as there is no point in nesting try-catch blocks here.
59 std::cerr << "WARNING: " << *argv << ": An error has occurred when running "
60 "the classifier inference tests: " << e.what() << std::endl;
61 }
62 return retVal;
63}