YOLO11s-seg Random bounding boxes and masks clustered in top left corner coordinates using DeepStream + TensorRT

• Hardware Platform (Jetson / GPU) Jetson Orin NX 16 GB
• DeepStream Version 7.0
• JetPack Version (valid for Jetson only) 6.0
• TensorRT Version 8.6.2.3
• Issue Type( questions, new requirements, bugs) bugs

I am experiencing the same issue described in the following reports:

In my case, the bounding boxes are also incorrectly positioned, with detections appearing clustered in the corner instead of around the actual objects.

I think I have identified the root cause, at least in my case.

I inspected the values coming from the C++ parser, and they look essentially random. In particular, some bounding-box coordinates are negative or greater than 1, and some confidence values are also outside the expected [0, 1] range.

For example, I added the following debug output to the parser:

static std::vector<NvDsInferInstanceMaskInfo>
decodeTensorYoloSeg(const float* output, size_t outputSize, size_t channelsSize, uint netW, uint netH,
    const std::vector<float>& preclusterThreshold)
{
    ...

    printf("\n%f, %f, %f, %f, %d, %d, %d, %f",
           x1, y1, x2, y2, netW, netH, maxIndex, maxProb);

    ...
}

The output is, for example:

0.828446, -1.513429, -1.210902, 0.919769, 640, 640, 3, 0.398672
-0.107532, 1.664590, 1.283733, 1.328371, 640, 640, 0, 1.189092
0.746693, -2.430774, 1.200745, 0.771150, 640, 640, 3, 1.503525
-1.094395, 0.714550, -1.481603, 1.571921, 640, 640, 1, 1.625027
0.536440, -0.117699, 0.957577, -0.133905, 640, 640, 0, 2.352473
...

These values strongly suggest that the problem occurs before the parser itself, i.e. that the tensor being parsed does not contain valid YOLO detections.

ONNX investigation

I then inspected the ONNX model generated using the export_yolo11_seg.py script:

I generated the model with:

python export_yolo11_seg.py -w model.pt -s 640

While inspecting the resulting ONNX graph, I noticed that it contains several random-number operators, including:

name = node_randn op_type = RandomNormalLike domain = inputs = ['val_288'] outputs = ['randn']
name = node_ConstantOfShape_287 op_type = ConstantOfShape domain = inputs = ['val_289'] outputs = ['val_290']
name = node_randn_1 op_type = RandomNormalLike domain = inputs = ['val_290'] outputs = ['randn_1']
name = node_RandomUniformLike_289 op_type = RandomUniformLike domain = inputs = ['val_290'] outputs = ['val_292']
name = node_Mul_294 op_type = Mul domain = inputs = ['val_292', 'val_296'] outputs = ['val_297']
name = node_Floor_296 op_type = Floor domain = inputs = ['val_297'] outputs = ['val_299']
name = node_randint_1 op_type = Cast domain = inputs = ['val_299'] outputs = ['randint_1']
name = node_RandomUniformLike_298 op_type = RandomUniformLike domain = inputs = ['val_290'] outputs = ['val_301']
name = node_Mul_303 op_type = Mul domain = inputs = ['val_301', 'val_305'] outputs = ['val_306']
name = node_Floor_305 op_type = Floor domain = inputs = ['val_306'] outputs = ['val_308']
name = node_randint_2 op_type = Cast domain = inputs = ['val_308'] outputs = ['randint_2']
name = node_view_23 op_type = Reshape domain = inputs = ['randint_2', 'val_320'] outputs = ['view_23']
name = node_Unsqueeze_325 op_type = Unsqueeze domain = inputs = ['view_23', 'val_325'] outputs = ['val_328']
name = node_Concat_326 op_type = Concat domain = inputs = ['val_326', 'val_328'] outputs = ['val_329']
name = node_GatherND_327 op_type = GatherND domain = inputs = ['slice_3', 'val_329'] outputs = ['val_330']
name = node_ConstantOfShape_329 op_type = ConstantOfShape domain = inputs = ['val_331'] outputs = ['val_332']
name = node_randn_2 op_type = RandomNormalLike domain = inputs = ['val_332'] outputs = ['randn_2']
name = node_unsqueeze_2 op_type = Unsqueeze domain = inputs = ['val_330', 'val_286'] outputs = ['unsqueeze_2']
name = node_view_24 op_type = Reshape domain = inputs = ['randn_2'] outputs = ['view_24']
name = node_matmul_2 op_type = MatMul domain = inputs = ['unsqueeze_2', 'view_24'] outputs = ['matmul_2']
name = node_sigmoid_1 op_type = Sigmoid domain = inputs = ['matmul_2'] outputs = ['sigmoid_1']
name = node_view_25 op_type = Reshape domain = ['sigmoid_1'] outputs = ['view_25']
name = node_unsqueeze_3 op_type = Unsqueeze domain = inputs = ['randn_1'] outputs = ['unsqueeze_3']
name = node_unsqueeze_4 op_type = Unsqueeze domain = inputs = ['randint_1'] outputs = ['unsqueeze_4']
name = node_convert_element_type_default op_type = Cast domain = inputs = ['unsqueeze_4'] outputs = ['convert_element_type_default']
name = node_cat_25 op_type = Concat domain = inputs = ['randn', 'unsqueeze_3', 'convert_element_type_default', 'view_25'] outputs = ['output']

This is particularly concerning because these random operators appear to be part of the graph that produces the model output.

TensorRT engine investigation

I also inspected the TensorRT engine generated with:

trtexec --onnx=model.onnx --saveEngine=model.engine

Using:

trtexec --onnx=model.onnx \
        --dumpLayerInfo \
        --profilingVerbosity=detailed

I can see the same random-number operations being executed by TensorRT.

For example:

[10/08/2026-17:13:12] [I]        0.99       0.0160       0.0146       0.0   node_randn
[10/08/2026-17:13:12] [I]        0.78       0.0126       0.0126       0.0   node_randn_1
[10/08/2026-10-08-17:13:12] [I]      538.47       8.6850       8.6363      16.4   node_randn_2
[10/08/2026-17:13:12] [I]      539.88       8.7078       8.6137       16.5   node_matmul_2
[10/08/2026-17:13:12] [I]       29.32       0.4729       0.4727        0.9   PWN(node_sigmoid_1)
[10/08/2026-17:13:12] [I]       30.64       0.4942       0.4940        0.9   node_view_25_copy_output

More importantly, --dumpLayerInfo explicitly reports these operations as TensorRT Fill layers with RANDOM_NORMAL:

Name: node_randn,
LayerType: Fill,
Inputs: [],
Outputs: [
    { Name: randn, Location: Device,
      Dimensions: [1,100,4],
      Format/Datatype: Row major linear FP32 }
],
ParameterType: Fill,
Op: RANDOM_NORMAL,
dimension: [1,100,4],
alpha: 0,
beta: 1,
TacticValue: 0x0000000000000000,
StreamId: 0,
Metadata: [ONNX Layer: node_randn]

Similarly:

Name: node_randn_1,
LayerType: Fill,
...
Dimensions: [1,100],
...
Op: RANDOM_NORMAL,
dimension: [1,100]

and:

Name: node_randn_2,
LayerType: Fill,
...
Dimensions: [100,32,160,160],
...
Op: RANDOM_NORMAL,
dimension: [100,32,160,160]

Therefore, these are not merely unused nodes left in the ONNX graph: TensorRT actually imports them and executes them during inference.

Relation with NMS and ROIAlign

Looking back at the conversion script, I noticed that the NMS and ROIAlign implementations used during export contain placeholder random operations in their forward() methods.

For example, the NMS implementation contains:

num_detections = torch.randint(
    0, max_output_boxes, (batch_size, 1), dtype=torch.int32
)

detection_boxes = torch.randn(
    batch_size, max_output_boxes, 4
)

detection_scores = torch.randn(
    batch_size, max_output_boxes
)

detection_classes = torch.randint(
    0, num_classes, (batch_size, max_output_boxes),
    dtype=torch.int32
)

detections_indices = torch.randint(
    0, max_output_boxes, (batch_size, max_output_boxes),
    dtype=torch.int32
)

These appear to be placeholders intended to represent the outputs of the corresponding TensorRT plugins during export.

However, in the exported ONNX graph, these operations are preserved as actual RandomNormalLike, RandomUniformLike, etc. nodes.

Consequently, when TensorRT builds the engine from this ONNX model, it appears to interpret them as actual runtime operations rather than as placeholders for:

TRT::EfficientNMSX_TRT
TRT::ROIAlignX_TRT

In fact, when inspecting the generated engine, I cannot find any evidence of TRT::EfficientNMSX_TRT or TRT::ROIAlignX_TRT. Instead, I see the corresponding random Fill layers.

This would also explain the apparently random values reaching the DeepStream parser.

Additional test

I performed one more test to verify that these nodes are actually propagated through the export/build process.

I replaced the torch.randn() operations in the Python export code with torch.zeros() and then with torch.ones().

In both cases, the generated ONNX model and TensorRT engine contained the corresponding node_zeros / node_ones operations instead of the random nodes.

This seems to confirm that these operations are not being removed or treated as symbolic placeholders during export: they are actually being serialized into the ONNX graph and subsequently executed by TensorRT.

Possible cause / question

At this point, I am not sure what the correct fix should be.

My suspicion is that the export script is relying on placeholder operations for EfficientNMS and ROIAlign, but under my current combination of Ultralytics / PyTorch / ONNX / TensorRT versions these placeholders are being exported as real operators instead of being replaced by the corresponding TensorRT plugins.

It could therefore be related to a version incompatibility or a change in the Ultralytics ONNX export pipeline.

Could you please check whether you can reproduce this behavior by inspecting the generated .onnx and .engine files?

In particular, it would be useful to verify whether:

  1. the exported ONNX model contains RandomNormalLike / RandomUniformLike nodes;
  2. the TensorRT engine contains Fill layers with Op: RANDOM_NORMAL;
  3. TRT::EfficientNMSX_TRT and TRT::ROIAlignX_TRT are actually present in the generated engine;
  4. the behavior depends on the versions of Ultralytics, PyTorch, ONNX, ONNX Runtime, or TensorRT.

If the same random nodes are present in other environments as well, I think this could explain the incorrect/random bounding boxes and segmentation outputs reported in these issues.

Hello @iamvince!

Based on the title and content of your topic, it looks like it may receive better visibility and feedback in a different category. We took the liberty of moving it for you.

If this was an incorrect assessment, please send me a direct message.

Disclaimer: this moderation suggestion and message were generated with AI assistance.

This fixed the issue for me.

1. Modify the ONNX export script

In export_yolo11_seg.py, add dynamo=False to torch.onnx.export():

torch.onnx.export(
    ...,
    dynamo=False,
)

The script uses custom symbolic() methods to map the NMS and RoiAlign operations to TRT::EfficientNMSX_TRT and TRT::ROIAlignX_TRT.

These functions have placeholder implementations that generate random tensors. The legacy ONNX exporter supports the symbolic() mechanism, whereas the newer Dynamo exporter handles custom operations differently.

Setting dynamo=False allows the intended TensorRT plugin operations to be exported instead of the placeholder operations.

Alternatively, use an older version of PyTorch or rewrite the exporter according to Symbolic operators.

2. Build the TensorRT engine with the custom plugins

trtexec \
    --onnx=model.onnx \
    --saveEngine=model.engine \
    --plugins=nvdsinfer_custom_impl_Yolo_seg/libnvdsinfer_custom_impl_Yolo_seg.so

Hope this helps others facing the same issue!