Skip to content

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

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

Open
hjander opened this issue Jul 17, 2024 · 3 comments
Open

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

hjander opened this issue Jul 17, 2024 · 3 comments

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.

@j99ca
Copy link

j99ca commented Apr 10, 2025

@abrown I am also running into this issue. Is there any plan to extend the preprocessing functionality to include scale() and mean()?

@abrown
Copy link
Contributor

abrown commented Apr 15, 2025

Sure, contributions to add more methods to cover missing parts of the API are always welcome! Are you interested?

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

3 participants