67 [[maybe_unused]]
const EventContext& ctx)
const {
70 const std::size_t n_batches =
75 for (std::size_t batch_idx = 0; batch_idx < n_batches; ++batch_idx) {
77 std::vector<float> inputDataVector;
78 inputDataVector.reserve(
m_batchSize.value() * n_rows * n_cols);
79 for (
const std::vector<std::vector<float>>& imageData :
83 std::vector<float> flatten =
85 inputDataVector.insert(inputDataVector.end(), flatten.begin(),
89 std::vector<int64_t> inputShape = {
m_batchSize.value(), n_rows, n_cols};
92 inputData[
"flatten_input:0"] =
93 std::make_pair(inputShape, std::move(inputDataVector));
95 const std::int64_t n_scores = 10;
97 outputData[
"dense_1/Softmax:0"] = std::make_pair(
98 std::vector<int64_t>{
m_batchSize, n_scores}, std::vector<float>{});
102 auto const& outputScores =
103 std::get<std::vector<float>>(outputData[
"dense_1/Softmax:0"].second);
105 if (outputScores.size() != std::size_t(n_scores *
m_batchSize.value())) {
107 <<
" scores when it should have been "
110 return StatusCode::FAILURE;
113 for (
int img_idx = 0; img_idx <
m_batchSize.value(); img_idx++) {
114 std::span scores(outputScores.begin() + img_idx * n_scores,
115 outputScores.begin() + (img_idx + 1) * n_scores);
116 ATH_MSG_DEBUG(
"Scores for img " << img_idx <<
" of batch " << batch_idx
118 << fmt::format(
"{::.2e}", scores));
119 const auto max_elem = std::ranges::max_element(scores);
121 <<
" has the highest score: " << *max_elem
122 <<
" in img " << img_idx <<
" of batch "
126 return StatusCode::SUCCESS;