Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] PreProcessor methods missing , e.g. scale() #134

Open
hjander opened this issue Jul 17, 2024 · 1 comment
Open

[Question] PreProcessor methods missing , e.g. scale() #134

hjander opened this issue Jul 17, 2024 · 1 comment

Comments

@hjander
Copy link

hjander commented Jul 17, 2024

i am trying to create a Yolov10 example with openvino-rs 0.7.2

I am trying to replicate this cpp code from here.

void Inference::InitialModel(const std::string &model_path) {
	ov::Core core;
	std::shared_ptr<ov::Model> model = core.read_model(model_path);

	if (model->is_dynamic()) {
		model->reshape({1, 3, static_cast<long int>(model_input_shape_.height), static_cast<long int>(model_input_shape_.width)});
	}

	ov::preprocess::PrePostProcessor ppp = ov::preprocess::PrePostProcessor(model);

  ppp.input().tensor().set_element_type(ov::element::u8).set_layout("NHWC").set_color_format(ov::preprocess::ColorFormat::BGR);
  ppp.input().preprocess().convert_element_type(ov::element::f32)
     .convert_color(ov::preprocess::ColorFormat::RGB).scale({ 255, 255, 255 });
  ppp.input().model().set_layout("NCHW");
  ppp.output().tensor().set_element_type(ov::element::f32);

  model = ppp.build();
	compiled_model_ = core.compile_model(model, "AUTO");
	inference_request_ = compiled_model_.create_infer_request();

	short width, height;

  const std::vector<ov::Output<ov::Node>> inputs = model->inputs();
  const ov::Shape input_shape = inputs[0].get_shape();

	height = input_shape[1];
	width = input_shape[2];
	model_input_shape_ = cv::Size2f(width, height);

  const std::vector<ov::Output<ov::Node>> outputs = model->outputs();
  const ov::Shape output_shape = outputs[0].get_shape();

	height = output_shape[1];
	width = output_shape[2];
	model_output_shape_ = cv::Size(width, height);
}

It seems the convert_color() and scale() methods are missing in openvino-rs PreProcessor though they exist in openvino-sys.

Are there any plans to add those methods or is there a particular method reason not to add them ?

@abrown
Copy link
Contributor

abrown commented Jul 17, 2024

I am completely open to adding those methods if you want to take a stab at it. In these 0.7.* releases we were primarily interested in switching over to OpenVINO's new 2.0 API and not necessarily completeness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants