Views
No views yet
lightly-train framework.1import torch
2from torch.hub import load_state_dict_from_url
3
4# 1. Load the original RT-DETR-L model architecture
5# Make sure you have the 'rtdetr' repository cloned locally or installed
6rtdetr_l = torch.hub.load('lyuwenyu/RT-DETR', 'rtdetrv2_l', pretrained=True)
7model = rtdetr_l.model
8
9# 2. Load the distilled weights from this Hugging Face Hub repository
10MODEL_URL = "https://huggingface.co/hnamt/RT-DisDINOv3-ViT-Base/resolve/main/distilled_rtdetr_vit_teacher_BEST.pth"
11distilled_state_dict = load_state_dict_from_url(MODEL_URL, map_location='cpu')['model']
12
13# 3. Load the weights into the model's backbone and encoder
14# The `strict=False` flag ensures that only matching keys (backbone + encoder) are loaded.
15model.load_state_dict(distilled_state_dict, strict=False)
16
17print("Successfully loaded and applied distilled knowledge from ViT teacher!")
18
19# Now the 'model' is ready for fine-tuning on your own dataset.
20# For example:
21# optimizer = torch.optim.AdamW(model.parameters(), lr=1e-4)
22# model.train()
23# ... your fine-tuning loop ...rtdetrv2_l from lyuwenyu/RT-DETR).dinov3/vitb16 via Lightly).lightly-train library.| Model | mAP@50-95 | mAP@50 | Speed (ms) | Notes |
|---|---|---|---|---|
| RT-DETR-L (Baseline) | 2.80% | 4.60% | 50.05 | Fine-tuned from COCO pre-trained. |
| RT-DisDINOv3 (w/ ViT) | 2.80% | 4.20% | 49.80 | No performance improvement observed. |