From 6940dd720ebb6b3d1df8ca203ab696daefe58189 Mon Sep 17 00:00:00 2001 From: Jim Flynn Date: Fri, 20 Mar 2020 12:25:56 +0000 Subject: renamed Documentation folder 20.02 and added .nojekyll file Signed-off-by: Jim Flynn --- 20.02/_yolo_database_8cpp_source.xhtml | 133 +++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 20.02/_yolo_database_8cpp_source.xhtml (limited to '20.02/_yolo_database_8cpp_source.xhtml') diff --git a/20.02/_yolo_database_8cpp_source.xhtml b/20.02/_yolo_database_8cpp_source.xhtml new file mode 100644 index 0000000000..d7392014fe --- /dev/null +++ b/20.02/_yolo_database_8cpp_source.xhtml @@ -0,0 +1,133 @@ + + + + + + + + + + + + + +ArmNN: tests/YoloDatabase.cpp Source File + + + + + + + + + + + + + + + + +
+
+ + + + ArmNN + + + +
+
+  20.02 +
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
YoloDatabase.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 "YoloDatabase.hpp"
6 
7 #include <armnn/Exceptions.hpp>
8 #include <armnn/Logging.hpp>
9 
10 #include <array>
11 #include <cstdint>
12 #include <tuple>
13 #include <utility>
14 
15 #include <boost/assert.hpp>
16 #include <boost/format.hpp>
17 #include <boost/numeric/conversion/cast.hpp>
18 
19 #include "InferenceTestImage.hpp"
20 
21 namespace
22 {
23 enum class YoloVocClass : unsigned int
24 {
25  Aeroplane,
26  Bicycle,
27  Bird,
28  Boat,
29  Bottle,
30  Bus,
31  Car,
32  Cat,
33  Chair,
34  Cow,
35  DiningTable,
36  Dog,
37  Horse,
38  Motorbike,
39  Person,
40  PottedPlant,
41  Sheep,
42  Sofa,
43  Train,
44  TvMonitor
45 };
46 
47 template <typename E>
48 constexpr auto to_underlying(E e) noexcept
49 {
50  return static_cast<std::underlying_type_t<E>>(e);
51 }
52 
53 class ImageNotFoundException : public armnn::Exception
54 {
55  using Exception::Exception;
56 };
57 
58 using YoloInputOutput = std::pair<const char* const, YoloDetectedObject>;
59 
60 const std::array<YoloInputOutput,1> g_PerTestCaseInputOutput =
61 {
62  YoloInputOutput{
63  "yolo_dog_448x448.png",
64  { to_underlying(YoloVocClass::Dog), YoloBoundingBox{ 233.0f, 256.0f, 299.0f, 462.0f }, 0.5088733434677124f }
65  },
66 };
67 
68 } // namespace
69 
70 YoloDatabase::YoloDatabase(const std::string& imageDir)
71  : m_ImageDir(imageDir)
72 {
73 }
74 
75 std::unique_ptr<YoloDatabase::TTestCaseData> YoloDatabase::GetTestCaseData(unsigned int testCaseId)
76 {
77  testCaseId = testCaseId % boost::numeric_cast<unsigned int>(g_PerTestCaseInputOutput.size());
78  const auto& testCaseInputOutput = g_PerTestCaseInputOutput[testCaseId];
79  const std::string imagePath = m_ImageDir + testCaseInputOutput.first;
80 
81  // Loads test case input image.
82  std::vector<float> imageData;
83  try
84  {
85  InferenceTestImage image(imagePath.c_str());
86  if (YoloImageWidth != image.GetWidth() || YoloImageHeight != image.GetHeight())
87  {
89  }
91  }
92  catch (const InferenceTestImageException& e)
93  {
94  ARMNN_LOG(fatal) << "Failed to load test case " << testCaseId << " with error: " << e.what();
95  return nullptr;
96  }
97 
98  // Prepares test case output.
99  std::vector<YoloDetectedObject> topObjectDetections;
100  topObjectDetections.reserve(1);
101  topObjectDetections.push_back(testCaseInputOutput.second);
102 
103  return std::make_unique<YoloTestCaseData>(std::move(imageData), std::move(topObjectDetections));
104 }
constexpr unsigned int YoloImageHeight
+ +
virtual const char * what() const noexcept override
Definition: Exceptions.cpp:32
+
#define ARMNN_LOG(severity)
Definition: Logging.hpp:163
+ + + +
std::vector< float > GetImageDataInArmNnLayoutAsNormalizedFloats(ImageChannelLayout layout, const InferenceTestImage &image)
+
YoloVocClass
+
YoloDatabase(const std::string &imageDir)
+
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:33
+
std::unique_ptr< TTestCaseData > GetTestCaseData(unsigned int testCaseId)
+
#define CHECK_LOCATION()
Definition: Exceptions.hpp:192
+ + +
Base class for all ArmNN exceptions so that users can filter to just those.
Definition: Exceptions.hpp:46
+ +
constexpr unsigned int YoloImageWidth
+ +
std::vector< float > Resize(unsigned int newWidth, unsigned int newHeight, const armnn::CheckLocation &location, const ResizingMethods meth=ResizingMethods::STB, const std::array< float, 3 > &mean={{0.0, 0.0, 0.0}}, const std::array< float, 3 > &stddev={{1.0, 1.0, 1.0}}, const float scale=255.0f)
+
+
+ + + + -- cgit v1.2.1