MCPcopy Create free account
hub / github.com/ARM-software/armnn / ProcessResult

Method ProcessResult

tests/MobileNetSsdInferenceTest.hpp:34–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32 {}
33
34 TestCaseResult ProcessResult(const InferenceTestOptions& options) override
35 {
36 armnn::IgnoreUnused(options);
37
38 // bounding boxes
39 const std::vector<float>& output1 = mapbox::util::get<std::vector<float>>(this->GetOutputs()[0]);
40 ARMNN_ASSERT(output1.size() == k_OutputSize1);
41
42 // classes
43 const std::vector<float>& output2 = mapbox::util::get<std::vector<float>>(this->GetOutputs()[1]);
44 ARMNN_ASSERT(output2.size() == k_OutputSize2);
45
46 // scores
47 const std::vector<float>& output3 = mapbox::util::get<std::vector<float>>(this->GetOutputs()[2]);
48 ARMNN_ASSERT(output3.size() == k_OutputSize3);
49
50 // valid detections
51 const std::vector<float>& output4 = mapbox::util::get<std::vector<float>>(this->GetOutputs()[3]);
52 ARMNN_ASSERT(output4.size() == k_OutputSize4);
53
54 const size_t numDetections = armnn::numeric_cast<size_t>(output4[0]);
55
56 // Check if number of valid detections matches expectations
57 const size_t expectedNumDetections = m_DetectedObjects.size();
58 if (numDetections != expectedNumDetections)
59 {
60 ARMNN_LOG(error) << "Number of detections is incorrect: Expected (" <<
61 expectedNumDetections << ")" << " but got (" << numDetections << ")";
62 return TestCaseResult::Failed;
63 }
64
65 // Extract detected objects from output data
66 std::vector<DetectedObject> detectedObjects;
67 const float* outputData = output1.data();
68 for (unsigned int i = 0u; i < numDetections; i++)
69 {
70 // NOTE: Order of coordinates in output data is yMin, xMin, yMax, xMax
71 float yMin = *outputData++;
72 float xMin = *outputData++;
73 float yMax = *outputData++;
74 float xMax = *outputData++;
75
76 DetectedObject detectedObject(
77 output2.at(i),
78 BoundingBox(xMin, yMin, xMax, yMax),
79 output3.at(i));
80
81 detectedObjects.push_back(detectedObject);
82 }
83
84 std::sort(detectedObjects.begin(), detectedObjects.end());
85 std::sort(m_DetectedObjects.begin(), m_DetectedObjects.end());
86
87 // Compare detected objects with expected results
88 std::vector<DetectedObject>::const_iterator it = detectedObjects.begin();
89 for (unsigned int i = 0; i < numDetections; i++)
90 {
91 if (it == detectedObjects.end())

Callers

nothing calls this directly

Calls 10

push_backMethod · 0.80
GetTestCaseIdMethod · 0.80
BoundingBoxClass · 0.70
IgnoreUnusedFunction · 0.50
GetOutputsMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected