Bruno Goncalves | c981df3 | 2018-12-27 16:15:01 -0200 | [diff] [blame] | 1 | // |
| 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 | |
| 9 | using namespace armnnTfLiteParser; |
| 10 | |
| 11 | int 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 | |
| 24 | armnn::TensorShape inputTensorShape({ 1, 299, 299, 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 | "inception_v3_quant.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 |
Derek Lamberti | eb1fce0 | 2019-12-10 21:20:10 +0000 | [diff] [blame] | 40 | [&imageSet](const char* dataDir, const ModelType &) { |
Bruno Goncalves | c981df3 | 2018-12-27 16:15:01 -0200 | [diff] [blame] | 41 | // we need to get the input quantization parameters from |
| 42 | // the parsed model |
Bruno Goncalves | c981df3 | 2018-12-27 16:15:01 -0200 | [diff] [blame] | 43 | return DatabaseType( |
| 44 | dataDir, |
| 45 | 299, |
| 46 | 299, |
| 47 | imageSet, |
FinnWilliamsArm | af8b72d | 2019-05-22 14:50:55 +0100 | [diff] [blame] | 48 | 1); |
Bruno Goncalves | c981df3 | 2018-12-27 16:15:01 -0200 | [diff] [blame] | 49 | }, |
| 50 | &inputTensorShape); |
| 51 | } |
| 52 | catch (const std::exception& e) |
| 53 | { |
| 54 | // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an |
| 55 | // exception of type std::length_error. |
| 56 | // Using stderr instead in this context as there is no point in nesting try-catch blocks here. |
| 57 | std::cerr << "WARNING: " << *argv << ": An error has occurred when running " |
| 58 | "the classifier inference tests: " << e.what() << std::endl; |
| 59 | } |
| 60 | return retVal; |
| 61 | } |