66 [[maybe_unused]]
const EventContext& ctx)
const {
69 const std::size_t n_batches =
74 for (std::size_t batch_idx = 0; batch_idx < n_batches; ++batch_idx) {
76 std::vector<float> inputDataVector;
77 inputDataVector.reserve(
m_batchSize.value() * n_rows * n_cols);
78 for (
const std::vector<std::vector<float>>& imageData :
82 std::vector<float> flatten =
84 inputDataVector.insert(inputDataVector.end(), flatten.begin(),
88 std::vector<int64_t> inputShape = {
m_batchSize.value(), n_rows, n_cols};
91 inputData[
"flatten_input:0"] =
92 std::make_pair(inputShape, std::move(inputDataVector));
94 const std::int64_t n_scores = 10;
96 outputData[
"dense_1/Softmax:0"] = std::make_pair(
97 std::vector<int64_t>{
m_batchSize, n_scores}, std::vector<float>{});
101 auto const& outputScores =
102 std::get<std::vector<float>>(outputData[
"dense_1/Softmax:0"].second);
104 if (outputScores.size() != std::size_t(n_scores *
m_batchSize.value())) {
106 <<
" scores when it should have been "
109 return StatusCode::FAILURE;
112 for (
int img_idx = 0; img_idx <
m_batchSize.value(); img_idx++) {
113 std::span scores(outputScores.begin() + img_idx * n_scores,
114 outputScores.begin() + (img_idx + 1) * n_scores);
115 ATH_MSG_DEBUG(
"Scores for img " << img_idx <<
" of batch " << batch_idx
117 << fmt::format(
"{::.2e}", scores));
118 const auto max_elem = std::ranges::max_element(scores);
120 <<
" has the highest score: " << *max_elem
121 <<
" in img " << img_idx <<
" of batch "
125 return StatusCode::SUCCESS;