Skip to content

Commit 098bf73

Browse files
Removed runtime::Tensor usage (#3901)
1 parent 866e054 commit 098bf73

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

demos/text_detection_demo/cpp/include/text_detection.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class TextDetector : public Cnn {
2323
std::map<std::string, ov::Tensor> Infer(const cv::Mat& frame) override;
2424

2525
std::vector<cv::RotatedRect> postProcess(
26-
const std::map<std::string, ov::runtime::Tensor>& output_tensors, const cv::Size& image_size,
26+
const std::map<std::string, ov::Tensor>& output_tensors, const cv::Size& image_size,
2727
const cv::Size& image_shape, float cls_conf_threshold, float link_conf_threshold);
2828
private:
2929
cv::Mat decodeImageByJoin(

demos/text_detection_demo/cpp/include/text_recognition.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class TextRecognizer : public Cnn {
3030
size_t end_token,
3131
bool use_auto_resize = false);
3232

33-
std::map<std::string, ov::runtime::Tensor> Infer(const cv::Mat& frame) override;
33+
std::map<std::string, ov::Tensor> Infer(const cv::Mat& frame) override;
3434

3535
const cv::Size& input_size() const { return m_input_size; }
3636

demos/text_detection_demo/cpp/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ int main(int argc, char* argv[]) {
254254

255255
std::vector<cv::RotatedRect> rects;
256256
if (text_detector != nullptr) {
257-
std::map<std::string, ov::runtime::Tensor> output_tensors = text_detector->Infer(image);
257+
std::map<std::string, ov::Tensor> output_tensors = text_detector->Infer(image);
258258

259259
std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
260260
rects = text_detector->postProcess(output_tensors, image.size(), text_detector->input_size(),
@@ -306,9 +306,9 @@ int main(int argc, char* argv[]) {
306306
std::string res = "";
307307
double conf = 1.0;
308308
if (text_recognition != nullptr) {
309-
std::map<std::string, ov::runtime::Tensor> output_tensors = text_recognition->Infer(cropped_text);
309+
std::map<std::string, ov::Tensor> output_tensors = text_recognition->Infer(cropped_text);
310310

311-
ov::runtime::Tensor out_tensor = output_tensors.begin()->second;
311+
ov::Tensor out_tensor = output_tensors.begin()->second;
312312
if (FLAGS_tr_o_blb_nm != "") {
313313
const auto& it = output_tensors.find(FLAGS_tr_o_blb_nm);
314314
if (it == output_tensors.end()) {

demos/text_detection_demo/cpp/src/text_detection.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ cv::Mat get_all(const std::vector<cv::Point>& points, int w, int h, std::unorder
171171
} // namespace
172172

173173

174-
std::map<std::string, ov::runtime::Tensor> TextDetector::Infer(const cv::Mat& frame) {
174+
std::map<std::string, ov::Tensor> TextDetector::Infer(const cv::Mat& frame) {
175175
std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
176176

177177
cv::Mat resizedImg = frame;
@@ -184,7 +184,7 @@ std::map<std::string, ov::runtime::Tensor> TextDetector::Infer(const cv::Mat& fr
184184
m_infer_request.infer();
185185

186186
// Processing output
187-
std::map<std::string, ov::runtime::Tensor> output_tensors;
187+
std::map<std::string, ov::Tensor> output_tensors;
188188
for (const auto& output_name : m_output_names) {
189189
output_tensors[output_name] = m_infer_request.get_tensor(output_name);
190190
}
@@ -197,7 +197,7 @@ std::map<std::string, ov::runtime::Tensor> TextDetector::Infer(const cv::Mat& fr
197197
}
198198

199199
std::vector<cv::RotatedRect> TextDetector::postProcess(
200-
const std::map<std::string, ov::runtime::Tensor>& output_tensors,
200+
const std::map<std::string, ov::Tensor>& output_tensors,
201201
const cv::Size& image_size, const cv::Size& input_shape,
202202
float cls_conf_threshold, float link_conf_threshold) {
203203
const int kMinArea = 300;

demos/text_detection_demo/cpp/src/text_recognition.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ TextRecognizer::TextRecognizer(
224224
m_infer_request_decoder = compiled_model_decoder.create_infer_request();
225225
}
226226

227-
std::map<std::string, ov::runtime::Tensor> TextRecognizer::Infer(const cv::Mat& frame) {
227+
std::map<std::string, ov::Tensor> TextRecognizer::Infer(const cv::Mat& frame) {
228228
std::chrono::steady_clock::time_point begin_enc = std::chrono::steady_clock::now();
229229

230230
cv::Mat image;
@@ -243,7 +243,7 @@ std::map<std::string, ov::runtime::Tensor> TextRecognizer::Infer(const cv::Mat&
243243
m_infer_request.infer();
244244

245245
// Processing output
246-
std::map<std::string, ov::runtime::Tensor> output_tensors;
246+
std::map<std::string, ov::Tensor> output_tensors;
247247
for (const auto& output_name : m_output_names) {
248248
output_tensors[output_name] = m_infer_request.get_tensor(output_name);
249249
}
@@ -261,18 +261,18 @@ std::map<std::string, ov::runtime::Tensor> TextRecognizer::Infer(const cv::Mat&
261261
// Processing encoder output
262262
// tensors here are set for concrete network
263263
// in case of different network this needs to be changed or generalized
264-
ov::runtime::Tensor features_tensor = output_tensors[m_features_name];
264+
ov::Tensor features_tensor = output_tensors[m_features_name];
265265
m_infer_request_decoder.set_tensor(m_features_name, features_tensor);
266266

267-
ov::runtime::Tensor out_enc_hidden_tensor = output_tensors[m_out_enc_hidden_name];
267+
ov::Tensor out_enc_hidden_tensor = output_tensors[m_out_enc_hidden_name];
268268
m_infer_request_decoder.set_tensor(m_in_dec_hidden_name, out_enc_hidden_tensor);
269269

270270
float* input_data_decoder = m_infer_request_decoder.get_tensor(m_in_dec_symbol_name).data<float>();
271271

272272
input_data_decoder[0] = 0;
273273
size_t num_classes = m_infer_request_decoder.get_tensor(m_out_dec_symbol_name).get_size();
274274

275-
ov::runtime::Tensor targets(ov::element::f32, { 1, MAX_NUM_DECODER, num_classes });
275+
ov::Tensor targets(ov::element::f32, { 1, MAX_NUM_DECODER, num_classes });
276276
float* data_targets = targets.data<float>();
277277

278278
for (size_t num_decoder = 0; num_decoder < MAX_NUM_DECODER; num_decoder++) {
@@ -290,7 +290,7 @@ std::map<std::string, ov::runtime::Tensor> TextRecognizer::Infer(const cv::Mat&
290290

291291
input_data_decoder[0] = float(argmax);
292292

293-
ov::runtime::Tensor out_enc_hidden_tensor = m_infer_request_decoder.get_tensor(m_out_enc_hidden_name);
293+
ov::Tensor out_enc_hidden_tensor = m_infer_request_decoder.get_tensor(m_out_enc_hidden_name);
294294
m_infer_request_decoder.set_tensor(m_in_dec_hidden_name, out_enc_hidden_tensor);
295295
}
296296

0 commit comments

Comments
 (0)