summaryrefslogtreecommitdiff
path: root/source/application/main/include/UseCaseCommonUtils.hpp
diff options
context:
space:
mode:
authorRichard Burton <richard.burton@arm.com>2022-04-07 18:00:55 +0100
committerRichard Burton <richard.burton@arm.com>2022-04-07 18:00:55 +0100
commit11b75cc7dc140119dee490f425e25a004122703b (patch)
treee048484e170c0c3aa9622671f08def0bc5fa6b0e /source/application/main/include/UseCaseCommonUtils.hpp
parent68fdd119f38c37ab28066474086b0e352d991baf (diff)
downloadml-embedded-evaluation-kit-11b75cc7dc140119dee490f425e25a004122703b.tar.gz
MLECO-3079: Implement image classification API
All ML related work for image classification seperated out and accessed via new Runner Further work to improve profiling integration to be done in follow up ticket: MLECO-3154 Signed-off-by: Richard Burton <richard.burton@arm.com> Change-Id: I0fe0550c932241a2d335a560ecb7abc329c934e9
Diffstat (limited to 'source/application/main/include/UseCaseCommonUtils.hpp')
-rw-r--r--source/application/main/include/UseCaseCommonUtils.hpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/source/application/main/include/UseCaseCommonUtils.hpp b/source/application/main/include/UseCaseCommonUtils.hpp
index 9b6d550..f79f6ed 100644
--- a/source/application/main/include/UseCaseCommonUtils.hpp
+++ b/source/application/main/include/UseCaseCommonUtils.hpp
@@ -24,6 +24,7 @@
#include "UseCaseHandler.hpp" /* Handlers for different user options. */
#include "Classifier.hpp" /* Classifier. */
#include "InputFiles.hpp"
+#include "BaseProcessing.hpp"
void DisplayCommonMenu();
@@ -107,6 +108,67 @@ namespace app {
**/
bool ListFilesHandler(ApplicationContext& ctx);
+ /**
+ * @brief Use case runner class that will handle calling pre-processing,
+ * inference and post-processing.
+ * After constructing an instance of this class the user can call
+ * PreProcess(), RunInference() and PostProcess() to perform inference.
+ */
+ class UseCaseRunner {
+
+ private:
+ BasePreProcess* m_preProcess;
+ BasePostProcess* m_postProcess;
+ Model* m_model;
+
+ public:
+ explicit UseCaseRunner(BasePreProcess* preprocess, BasePostProcess* postprocess, Model* model)
+ : m_preProcess{preprocess},
+ m_postProcess{postprocess},
+ m_model{model}
+ {};
+
+ /**
+ * @brief Runs pre-processing as defined by PreProcess object within the runner.
+ * Templated for the input data type.
+ * @param[in] inputData Pointer to the data that inference will be performed on.
+ * @param[in] inputSize Size of the input data that inference will be performed on.
+ * @return true if successful, false otherwise.
+ **/
+ template<typename T>
+ bool PreProcess(T* inputData, size_t inputSize) {
+ if (!this->m_preProcess->DoPreProcess(inputData, inputSize)) {
+ printf_err("Pre-processing failed.");
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * @brief Runs inference with the Model object within the runner.
+ * @return true if successful, false otherwise.
+ **/
+ bool RunInference() {
+ if (!this->m_model->RunInference()) {
+ printf_err("Inference failed.");
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * @brief Runs post-processing as defined by PostProcess object within the runner.
+ * @return true if successful, false otherwise.
+ **/
+ bool PostProcess() {
+ if (!this->m_postProcess->DoPostProcess()) {
+ printf_err("Post-processing failed.");
+ return false;
+ }
+ return true;
+ }
+ };
+
} /* namespace app */
} /* namespace arm */