From a3d730afd64a4097b113e245d1ee5cfb21338832 Mon Sep 17 00:00:00 2001 From: Jithendar Reddy Chengalapattu Date: Tue, 14 Jul 2026 11:17:39 +0530 Subject: [PATCH] feat: add OUTPUT_PREDICTION_METADATA config to control ML output metadata Summary of changes: - Add OUTPUT_PREDICTION_METADATA to AlgorithmTest.cproject.yml. - When enabled (1), ML_out.sds includes prediction metadata for Fusion Studio live inference streaming: - Predicted class label - Predicted class confidence score - Predicted class index - When disabled (0), ML_out.sds contains only model class confidence scores for the Arm SDS VS Code extension. - By default, `OUTPUT_PREDICTION_METADATA` is set to `0` --- README.md | 9 +++++++++ .../AppKit-E8_USB/algorithm/AlgorithmTest.cproject.yml | 1 + .../AppKit-E8_USB/algorithm/algorithm_config.h | 7 +++++-- .../AppKit-E8_USB/algorithm/arm_executor_runner.cc | 6 ++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d30bcb9..fe57c30 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,15 @@ The diagram below illustrates the RPS application architecture. During algorithm 1. [Create the input interface](./Documentation/README.md#input-interface-and-signal-conditioning), add signal conditioning, and start capturing data for ML model training. 2. [Select an ML model](./Documentation/README.md#create-ml-model), then use the captured data for training, analysis, and creation of the optimized ML model. 3. [Integrate the ML model](./Documentation/README.md#integrate-ml-model) into the SDS framework and analyze performance. +4. Configure `OUTPUT_PREDICTION_METADATA` based on your workflow: + + **Configuration file:** + `RockPaperScissors/AppKit-E8_USB/algorithm/AlgorithmTest.cproject.yml` + - Set `OUTPUT_PREDICTION_METADATA = 0` to view the generated `.sds` files using the Arm SDS VS Code extension. + - Set `OUTPUT_PREDICTION_METADATA = 1` to enable live inference streaming in Fusion Studio, which parses the prediction metadata (predicted class label, confidence score, and class index) to render overlayed frames. + > [!Note] + > + > By default, `OUTPUT_PREDICTION_METADATA` is set to `0` **Test Embedded Application:** diff --git a/RockPaperScissors/AppKit-E8_USB/algorithm/AlgorithmTest.cproject.yml b/RockPaperScissors/AppKit-E8_USB/algorithm/AlgorithmTest.cproject.yml index 26f1241..e1cad5d 100644 --- a/RockPaperScissors/AppKit-E8_USB/algorithm/AlgorithmTest.cproject.yml +++ b/RockPaperScissors/AppKit-E8_USB/algorithm/AlgorithmTest.cproject.yml @@ -30,6 +30,7 @@ project: - ET_DEBUG_BUFFER_SIZE: 0x8000 - USE_PERFORMANCE_MONITOR - USE_SEGGER_SYSVIEW + - OUTPUT_PREDICTION_METADATA: 0 setups: - setup: Scratch pool for non-simulator diff --git a/RockPaperScissors/AppKit-E8_USB/algorithm/algorithm_config.h b/RockPaperScissors/AppKit-E8_USB/algorithm/algorithm_config.h index 8adc296..18a3f83 100644 --- a/RockPaperScissors/AppKit-E8_USB/algorithm/algorithm_config.h +++ b/RockPaperScissors/AppKit-E8_USB/algorithm/algorithm_config.h @@ -27,9 +27,12 @@ #define ALGO_DATA_IN_BLOCK_SIZE (ML_IMAGE_WIDTH * ML_IMAGE_HEIGHT * 3U) #endif -// Output Data block size, in bytes #ifndef ALGO_DATA_OUT_BLOCK_SIZE -#define ALGO_DATA_OUT_BLOCK_SIZE (MODEL_NUM_CLASSES * sizeof(float)) +#if defined(OUTPUT_PREDICTION_METADATA) && OUTPUT_PREDICTION_METADATA +#define ALGO_DATA_OUT_BLOCK_SIZE (120U) +#else +#define ALGO_DATA_OUT_BLOCK_SIZE (MODEL_NUM_CLASSES * sizeof(float)) +#endif #endif #endif diff --git a/RockPaperScissors/AppKit-E8_USB/algorithm/arm_executor_runner.cc b/RockPaperScissors/AppKit-E8_USB/algorithm/arm_executor_runner.cc index 509e6ce..940882f 100644 --- a/RockPaperScissors/AppKit-E8_USB/algorithm/arm_executor_runner.cc +++ b/RockPaperScissors/AppKit-E8_USB/algorithm/arm_executor_runner.cc @@ -953,9 +953,15 @@ void postprocess(RunnerContext& ctx, uint8_t* img_buf, print_outputs(ctx); /* Copy shortened label plus confidence into caller's output buffer */ +#if OUTPUT_PREDICTION_METADATA + if (out_num >= sizeof(output_label_t)) { + memcpy(out_buf, &output_label, sizeof(output_label)); + } +#else if (out_num >= sizeof(class_probs)) { memcpy(out_buf, class_probs, sizeof(class_probs)); } +#endif /* Only draw if label is valid */ if (output_label.label_name[0] != '\0')