63 [[maybe_unused]]
const EventContext& ctx)
const {
66 const std::size_t n_batches =
71 for (std::size_t batch_idx = 0; batch_idx < n_batches; ++batch_idx) {
73 std::vector<float> inputDataVector;
74 inputDataVector.reserve(
m_batchSize.value() * n_rows * n_cols);
75 for (
const std::vector<std::vector<float>>& imageData :
79 std::vector<float> flatten =
81 inputDataVector.insert(inputDataVector.end(), flatten.begin(),
85 std::vector<int64_t> inputShape = {
m_batchSize.value(), n_rows, n_cols};
88 inputData[
"flatten_input:0"] =
89 std::make_pair(inputShape, std::move(inputDataVector));
91 const std::int64_t n_scores = 10;
93 outputData[
"dense_1/Softmax:0"] = std::make_pair(
94 std::vector<int64_t>{
m_batchSize, n_scores}, std::vector<float>{});
98 auto const& outputScores =
99 std::get<std::vector<float>>(outputData[
"dense_1/Softmax:0"].second);
101 if (outputScores.size() != std::size_t(n_scores *
m_batchSize.value())) {
103 <<
" scores when it should have been "
106 return StatusCode::FAILURE;
109 for (
int img_idx = 0; img_idx <
m_batchSize.value(); img_idx++) {
110 std::span scores(outputScores.begin() + img_idx * n_scores,
111 outputScores.begin() + (img_idx + 1) * n_scores);
112 ATH_MSG_DEBUG(
"Scores for img " << img_idx <<
" of batch " << batch_idx
115 const auto max_elem = std::ranges::max_element(scores);
117 <<
" has the highest score: " << *max_elem
118 <<
" in img " << img_idx <<
" of batch "
122 return StatusCode::SUCCESS;