Skip to content

v1.13.0: Test-time augmentation, lighter install and upright photos

Latest

Choose a tag to compare

@Borda Borda released this 04 Dec 08:59
· 1 commit to develop since this release
db547ad

RF-DETR v1.13.0 trims the core install, reads photos the way you see them, and lets you trade latency for accuracy.

  • A core install no longer pulls in transformers.
  • Test-time augmentation adds accuracy at prediction time when you opt in.
  • A new ExecuTorch TensorRT backend runs exported models on NVIDIA GPUs without an ONNX step.
  • WeightedMultiSourceBatchSampler keeps small datasets visible when you train on several at once.
  • Long-tailed datasets get class-support gating and class-agnostic mAP.

Upgrade with care: transformers leaves the core install, tagged photos are read upright, the DINOv2 backbone classes, measure_latency() results and numpy.complex_ change without an earlier warning, and eval_ema_only is removed as announced.

Impact of Test-Time Augmentation (TTA) per model size

✨ Spotlights / highlights

Test-time augmentation

TTAConfig() fuses the native view with three zoomed views. On COCO val2017 it added 4.02, 3.11 and 1.96 box AP to Nano, Small and Large at 3 to 4 times the latency of one plain call. It works with detection and segmentation models. (#1726, #1765, #1768)

from rfdetr import RFDETRInference, RFDETRSmall, TTAConfig

predictor = RFDETRInference(RFDETRSmall())

detections = predictor.predict("image.jpg", threshold=0.5, tta=TTAConfig())

A lighter core install

pip install rfdetr no longer installs transformers. You don't need it to build released models, predict, train from RF-DETR weights or load non-LoRA checkpoints. (#1702, #1703)

pip install rfdetr transformers   # only if your own code imports transformers

Photos are read upright

Phone photos with an orientation tag are now decoded the way viewers and annotation tools show them, so labels drawn on the upright photo land on the right pixels. (#1739)

from rfdetr import RFDETRInference, RFDETRSmall

predictor = RFDETRInference(RFDETRSmall())

detections = predictor.predict("phone_photo.jpg", threshold=0.5)  # boxes are in the upright frame

ExecuTorch on NVIDIA GPUs

The new TensorRT backend writes a .pte through Torch-TensorRT. It needs the rfdetr[executorch-tensorrt] extra (Linux, Python 3.11 to 3.14) and an NVIDIA Ampere or newer GPU (compute capability 8.0 or higher), which you need at export time too. That extra can't share an environment with rfdetr[executorch]. (#1712)

from rfdetr import RFDETRSmall

model = RFDETRSmall()

model.export(format="executorch", backend="tensorrt")

Balanced training across datasets

WeightedMultiSourceBatchSampler gives each dataset a fixed share of every batch, so a large dataset doesn't drown out your small hand-labelled set. (#1287)

from torch.utils.data import ConcatDataset

from rfdetr.datasets import WeightedMultiSourceBatchSampler
from rfdetr.training import RFDETRDataModule


class MultiSourceDataModule(RFDETRDataModule):
    def setup(self, stage: str) -> None:
        super().setup(stage)
        if stage == "fit":
            self._dataset_train = ConcatDataset([labeled_dataset, synthetic_dataset, public_dataset])

    def build_train_sampler(self, dataset: ConcatDataset) -> WeightedMultiSourceBatchSampler:
        return WeightedMultiSourceBatchSampler.from_concat_dataset(
            dataset,
            weights=[0.6, 0.3, 0.1],
            batch_size=self._resolve_batch_size(),
            num_replicas=self.trainer.world_size if self.trainer else 1,
            rank=self.trainer.global_rank if self.trainer else 0,
            batch_multiple=self.train_config.grad_accum_steps,
        )

🔄 Migration guide

transformers is no longer a core dependency

Install transformers, tokenizers, huggingface_hub or safetensors yourself if your code relied on rfdetr to bring them. rfdetr[train] and rfdetr[lora] still do, through peft. On a core install, two direct uses of the backbone modules raise an ImportError: a patch-14 DINOv2 backbone with 37 positional encodings built with pretrain_weights=None (such as the deprecated Base configs) needs huggingface_hub and safetensors, and DinoV2(use_windowed_attn=False) needs transformers. (#1702, #1703)

# Before (v1.12.1)
"transformers>=5.1.0,<6.0.0",     # DINOv2 backbone loading
"pydantic>=2.0,<3",               # ModelConfig / TrainConfig validation
# After (v1.13.0)
"pydantic>=2.0,<3",               # ModelConfig / TrainConfig validation

The unused WindowedDinov2WithRegistersForImageClassification class and the head-pruning methods are removed with no replacement, so there is no snippet for them. (#1702, #1703)

DINOv2 backbone classes are plain PyTorch modules (#1702, #1703)

The windowed DINOv2 backbone classes are now plain torch.nn.Module subclasses. Save and load them through their state dict. push_to_hub has no replacement. Outputs are read by attribute, and WindowedDinov2WithRegistersConfig rejects keywords it does not use with a TypeError.

# Before (v1.12.1)
backbone.save_pretrained("backbone")
backbone = WindowedDinov2WithRegistersBackbone.from_pretrained("backbone")
# After (v1.13.0)
torch.save(backbone.state_dict(), "backbone.pt")
backbone = WindowedDinov2WithRegistersBackbone(config)  # the config you built the first one from
backbone.load_state_dict(torch.load("backbone.pt", weights_only=True))

DINOv2 hidden_act strings other than "gelu" are refused (#1702, #1703)

Only "gelu" or a callable is accepted; other strings raise ValueError. Pass the function itself, for example torch.nn.GELU(approximate="tanh") for "gelu_new".

# Before (v1.12.1)
WindowedDinov2WithRegistersConfig(hidden_act="relu")
# After (v1.13.0)
WindowedDinov2WithRegistersConfig(hidden_act=torch.nn.functional.relu)

measure_latency() results have a fourth field (#1710)

BenchmarkResult has a fourth field, timings_ms, so unpacking it into three names raises ValueError.

# Before (v1.12.1)
label, mean_ms, std_ms = measure_latency(run_once, label="rfdetr-small")
# After (v1.13.0)
result = measure_latency(run_once, label="rfdetr-small")
label, mean_ms, std_ms = result.label, result.mean_ms, result.std_ms

numpy.complex_ is no longer restored (#1758)

import rfdetr no longer sets numpy.complex_ on NumPy 2.

# Before (v1.12.1)
import rfdetr  # restored numpy.complex_ on NumPy 2
value = numpy.complex_(1)
# After (v1.13.0)
value = numpy.complex128(1)

Tagged photos are read upright

Your code doesn't change, so there's no snippet to show; the decoded pixels are what differ. Labels drawn on the stored pixels of a tagged photo no longer line up; regenerate them or strip the orientation metadata, and repack affected WebDataset splits. The COCO and WebDataset readers warn once per dataset object when the boxes of a quarter-turned photo fit only its stored frame, and a file with corrupt EXIF can now raise Pillow's UserWarning. (#1739)

eval_ema_only is removed, as announced

It was deprecated with a warning in v1.10.0. If you already use eval_base_model, there's nothing to do. If you pass eval_ema_only=True, just drop it, since it matches the default. (#1795)

# Before (v1.12.1)
TrainConfig(dataset_dir="dataset", eval_ema_only=False)  # also evaluates the base model
# After (v1.13.0)
TrainConfig(dataset_dir="dataset", eval_base_model=True)  # also evaluates the base model

Pass eval_base_model and eval_backend to COCOEvalCallback by keyword, and remove the old key from a saved training_config.json, or a config.yaml saved by the training CLI, before reusing it.

Deprecated: unused ViT decay helpers

get_vit_lr_decay_rate and get_vit_weight_decay_rate still work, warn once, and are planned for removal in v1.16.0. There is no drop-in replacement, so there is no snippet. (#1757)

Behaviour changes to check

Area What differs What to do
Large images (#1717) Pillow's default pixel limit applies again outside Objects365 Set PIL.Image.MAX_IMAGE_PIXELS at module level if you need larger images
Corrupt images (#1761) A corrupt image raises OSError Catch OSError for corrupt files
Non-RGB resume (#1735) A checkpoint with a 3-channel input stem is refused when num_channels is not 3 Start a fresh run with pretrain_weights=<checkpoint>
Albumentations (#1735) A transform that changes the channel count raises ValueError Keep the channel count
Query layout (#1714) A checkpoint with no recorded layout can be refused Save model_config in it, or set pretrain_weights=None
Learning-rate decay (#1718) lr_vit_layer_decay must be above 0, lr_component_decay at least 0 Fix saved configs
ONNX Runtime CPU threads (#1719) Prediction uses every logical core the process may use Pass runtime_options={"num_threads": N} to cap it
ExecuTorch (#1777) Needs executorch>=1.5,<1.6 and torch>=2.14,<2.16 Update pins
TensorRT (#1712) 11.5 and newer are excluded Pin below 11.5
TensorRT INT8 (#1732, #1773) Export now places FP16 layers differently Rebuild INT8 engines
Core ML (#1751) An FP16ComputePrecision export is named _fp16.mlpackage (a custom output_name is kept as given) Update paths; use another directory if you also export float16
Model cache (#1759) New installs use ~/.cache/roboflow/models Set RF_HOME to pin a directory

📝 Notable changes

🚀 Added

  • Test-time augmentation — RFDETRInference.predict(tta=TTAConfig(...)) fuses shifted and zoomed views, halves the view batch when CUDA runs out of memory, and ships with a study page and cookbook. (#1726, #1765, #1768)
  • ExecuTorch TensorRT backend — export to a .pte for NVIDIA GPUs and load it with RFDETRInference. (#1712)
  • Weighted multi-source sampling — WeightedMultiSourceBatchSampler with compute_source_batch_sizes, a RFDETRDataModule.build_train_sampler() hook and a joint-training cookbook. (#1287)
  • Long-tail evaluation — opt-in min_class_support and class_agnostic_eval. (#1762)
  • Unreadable images — opt-in skip_unreadable_images retries, then substitutes another sample in COCO and YOLO training. (#1761)
  • ONNX INT8 — opt-in int8_keep_mlp_float=True keeps GELU-fed projections in float. (#1750)
  • OpenVINO — openvino_static_shape=True fixes the IR's batch and resolution. (#1715)
  • Thread control — ONNX and OpenVINO predictors accept runtime_options={"num_threads": N}. (#1710)

⚠️ Breaking Changes

  • Dependencies — transformers and the packages it brought are no longer installed with rfdetr. (#1702, #1703)
  • DINOv2 backbone — WindowedDinov2WithRegistersForImageClassification and the head-pruning methods are removed. (#1702, #1703)
  • Image reading — tagged photos are turned upright in training, prediction and export helpers. (#1739)
  • DINOv2 classes — plain torch.nn.Module subclasses: no from_pretrained, save_pretrained or push_to_hub, outputs read by attribute, unknown config keywords raise TypeError. (#1702, #1703)
  • DINOv2 activations — a hidden_act string other than "gelu" raises ValueError. (#1702, #1703)
  • Latency results — BenchmarkResult gains timings_ms and median_ms; three-name unpacking raises ValueError. (#1710)
  • NumPy 2 — numpy.complex_ is no longer set on import. (#1758)

🌱 Changed

  • DINOv2 Hub weights load strictly, so a key mismatch raises. (#1702, #1703)
  • Weight cache: ~/.roboflow/models → the XDG cache directory; an existing old directory keeps being used. (#1759)
  • Corrupt images: mixed error types → OSError. (#1761)
  • More num_queries than the checkpoint has: size mismatch error → extra slots are padded with a warning; an unrecorded query layout is now refused with ValueError. (#1714)
  • ONNX Runtime CPU threads: physical cores → every logical core the process may use. (#1719)
  • Pillow pixel limit: raised for the whole process on import → raised only for Objects365 reads. (#1717)
  • Dependencies: pillow>=11.0 is required (#1739); [executorch] moves to executorch>=1.5,<1.6 with torch>=2.14,<2.16 (#1777); [tensorrt] excludes 11.5 and newer (#1712); [train] takes torch-hungarian>=0.1.0,<0.2.0 (4b8f87c).
  • Less overhead: segmentation mask encoding runs in one hotcoco call (#1709), and ONNX and TFLite decoding skips unused debug statistics (#1754).

🗑️ Deprecated

  • get_vit_lr_decay_rate and get_vit_weight_decay_rate, planned for removal in v1.16.0, with no drop-in replacement. (#1757)

❌ Removed

  • eval_ema_only on TrainConfig and COCOEvalCallback, deprecated since v1.10.0. Use eval_base_model=True where you passed eval_ema_only=False. (#1795)

🔧 Fixed

  • Static TensorRT INT8 engines of Atto, Femto and Pico keep the early backbone MLP layers in FP16, which restores most of their accuracy. (#1732)
  • TensorRT INT8 no longer leaves a quantized qkv projection in front of FP16 attention on those models. (#1773)
  • Static ONNX INT8 keeps the attention-value multiply in float, which reduces accuracy loss on larger models. (#1747)
  • A Core ML export with an FP16ComputePrecision pass is named _fp16.mlpackage (a custom output_name is kept as given) instead of _fp32.mlpackage. (#1751)
  • batch_size="auto" works for keypoint models. (#1745)
  • Fine-tuning the keypoint preview with an explicit schema starts classes from the right pretrained rows. (#1744)
  • Keypoint predict() after train() decodes with the trained schema. (#1776)
  • CocoEvaluator now scores a ground-truth annotation with id 0. (#1738)
  • TrainConfig rejects invalid learning-rate decay values. (#1718)
  • A failed weight re-download keeps the existing checkpoint. (#1730)
  • export() builds on the model's own CUDA device instead of GPU 0. (#1712)
  • num_channels other than 3 is honoured in training and dataset loading. (#1735)
  • 16-bit grayscale PNGs are no longer clipped to white. (#1755)
  • Narrow half-precision boxes no longer collapse to zero width. (#1767)
  • Inductor-compiled predictors no longer slow down or fail to compile after many are built in one process. (#1710)
  • Export extras install and work again: pyarrow<26 for [tflite] on Python 3.12 (#1760), jax<0.12.1 for [litert] and coreai-core<1.0.0rc1 for [coreai] (#1712).

🏆 Contributors

Welcome to our new contributors @shoumikhin, @SajjadPSavoji, @mattdawkins, @bhargavchintam, @SIDDARTHAREDDY8 and @emreyoleridev!

  • Maryam Saif (@Maryyyyyyyam142) — added weighted multi-source batch sampling and made TrainConfig reject invalid learning-rate decay values.
  • Anthony Shoumikhin (@shoumikhin) — added the ExecuTorch TensorRT backend and bounded export extra dependencies.
  • Sajjad Pakdamansavoji (@SajjadPSavoji, LinkedIn) — added sub-patch shift test-time augmentation.
  • Matthew Dawkins (@mattdawkins) — added class-support gating, class-agnostic mAP and skip_unreadable_images.
  • Bindu Bhargava Reddy Chintam (@bhargavchintam, LinkedIn) — made tagged photos read upright, split the TensorRT tests and fixed the changelog pre-commit check.
  • Omkar Kabde (@omkar-334, LinkedIn) — stopped the import from changing Pillow's pixel limit, made training honour num_channels, fixed keypoint prediction after training and annotation id 0 in CocoEvaluator, and tidied dependency pins and legacy helpers.
  • Anna Gubenkova (@avbelova) — added the static shape option for OpenVINO export.
  • Ali Tharwat (@Ali-Tharwat, LinkedIn) — moved the model cache to the XDG layout with a fallback.
  • Matvei Popov (@Matvezy, LinkedIn) — made ONNX Runtime CPU prediction use all logical cores and documented compact CPU export.
  • Lương Thanh Hoàng Phú (@lthphuw, LinkedIn) — fixed TensorRT INT8 attention precision and Core ML FP16 file naming, and removed unused decoding work.
  • Raghav Rathi (@raghav-rathi, LinkedIn) — fixed automatic batch size and class rows for keypoint models.
  • SIDDARTHA REDDY (@SIDDARTHAREDDY8, LinkedIn) — fixed 16-bit grayscale PNG handling.
  • A Aswanth Raj (@aswanth-07, LinkedIn) — fixed narrow half-precision boxes in postprocessing.
  • Vlad Voropaev (@voropaevv, LinkedIn) — made weight re-downloads keep the old checkpoint until the new one is verified.
  • Emre Yoleri (@emreyoleridev, LinkedIn) — fixed broken documentation links.
  • Jirka Borovec (@Borda, LinkedIn) — added batched test-time augmentation, dropped transformers from the core install, added a more precise ONNX INT8 option, and maintained CI and docs.

Automated contributions: @claude[bot], @pre-commit-ci[bot], @github-actions[bot], @Copilot, Codex


Full changelog: 1.12.1...1.13.0

Drafted by /oss:release, an AI skill in AI Rig. If it saved you time, a ⭐ helps others find it.