surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // See LICENSE file in the project root for full license information. |
| 4 | // |
| 5 | #include "../InferenceTest.hpp" |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 6 | #include "../ImagePreprocessor.hpp" |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 7 | #include "armnnTfParser/ITfParser.hpp" |
| 8 | |
| 9 | int main(int argc, char* argv[]) |
| 10 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 11 | int retVal = EXIT_FAILURE; |
| 12 | try |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 13 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 14 | // Coverity fix: The following code may throw an exception of type std::length_error. |
| 15 | std::vector<ImageSet> imageSet = |
| 16 | { |
| 17 | { "Dog.jpg", 208 }, |
| 18 | { "Cat.jpg", 283 }, |
| 19 | { "shark.jpg", 3 }, |
| 20 | }; |
| 21 | |
| 22 | armnn::TensorShape inputTensorShape({ 1, 299, 299, 3 }); |
| 23 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 24 | using DataType = float; |
| 25 | using DatabaseType = ImagePreprocessor<float>; |
| 26 | using ParserType = armnnTfParser::ITfParser; |
| 27 | using ModelType = InferenceModel<ParserType, DataType>; |
| 28 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 29 | // Coverity fix: InferenceTestMain() may throw uncaught exceptions. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 30 | retVal = armnn::test::ClassifierInferenceTestMain<DatabaseType, ParserType>( |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 31 | argc, argv, "inception_v3_2016_08_28_frozen_transformed.pb", true, |
| 32 | "input", "InceptionV3/Predictions/Reshape_1", { 0, 1, 2, }, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 33 | [&imageSet](const char* dataDir, const ModelType&) { |
| 34 | return DatabaseType(dataDir, 299, 299, imageSet); |
| 35 | }, |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 36 | &inputTensorShape); |
| 37 | } |
| 38 | catch (const std::exception& e) |
| 39 | { |
| 40 | // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an |
| 41 | // exception of type std::length_error. |
| 42 | // Using stderr instead in this context as there is no point in nesting try-catch blocks here. |
| 43 | std::cerr << "WARNING: TfInceptionV3-Armnn: An error has occurred when running " |
| 44 | "the classifier inference tests: " << e.what() << std::endl; |
| 45 | } |
| 46 | return retVal; |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 47 | } |