11 #include <mapbox/variant.hpp>
22 using namespace armnn;
34 std::vector<std::string>
35 SplitBy(
const std::string& originalString,
const std::string& delimiter =
" ",
bool includeEmptyToken =
false);
43 std::string
Strip(
const std::string& originalString,
const std::string& characterSet =
" ");
56 const std::vector<LabelCategoryNames>& modelOutputLabels);
72 template <
typename TContainer>
73 void AddImageResult(
const std::string& imageName, std::vector<TContainer> outputTensor)
78 std::map<int, float> confidenceMap;
79 auto& output = outputTensor[0];
82 mapbox::util::apply_visitor([&confidenceMap](
auto && value)
85 for (
const auto & o : value)
89 confidenceMap.insert(std::pair<int, float>(index,
static_cast<float>(o)));
97 typedef std::function<bool(std::pair<int, float>, std::pair<int, float>)> Comparator;
99 Comparator compFunctor =
100 [](std::pair<int, float> element1, std::pair<int, float> element2)
102 return element1.second > element2.second;
106 std::set<std::pair<int, float>, Comparator> setOfPredictions(
107 confidenceMap.begin(), confidenceMap.end(), compFunctor);
109 const std::string correctLabel = m_GroundTruthLabelSet.at(imageName);
111 unsigned int index = 1;
112 for (std::pair<int, float> element : setOfPredictions)
114 if (index >= m_TopK.size())
120 const LabelCategoryNames predictionLabels = m_ModelOutputLabels[
static_cast<size_t>(element.first)];
121 if (std::find(predictionLabels.begin(), predictionLabels.end(), correctLabel) != predictionLabels.end())
131 const std::map<std::string, std::string> m_GroundTruthLabelSet;
132 const std::vector<LabelCategoryNames> m_ModelOutputLabels;
133 std::vector<unsigned int> m_TopK = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
134 unsigned int m_ImagesProcessed = 0;