YOLO-NAS
Un detector convoluzionale il cui backbone e il cui neck sono usciti dalla ricerca architetturale di Deci.AI, costruito con blocchi RepVGG pensati per la quantizzazione. I suoi pesi sono di Deci.AI, con licenza solo per uso non commerciale, e LibreYOLO non ne pubblica nessuno.
- Task
- detection, pose, oriented boxes
- Dimensioni
- s, m, l at 640 px
- Installa
pip install libreyolo- Livello di supporto
- Principale, dalla v1.1.0. Rilevatori addestrabili principali: le funzionalità seguono i modelli di punta nella stessa ondata di release.
- Licenze
- Codice Apache-2.0, pesi Deci.AI proprietary, non-commercial. Uso commerciale
Installazione
YOLO-NAS non richiede nulla oltre al pacchetto base.
pip install libreyoloPredizione
Il nome di un checkpoint non ancora presente su disco viene scaricato dalla CDN pubblica di Deci, non dall'org LibreYOLO, che non ospita nessuno di questi pesi. Prima che il trasferimento inizi, la libreria stampa i termini di licenza di Deci una volta per processo, e prima che il file scaricato venga aperto il suo SHA-256 viene confrontato con un valore fissato. Cosa permettono quei termini è spiegato in licenza.
from libreyolo import LibreYOLO, SAMPLE_IMAGE # Un nome non ancora presente su disco viene scaricato dalla CDN di Deci.# Il download stampa prima i termini di licenza di Deci; prendere il file# significa accettarli.model = LibreYOLO("LibreYOLONASs.pt")result = model(SAMPLE_IMAGE, save=True) for box in result.boxes: print(box.cls, box.conf, box.xyxy)libreyolo predict model=LibreYOLONASs.pt save=True \ source=https://raw.githubusercontent.com/LibreYOLO/libreyolo/release/libreyolo/assets/parkour.jpgfrom libreyolo import LibreYOLO, SAMPLE_IMAGE # Il suffisso -pose seleziona la testa per la posa e il suo set di pesi.model = LibreYOLO("LibreYOLONASs-pose.pt")result = model(SAMPLE_IMAGE) print(result.keypoints.xy)L'oggetto Results restituito è lo stesso che restituisce ogni famiglia, quindi
passare a un detector diverso è una modifica di una riga. conf imposta la
soglia di confidenza e iou la soglia della NMS. Vedi
predizione per sorgenti, streaming e gestione dei risultati.
Il task con box orientati restituisce result.obb. Il grafo OBB pubblicato usa un canvas di 1024 pixel e il suo insieme registrato di 18 etichette di classe.
Varianti
Rilevamento e posa sono la stessa architettura sotto teste diverse, e prendono gli stessi argomenti. Le dimensioni nella tabella qui sotto sono quelle del rilevamento; la posa è pubblicata in quelle e in una dimensione più piccola. La testa per la posa predice il set di keypoint di COCO.
| Checkpoint | Ingresso (px) | mAP 50-95 | Parametri (M) |
|---|---|---|---|
| LibreYOLONASl | 640 | 56.3 | 66.98 |
| LibreYOLONASm | 640 | 55.4 | 51.18 |
| LibreYOLONASs | 640 | 51.8 | 19.05 |
COCO val2017, 500 images. Misurato con il sistema di benchmark di LibreYOLO e pubblicato su Vision Analysis, dove vengono confrontate le latenze tra hardware e runtime e sono disponibili i record completi delle esecuzioni.
Addestramento
from libreyolo import LibreYOLO model = LibreYOLO("LibreYOLONASs.pt")model.train(data="my-dataset.yaml", epochs=100, imgsz=640, batch=16)libreyolo train model=LibreYOLONASs.pt data=my-dataset.yaml \ epochs=100 imgsz=640 batch=16from libreyolo import LibreYOLONAS # Nessun checkpoint di Deci viene toccato: il modello parte da pesi# casuali, quindi ciò che esce dalla run deriva solo dai tuoi dati.model = LibreYOLONAS(None, size="s")model.train(data="my-dataset.yaml", imgsz=640, batch=16)epochs, lr0 e amp vengono risolti in base al task quando li ometti, quindi
una run di posa parte da valori predefiniti diversi rispetto a una run di
rilevamento. L'optimizer predefinito è AdamW. Il numero di classi viene dallo
YAML del dataset e la testa viene ricostruita per adattarvisi prima della prima
epoca; sulla testa per la posa il numero di keypoint è gestito allo stesso modo,
quindi su un checkpoint di posa COCO si può fare fine-tuning verso uno scheletro
di dimensione diversa.
Il fine-tuning parte dai pesi di Deci, ed è questo che la licenza di Deci copre. Addestrare da un modello inizializzato a caso non coinvolge nessun checkpoint di Deci, ed è il terzo snippet qui sopra.
Vedi addestramento per dataset, augmentation, multi-GPU e logger.
Il rilevamento usa di default amp=True con amp_dtype="float16"; l'addestramento con box orientati mantiene amp=False. La testa OBB supporta addestramento, predizione e validazione, usa augmentation con ribaltamenti/HSV e seleziona i checkpoint con metrics/mAP50-95(OBB). load_detect_weights_for_obb() la inizializza dai pesi di rilevamento.
Validazione
val() restituisce un dizionario di chiavi metrics/ che coprono precisione,
recall, mAP 50 e mAP 50-95, misurate su qualsiasi dataset nel formato su cui hai
addestrato.
from libreyolo import LibreYOLO model = LibreYOLO("LibreYOLONASs.pt")metrics = model.val(data="my-dataset.yaml") print(metrics["metrics/mAP50-95"])print(metrics["metrics/mAP50"])libreyolo val model=LibreYOLONASs.pt data=my-dataset.yaml# Il file yaml di COCO incluso porta con sé uno script di download, quindi# serve un permesso esplicito a meno che il dataset non sia già in locale.libreyolo val model=LibreYOLONASl.pt data=coco.yaml imgsz=640 \ allow_download_scripts=TrueEsportazione
| Task | ONNX | TorchScript | ExecuTorch | TensorRT | OpenVINO | Paddle | MNN | RKNN | ncnn | TFLite | CoreML | Core AI |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Detection | Detection to ONNX: supportato | Detection to TorchScript: supportato | Detection to ExecuTorch: supportato | Detection to TensorRT: supportato | Detection to OpenVINO: supportato | Detection to Paddle: supportato | Detection to MNN: supportato | Detection to RKNN: supportato | Detection to ncnn: supportato | Detection to TFLite: supportato | Detection to CoreML: non supportato | Detection to Core AI: supportato |
| Pose | Pose to ONNX: supportato | Pose to TorchScript: supportato | Pose to ExecuTorch: supportato | Pose to TensorRT: supportato | Pose to OpenVINO: supportato | Pose to Paddle: supportato | Pose to MNN: non supportato | Pose to RKNN: non supportato | Pose to ncnn: supportato | Pose to TFLite: non supportato | Pose to CoreML: non supportato | Pose to Core AI: non supportato |
| Oriented boxes | Oriented boxes to ONNX: supportato | Oriented boxes to TorchScript: supportato | Oriented boxes to ExecuTorch: supportato | Oriented boxes to TensorRT: supportato | Oriented boxes to OpenVINO: supportato | Oriented boxes to Paddle: non supportato | Oriented boxes to MNN: non supportato | Oriented boxes to RKNN: non supportato | Oriented boxes to ncnn: supportato | Oriented boxes to TFLite: non supportato | Oriented boxes to CoreML: non supportato | Oriented boxes to Core AI: non supportato |
Un artefatto esportato si ricarica con LibreYOLO() in base al suffisso del
file, quindi un file .onnx o .engine si comporta come un checkpoint e
restituisce gli stessi Results. Eseguire il grafo in un runtime nudo, senza
LibreYOLO installato, è altrettanto supportato, ma in quel caso preprocessing e
postprocessing li scrivi tu. Ogni formato installa un extra diverso e prende
qualche argomento suo. Entrambe le cose sono sulla pagina di quel formato.
Un'esportazione è un'altra copia degli stessi pesi in un contenitore diverso. Esportare un checkpoint di Deci non cambia né da dove vengono i pesi né la licenza che li copre.
from libreyolo import LibreYOLO model = LibreYOLO("LibreYOLONASs.pt")model.export(format="onnx", imgsz=640)libreyolo export model=LibreYOLONASs.pt format=onnx imgsz=640from libreyolo import LibreYOLO, SAMPLE_IMAGE # La factory sceglie in base al suffisso del file, quindi un artefatto# esportato si carica come qualsiasi checkpoint e restituisce lo stesso# oggetto Results.model = LibreYOLO("LibreYOLONASs.onnx")result = model(SAMPLE_IMAGE) print(result.boxes.xyxy)Input e output ONNX
LibreYOLONAS detect
| Tensore | images float32 [batch, 3, height, width] |
|---|---|
| Colore | RGB |
| Scala | pixel / 255 |
| Normalizzazione | nessuna |
| Ridimensionamento | custom, Pillow bilinear |
Come riprodurre il ridimensionamento bilineare di Pillow
LibreYOLO ridimensiona con il filtro BILINEAR di Pillow (Image.resize). Non è OpenCV INTER_LINEAR né INTER_AREA: in riduzione, Pillow allarga il filtro del fattore di riduzione, e i ridimensionamenti di OpenCV cambiano le rilevazioni e spostano i riquadri di diversi pixel. Per riprodurlo senza Pillow, ridimensiona un asse, arrotonda a 8 bit, poi ridimensiona l'altro asse e arrotonda di nuovo. Per ogni asse, siano s = in_size / out_size e f = max(s, 1). Il pixel di uscita i ha centro c = (i + 0.5) * s e legge i pixel sorgente j da int(c - f + 0.5) a int(c + f + 0.5) - 1, limitati all'immagine, ciascuno con peso max(0, 1 - |j + 0.5 - c| / f), diviso per la somma dei pesi. Pillow lavora in virgola fissa e sceglie l'ordine degli assi dalla forma dell'immagine, quindi i pesi in virgola mobile possono differire di un livello su pochi pixel. Questo non cambia i risultati nei nostri controlli.
Square input only. Export rejects a non-square imgsz, and height equals width, 640 by default.
The image is not scaled to fill the canvas. The longest side goes to R = min(636, height, width), so 636 at 640 x 640.
Scale by r = min(R / h, R / w) and resize to (round(w * r), round(h * r)). The rounding is Python round, so an exact .5 goes to the even neighbor.
Paste the resized image onto a canvas filled with 114 at left = (width - new_w) // 2 and top = (height - new_h) // 2.
On the test image, cv2.resize with INTER_LINEAR loses two of the eight detections, and INTER_AREA moves boxes by up to 1.4 px.
Divide by 255 after the resize. There is no mean or std normalization.
Detection, esportazione predefinita
| Output | Forma | Significato |
|---|---|---|
pred_logits | [batch, anchors, 4] | Boxes, despite the name. x1, y1, x2, y2 in input-canvas pixels. anchors is the cell count over strides 8, 16 and 32, 8400 at 640 x 640. |
pred_boxes | [batch, anchors, nc] | Class scores, despite the name. Sigmoid already applied. 80 classes for the COCO checkpoints. |
Post-elaborazione
- The output names are swapped relative to their content. Read boxes from pred_logits and scores from pred_boxes, or tell them apart by the last dimension (4 for boxes).
- Take the best class per anchor: score = max over classes, class = argmax. One anchor yields at most one detection.
- Keep anchors whose score is strictly above the confidence threshold (0.25 by default).
- Keep the 1000 highest scoring candidates.
- Map boxes back to the original image: subtract left from x and top from y, divide by r, clip to the image. Drop boxes left with zero width or height.
- Run NMS per class with IoU 0.45 and keep at most 300 detections.
- nms=True is not available for this family: export raises NotImplementedError.
LibreYOLONAS pose
| Tensore | images float32 [batch, 3, height, width] |
|---|---|
| Colore | BGR |
| Scala | pixel / 255 |
| Normalizzazione | nessuna |
| Ridimensionamento | custom, Pillow bilinear |
Come riprodurre il ridimensionamento bilineare di Pillow
LibreYOLO ridimensiona con il filtro BILINEAR di Pillow (Image.resize). Non è OpenCV INTER_LINEAR né INTER_AREA: in riduzione, Pillow allarga il filtro del fattore di riduzione, e i ridimensionamenti di OpenCV cambiano le rilevazioni e spostano i riquadri di diversi pixel. Per riprodurlo senza Pillow, ridimensiona un asse, arrotonda a 8 bit, poi ridimensiona l'altro asse e arrotonda di nuovo. Per ogni asse, siano s = in_size / out_size e f = max(s, 1). Il pixel di uscita i ha centro c = (i + 0.5) * s e legge i pixel sorgente j da int(c - f + 0.5) a int(c + f + 0.5) - 1, limitati all'immagine, ciascuno con peso max(0, 1 - |j + 0.5 - c| / f), diviso per la somma dei pesi. Pillow lavora in virgola fissa e sceglie l'ordine degli assi dalla forma dell'immagine, quindi i pesi in virgola mobile possono differire di un livello su pochi pixel. Questo non cambia i risultati nei nostri controlli.
Square input only. Export rejects a non-square imgsz, and height equals width, 640 by default.
Channels are BGR, unlike detection. Pad value and position also differ from detection.
The longest side goes to R = min(640, height, width), so it fills the canvas.
Scale by r = min(R / h, R / w) and resize to (round(w * r), round(h * r)). The rounding is Python round, so an exact .5 goes to the even neighbor.
Paste the resized image in the top-left corner of a canvas filled with 127. All padding is on the bottom and the right.
On the test image, cv2.resize with INTER_LINEAR or INTER_AREA moves boxes by up to 5 px and keypoints by more than 10 px.
Divide by 255 after the resize. There is no mean or std normalization.
Pose, esportazione predefinita
| Output | Forma | Significato |
|---|---|---|
boxes | [batch, anchors, 4] | Person boxes as x1, y1, x2, y2 in input-canvas pixels. anchors is the cell count over strides 8, 16 and 32, 8400 at 640 x 640. |
scores | [batch, anchors, nc] | Class scores, sigmoid already applied. nc is 1 (person) for the COCO pose checkpoints. |
keypoints_xy | [batch, anchors, num_keypoints, 2] | Keypoint x, y in input-canvas pixels. num_keypoints is 17 (COCO order) for the COCO pose checkpoints. |
keypoints_conf | [batch, anchors, num_keypoints] | Per-keypoint visibility score, sigmoid already applied. |
Post-elaborazione
- Take the best class per anchor: score = max over classes, class = argmax. With one class this is just the person score.
- Keep anchors whose score is at or above the confidence threshold (0.25 by default). This is >=, not > as in detection.
- Keep the 1000 highest scoring candidates.
- Map boxes and keypoints back to the original image: divide x and y by r. The image sits in the top-left corner, so there is no pad offset to subtract.
- Clip boxes to the image and drop boxes left with zero width or height. Keypoints are not clipped and can fall outside the image.
- Run NMS per class with IoU 0.45 and keep at most 300 detections. Keep each survivor's keypoints as (x, y, keypoints_conf).
- nms=True is not available for this family: export raises NotImplementedError.
LibreYOLONAS obb
| Tensore | images float32 [batch, 3, height, width] |
|---|---|
| Colore | BGR |
| Scala | pixel / 255 |
| Normalizzazione | nessuna |
| Ridimensionamento | custom, bilinear |
Square input only. Export rejects a non-square imgsz, and height equals width, 1024 by default.
Channels are BGR, unlike detection. The resize filter and the pad position also differ from detection.
The longest side goes to R = min(1024, height, width), so it fills the canvas.
Scale by r = min(R / h, R / w) and resize to (round(w * r), round(h * r)). The rounding is Python round, so an exact .5 goes to the even neighbor.
The resize is cv2.resize with INTER_LINEAR, not Pillow as in detection and pose. It is skipped when the image already has that size. On the test image, Pillow's filter here changes the detection count.
Paste the resized image in the top-left corner of a canvas filled with 114. All padding is on the bottom and the right.
Divide by 255 after the resize. There is no mean or std normalization.
Oriented boxes, esportazione predefinita
| Output | Forma | Significato |
|---|---|---|
boxes | [batch, anchors, 5] | Rotated boxes as cx, cy, w, h, angle. cx, cy, w and h are in input-canvas pixels. The angle is in radians. The graph computes it as (sigmoid(logit) - 0.25) x pi, so it lies between -pi/4 and 3pi/4 and is not wrapped yet. The w side points along (cos angle, sin angle) in image coordinates, y down. anchors is the cell count over strides 8, 16 and 32, 21504 at 1024 x 1024. |
scores | [batch, anchors, nc] | Class scores, sigmoid already applied. 18 classes (DOTA 2.0) for the published checkpoints. |
Post-elaborazione
- Take the best class per anchor: score = max over classes, class = argmax. One anchor yields at most one detection.
- Keep anchors whose score is at or above the confidence threshold (0.25 by default). This is >=, not > as in detection.
- Keep the 1000 highest scoring candidates.
- Map boxes back to the original image: divide cx, cy, w and h by r. The image sits in the top-left corner, so there is no pad offset, and the angle does not change.
- Clip cx to 0 to the image width and cy to 0 to the image height. w and h are not clipped. Drop boxes with w or h at or below 0.
- Put the long side first: if h > w, swap w and h and add pi/2 to the angle. Then wrap the angle to [-pi/2, pi/2) with angle = ((angle + pi/2) mod pi) - pi/2.
- Run greedy NMS per class on exact rotated-box IoU (polygon intersection area over union, for example cv2.rotatedRectangleIntersection) with IoU 0.45, and keep at most 300 detections. LibreYOLO does not use upstream's matrix soft-NMS.
- LibreYOLO also reports an axis-aligned box per detection. With ex = abs(cos angle) * w / 2 + abs(sin angle) * h / 2 and ey = abs(sin angle) * w / 2 + abs(cos angle) * h / 2, it is cx - ex, cy - ey, cx + ex, cy + ey, clipped to the image.
- nms=True is not available for this family: export raises NotImplementedError.
Per verificare la tua implementazione, passa lo stesso file a LibreYOLO: LibreYOLO("model.onnx").predict("image.jpg") restituisce i risultati di riferimento. Verificato con LibreYOLO 1.7.0.
Checkpoint
Non ce ne sono da elencare. La licenza di Deci vieta la ridistribuzione, quindi
l'org LibreYOLO non pubblica nessun peso di YOLO-NAS e il download si risolve
altrove: un nome della forma LibreYOLONAS<size>.pt,
LibreYOLONAS<size>-pose.pt per la posa, o LibreYOLONAS<size>-obb.pt (s, m, l)
per i box orientati, corrisponde all'oggetto omologo sulla CDN pubblica di Deci.
Solo i checkpoint di cui la libreria fissa lo SHA-256 possono essere scaricati
così. Tutto il resto fallisce invece di aprire un pickle di terze parti non
verificato, e va scaricato a mano e passato come percorso. Un file già su disco
si carica dal suo percorso, senza download e senza controllo del checksum.
Questo vale anche per un .pth di Deci con il suo nome originale, che il loader
riconosce.
Licenza
Controlla la licenza nel repository Hugging Face degli specifici pesi che scarichi. Ogni checkpoint nell<link>organizzazione LibreYOLO</link> ne include una e non è sempre la stessa per tutta la famiglia. Quel repository è la fonte autorevole; il riepilogo seguente descrive le condizioni applicabili al momento dellultima verifica di questa pagina.
Questa è una descrizione delle licenze coinvolte, non una consulenza legale. Se la risposta è importante a fini commerciali, leggi personalmente le licenze e chiedi una consulenza indipendente.
- Lavoro originale
- YOLO-NAS, Deci.AI
- Licenza upstream
- Deci.AI proprietary, non-commercial
- Sorgente upstream
- github.com/Deci-AI/super-gradients
- Codice LibreYOLO
- MIT
- Pesi
- Deci.AI proprietary, non-commercial, distribuiti dai rispettivi autori. LibreYOLO non li ospita né ne mantiene una copia.
- Interpretazione
- Two licenses apply here and they are not the same. The SuperGradients source this port follows is Apache-2.0 and LibreYOLO's own implementation is MIT, so nothing restricts the architecture or the training code. Deci's published checkpoints are a different matter: the YOLO-NAS license grants a revocable, non-transferable right to use them and nothing more. It forbids redistribution and sublicensing, forbids offering them as a managed or remote service, restricts modification and reverse engineering, and rules out commercial use, including any model running in a production environment, unless you hold a separate agreement with Deci. LibreYOLO therefore does not mirror them, and prints those terms once before the download starts. Weights trained from a randomly initialized model on your own data derive from no Deci checkpoint.
LibreYOLO non ospita né fa da mirror per questi pesi: per questa famiglia non esiste nulla nell'org Hugging Face di LibreYOLO. Ogni download automatico va invece alla CDN pubblica di Deci, stampa i termini di Deci una volta per processo prima di iniziare, e viene confrontato con uno SHA-256 fissato prima che il file venga aperto.
L'alternativa è addestrare da un modello inizializzato a caso. L'architettura è Apache-2.0 a monte e MIT qui, quindi un modello addestrato così sui tuoi dati non deriva da nessun checkpoint di Deci.
Citazione
YOLO-NAS è stato rilasciato senza un paper. La voce qui sotto è quella che chiedono i suoi autori, e copre SuperGradients, la libreria in cui è arrivato.
@misc{supergradients,
doi = {10.5281/ZENODO.7789328},
url = {https://zenodo.org/record/7789328},
author = {Aharon, Shay and {Louis-Dupont} and {Ofri Masad} and Yurkova, Kate and {Lotem Fridman} and {Lkdci} and Khvedchenya, Eugene and Rubin, Ran and Bagrov, Natan and Tymchenko, Borys and Keren, Tomer and Zhilko, Alexander and {Eran-Deci}},
title = {Super-Gradients},
publisher = {GitHub},
journal = {GitHub repository},
year = {2021},
}Copiato dal blocco di citazione degli autori disponibile su github.com/Deci-AI/super-gradients#citing.