ArmNN
 20.08
TfInceptionV3-Armnn.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #include "../InferenceTest.hpp"
6 #include "../ImagePreprocessor.hpp"
8 
9 int main(int argc, char* argv[])
10 {
11  int retVal = EXIT_FAILURE;
12  try
13  {
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  // Top five predictions in tensorflow:
19  // -----------------------------------
20  // 208:golden retriever 0.57466376
21  // 209:Labrador retriever 0.30202731
22  // 853:tennis ball 0.0060001756
23  // 223:kuvasz 0.0053707925
24  // 160:Rhodesian ridgeback 0.0018179063
25 
26  { "Cat.jpg", 283 },
27  // Top five predictions in tensorflow:
28  // -----------------------------------
29  // 283:tiger cat 0.4667799
30  // 282:tabby, tabby cat 0.32511184
31  // 286:Egyptian cat 0.1038616
32  // 288:lynx, catamount 0.0017019814
33  // 284:Persian cat 0.0011340436
34 
35  { "shark.jpg", 3 },
36  // Top five predictions in tensorflow:
37  // -----------------------------------
38  // 3:great white shark, white shark, ... 0.98808634
39  // 148:grey whale, gray whale, ... 0.00070245547
40  // 234:Bouvier des Flandres, ... 0.00024639888
41  // 149:killer whale, killer, ... 0.00014115588
42  // 95:hummingbird 0.00011129203
43  };
44 
45  armnn::TensorShape inputTensorShape({ 1, 299, 299, 3 });
46 
47  using DataType = float;
48  using DatabaseType = ImagePreprocessor<float>;
49  using ParserType = armnnTfParser::ITfParser;
50  using ModelType = InferenceModel<ParserType, DataType>;
51 
52  // Coverity fix: InferenceTestMain() may throw uncaught exceptions.
53  retVal = armnn::test::ClassifierInferenceTestMain<DatabaseType, ParserType>(
54  argc, argv, "inception_v3_2016_08_28_frozen.pb", true,
55  "input", "InceptionV3/Predictions/Reshape_1", { 0, 1, 2, },
56  [&imageSet](const char* dataDir, const ModelType&) {
57  return DatabaseType(dataDir, 299, 299, imageSet);
58  },
59  &inputTensorShape);
60  }
61  catch (const std::exception& e)
62  {
63  // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an
64  // exception of type std::length_error.
65  // Using stderr instead in this context as there is no point in nesting try-catch blocks here.
66  std::cerr << "WARNING: TfInceptionV3-Armnn: An error has occurred when running "
67  "the classifier inference tests: " << e.what() << std::endl;
68  }
69  return retVal;
70 }
DataType
Definition: Types.hpp:32
Parses a directed acyclic graph from a tensorflow protobuf file.
Definition: ITfParser.hpp:25
int main(int argc, char *argv[])