blob: 54759bf88a236cb17efd7ad248d2ca694ae28c0c [file] [log] [blame]
surmeh01bceff2f2018-03-29 16:29:27 +01001//
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"
6#include "../MobileNetDatabase.hpp"
7#include "armnnTfParser/ITfParser.hpp"
8
9int main(int argc, char* argv[])
10{
surmeh013537c2c2018-05-18 16:31:43 +010011 int retVal = EXIT_FAILURE;
12 try
surmeh01bceff2f2018-03-29 16:29:27 +010013 {
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 {"Dog.jpg", 209},
18 // top five predictions in tensorflow:
19 // -----------------------------------
20 // 209:Labrador retriever 0.949995
21 // 160:Rhodesian ridgeback 0.0270182
22 // 208:golden retriever 0.0192866
23 // 853:tennis ball 0.000470382
24 // 239:Greater Swiss Mountain dog 0.000464451
25 {"Cat.jpg", 283},
26 // top five predictions in tensorflow:
27 // -----------------------------------
28 // 283:tiger cat 0.579016
29 // 286:Egyptian cat 0.319676
30 // 282:tabby, tabby cat 0.0873346
31 // 288:lynx, catamount 0.011163
32 // 289:leopard, Panthera pardus 0.000856755
33 {"shark.jpg", 3},
34 // top five predictions in tensorflow:
35 // -----------------------------------
36 // 3:great white shark, white shark, ... 0.996926
37 // 4:tiger shark, Galeocerdo cuvieri 0.00270528
38 // 149:killer whale, killer, orca, ... 0.000121848
39 // 395:sturgeon 7.78977e-05
40 // 5:hammerhead, hammerhead shark 6.44127e-055
41 };
surmeh01bceff2f2018-03-29 16:29:27 +010042
surmeh013537c2c2018-05-18 16:31:43 +010043 armnn::TensorShape inputTensorShape({ 1, 224, 224, 3 });
44
45 // Coverity fix: ClassifierInferenceTestMain() may throw uncaught exceptions.
46 retVal = armnn::test::ClassifierInferenceTestMain<MobileNetDatabase, armnnTfParser::ITfParser>(
47 argc, argv, "mobilenet_v1_1.0_224_fp32.pb", true, "input", "output", { 0, 1, 2 },
48 [&imageSet](const char* dataDir) {
49 return MobileNetDatabase(
50 dataDir,
51 224,
52 224,
53 imageSet);
54 },
55 &inputTensorShape);
56 }
57 catch (const std::exception& e)
58 {
59 // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an
60 // exception of type std::length_error.
61 // Using stderr instead in this context as there is no point in nesting try-catch blocks here.
62 std::cerr << "WARNING: TfMobileNet-Armnn: An error has occurred when running "
63 "the classifier inference tests: " << e.what() << std::endl;
64 }
65 return retVal;
surmeh01bceff2f2018-03-29 16:29:27 +010066}