Skip to content

[Fix] issue of predictions overwrite regarding instance masks#430

Closed
Cedric-Perauer wants to merge 1 commit intoroboflow:developfrom
Cedric-Perauer:patch-1
Closed

[Fix] issue of predictions overwrite regarding instance masks#430
Cedric-Perauer wants to merge 1 commit intoroboflow:developfrom
Cedric-Perauer:patch-1

Conversation

@Cedric-Perauer
Copy link
Copy Markdown

@Cedric-Perauer Cedric-Perauer commented Oct 30, 2025

Description

Please include a summary of the change and which issue is fixed or implemented. Please also include relevant motivation and context (e.g. links, docs, tickets etc.).

List any dependencies that are required for this change.

Type of change

Change in the prediction function to avoid an overwrite of predictions, which leads to len(predictions)==3 not being reached in mask inference mode.

In post process masks are move to cpu(), therefore keep needs to be moved for subsequent indexing as well.
With this change sv.MaskAnnotator().annotate() can be used for mask inference visualisation.

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How has this change been tested, please provide a testcase or example of how you tested the change?

Via inference script visualisation that is based on predict script +

import io
import requests
import supervision as sv
from PIL import Image
from rfdetr import 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)
]

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)


sv.plot_image(annotated_image)

Any specific deployment considerations

For example, documentation changes, usability, usage/costs, secrets, etc.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Oct 30, 2025

CLA assistant check
All committers have signed the CLA.

@jrdalenberg jrdalenberg mentioned this pull request Jan 21, 2026
6 tasks
@Borda Borda added the bug Something isn't working label Jan 22, 2026
@Borda Borda requested a review from isaacrob as a code owner February 11, 2026 15:57
@Borda Borda force-pushed the develop branch 4 times, most recently from 60b16c1 to 523f9df Compare February 14, 2026 06:46
@Borda
Copy link
Copy Markdown
Member

Borda commented Feb 18, 2026

It seems to be resolved already, but still, thank you for your help!

@Borda Borda closed this Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working has conflicts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants