Skip to content

v1.12.1: Batching fix and earlier failures for bad input

Latest

Choose a tag to compare

@Borda Borda released this 12 Nov 13:24

1.12.1 fixes batched prediction on fixed-batch predictors and makes bad training settings and input values fail early, with clear errors.

  • Predicting a directory or video with a fixed-batch RFDETR.inference(batch_size=N) predictor now batches at N without passing batch=N.
  • Out-of-range epochs, ema_decay, drop_path and warmup_epochs now fail when you build the config, not mid-training.
  • NaN pixels and non-finite YOLO label coordinates raise clear errors instead of reaching the model.
  • Segmentation prediction uses less GPU memory when every detection passes the threshold.
  • Evaluation no longer crashes on noncontiguous segmentation masks.

Drop-in upgrade, no API changes: settings and inputs that were invalid or silently ignored now raise an error.

✨ Spotlights / highlights

Fixed-batch predictors batch directories and videos by default

RFDETRInference.predict() without batch now predicts a directory, glob or recorded video in batches of the predictor's fixed batch size, with stream=True or stream=False. It used one image per batch, so any N above one failed on the first batch with Batch size mismatch. A final batch with fewer than N images is still refused, not padded. (#1695)

from rfdetr import RFDETRSmall

predictor = RFDETRSmall().inference(batch_size=4)
for result in predictor.predict("frames/", stream=True):  # batches of 4; a short last batch is still refused
    ...

Bad training settings fail when the config is built

TrainConfig rejects epochs below 1, ema_decay outside [0, 1], drop_path outside [0, 1) and a negative warmup_epochs, and names the field. Before, these gave a ZeroDivisionError, diverging EMA weights, NaN from drop-path, or a shifted LR schedule. ema_decay=1.0 and drop_path=0.0 stay valid. (#1699, #1705)

from rfdetr.config import TrainConfig

TrainConfig(dataset_dir=".", epochs=0)  # ValidationError: epochs, Input should be greater than or equal to 1

Bad inputs are rejected before they do damage

Prediction raises on float NumPy arrays and PyTorch tensors that contain NaN, before the forward pass. The message is now Image has pixel values below 0 or NaN. .... YOLO dataset loading rejects non-finite box and polygon coordinates and reports the label file and its physical line number; line numbers in every malformed-label error now count blank lines. (#1698, #1706)

Lighter segmentation prediction

Segmentation predict() no longer copies every full-resolution mask on the device a second time when all detections pass the threshold. On a Tesla T4, decoding 100 masks at 1920×1080 peaked at 198 MiB less CUDA memory and took 15.8 ms instead of 17.6 ms. That covers mask decoding and the copy to the CPU, not the model forward pass or mask resizing. Predictions are unchanged. (#1688)

🔄 Migration guide

No breaking changes in this release.

📝 Notable changes

🌱 Changed

  • Segmentation prediction skips the second device-side copy of full-resolution masks when all detections pass the threshold; predictions are unchanged. (#1688)
  • The package build rewrites the README's relative paths to absolute URLs before uv build, so the PyPI long description shows its images and links; a missing path fails the build. The README and benchmark docs use new SVG charts. (#1693)
  • The docs gain Train and Inference & Export navigation tabs, per-task benchmark tabs for the TensorRT latency tables, and a batch 1, 4 and 8 end-to-end latency section in the CUDA export cookbook, with reworked latency tables on the export pages. (#1694, #1696, #1704)

🔧 Fixed

  • RFDETRInference.predict() without batch now batches directories, globs and recorded videos at the fixed batch size of a predictor from RFDETR.inference(batch_size=N) or of a fixed-batch export. It used one image per batch, so any N above one failed with Batch size mismatch. Live captures and .streams manifests keep one frame per source in each simultaneous batch. (#1695)
  • Prediction rejects floating NumPy arrays and PyTorch tensors containing NaN before running the model, including when the original pixels are retained in result metadata. The error text is now Image has pixel values below 0 or NaN. ...; it still begins with the old wording, so only exact-text comparisons need updating. (#1698)
  • YOLO dataset loading rejects non-finite box and polygon coordinates before building COCO annotations and reports the label file and its physical line number; line numbers in every malformed-label error now count blank lines. (#1706)
  • TrainConfig rejects epochs below 1 and ema_decay outside [0, 1] when it is built, naming the field. epochs=0 used to fail with a ZeroDivisionError in configure_optimizers, and an ema_decay outside [0, 1] could make EMA weights diverge without any error. (#1699)
  • TrainConfig rejects drop_path outside [0, 1) and a negative warmup_epochs when it is built, naming the field. A peak drop_path=1.0 could divide by a zero keep probability and return NaN, and a negative warmup_epochs could start the cosine LR schedule part-way through decay. (#1705)
  • The windowed DINOv2 drop-path now masks before scaling and computes in float32 for FP16 input so a dropped path cannot overflow, and per-layer drop-path rates are built in float64 so a rate just below 1 cannot round to 1.0. (#1705)
  • Segmentation mask IoU in evaluation accepts noncontiguous mask tensors; they used to raise a view RuntimeError. Any copy stays bounded to one chunk. (#1700)

🏆 Contributors

  • Iuri de Silvio (@iurisilvio, LinkedIn) — made segmentation prediction lighter on GPU memory by skipping the full-resolution mask copy when every detection passes the threshold.
  • Mohammad Sohail Shaikh (@sohailshk, LinkedIn) — made TrainConfig reject out-of-range epochs, ema_decay, drop_path and warmup_epochs, and fixed the FP16 drop-path overflow.
  • Vlad Voropaev (@voropaevv, LinkedIn) — made prediction reject NaN pixels, YOLO loading reject non-finite label coordinates with correct line numbers, and segmentation evaluation accept noncontiguous masks.
  • Jirka Borovec (@Borda, LinkedIn) — fixed the default batch size for fixed-batch predictors, made the PyPI README render its images and links, and refreshed the benchmark charts, latency docs and docs navigation.

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


Full changelog: 1.12.0...1.12.1
Co-authored with /oss:release.