blob: aa814ff44b72cbd6ee589332e5d2a296fb28ec89 [file] [log] [blame]
Laurent Carlier749294b2020-06-01 09:03:17 +01001//
telsoa014fcda012018-03-09 14:13:49 +00002// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa014fcda012018-03-09 14:13:49 +00004//
5#include "../InferenceTest.hpp"
telsoa01c577f2c2018-08-31 09:22:23 +01006#include "../CaffePreprocessor.hpp"
telsoa014fcda012018-03-09 14:13:49 +00007#include "armnnCaffeParser/ICaffeParser.hpp"
8
9int main(int argc, char* argv[])
10{
surmeh013537c2c2018-05-18 16:31:43 +010011 int retVal = EXIT_FAILURE;
12 try
telsoa014fcda012018-03-09 14:13:49 +000013 {
surmeh013537c2c2018-05-18 16:31:43 +010014 // Coverity fix: The following code may throw an exception of type std::length_error.
15 std::vector<ImageSet> imageSet =
16 {
17 {"ILSVRC2012_val_00000018.JPEG", 21 },
18 {"shark.jpg", 2}
19 };
telsoa014fcda012018-03-09 14:13:49 +000020
surmeh013537c2c2018-05-18 16:31:43 +010021 armnn::TensorShape inputTensorShape({ 1, 3, 224, 224 });
22
telsoa01c577f2c2018-08-31 09:22:23 +010023 using DataType = float;
24 using DatabaseType = CaffePreprocessor;
25 using ParserType = armnnCaffeParser::ICaffeParser;
26 using ModelType = InferenceModel<ParserType, DataType>;
27
surmeh013537c2c2018-05-18 16:31:43 +010028 // Coverity fix: ClassifierInferenceTestMain() may throw uncaught exceptions.
telsoa01c577f2c2018-08-31 09:22:23 +010029 retVal = armnn::test::ClassifierInferenceTestMain<DatabaseType, ParserType>(
surmeh013537c2c2018-05-18 16:31:43 +010030 argc, argv, "ResNet_50_ilsvrc15_model.caffemodel", true,
31 "data", "prob", { 0, 1 },
telsoa01c577f2c2018-08-31 09:22:23 +010032 [&imageSet](const char* dataDir, const ModelType&) {
33 return DatabaseType(dataDir, 224, 224, imageSet);
34 }, &inputTensorShape);
surmeh013537c2c2018-05-18 16:31:43 +010035 }
36 catch (const std::exception& e)
37 {
38 // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an
39 // exception of type std::length_error.
40 // Using stderr instead in this context as there is no point in nesting try-catch blocks here.
41 std::cerr << "WARNING: CaffeResNet-Armnn: An error has occurred when running "
42 "the classifier inference tests: " << e.what() << std::endl;
43 }
44 return retVal;
telsoa014fcda012018-03-09 14:13:49 +000045}