70 [[maybe_unused]]
const EventContext& ctx)
const {
73 const std::size_t n_batches =
78 for (std::size_t batch_idx = 0; batch_idx < n_batches; ++batch_idx) {
80 std::vector<float> inputDataVector;
81 inputDataVector.reserve(
m_batchSize.value() * n_rows * n_cols);
82 for (
const std::vector<std::vector<float>>& imageData :
86 std::vector<float> flatten =
88 inputDataVector.insert(inputDataVector.end(), flatten.begin(),
92 std::vector<int64_t> inputShape = {
m_batchSize.value(), n_rows, n_cols};
95 inputData[
"flatten_input:0"] =
96 std::make_pair(inputShape, std::move(inputDataVector));
98 const std::int64_t n_scores = 10;
100 outputData[
"dense_1/Softmax:0"] = std::make_pair(
101 std::vector<int64_t>{
m_batchSize, n_scores}, std::vector<float>{});
105 auto const& outputScores =
106 std::get<std::vector<float>>(outputData[
"dense_1/Softmax:0"].second);
108 if (outputScores.size() != std::size_t(n_scores *
m_batchSize.value())) {
110 <<
" scores when it should have been "
113 return StatusCode::FAILURE;
116 for (
int img_idx = 0; img_idx <
m_batchSize.value(); img_idx++) {
117 std::span scores(outputScores.begin() + img_idx * n_scores,
118 outputScores.begin() + (img_idx + 1) * n_scores);
119 ATH_MSG_DEBUG(
"Scores for img " << img_idx <<
" of batch " << batch_idx
121 << fmt::format(
"{::.2e}", scores));
122 const auto max_elem = std::ranges::max_element(scores);
124 <<
" has the highest score: " << *max_elem
125 <<
" in img " << img_idx <<
" of batch "
129 return StatusCode::SUCCESS;