RTDETR-To-YOLO-Distill
Weights for RTDETR-To-YOLO-Distill: an RT-DETR-R50vd transformer teacher distilled into a YOLO26n CNN student (17× fewer parameters) for aerial object detection on VisDrone-DET, under label scarcity, with accuracy-gated INT8 post-training quantization and TensorRT export.
The training code, method, and full results are in the GitHub repository. This card covers the released files and how to use them.
Files
All scores are on the VisDrone-DET test-dev set (1,610 images), clean condition, confidence threshold 0.001.
| File | Model | Training | mAP@0.5:0.95 | mAP@0.5 |
|---|---|---|---|---|
rtdetr_r50vd_full/rtdetr_best.pth | RT-DETR-R50vd teacher | Supervised, full label budget (6,471 images) | 26.55 | 44.15 |
rtdetr_r50vd_full/rtdetr_best_fp32.onnx | same, FP32 ONNX | — | 26.56 | 44.20 |
rtdetr_r50vd_full/rtdetr_best_int8.onnx | same, INT8 Q/DQ ONNX | TensorRT engine built from this file | 26.59 | 44.19 |
yolo26n_semi-supervised_eighth/yolo_manual_best_semi-supervised-soft-feat_eighth.pth | YOLO26n student | Semi-supervised + soft logit and feature KD, 805 labelled images (one-eighth budget) | 16.34 | 28.72 |
yolo26n_teacher-only_full/yolo_manual_best_teacher-only-soft-feat.pth | YOLO26n student | Zero human boxes: teacher pseudo-labels + soft logit and feature KD | 19.82 | 34.34 |
yolo26n_supervised-kd_full/yolo_manual_best_kd-soft-feat.pth | YOLO26n student | Supervised + soft logit and feature KD, full label budget | 20.04 | 34.04 |
yolo26n_supervised-kd_full/yolo_manual_best_kd-soft-feat_fp32.onnx | same, FP32 ONNX | — | 20.04 | 34.06 |
yolo26n_supervised-kd_full/yolo_manual_best_kd-soft-feat_int8.onnx | same, INT8 Q/DQ ONNX | TensorRT engine built from this file; detection head kept in FP32 | 19.41 | 33.02 |
The .pth files hold the EMA weights under ema["module"] plus the run's lineage metadata
(training regime, label budget, provenance). Optimizer and scheduler state were removed, so these
are for inference and fine-tuning, not for resuming the original runs. They load with
torch.load(..., weights_only=True).
TensorRT engines are not included: an engine is tied to the TensorRT version and GPU it was built on. Build one from the ONNX files as shown below.
Input and output
Both architectures take a single fixed-shape input and were exported with opset 17 and a static batch of 1.
| Input name | images |
| Shape | [1, 3, 736, 1280] (N, C, H, W), float32 |
| Preprocessing | RGB; plain resize to 736×1280 (no letterbox, aspect ratio not preserved); scale to [0, 1]; no mean/std normalization |
YOLO26n is NMS-free. Output output0 has shape [1, 300, 6]: [x1, y1, x2, y2, score, class]
per detection, sorted by score, in input-pixel coordinates (736×1280). Rescale x by
original_width / 1280 and y by original_height / 736.
RT-DETR-R50vd outputs pred_logits [1, 300, 10] (apply a sigmoid; take the max over classes
per query) and pred_boxes [1, 300, 4] as normalized (cx, cy, w, h). Multiply by the original
image size directly.
Classes (index → name): 0 pedestrian, 1 people, 2 bicycle, 3 car, 4 van, 5 truck, 6 tricycle, 7 awning-tricycle, 8 bus, 9 motor.
Usage
ONNX Runtime, without the repository
import cv2
import numpy as np
import onnxruntime as ort
from huggingface_hub import hf_hub_download
REPO = "pooryanh/rtdetr-to-yolo-distill"
H, W = 736, 1280
def preprocess(path):
img = cv2.cvtColor(cv2.imread(path), cv2.COLOR_BGR2RGB)
x = cv2.resize(img, (W, H)).astype(np.float32) / 255.0
return x.transpose(2, 0, 1)[None], img.shape[:2]
x, (h, w) = preprocess("frame.jpg")
# YOLO26n student
onnx_path = hf_hub_download(REPO, "yolo26n_supervised-kd_full/yolo_manual_best_kd-soft-feat_fp32.onnx")
sess = ort.InferenceSession(onnx_path, providers=["CPUExecutionProvider"])
det = sess.run(None, {"images": x})[0][0] # (300, 6)
det = det[det[:, 4] >= 0.25]
det[:, [0, 2]] *= w / W
det[:, [1, 3]] *= h / H # x1, y1, x2, y2, score, class
# RT-DETR-R50vd teacher
onnx_path = hf_hub_download(REPO, "rtdetr_r50vd_full/rtdetr_best_fp32.onnx")
sess = ort.InferenceSession(onnx_path, providers=["CPUExecutionProvider"])
logits, boxes = sess.run(None, {"images": x})
scores = 1.0 / (1.0 + np.exp(-logits[0])) # (300, 10)
cls, conf = scores.argmax(-1), scores.max(-1)
keep = conf >= 0.25
cx, cy, bw, bh = boxes[0][keep].T
xyxy = np.stack([(cx - bw / 2) * w, (cy - bh / 2) * h, (cx + bw / 2) * w, (cy + bh / 2) * h], axis=1)
With the repository: evaluation and TensorRT
git clone https://github.com/pouryahoseini/RTDETR-To-YOLO-Distill
cd RTDETR-To-YOLO-Distill && pip install -r requirements.txt
python src/prepare_dataset.py # VisDrone -> COCO manifests
# PyTorch checkpoints
python src/evaluate.py --model yolo_manual --weights yolo_manual_best_kd-soft-feat.pth
python src/evaluate.py --model rtdetr --weights rtdetr_best.pth
# Build and evaluate a TensorRT engine from the INT8 ONNX (TensorRT 11)
python src/trt_export.py --onnx yolo_manual_best_kd-soft-feat_int8.onnx --precision int8
python src/evaluate.py --model trt --onnx-arch yolo --weights yolo_manual_best_kd-soft-feat_int8.engine
Training
- Data: VisDrone-DET, 10 classes; 6,471 train / 548 val / 1,610 test-dev images. Label budgets (half 3,249, quarter 1,546, eighth 805 images) are nested and split by flight sequence, so no sequence appears in both a labelled and an unlabelled pool.
- Teacher: RT-DETR-R50vd (v1), initialized from the COCO + Objects365 pretrained checkpoint, 60 epochs at 736×1280. For each budget, the teacher is trained on the same labelled subset as the student.
- Students: YOLO26n, initialized from Ultralytics' COCO-pretrained
yolo26n.pt, 50 epochs at 736×1280. - Distillation: hard pseudo-labels from the teacher, decoupled soft logit KD (top-1 BCE for confidence plus softmax KL for inter-class relations), and feature KD with per-instance normalized foreground masks through a 1×1 conv + GroupNorm adapter.
- Quantization: post-training INT8 with percentile calibration on 300 training images, strongly-typed Q/DQ graphs for TensorRT 11, and an accuracy gate of at most 2.0 mAP@0.5:0.95 drop.
Limitations
- Trained and evaluated on drone imagery only; expect degraded accuracy on ground-level or satellite views.
- VisDrone is mostly clear-weather; the robustness augmentation is synthetic.
- Every result comes from a single training run (one seed).
- Small objects remain hard: AP on small objects is below 10 for every YOLO26n student.
- The released zero-human-box student (
yolo26n_teacher-only_full) learns from the full-budget teacher, which was trained on all 6,471 labelled images, so it removes human boxes from student training, not from the pipeline. - Inputs are a fixed 736×1280 with batch 1; other shapes require re-export.
License
Released under AGPL-3.0. The YOLO26n students are fine-tuned from Ultralytics yolo26n.pt
(AGPL-3.0). The RT-DETR-R50vd teacher derives from RT-DETR
(Apache-2.0). All models were trained on VisDrone-DET, which its authors release under
CC BY-NC-SA 3.0 for academic use only; these weights are therefore intended for non-commercial
research use. Commercial use of the YOLO models additionally requires an
Ultralytics Enterprise License.
Citation
If you use these weights, please link the GitHub repository and cite the works they build on:
@article{zhu2021detection,
title = {Detection and Tracking Meet Drones Challenge},
author = {Zhu, Pengfei and Wen, Longyin and Du, Dawei and Bian, Xiao and Fan, Heng and Hu, Qinghua and Ling, Haibin},
journal = {IEEE Transactions on Pattern Analysis and Machine Intelligence},
volume = {44},
number = {11},
pages = {7380--7399},
year = {2021}
}
@inproceedings{zhao2024detrs,
title = {DETRs Beat YOLOs on Real-time Object Detection},
author = {Zhao, Yian and Lv, Wenyu and Xu, Shangliang and Wei, Jinman and Wang, Guanzhong and Dang, Qingqing and Liu, Yi and Chen, Jie},
booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
pages = {16965--16974},
year = {2024}
}
@software{ultralytics_yolo,
author = {Jocher, Glenn and Qiu, Jing},
title = {Ultralytics YOLO},
url = {https://github.com/ultralytics/ultralytics},
license = {AGPL-3.0}
}