19 std::vector<std::vector<std::vector<float>>> input_tensor_values;
20 input_tensor_values.resize(10000, std::vector<std::vector<float> >(28,std::vector<float>(28)));
21 std::ifstream
file (full_path.c_str(), std::ios::binary);
23 int number_of_images=0;
26 file.read((
char*)&magic_number,
sizeof(magic_number));
27 magic_number= ntohl(magic_number);
28 file.read((
char*)&number_of_images,
sizeof(number_of_images));
29 number_of_images= ntohl(number_of_images);
30 file.read((
char*)&n_rows,
sizeof(n_rows));
31 n_rows= ntohl(n_rows);
32 file.read((
char*)&n_cols,
sizeof(n_cols));
33 n_cols= ntohl(n_cols);
34 for(
int i=0;
i<number_of_images;++
i)
36 for(
int r=0;
r<n_rows;++
r)
38 for(
int c=0;
c<n_cols;++
c)
41 file.read((
char*)&temp,
sizeof(temp));
42 input_tensor_values[
i][
r][
c]=
float(temp)/255;
46 return input_tensor_values;
53 std::vector<int> output_tensor_values(1*10000);
54 std::ifstream
file (full_path.c_str(), std::ios::binary);
56 int number_of_labels=0;
57 file.read((
char*)&magic_number,
sizeof(magic_number));
58 magic_number= ntohl(magic_number);
59 file.read((
char*)&number_of_labels,
sizeof(number_of_labels));
60 number_of_labels= ntohl(number_of_labels);
61 for(
int i=0;
i<number_of_labels;++
i)
64 file.read((
char*)&temp,
sizeof(temp));
65 output_tensor_values[
i]=
int(temp);
67 return output_tensor_values;
80 ATH_MSG_INFO(
"The total no. of sample crossed the no. of available sample ....");
81 return StatusCode::FAILURE;
89 return StatusCode::SUCCESS;
95 std::vector<float> inputData;
96 for (
int ibatch = 0; ibatch <
m_batchSize; ibatch++){
99 inputData.insert(inputData.end(), flatten.begin(), flatten.end());
102 int64_t batchSize =
m_onnxTool->getBatchSize(inputData.size());
107 std::vector<Ort::Value> inputTensors;
111 std::vector<float> outputScores;
112 std::vector<Ort::Value> outputTensors;
120 for(
int ibatch = 0; ibatch <
m_batchSize; ibatch++){
123 for (
int i = 0;
i < 10;
i++){
124 ATH_MSG_DEBUG(
"Score for class "<<
i <<
" = "<<outputScores[
i] <<
" in batch " << ibatch);
125 int index =
i + ibatch * 10;
131 ATH_MSG_INFO(
"Class: "<<max_index<<
" has the highest score: "<<outputScores[max_index] <<
" in batch " << ibatch);
134 return StatusCode::SUCCESS;
138 return StatusCode::SUCCESS;