DEIM
Detection transformer yang dilatih dengan dense one-to-one matching, dan konvergen dalam epoch jauh lebih sedikit dibanding resep DETR yang mendasarinya. LibreYOLO menyediakan dua versinya, dibedakan lewat checkpoint yang dimuat.
- Task
- detection
- Ukuran
- deim: n, s, m, l, x at 640 px
- Instalasi
pip install libreyolo- Tier dukungan
- Inti, sejak v1.2.0. Detektor inti yang dapat dilatih: fitur menyusul tier unggulan dalam gelombang rilis yang sama.
- Proyek upstream
- DEIM and DEIMv2 oleh Intellindust AI Lab, Apache-2.0; the DEIMv2 DINOv3 backbone adds Meta's DINOv3 License. Makalah, sumber
- Lisensi
- Kode Apache-2.0, bobot Apache-2.0; the DEIMv2 DINOv3 backbone adds Meta's DINOv3 License. Penggunaan komersial
Instalasi
Tidak ada versi yang memerlukan extra opsional. Semua yang diimpor keduanya sudah tersedia di instalasi dasar.
pip install libreyoloFine-tuning adapter dengan lora=True adalah pengecualiannya, dan memerlukan
extra lora.
pip install "libreyolo[lora]"Prediksi
Bobot diunduh dari Hugging Face saat pertama kali dipakai lalu disimpan di cache lokal.
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreDEIMn.pt")result = model(SAMPLE_IMAGE, save=True) for box in result.boxes: print(box.cls, box.conf, box.xyxy)libreyolo predict model=LibreDEIMn.pt save=True \ source=https://raw.githubusercontent.com/LibreYOLO/libreyolo/release/libreyolo/assets/parkour.jpgfrom libreyolo import LibreYOLO # Versinya menjadi bagian dari nama berkas, dan factory-nya memilih# berdasarkan checkpoint, jadi keduanya dimuat dengan cara yang sama.model = LibreYOLO("LibreDEIMv2pico.pt") # Source apa pun yang diterima library: berkas, folder, URL, indeks# webcam, stream RTSP, atau daftar .streamsfor result in model.predict("clip.mp4", stream=True, save=True): print(len(result.boxes))Objek Results yang dikembalikan sama dengan yang dikembalikan setiap family,
jadi mengganti detektor dengan yang lain hanya butuh perubahan satu baris.
conf dan max_det menyaring decode top-k atas query dan kelas; tidak ada
langkah NMS yang perlu disetel, dan iou tetap diterima tetapi tidak dipakai.
Lihat prediksi untuk source, streaming dan penanganan hasil.
DEIM menerima imgsz=(height, width) persegi panjang untuk prediksi. DEIMv2 secara eksplisit menolak permintaan prediksi/validasi persegi panjang. Ini tidak berarti pelatihan atau ekspor persegi panjang didukung.
Varian
Versi 1 hadir dengan lima ukuran, semuanya pada ukuran input yang sama. Versi 2
mempertahankan kelima nama itu dan menambahkan tiga ukuran yang lebih kecil,
atto, femto dan pico, dan dua yang pertama native pada ukuran input yang
lebih rendah daripada sisanya. Karena itu lima kode ukuran ada di kedua versi
dan menamai model yang berbeda; versinya ditulis ke dalam nama berkas
checkpoint.
| Checkpoint | Input (piksel) | mAP 50-95 | Parameter (juta) |
|---|---|---|---|
| LibreDEIMl | 640 | 57.8 | 31.24 |
| LibreDEIMm | 640 | 55.4 | 19.59 |
| LibreDEIMn | 640 | 46.8 | 3.78 |
| LibreDEIMs | 640 | 52.1 | 10.32 |
| LibreDEIMx | 640 | 59.6 | 62.62 |
| LibreDEIMv2atto | 320 | 27.5 | 0.51 |
| LibreDEIMv2femto | 416 | 34.5 | 0.98 |
| LibreDEIMv2l | 640 | 58.6 | 32.55 |
| LibreDEIMv2m | 640 | 56.0 | 18.36 |
| LibreDEIMv2n | 640 | 46.7 | 3.6 |
| LibreDEIMv2pico | 640 | 42.2 | 1.54 |
| LibreDEIMv2s | 640 | 53.0 | 9.78 |
| LibreDEIMv2x | 640 | 61.3 | 51.21 |
COCO val2017, 500 images. Diukur oleh perangkat benchmark LibreYOLO dan dipublikasikan di Vision Analysis, tempat latensi pada berbagai hardware dan runtime dibandingkan serta rekaman lengkap setiap pengujian tersedia.
Versi 1 mempertahankan arsitektur D-FINE dan mengganti objective klasifikasinya
dengan loss matchability-aware dari resep dense one-to-one, sehingga kedua
family berbagi hampir semua key state dict dan dibedakan lewat metadata di
dalam checkpoint. Versi 2 mempertahankan kontrak pelatihan itu dan mencampur
backbone: HGNetv2 di bawah s, dan vision transformer DINOv3 dengan adapter
spatial tuning pada s ke atas. Backbone itulah yang menempelkan lisensi kedua
pada keempat checkpoint tersebut, jadi baca lisensi sebelum
menerapkan salah satunya ke produksi.
Pelatihan
Pelatihan dimulai dari checkpoint yang sudah dipublikasikan. pretrained tidak
pernah sampai ke trainer: versi 1 memperingatkan bahwa key itu tidak dikenal
lalu mengabaikannya, versi 2 menghapusnya. Keduanya tidak memberi model dengan
inisialisasi acak.
from libreyolo import LibreYOLO model = LibreYOLO("LibreDEIMn.pt") # coco128.yaml mengunduh sampel 128 gambar saat pertama kali dipakai.# Arahkan `data` ke YAML dataset Anda sendiri untuk pelatihan sungguhan.model.train(data="coco128.yaml", epochs=50, batch=8, lr0=1e-4)libreyolo train model=LibreDEIMn.pt data=coco128.yaml \ epochs=50 batch=8 lr0=1e-4from libreyolo import LibreYOLO # Bila dibiarkan kosong, epochs, batch, imgsz dan lr0 diambil dari# resep rilis untuk ukuran yang dimuat.model = LibreYOLO("LibreDEIMv2pico.pt")model.train(data="coco128.yaml", epochs=50)# Butuh extra lora: pip install "libreyolo[lora]"from libreyolo import LibreYOLO model = LibreYOLO("LibreDEIMn.pt")model.train(data="coco128.yaml", epochs=50, lora=True)libreyolo train model=LibreDEIMn.pt data=coco128.yaml \ epochs=50 device=0,1Berikan lr0 sendiri pada versi 1. Signature train() Python-nya memakai
default 4e-4, yaitu laju dari resep COCO yang dipublikasikan, sementara
config pelatihan family ini memuat 1e-4 sebagai default fine-tune-nya, dan
nilai yang lebih rendah itulah yang dipakai CLI ketika argumennya tidak
diberikan. Config itu mencatat pengukuran di baliknya: pada ukuran batch yang
benar-benar dipakai saat fine-tuning, pada dataset kecil, laju COCO menurunkan
kualitas transfer secara terukur.
Versi 2 menentukan default itu sendiri. Membiarkan epochs, batch, imgsz
dan lr0 tidak diisi membuatnya membaca masing-masing dari resep rilis untuk
ukuran yang dimuat, sehingga ukuran yang kecil dilatih pada resolusi input
masing-masing tanpa perlu diberi tahu, dan nilai yang Anda berikan menimpa
resep tersebut. imgsz adalah argumen yang dibatasinya: nilainya harus
kelipatan positif dari 32, dan jika tidak, versi 2 memunculkan error sebelum
run dimulai.
Lihat pelatihan untuk dataset, augmentasi, multi-GPU dan logger.
DEIM mengaktifkan AMP secara default dengan amp_dtype="float16". Berikan amp=False untuk pelatihan FP32.
Validasi
val() mengembalikan dictionary berisi key metrics/ yang mencakup presisi,
recall, mAP 50 dan mAP 50-95, diukur terhadap dataset apa pun dalam format yang
dipakai saat pelatihan.
from libreyolo import LibreYOLO model = LibreYOLO("LibreDEIMn.pt") # val() mengembalikan dict biasa, bukan objekmetrics = model.val(data="coco128.yaml") print(metrics["metrics/mAP50-95"])print(metrics["metrics/mAP50"])print(metrics["metrics/precision"], metrics["metrics/recall"])libreyolo val model=LibreDEIMn.pt data=coco128.yaml# coco-val-only.yaml mengambil 5000 gambar val2017 dan melewati set# pelatihan. Di dalamnya ada skrip unduhan tertanam, jadi butuh izin# eksplisit kecuali datasetnya sudah tersedia secara lokal.libreyolo val model=LibreDEIMn.pt data=coco-val-only.yaml \ allow_download_scripts=TrueBaris pada tabel benchmark di atas berasal dari harness benchmark LibreYOLO; catatan di bawah tabel itu mencatat dataset mana yang menghasilkannya dan menautkan catatan run-nya.
Ekspor
| Task | ONNX | TorchScript | ExecuTorch | TensorRT | OpenVINO | Paddle | MNN | RKNN | ncnn | TFLite | CoreML | Core AI |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Detection | Detection to ONNX: didukung | Detection to TorchScript: didukung | Detection to ExecuTorch: tidak didukung | Detection to TensorRT: didukung | Detection to OpenVINO: didukung | Detection to Paddle: didukung | Detection to MNN: didukung | Detection to RKNN: tidak didukung | Detection to ncnn: tidak didukung | Detection to TFLite: tidak didukung | Detection to CoreML: tidak didukung | Detection to Core AI: didukung |
Matriks ini mencakup kedua versi dalam satu halaman: bila keduanya berbeda soal suatu format, selnya menampilkan yang lebih lemah di antara keduanya, sehingga tidak ada yang dilebih-lebihkan untuk versi mana pun yang dimuat.
Artefak hasil ekspor dimuat kembali lewat LibreYOLO() berdasarkan sufiks
berkasnya, jadi berkas .onnx atau .engine berperilaku seperti checkpoint
dan mengembalikan Results yang sama.
# Butuh extra onnx: pip install "libreyolo[onnx]"from libreyolo import LibreYOLO model = LibreYOLO("LibreDEIMn.pt")path = model.export(format="onnx")print(path)libreyolo export model=LibreDEIMn.pt format=onnxfrom libreyolo import LibreYOLO, SAMPLE_IMAGE # Factory-nya memilih berdasarkan sufiks berkas, jadi artefak hasil# ekspor dimuat seperti checkpoint biasa dan mengembalikan objek# Results yang sama.model = LibreYOLO("LibreDEIMn.onnx")result = model(SAMPLE_IMAGE) print(result.boxes.xyxy)Input dan output ONNX
LibreDEIM, and LibreDEIMv2 atto, femto, pico and n
| Tensor | images float32 [batch, 3, height, width] |
|---|---|
| Warna | RGB |
| Penskalaan | piksel / 255 |
| Normalisasi | tidak ada |
| Ubah ukuran | regangkan ke lebar x tinggi (tanpa padding, rasio aspek tidak dipertahankan), Pillow bilinear |
Cara mereproduksi resize bilinear Pillow
LibreYOLO mengubah ukuran dengan filter BILINEAR milik Pillow (Image.resize). Ini bukan OpenCV INTER_LINEAR maupun INTER_AREA: saat memperkecil, Pillow memperlebar filter sebesar faktor pengecilan, dan resize OpenCV mengubah deteksi serta menggeser kotak beberapa piksel. Untuk mereproduksinya tanpa Pillow, ubah ukuran satu sumbu, bulatkan ke 8 bit, lalu ubah ukuran sumbu lainnya dan bulatkan lagi. Per sumbu, misalkan s = in_size / out_size dan f = max(s, 1). Piksel keluaran i berpusat di c = (i + 0.5) * s dan membaca piksel sumber j dari int(c - f + 0.5) sampai int(c + f + 0.5) - 1, dibatasi pada gambar, masing-masing dengan bobot max(0, 1 - |j + 0.5 - c| / f), dibagi jumlah bobot. Pillow bekerja dengan fixed point dan memilih urutan sumbu dari bentuk gambar, sehingga bobot float dapat berbeda satu level pada beberapa piksel. Hal itu tidak mengubah hasil pada pemeriksaan kami.
Square input only. Export rejects a non-square imgsz. height and width equal the imgsz metadata key: 640 by default, 320 for DEIMv2 atto and 416 for DEIMv2 femto.
Batch size 1 only. The graph declares a dynamic batch axis, but batches of 2 or more fail in 1.7.0.
To run several images per call, export with batch=2. That graph takes any batch size and gives the same results per image.
Divide by 255 after the resize. There is no mean or std normalization for these sizes.
Only the default export exists. nms=True raises NotImplementedError for this family.
Detection, ekspor default
| Output | Bentuk | Arti |
|---|---|---|
pred_logits | [batch, queries, nc] | One logit per query and class. Sigmoid is not applied, and there is no background class. 300 queries, except DEIMv2 atto with 100 queries, femto with 150 queries and pico with 200 queries. |
pred_boxes | [batch, queries, 4] | cx, cy, w, h of each query, normalized 0 to 1 of the input. The input is the whole image stretched, so these are also fractions of the original image. |
Pascapemrosesan
- Apply sigmoid to pred_logits.
- Flatten the [queries, nc] scores and take the top 300 (max_det, 300 by default). For flat index k, the query is k // nc and the class is k % nc. One query can yield several classes.
- Keep the pairs whose score is above the confidence threshold (0.25 by default).
- Convert the query's box to x1 = cx - w / 2, y1 = cy - h / 2, x2 = cx + w / 2, y2 = cy + h / 2. Multiply x by the original image width and y by the original image height.
- There is no NMS and the iou threshold is not used. DEIM predicts a set of boxes.
- LibreYOLO does not clip these boxes, so an edge can sit slightly outside the image.
LibreDEIMv2 s, m, l and x
| Tensor | images float32 [batch, 3, height, width] |
|---|---|
| Warna | RGB |
| Penskalaan | piksel / 255 |
| Normalisasi | rata-rata [0.485,0.456,0.406], simpangan baku [0.229,0.224,0.225] |
| Ubah ukuran | regangkan ke lebar x tinggi (tanpa padding, rasio aspek tidak dipertahankan), Pillow bilinear |
Cara mereproduksi resize bilinear Pillow
LibreYOLO mengubah ukuran dengan filter BILINEAR milik Pillow (Image.resize). Ini bukan OpenCV INTER_LINEAR maupun INTER_AREA: saat memperkecil, Pillow memperlebar filter sebesar faktor pengecilan, dan resize OpenCV mengubah deteksi serta menggeser kotak beberapa piksel. Untuk mereproduksinya tanpa Pillow, ubah ukuran satu sumbu, bulatkan ke 8 bit, lalu ubah ukuran sumbu lainnya dan bulatkan lagi. Per sumbu, misalkan s = in_size / out_size dan f = max(s, 1). Piksel keluaran i berpusat di c = (i + 0.5) * s dan membaca piksel sumber j dari int(c - f + 0.5) sampai int(c + f + 0.5) - 1, dibatasi pada gambar, masing-masing dengan bobot max(0, 1 - |j + 0.5 - c| / f), dibagi jumlah bobot. Pillow bekerja dengan fixed point dan memilih urutan sumbu dari bentuk gambar, sehingga bobot float dapat berbeda satu level pada beberapa piksel. Hal itu tidak mengubah hasil pada pemeriksaan kami.
These sizes use a DINOv3 backbone, so they take ImageNet mean and std. The atto, femto, pico and n sizes do not.
Square input only. Export rejects a non-square imgsz. height and width equal the imgsz metadata key, 640 by default.
Batch size 1 only. The graph declares a dynamic batch axis, but batches of 2 or more fail in 1.7.0.
To run several images per call, export with batch=2. That graph takes any batch size and gives the same results per image.
After the resize, divide by 255, then subtract the ImageNet mean and divide by the ImageNet std, per channel in RGB order.
Only the default export exists. nms=True raises NotImplementedError for this family.
Detection, ekspor default
| Output | Bentuk | Arti |
|---|---|---|
pred_logits | [batch, queries, nc] | One logit per query and class. Sigmoid is not applied, and there is no background class. 300 queries. |
pred_boxes | [batch, queries, 4] | cx, cy, w, h of each query, normalized 0 to 1 of the input. The input is the whole image stretched, so these are also fractions of the original image. |
Pascapemrosesan
- Apply sigmoid to pred_logits.
- Flatten the [queries, nc] scores and take the top 300 (max_det, 300 by default). For flat index k, the query is k // nc and the class is k % nc. One query can yield several classes.
- Keep the pairs whose score is above the confidence threshold (0.25 by default).
- Convert the query's box to x1 = cx - w / 2, y1 = cy - h / 2, x2 = cx + w / 2, y2 = cy + h / 2. Multiply x by the original image width and y by the original image height.
- There is no NMS and the iou threshold is not used. DEIM predicts a set of boxes.
- LibreYOLO does not clip these boxes, so an edge can sit slightly outside the image.
Untuk memeriksa implementasi Anda sendiri, jalankan file yang sama lewat LibreYOLO: LibreYOLO("model.onnx").predict("image.jpg") mengembalikan hasil acuan. Diverifikasi dengan LibreYOLO 1.7.0.
Checkpoint
Semua berkas bobot yang dipublikasikan untuk family ini.
| Berkas | Input (piksel) | Lisensi bobot |
|---|---|---|
| Detection | ||
| LibreDEIMn.pt | 640 | apache-2.0 |
| LibreDEIMs.pt | 640 | apache-2.0 |
| LibreDEIMm.pt | 640 | apache-2.0 |
| LibreDEIMl.pt | 640 | apache-2.0 |
| LibreDEIMx.pt | 640 | apache-2.0 |
| LibreDEIMv2n.pt | 640 | apache-2.0 |
| LibreDEIMv2s.pt | 640 | other |
| LibreDEIMv2m.pt | 640 | other |
| LibreDEIMv2l.pt | 640 | other |
| LibreDEIMv2x.pt | 640 | other |
| LibreDEIMv2atto.pt | apache-2.0 | |
| LibreDEIMv2femto.pt | apache-2.0 | |
| LibreDEIMv2pico.pt | apache-2.0 | |
Setiap berkas di atas saat ini tersedia di organisasi LibreYOLO dan diunduh saat pertama kali digunakan.
Lisensi
Periksa lisensi di repositori Hugging Face untuk bobot tertentu yang diunduh. Setiap checkpoint di organisasi LibreYOLO memiliki lisensi, dan lisensinya tidak selalu sama dalam satu family. Repositori tersebut adalah sumber resmi. Ringkasan di bawah menjelaskan ketentuan yang berlaku saat halaman ini terakhir diverifikasi.
Ini adalah deskripsi lisensi yang terlibat, bukan nasihat hukum. Jika jawabannya penting secara komersial, baca sendiri lisensinya dan mintalah nasihat dari penasihat hukum Anda.
- Karya asli
- DEIM and DEIMv2, Intellindust AI Lab
- Lisensi upstream
- Apache-2.0; the DEIMv2 DINOv3 backbone adds Meta's DINOv3 License
- Sumber upstream
- github.com/Intellindust-AI-Lab/DEIM
- Kode LibreYOLO
- MIT
- Bobot
- Apache-2.0; the DEIMv2 DINOv3 backbone adds Meta's DINOv3 License, dipublikasikan ulang di huggingface.co/LibreYOLO
- Interpretasi
- Apache-2.0 is a permissive license, so these weights can be used in commercial and closed-source products. It asks you to keep its license text and attribution notices with any copy of the weights you redistribute, and it grants a patent license. It places no obligation on your own application code, and weights you train yourself on your own data are yours. DEIM is Apache-2.0 throughout, and so are the DEIMv2 sizes below S, which use an HGNetv2 backbone. The DEIMv2 S, M, L and X sizes take their backbone from DINOv3, so both their weights and the backbone source vendored in LibreYOLO are additionally governed by Meta's DINOv3 License Agreement, which is not an OSI license: redistribution has to carry the agreement with it, and it forbids use for military or warfare purposes, weapons development, espionage, nuclear industries and anything subject to ITAR. Their Hugging Face repositories declare both licenses, and DEIMv2 is also cited separately (arXiv 2509.20787).
Sitasi
@misc{huang2024deim,
title={DEIM: DETR with Improved Matching for Fast Convergence},
author={Shihua, Huang and Zhichao, Lu and Xiaodong, Cun and Yongjun, Yu and Xiao, Zhou and Xi, Shen},
booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
year={2025},
}Disalin dari blok sitasi penulis di github.com/Intellindust-AI-Lab/DEIM#5-citation.
DEIMv2 adalah paper terpisah dan punya blok sitasi sendiri di github.com/Intellindust-AI-Lab/DEIMv2; kutip yang itu jika Anda memakai checkpoint versi 2.