13 #include <doctest/doctest.h> 21 const std::vector<T>& anchors,
31 desc.m_MaxDetections = 3;
32 desc.m_MaxClassesPerDetection = 1;
33 desc.m_DetectionsPerClass =1;
34 desc.m_NmsScoreThreshold = 0.0;
35 desc.m_NmsIouThreshold = 0.5;
36 desc.m_NumClasses = 2;
48 "DetectionPostProcess");
53 Connect(boxesLayer, detectionLayer, boxEncodingsInfo, 0, 0);
54 Connect(scoresLayer, detectionLayer, scoresInfo, 0, 1);
55 Connect(detectionLayer, detectionBoxesLayer, detectionBoxesInfo, 0, 0);
56 Connect(detectionLayer, detectionClassesLayer, detectionClassesInfo, 1, 0);
57 Connect(detectionLayer, detectionScoresLayer, detectionScoresInfo, 2, 0);
58 Connect(detectionLayer, numDetectionLayer, numDetectionInfo, 3, 0);
63 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
64 void DetectionPostProcessEndToEnd(
const std::vector<BackendId>& backends,
bool useRegularNms,
65 const std::vector<T>& boxEncodings,
66 const std::vector<T>& scores,
67 const std::vector<T>& anchors,
68 const std::vector<float>& expectedDetectionBoxes,
69 const std::vector<float>& expectedDetectionClasses,
70 const std::vector<float>& expectedDetectionScores,
71 const std::vector<float>& expectedNumDetections,
72 float boxScale = 1.0f,
73 int32_t boxOffset = 0,
74 float scoreScale = 1.0f,
75 int32_t scoreOffset = 0,
76 float anchorScale = 1.0f,
77 int32_t anchorOffset = 0)
91 armnn::INetworkPtr net = CreateDetectionPostProcessNetwork<T>(boxEncodingsInfo, scoresInfo,
92 anchorsInfo, anchors, useRegularNms);
96 std::map<int, std::vector<T>> inputTensorData = {{ 0, boxEncodings }, { 1, scores }};
97 std::map<int, std::vector<float>> expectedOutputData = {{ 0, expectedDetectionBoxes },
98 { 1, expectedDetectionClasses },
99 { 2, expectedDetectionScores },
100 { 3, expectedNumDetections }};
102 EndToEndLayerTestImpl<ArmnnType, armnn::DataType::Float32>(
103 move(net), inputTensorData, expectedOutputData, backends);
106 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
107 void DetectionPostProcessRegularNmsEndToEnd(
const std::vector<BackendId>& backends,
108 const std::vector<T>& boxEncodings,
109 const std::vector<T>& scores,
110 const std::vector<T>& anchors,
111 float boxScale = 1.0f,
112 int32_t boxOffset = 0,
113 float scoreScale = 1.0f,
114 int32_t scoreOffset = 0,
115 float anchorScale = 1.0f,
116 int32_t anchorOffset = 0)
118 std::vector<float> expectedDetectionBoxes({
119 0.0f, 10.0f, 1.0f, 11.0f,
120 0.0f, 10.0f, 1.0f, 11.0f,
121 0.0f, 0.0f, 0.0f, 0.0f
123 std::vector<float> expectedDetectionScores({ 0.95f, 0.93f, 0.0f });
124 std::vector<float> expectedDetectionClasses({ 1.0f, 0.0f, 0.0f });
125 std::vector<float> expectedNumDetections({ 2.0f });
127 DetectionPostProcessEndToEnd<ArmnnType>(backends,
true, boxEncodings, scores, anchors,
128 expectedDetectionBoxes, expectedDetectionClasses,
129 expectedDetectionScores, expectedNumDetections,
130 boxScale, boxOffset, scoreScale, scoreOffset,
131 anchorScale, anchorOffset);
136 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
137 void DetectionPostProcessFastNmsEndToEnd(
const std::vector<BackendId>& backends,
138 const std::vector<T>& boxEncodings,
139 const std::vector<T>& scores,
140 const std::vector<T>& anchors,
141 float boxScale = 1.0f,
142 int32_t boxOffset = 0,
143 float scoreScale = 1.0f,
144 int32_t scoreOffset = 0,
145 float anchorScale = 1.0f,
146 int32_t anchorOffset = 0)
148 std::vector<float> expectedDetectionBoxes({
149 0.0f, 10.0f, 1.0f, 11.0f,
150 0.0f, 0.0f, 1.0f, 1.0f,
151 0.0f, 100.0f, 1.0f, 101.0f
153 std::vector<float> expectedDetectionScores({ 0.95f, 0.9f, 0.3f });
154 std::vector<float> expectedDetectionClasses({ 1.0f, 0.0f, 0.0f });
155 std::vector<float> expectedNumDetections({ 3.0f });
157 DetectionPostProcessEndToEnd<ArmnnType>(backends,
false, boxEncodings, scores, anchors,
158 expectedDetectionBoxes, expectedDetectionClasses,
159 expectedDetectionScores, expectedNumDetections,
160 boxScale, boxOffset, scoreScale, scoreOffset,
161 anchorScale, anchorOffset);
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
void SetQuantizationScale(float scale)
bool m_UseRegularNms
Use Regular NMS.
void SetQuantizationOffset(int32_t offset)
void Connect(armnn::IConnectableLayer *from, armnn::IConnectableLayer *to, const armnn::TensorInfo &tensorInfo, unsigned int fromIndex, unsigned int toIndex)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
static INetworkPtr Create(NetworkOptions networkOptions={})