Skip to content

Problem with segmentation mask prediction in RFDETRSegPreview model #403

@jbdebelle

Description

@jbdebelle

Search before asking

  • I have searched the RF-DETR issues and found no similar bug report.

Bug

When using the RFDETRSegPreview model, the predictions do not include segmentation masks.
The condition len(predictions) == 3 is never satisfied, indicating that the model only outputs detection results without the expected mask data.

Even though RFDETRSegPreview is supposed to support segmentation, it behaves as if segmentation heads are not active or returned by the model.

Environment

⚙️ Environment:

OS: Windows

Python: 3.12

PyTorch: 2.8

Model: RFDETRSegPreview

Minimal Reproducible Example

`import io
import requests
import supervision as sv
from PIL import Image
from rfdetr import RFDETRBase, RFDETRNano, RFDETRSmall, RFDETRMedium, RFDETRSegPreview
from rfdetr.util.coco_classes import COCO_CLASSES

model = RFDETRSegPreview()

model.optimize_for_inference()

url = "https://media.roboflow.com/notebooks/examples/dog-2.jpeg"

image = Image.open(io.BytesIO(requests.get(url).content))
detections = model.predict(image, threshold=0.5)

labels = [
f"{COCO_CLASSES[class_id]} {confidence:.2f}"
for class_id, confidence
in zip(detections.class_id, detections.confidence)
]
print(detections)
annotated_image = image.copy()
annotated_image = sv.BoxAnnotator().annotate(annotated_image, detections)
annotated_image = sv.LabelAnnotator().annotate(annotated_image, detections, labels)
annotated_image = sv.MaskAnnotator().annotate(annotated_image, detections, labels)

sv.plot_image(annotated_image)`

Additional

No response

Are you willing to submit a PR?

  • Yes, I'd like to help by submitting a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions