@@ -32,10 +32,10 @@ ClassificationModel::ClassificationModel(const std::string& modelFileName, size_
32
32
labels(labels) {}
33
33
34
34
std::unique_ptr<ResultBase> ClassificationModel::postprocess (InferenceResult& infResult) {
35
- const ov::Tensor& scoresTensor = infResult.outputsData .find (outputsNames[0 ])->second ;
36
- const float * scoresPtr = scoresTensor.data <float >();
37
- const ov::Tensor& indicesTensor = infResult.outputsData .find (outputsNames[1 ])->second ;
35
+ const ov::Tensor& indicesTensor = infResult.outputsData .find (outputsNames[0 ])->second ;
38
36
const int * indicesPtr = indicesTensor.data <int >();
37
+ const ov::Tensor& scoresTensor = infResult.outputsData .find (outputsNames[1 ])->second ;
38
+ const float * scoresPtr = scoresTensor.data <float >();
39
39
40
40
ClassificationResult* result = new ClassificationResult (infResult.frameId , infResult.metaData );
41
41
auto retVal = std::unique_ptr<ResultBase>(result);
@@ -165,13 +165,20 @@ void ClassificationModel::prepareInputsOutputs(std::shared_ptr<ov::Model>& model
165
165
ov::op::v3::TopK::Mode::MAX,
166
166
ov::op::v3::TopK::SortType::SORT_VALUES);
167
167
168
- auto scores = std::make_shared<ov::op::v0::Result>(topkNode->output (0 ));
169
- auto indices = std::make_shared<ov::op::v0::Result>(topkNode->output (1 ));
168
+ auto indices = std::make_shared<ov::op::v0::Result>(topkNode->output (0 ));
169
+ auto scores = std::make_shared<ov::op::v0::Result>(topkNode->output (1 ));
170
170
ov::ResultVector res ({ scores, indices });
171
171
model = std::make_shared<ov::Model>(res, model->get_parameters (), " classification" );
172
+
172
173
// manually set output tensors name for created topK node
173
- model->outputs ()[0 ].set_names ({" indices" });
174
+ model->outputs ()[0 ].set_names ({ " indices" });
174
175
outputsNames.push_back (" indices" );
175
- model->outputs ()[1 ].set_names ({" scores" });
176
+ model->outputs ()[1 ].set_names ({ " scores" });
176
177
outputsNames.push_back (" scores" );
178
+
179
+ // set output precisions
180
+ ppp = ov::preprocess::PrePostProcessor (model);
181
+ ppp.output (" indices" ).tensor ().set_element_type (ov::element::i32 );
182
+ ppp.output (" scores" ).tensor ().set_element_type (ov::element::f32 );
183
+ model = ppp.build ();
177
184
}
0 commit comments