Repository navigation
Replies: 2 comments
|
@cansik From what I can tell, there isn't an OpenVINO equivalent of However, you do have a couple of options:
For example, the graph rewrite would conceptually look like: auto new_score = ov::op::v0::Constant::create(...);
auto new_iou = ov::op::v0::Constant::create(...);
// Recreate NMS with the desired constants
// or replace the corresponding constant inputs.I couldn't find a standalone GUI or CLI tool that performs this kind of IR editing automatically, so if your only artifact is the OpenVINO IR, the supported approach appears to be modifying the graph through the OpenVINO Runtime/Transformation API. One question:
That determines whether it's easier to modify the graph before conversion or perform a graph rewrite on the IR itself. If this solves your problem, feel free to mark it as the accepted answer so others can find it easily. |
|
You can edit the IR directly by replacing the two NMS input edges. For a model with one import openvino as ov
from openvino import opset13 as ops
model = ov.Core().read_model("model.xml")
nodes = [n for n in model.get_ops()
if n.get_type_name() == "NonMaxSuppression"]
if len(nodes) != 1:
raise ValueError("Select the intended NMS node by its friendly name")
nms = nodes[0]
if nms.get_input_size() < 5:
raise ValueError("This example requires existing threshold inputs")
for index, value in ((3, 0.5), (4, 0.25)): # IoU, score
port = nms.input(index)
replacement = ops.constant(value, dtype=port.get_element_type())
port.replace_source_output(replacement.output(0))
model.validate_nodes_and_infer_types()
ov.save_model(model, "edited.xml", compress_to_fp16=False)The NMS input order makes these zero-based ports 3 and 4. Replacing the input edge leaves other consumers of a shared constant alone. Load/compile the edited model afterward. Checked on a synthetic shared-constant NMS graph with OpenVINO 2026.4.1, including save/reload and CPU inference. Your model was not tested. |
Uh oh!
There was an error while loading. Please reload this page.
I am currently working with a model that contains a
NonMaxSuppressionoperator with fixed score and iou threshold. Does anyone know a tool like onnx-modifier to change openvino models and weights and adjust the constants?All reactions