MCPcopy Create free account
hub / github.com/OAID/Tengine / PrintTopLabels_uint8

Function PrintTopLabels_uint8

internal/bin/classification.cpp:140–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138}
139
140void PrintTopLabels_uint8(const char* label_file, uint8_t* data, int data_size, float scale, int zero_point)
141{
142 std::vector<std::string> labels;
143 LoadLabelFile(labels, label_file);
144
145 std::vector<float> result;
146 for(int i = 0; i < data_size; i++)
147 result.push_back((data[i] - zero_point) * scale);
148
149 std::vector<int> top_N = Argmax(result, 5);
150
151 for(unsigned int i = 0; i < top_N.size(); i++)
152 {
153 int idx = top_N[i];
154 std::cout << std::fixed << std::setprecision(4) << result[idx] << " - \"" << labels[idx] << "\"\n";
155 }
156}
157
158bool run_tengine_library(const char* model_format, const int model_fnum, const char* proto_file, const char* model_file,
159 const char* label_file, const char* image_file, const int img_h, const int img_w,

Callers 1

run_tengine_libraryFunction · 0.85

Calls 3

LoadLabelFileFunction · 0.70
ArgmaxFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected