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)
94 armnn::INetworkPtr net = CreateDetectionPostProcessNetwork<T>(boxEncodingsInfo, scoresInfo,
95 anchorsInfo, anchors, useRegularNms);
99 std::map<int, std::vector<T>> inputTensorData = {{ 0, boxEncodings }, { 1, scores }};
100 std::map<int, std::vector<float>> expectedOutputData = {{ 0, expectedDetectionBoxes },
101 { 1, expectedDetectionClasses },
102 { 2, expectedDetectionScores },
103 { 3, expectedNumDetections }};
105 EndToEndLayerTestImpl<ArmnnType, armnn::DataType::Float32>(
106 move(net), inputTensorData, expectedOutputData, backends);
109 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
110 void DetectionPostProcessRegularNmsEndToEnd(
const std::vector<BackendId>& backends,
111 const std::vector<T>& boxEncodings,
112 const std::vector<T>& scores,
113 const std::vector<T>& anchors,
114 float boxScale = 1.0f,
115 int32_t boxOffset = 0,
116 float scoreScale = 1.0f,
117 int32_t scoreOffset = 0,
118 float anchorScale = 1.0f,
119 int32_t anchorOffset = 0)
121 std::vector<float> expectedDetectionBoxes({
122 0.0f, 10.0f, 1.0f, 11.0f,
123 0.0f, 10.0f, 1.0f, 11.0f,
124 0.0f, 0.0f, 0.0f, 0.0f
126 std::vector<float> expectedDetectionScores({ 0.95f, 0.93f, 0.0f });
127 std::vector<float> expectedDetectionClasses({ 1.0f, 0.0f, 0.0f });
128 std::vector<float> expectedNumDetections({ 2.0f });
130 DetectionPostProcessEndToEnd<ArmnnType>(backends,
true, boxEncodings, scores, anchors,
131 expectedDetectionBoxes, expectedDetectionClasses,
132 expectedDetectionScores, expectedNumDetections,
133 boxScale, boxOffset, scoreScale, scoreOffset,
134 anchorScale, anchorOffset);
139 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
140 void DetectionPostProcessFastNmsEndToEnd(
const std::vector<BackendId>& backends,
141 const std::vector<T>& boxEncodings,
142 const std::vector<T>& scores,
143 const std::vector<T>& anchors,
144 float boxScale = 1.0f,
145 int32_t boxOffset = 0,
146 float scoreScale = 1.0f,
147 int32_t scoreOffset = 0,
148 float anchorScale = 1.0f,
149 int32_t anchorOffset = 0)
151 std::vector<float> expectedDetectionBoxes({
152 0.0f, 10.0f, 1.0f, 11.0f,
153 0.0f, 0.0f, 1.0f, 1.0f,
154 0.0f, 100.0f, 1.0f, 101.0f
156 std::vector<float> expectedDetectionScores({ 0.95f, 0.9f, 0.3f });
157 std::vector<float> expectedDetectionClasses({ 1.0f, 0.0f, 0.0f });
158 std::vector<float> expectedNumDetections({ 3.0f });
160 DetectionPostProcessEndToEnd<ArmnnType>(backends,
false, boxEncodings, scores, anchors,
161 expectedDetectionBoxes, expectedDetectionClasses,
162 expectedDetectionScores, expectedNumDetections,
163 boxScale, boxOffset, scoreScale, scoreOffset,
164 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 SetConstant(const bool IsConstant=true)
Marks the data corresponding to this tensor info as constant.
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={})