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())
133 std::vector<unsigned int> m_TopK = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };