1.6.2

roboflow/rf-detr1.6.2Mar 27, 2026by Borda

AI Summary

Adds explicit shape inference support and improves device handling for training and inference.

Key Highlights

  • `RFDETR.predict(shape=...)` allows running inference at non-square resolutions.
  • `ModelConfig.device` and `train()` now accept `torch.device` objects and indexed device strings.
  • Fixed ONNX export ignoring explicit `patch_size` argument.
  • Fixed ONNX export for models traced with dynamic batch dimensions.

New Features

  • Explicit `shape` parameter for `predict()` method.
  • Full support for `torch.device` objects in configuration.

Full Release Notes

## 🚀 Added

- **`RFDETR.predict(shape=...)`** — pass an explicit `(height, width)` tuple to run inference at a non-square resolution, matching the resolution used when exporting the model. Both dimensions must be positive integers divisible by 14. (#866)

	```python
	detections = model.predict("image.jpg", shape=(480, 640))
	```

## 🌱 Changed

- **`ModelConfig.device` and `RFDETR.train(device=...)`** now accept `torch.device` objects and indexed device strings (`"cuda:0"`, `"cuda:1"`). Existing string values (`"cpu"`, `"cuda"`) are unchanged. `RFDETR.train()` warns when a valid but unmapped device type is passed to PyTorch Lightning auto-detection. (#872)

	```python
	from rfdetr import RFDETRSmall
	from torch import device
	
	model = RFDETRSmall(...)
	
	model.train(..., device=device("cuda:1"))
	model.train(..., device="cuda:0")
	```

## 🔧 Fixed

- Fixed ONNX export ignoring an explicit `patch_size` argument: `export()` and `predict()` now resolve `patch_size` from `model_config` by default, validate it strictly (must be a positive integer, not bool), and enforce that `(H, W)` dimensions are divisible by `patch_size × num_windows`. (#876)
- Fixed ONNX export for models traced with dynamic batch dimensions — `torch.full` is now used for Python-int spatial dims to avoid `H_.expand(N_)` tracer failures. (#871)

---

## 🏆 Contributors

Welcome to our new contributors, and thank you to everyone who helped with this release:

- **zhaoshuo** (@zhaoshuo1223) — *ONNX export shape validation and patch_size fixes*
- **Sven Goluza** (@svengoluza) — *ONNX export dynamic batch fix*
- **Jirka Borovec** (@Borda) ([LinkedIn](https://www.linkedin.com/in/jirka-borovec/)) — *shape inference, torch.device support, release coordination*

---

**Full changelog**: https://github.com/roboflow/rf-detr/compare/1.6.1...1.6.2