62 [[maybe_unused]]
const EventContext& ctx)
const {
65 const std::size_t n_batches =
70 for (std::size_t batch_idx = 0; batch_idx < n_batches; ++batch_idx) {
72 std::vector<float> inputDataVector;
73 inputDataVector.reserve(
m_batchSize.value() * n_rows * n_cols);
74 for (
const std::vector<std::vector<float>>& imageData :
78 std::vector<float> flatten =
80 inputDataVector.insert(inputDataVector.end(), flatten.begin(),
84 std::vector<int64_t> inputShape = {
m_batchSize.value(), n_rows, n_cols};
87 inputData[
"flatten_input:0"] =
88 std::make_pair(inputShape, std::move(inputDataVector));
90 const std::int64_t n_scores = 10;
92 outputData[
"dense_1/Softmax:0"] = std::make_pair(
93 std::vector<int64_t>{
m_batchSize, n_scores}, std::vector<float>{});
97 auto const& outputScores =
98 std::get<std::vector<float>>(outputData[
"dense_1/Softmax:0"].second);
100 if (outputScores.size() != std::size_t(n_scores *
m_batchSize.value())) {
102 <<
" scores when it should have been "
105 return StatusCode::FAILURE;
108 for (
int img_idx = 0; img_idx <
m_batchSize.value(); img_idx++) {
109 std::span scores(outputScores.begin() + img_idx * n_scores,
110 outputScores.begin() + (img_idx + 1) * n_scores);
111 ATH_MSG_DEBUG(
"Scores for img " << img_idx <<
" of batch " << batch_idx
114 const auto max_elem = std::ranges::max_element(scores);
116 <<
" has the highest score: " << *max_elem
117 <<
" in img " << img_idx <<
" of batch "
121 return StatusCode::SUCCESS;