diff options
Diffstat (limited to 'source/application/api/common')
-rw-r--r-- | source/application/api/common/include/Classifier.hpp | 10 | ||||
-rw-r--r-- | source/application/api/common/include/Model.hpp | 12 | ||||
-rw-r--r-- | source/application/api/common/source/Classifier.cc | 22 |
3 files changed, 20 insertions, 24 deletions
diff --git a/source/application/api/common/include/Classifier.hpp b/source/application/api/common/include/Classifier.hpp index d641c22..e4eab01 100644 --- a/source/application/api/common/include/Classifier.hpp +++ b/source/application/api/common/include/Classifier.hpp @@ -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"); @@ -34,6 +34,8 @@ namespace app { /** @brief Constructor. */ Classifier() = default; + virtual ~Classifier() = default; + /** * @brief Gets the top N classification results from the * output vector. @@ -41,8 +43,8 @@ namespace app { * @param[out] vecResults A vector of classification results. * populated by this function. * @param[in] labels Labels vector to match classified classes. - * @param[in] topNCount Number of top classifications to pick. Default is 1. - * @param[in] useSoftmax Whether Softmax normalisation should be applied to output. Default is false. + * @param[in] topNCount Number of top classifications to pick. + * @param[in] useSoftmax Whether Softmax normalisation should be applied to output. * @return true if successful, false otherwise. **/ @@ -65,7 +67,7 @@ namespace app { std::vector<ClassificationResult>& vecResults, const std::vector <std::string>& labels); - private: + protected: /** * @brief Utility function that gets the top N classification results from the * output vector. diff --git a/source/application/api/common/include/Model.hpp b/source/application/api/common/include/Model.hpp index 70c6245..4892757 100644 --- a/source/application/api/common/include/Model.hpp +++ b/source/application/api/common/include/Model.hpp @@ -137,13 +137,13 @@ namespace app { const tflite::Model* m_pModel{nullptr}; /* Tflite model pointer. */ tflite::MicroInterpreter* m_pInterpreter{nullptr}; /* Tflite interpreter. */ tflite::MicroAllocator* m_pAllocator{nullptr}; /* Tflite micro allocator. */ - bool m_inited{false}; /* Indicates whether this object has been initialised. */ - const uint8_t* m_modelAddr{nullptr}; /* Model address */ - uint32_t m_modelSize{0}; /* Model size */ + bool m_inited{false}; /* Indicates whether this object has been initialised. */ + const uint8_t* m_modelAddr{nullptr}; /* Model address */ + uint32_t m_modelSize{0}; /* Model size */ - std::vector<TfLiteTensor*> m_input{}; /* Model's input tensor pointers. */ - std::vector<TfLiteTensor*> m_output{}; /* Model's output tensor pointers. */ - TfLiteType m_type{kTfLiteNoType}; /* Model's data type. */ + std::vector<TfLiteTensor*> m_input{}; /* Model's input tensor pointers. */ + std::vector<TfLiteTensor*> m_output{}; /* Model's output tensor pointers. */ + TfLiteType m_type{kTfLiteNoType}; /* Model's data type. */ }; } /* namespace app */ 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 arm { 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 @@ namespace app { } 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 @@ namespace app { 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"); |