Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#1516·rf-detr

`predict()` hardcodes `antialias=False` resize — silent output drift for checkpoints trained on antialiased inputs (Roboflow platform Resize, default torchvision backend), no opt-out

Author: MateuszryCreated Sep 23, 2026Updated Sep 24, 2026

Search before asking

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

(Related: #1203 / #1206 introduced the current behaviour; #1269 aligned the export paths with it. This report is about the cases that change did not cover.)

Bug

Since 1.9.0 (#1206), RFDETR.predict() resizes with a hardcoded antialias=False:

https://github.com/roboflow/rf-detr/blob/1.10.1/src/rfdetr/detr.py#L2608

The rationale in #1203 was to match the Albumentations training resize (cv2.INTER_LINEAR, no antialias). That holds for checkpoints trained with the Albumentations backend, but not for several other common training setups. For those, 1.9.0 moved predict() away from the training distribution. The public API has no way to restore the previous behaviour:

  1. The default training backend in ≥ 1.9 antialiases. Without the [augment] extra, training/validation resolve to the torchvision backend, which resizes PIL images with antialias=True: https://github.com/roboflow/rf-detr/blob/1.10.1/src/rfdetr/datasets/_torchvision.py#L406 (coco.py itself warns about this: "Albumentations (cv2 INTER_LINEAR, no antialias) to torchvision (BILINEAR + antialias=True)".) So with a default install, a model trained with 1.10.1 is trained on antialiased inputs and served non-antialiased inputs by predict().

  2. Checkpoints trained with rfdetr ≤ 1.4 used SquareResize → F.resize on PIL images, i.e. antialiased. This was already pointed out in the #1206 discussion.

  3. Models trained on the Roboflow platform with a dataset-version "Resize" preprocessing step. Here the images are downscaled before any training pipeline sees them. I checked what that step produces. Downscaled 3 original photos (2930–5712 px) to 576×576 locally with several filters and compared each result to the 576×576 image exported by Roboflow for the same photo (PSNR, higher = closer):

    Original size torchvision bilinear antialias=True PIL BILINEAR PIL BOX torchvision bilinear antialias=False (current predict()) PIL NEAREST
    5712×4284 36.22 dB 36.22 35.86 32.69 32.38
    2930×1975 34.04 dB 34.04 33.57 30.43 29.35
    3024×4032 32.97 dB 32.97 33.28 27.60 27.12

    The platform Resize is clearly antialiased. antialias=False is 3.5–5.4 dB further from it, and almost as far as nearest-neighbour. The model saw exactly these images during training. At inference, predict() downscales the same kind of photo without antialiasing.

The effect grows with the downscale factor. For COCO-sized inputs (~640 px → 576) antialiasing barely matters. For phone photos (3000–6000 px → 576, a factor of 5–10×) it matters a lot, because non-antialiased bilinear samples only a 2×2 neighbourhood out of each ~5×7–10×10 source block.

Observed impact (15 fine-tuned RFDETRMedium checkpoints trained on the Roboflow platform / rfdetr ≤ 1.4, 8 field photos, threshold=0.5, same torch/torchvision), 1.4.2 → 1.10.1:

  • 4 of the 21 model×image pairs with any detection returned a different set of detections: 4 detections disappeared and 1 new one appeared, all with confidence 0.50–0.65.
  • Surviving detections shifted confidence by up to 0.22 (e.g. 0.86 → 0.75, 0.61 → 0.82) and moved boxes by up to 35 px.
  • If force antialias=True (or pre-resize with antialiasing, see below), 1.10.1 reproduces the 1.4.2 outputs exactly: all 21 pairs match, max |Δconf| < 1e-4. The remaining box differences are only the edge clamping added in 1.7.1.

So the change is a silent accuracy regression for these checkpoints. The only way to opt out today is to pre-resize outside the library and rescale boxes afterwards, which depends on the internal model.model.resolution.

Environment

  • RF-DETR: 1.10.1 (baseline for comparison: 1.4.2; 1.8.3 matches 1.4.2 exactly)
  • OS: macOS 26.5 (arm64, Apple Silicon)
  • Python: 3.12.1
  • PyTorch: 2.8.0, torchvision: 0.23.0
  • CUDA/cuDNN: n/a
  • Hardware: Apple Silicon (default device selection); the effect is device-independent, as it comes from preprocessing

Minimal Reproducible Example

This uses the public COCO RFDETRMedium weights and any large photo (≥ ~3000 px on the long side):

python
import sys

import torchvision.transforms.functional as F
from PIL import Image
from rfdetr import RFDETRMedium

model = RFDETRMedium()
resolution = model.model.resolution

image = Image.open(sys.argv[1]).convert("RGB")
width, height = image.size

default = model.predict(image, threshold=0.3)

pre_resized = F.resize(F.to_tensor(image), [resolution, resolution], antialias=True).clamp(0, 1)
antialiased = model.predict(pre_resized, threshold=0.3)
antialiased.xyxy *= [width / resolution, height / resolution] * 2

print("predict() default (antialias=False):", sorted((int(c), round(float(s), 3)) for c, s in zip(default.class_id, default.confidence)))
print("antialiased pre-resize             :", sorted((int(c), round(float(s), 3)) for c, s in zip(antialiased.class_id, antialiased.confidence)))

Output on a 4032 px photo (COCO weights):

predict() default (antialias=False): [(44, 0.316), (44, 0.34), (44, 0.345), (44, 0.347), (44, 0.379), (44, 0.556)]
antialiased pre-resize             : [(44, 0.308), (44, 0.367), (44, 0.458), (78, 0.355)]

Additional

Proposed fix: make the resize antialias configurable and keep the current default, so nothing changes for existing users:

python
def predict(self, images, threshold=0.5, shape=None, patch_size=None,
            include_source_image=True, antialias: bool = False, **kwargs):
    ...
    batch_tensor = torch.stack([F.resize(t, resize_to, antialias=antialias) for t in processed_images])
  • The default False keeps the #1206 behaviour and ONNX/TFLite parity (#1269).
  • antialias=True restores the ≤ 1.8 behaviour for checkpoints trained on antialiased inputs.
  • The docs could state which setting matches which training setup: Albumentations backend → False; torchvision backend / rfdetr ≤ 1.4 / Roboflow-platform Resize → True.
  • Optional follow-up (out of scope for a minimal fix): let the default follow the training backend, e.g. recorded in the checkpoint or in ModelContext, so that predict() matches training without user input.

Are you willing to submit a PR?

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

Source: roboflow/rf-detr

View original on GitHubView discussion on GitHub