MLECO-3164: Additional refactoring of KWS API
Part 1
* Add KwsClassifier
* KwsPostProcess can now be told to average results
* Averaging is handlded by KwsClassifier
* Current sliding window index is now an argument of DoPreProcess
Change-Id: I07626da595ad1cbd982e8366f0d1bb56d1040459
diff --git a/source/application/api/common/source/Classifier.cc b/source/application/api/common/source/Classifier.cc
index 6fabebe..1b5fc64 100644
--- a/source/application/api/common/source/Classifier.cc
+++ b/source/application/api/common/source/Classifier.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021 Arm Limited. All rights reserved.
+ * Copyright (c) 2021-2022 Arm Limited. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -31,10 +31,9 @@
namespace app {
void Classifier::SetVectorResults(std::set<std::pair<float, uint32_t>>& topNSet,
- std::vector<ClassificationResult>& vecResults,
- const std::vector <std::string>& labels)
+ std::vector<ClassificationResult>& vecResults,
+ const std::vector <std::string>& labels)
{
-
/* Reset the iterator to the largest element - use reverse iterator. */
auto topNIter = topNSet.rbegin();
@@ -46,11 +45,9 @@
}
bool Classifier::GetTopNResults(const std::vector<float>& tensor,
- std::vector<ClassificationResult>& vecResults,
- uint32_t topNCount,
- const std::vector <std::string>& labels)
+ std::vector<ClassificationResult>& vecResults,
+ uint32_t topNCount, const std::vector <std::string>& labels)
{
-
std::set<std::pair<float , uint32_t>> sortedSet;
/* NOTE: inputVec's size verification against labels should be
@@ -80,12 +77,9 @@
return true;
}
- bool Classifier::GetClassificationResults(
- TfLiteTensor* outputTensor,
- std::vector<ClassificationResult>& vecResults,
- const std::vector <std::string>& labels,
- uint32_t topNCount,
- bool useSoftmax)
+ bool Classifier::GetClassificationResults(TfLiteTensor* outputTensor,
+ std::vector<ClassificationResult>& vecResults, const std::vector <std::string>& labels,
+ uint32_t topNCount, bool useSoftmax)
{
if (outputTensor == nullptr) {
printf_err("Output vector is null pointer.\n");