YOLOv9
단일 단계 합성곱 탐지기입니다. 한 번의 패스로 조밀한 박스 그리드에 점수를 매기고 NMS가 중복을 제거합니다. LibreYOLO는 세 가지 변형을 제공하며 그중 하나에는 NMS 단계가 없습니다.
- 작업
- detection
- 크기
- yolo9: t, s, m, c at 640 px; yolo9_p2: t, s at 640 px
- 설치
pip install libreyolo- 지원 티어
- 플래그십, v1.0.0부터 지원. 기능을 여기에서 먼저 설계하고 GPU로 완전히 검증합니다.
- 라이선스
- 코드 MIT, 가중치 MIT. 상업적 사용
설치
YOLOv9에는 기본 패키지 외의 extra가 필요하지 않습니다.
pip install libreyolo예측
처음 사용할 때 Hugging Face에서 가중치를 다운로드해 로컬에 캐시합니다.
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreYOLO9s.pt")result = model(SAMPLE_IMAGE, save=True) for box in result.boxes: print(box.cls, box.conf, box.xyxy)libreyolo predict model=LibreYOLO9s.pt save=True \ source=https://raw.githubusercontent.com/LibreYOLO/libreyolo/release/libreyolo/assets/parkour.jpgfrom libreyolo import LibreYOLO, SAMPLE_IMAGE # 호출은 같고 체크포인트만 다릅니다. end-to-end 헤드가 자체 최고 점수# 예측을 반환하므로 NMS를 실행하지 않고 iou를 무시합니다.model = LibreYOLO("LibreYOLO9E2Es.pt")result = model(SAMPLE_IMAGE, conf=0.25, max_det=300) print(len(result.boxes))반환되는 Results 객체는 모든 계열이 반환하는 것과 같으므로 탐지기를 바꾸려면 한 줄만 변경하면 됩니다. 기본 모델과 stride-4 모델에서 conf는 신뢰도 임곗값을, iou는 NMS 임곗값을 설정합니다. end-to-end 모델은 NMS를 실행하지 않고 iou를 무시하므로 conf와 max_det이 출력을 결정합니다. 소스, 스트리밍, 결과 처리는 예측을 참조합니다.
변형
세 변형은 백본을 공유합니다. 모두 탐지만 지원하고 같은 인수를 받습니다.
기본 모델은 세 특징 스케일에서 예측하고 NMS로 중복 박스를 제거합니다.
end-to-end 모델은 해당 헤드를 유지하고 옆에 일대일 매칭 브랜치를 추가합니다. 추론은 일대일 브랜치만 읽어 최고 점수 예측을 선택하므로 NMS를 실행하지 않습니다. 배포 런타임에 NMS 연산자가 없을 때 선택합니다.
stride-4 모델은 백본의 한 단계 더 위 레벨을 노출하고 넥을 해당 레벨까지 확장하여 세 스케일 대신 네 스케일에서 예측합니다. 추가 스케일은 픽셀을 적게 차지하는 객체를 위한 것입니다. 공개된 체크포인트 하나는 항공 이미지에서 학습했습니다. 기본 탐지 체크포인트를 전이할 수 있습니다. 백본과 넥은 그대로 불러오고 사전 학습한 세 헤드 타워를 한 슬롯 위로 옮기며 stride-4 타워는 무작위 초기화합니다.
| 체크포인트 | 입력(px) | mAP 50-95 | 파라미터(M) |
|---|---|---|---|
| LibreYOLO9c | 640 | 56.4 | 25.5 |
| LibreYOLO9m | 640 | 55.3 | 20.12 |
| LibreYOLO9s | 640 | 55.9 | 7.2 |
| LibreYOLO9t | 640 | 41.8 | 2.04 |
COCO val2017, 500 images. LibreYOLO 벤치마크 도구로 측정하고 Vision Analysis에 공개했습니다. 이곳에서 하드웨어와 런타임별 지연 시간을 비교하고 전체 실행 기록을 확인할 수 있습니다.
학습
from libreyolo import LibreYOLO model = LibreYOLO("LibreYOLO9s.pt")model.train(data="my-dataset.yaml", epochs=100, imgsz=640, batch=16)libreyolo train model=LibreYOLO9s.pt data=my-dataset.yaml \ epochs=100 imgsz=640 batch=16from libreyolo import LibreYOLO9P2 # stride-4 변형에는 자체 COCO 체크포인트가 없으므로 기본 탐지 체크포인트를# 지정합니다. 백본과 넥은 그대로 불러오고 stride-4 헤드 타워는 무작위 초기화합니다.model = LibreYOLO9P2(None, size="s")model.train(data="my-dataset.yaml", epochs=100, pretrained="LibreYOLO9s.pt")pretrained가 실행의 시작점을 결정합니다. True를 전달하면 같은 모델과 크기의 공개 체크포인트를 불러오고 다른 항목에는 이름이나 경로를 전달합니다. 형태가 일치하지 않는 텐서는 거부하지 않고 건너뛰며 불러온 수를 기록합니다. 따라서 클래스 수가 다른 체크포인트도 시작점으로 사용할 수 있습니다.
stride-4 모델에는 자체 공개 COCO 체크포인트가 없으므로 여기서 True는 존재하지 않는 파일로 해석되어 다운로드가 실패합니다. 대신 기본 탐지 체크포인트의 이름을 지정합니다.
데이터셋, 증강, 다중 GPU, 로거는 학습을 참조합니다.
기본 모델은 기본 헤드 옆에 PGI 보조 분기를 학습할 수 있습니다. 이 분기는 학습 전용이며, 예측과 내보내기는 기본 헤드를 사용합니다. 시작 가중치에 PGI 텐서가 있거나 처음부터 학습하는 경우에 실행이 이 분기를 붙입니다. 공개된 기본 체크포인트에는 PGI 텐서가 없으므로 이를 바탕으로 한 파인튜닝은 기본 헤드만 학습하며 그 사실을 로그로 남깁니다. aux_weight=0.25는 그래도 그 손실 가중치로 새 분기를 붙이고, aux_weight=0은 분기를 끈 채로 둡니다. 학습을 재개한 실행은 체크포인트의 PGI 설정을 유지합니다. m과 c 크기에서 이 분기는 업스트림의 것입니다: 입력 이미지에 대한 두 번째 백본이 있고, 그 단계들을 CBFuse가 기본 백본의 CBLinear 탭과 합산하며, 자체 헤드가 있습니다. 클래스 80개 기준으로 학습 전용 파라미터는 각각 12.8M과 25.7M입니다. 엔드투엔드 모델과 스트라이드 4 모델에는 PGI 분기가 없습니다.
세 변형 모두 각 옵티마이저 스텝 전에 그래디언트 L2 노름을 10으로 클리핑하며, clip_max_norm=0은 클리핑을 끕니다. 레이블 할당은 float16 오토캐스트에서도 앵커 점수를 fp32로 계산합니다. max_labels=300은 학습 이미지당 유지하는 박스 수의 상한이며, 이를 넘는 박스는 한 번만 경고를 남기고 버립니다. 할당 메모리는 상한이 아니라 각 이미지의 실제 박스 수를 따릅니다. SGD 모멘텀은 세 에폭 동안 0.8에서 0.937까지 워밍업합니다. letterbox_pad=None은 체크포인트에 기록된 값을 따릅니다. 기록이 없는 가중치는 topleft를 사용하고, 새로운 공식 변환은 center를 기록합니다.
YOLO9과 YOLOX 모자이크는 최대 20번 추출하여 어노테이션이 있는 짝 이미지를 우선하며, YOLO9 MixUp도 같은 방식을 사용합니다. MixUp은 기본적으로 꺼져 있습니다(mixup_prob=0). 켜면 혼합 비율을 MultimediaTechLab/YOLO와 같이 [0, 1]에서 균등한 Beta(1, 1)에서 추출합니다. RGB 이외 입력 프로파일은 이벤트 히스토그램을 참조하십시오.
검증
val()은 학습에 사용한 형식의 데이터셋을 대상으로 측정한 정밀도, 재현율, mAP 50, mAP 50-95를 포함하는 metrics/ 키 사전을 반환합니다.
from libreyolo import LibreYOLO model = LibreYOLO("LibreYOLO9s.pt")metrics = model.val(data="my-dataset.yaml") print(metrics["metrics/mAP50-95"])print(metrics["metrics/mAP50"])libreyolo val model=LibreYOLO9s.pt data=my-dataset.yaml# 번들 COCO yaml에는 내장 다운로드 스크립트가 있으므로 데이터셋이 이미# 로컬에 있지 않다면 명시적 권한이 필요합니다.libreyolo val model=LibreYOLO9c.pt data=coco.yaml imgsz=640 \ allow_download_scripts=True내보내기
| 작업 | ONNX | TorchScript | ExecuTorch | TensorRT | OpenVINO | Paddle | MNN | RKNN | ncnn | TFLite | CoreML | Core AI |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Detection | Detection to ONNX: 지원함 | Detection to TorchScript: 지원함 | Detection to ExecuTorch: 지원함 | Detection to TensorRT: 지원함 | Detection to OpenVINO: 지원함 | Detection to Paddle: 지원함 | Detection to MNN: 지원함 | Detection to RKNN: 지원하지 않음 | Detection to ncnn: 지원함 | Detection to TFLite: 지원하지 않음 | Detection to CoreML: 지원하지 않음 | Detection to Core AI: 지원함 |
체크 표시는 세 변형 모두에 적용됩니다. 차이가 있는 경우 매트릭스는 셋 중 가장 약한 지원 수준을 표시합니다.
내보낸 아티팩트는 파일 접미사에 따라 LibreYOLO()로 다시 불러오므로 .onnx 또는 .engine 파일은 체크포인트처럼 동작하며 동일한 Results를 반환합니다. LibreYOLO가 설치되지 않은 기본 런타임에서 그래프를 실행할 수도 있지만 이 경우 전처리와 후처리를 직접 작성해야 합니다.
기본 탐지 모델에서는 후처리 절반을 그래프로 옮길 수 있습니다. ONNX 내보내기에 nms=True를 사용하면 억제를 모델 안에 넣고 첫 출력은 행이 x1, y1, x2, y2, score, class인 고정 (1, max_det, 6) 텐서가 됩니다. 탐지 수 이후는 0으로 패딩합니다. 이 그래프는 배치 1이며 동적 축이 없습니다. end-to-end와 stride-4 모델은 이 플래그를 받지 않습니다.
각 형식은 서로 다른 extra를 설치하고 고유한 몇 가지 인수를 받습니다. 둘 다 해당 형식 페이지에 나와 있습니다.
from libreyolo import LibreYOLO model = LibreYOLO("LibreYOLO9s.pt")model.export(format="onnx", imgsz=640)libreyolo export model=LibreYOLO9s.pt format=onnx imgsz=640libreyolo export model=LibreYOLO9s.pt format=onnx nms=True \ conf=0.25 iou=0.45 max_det=300from libreyolo import LibreYOLO, SAMPLE_IMAGE # 팩토리는 파일 접미사에 따라 라우팅하므로 내보낸 아티팩트도# 다른 체크포인트처럼 불러와 동일한 Results 객체를 반환합니다.model = LibreYOLO("LibreYOLO9s.onnx")result = model(SAMPLE_IMAGE) print(result.boxes.xyxy)TFLite INT8는 보정 데이터와 int8=True를 사용합니다.
ONNX 입력과 출력
LibreYOLO9
| 텐서 | images float32 [batch, 3, height, width] |
|---|---|
| 색상 | RGB |
| 스케일링 | 픽셀 / 255 |
| 정규화 | 없음 |
| 크기 조정 | letterbox, bilinear, 패딩 값 114, 패딩 위치는 메타데이터 키 letterbox_pad에서 읽음 |
Scale by r = min(height / h, width / w), resize to (int(w * r), int(h * r)) and paste onto a canvas filled with 114.
Paste position comes from the letterbox_pad metadata key: topleft puts the image in the top-left corner, center splits the padding on both sides. A missing key means topleft.
Detection, 기본 내보내기
| 출력 | 형태 | 의미 |
|---|---|---|
output | [batch, 4 + nc, anchors] | Rows 0 to 3 are x1, y1, x2, y2 in input-canvas pixels. Rows 4 onward are per-class scores, sigmoid already applied. anchors is the cell count over strides 8, 16 and 32, 8400 at 640 x 640. |
후처리
- Transpose to [anchors, 4 + nc].
- Keep every (anchor, class) pair whose score is above the confidence threshold (0.25 by default). One anchor can yield several classes.
- Run NMS per class with IoU 0.45 and keep at most 300 detections.
- Map boxes back to the original image: subtract the pad offset, divide by r, clip to the image.
- Drop boxes whose width or height is 0 after clipping.
Detection, nms=True
| 출력 | 형태 | 의미 |
|---|---|---|
output | [1, max_det, 6] | Rows are x1, y1, x2, y2, score, class in input-canvas pixels, zero-padded past the detection count. Confidence, IoU and max_det are baked in and recorded as nms_conf, nms_iou and max_det metadata. |
raw | [1, 4 + nc, anchors] | The same tensor as the default export's output, before suppression. |
후처리
- Drop rows whose score is 0 or below your threshold.
- Map boxes back to the original image: subtract the pad offset, divide by r, clip to the image.
LibreYOLO9E2E
| 텐서 | images float32 [batch, 3, height, width] |
|---|---|
| 색상 | RGB |
| 스케일링 | 픽셀 / 255 |
| 정규화 | 없음 |
| 크기 조정 | letterbox, bilinear, 패딩 값 114, 패딩 위치는 메타데이터 키 letterbox_pad에서 읽음 |
Scale by r = min(height / h, width / w), resize to (int(w * r), int(h * r)) and paste onto a canvas filled with 114.
Paste position comes from the letterbox_pad metadata key: topleft puts the image in the top-left corner, center splits the padding on both sides. A missing key means topleft.
This model has no nms=True export. The exporter raises NotImplementedError, so only the default export below exists.
Detection, 기본 내보내기
| 출력 | 형태 | 의미 |
|---|---|---|
output | [batch, 4 + nc, anchors] | Predictions of the one-to-one head only. Rows 0 to 3 are x1, y1, x2, y2 in input-canvas pixels. Rows 4 onward are per-class scores, sigmoid already applied. anchors is the cell count over strides 8, 16 and 32, 8400 at 640 x 640. |
후처리
- Transpose to [anchors, 4 + nc].
- Flatten the [anchors, nc] scores into one list of anchors x nc (anchor, class) pairs. Pair i belongs to anchor i / nc (integer division) and class i % nc.
- Keep the 300 highest-scoring pairs (max_det), highest first. One anchor can yield several classes.
- Of those, keep the pairs whose score is above the confidence threshold (0.25 by default).
- Do not run NMS. The one-to-one head is trained to fire once per object, and LibreYOLO ignores the iou setting for this model.
- Map boxes back to the original image: subtract the pad offset, divide by r, clip to the image.
- Drop boxes whose width or height is 0 after clipping.
LibreYOLO9P2
| 텐서 | images float32 [batch, 3, height, width] |
|---|---|
| 색상 | RGB |
| 스케일링 | 픽셀 / 255 |
| 정규화 | 없음 |
| 크기 조정 | letterbox, bilinear, 패딩 값 114, 패딩 위치는 메타데이터 키 letterbox_pad에서 읽음 |
Scale by r = min(height / h, width / w), resize to (int(w * r), int(h * r)) and paste onto a canvas filled with 114.
Paste position comes from the letterbox_pad metadata key: topleft puts the image in the top-left corner, center splits the padding on both sides. A missing key means topleft.
This model has no nms=True export. The exporter raises NotImplementedError, so only the default export below exists.
Detection, 기본 내보내기
| 출력 | 형태 | 의미 |
|---|---|---|
output | [batch, 4 + nc, anchors] | Rows 0 to 3 are x1, y1, x2, y2 in input-canvas pixels. Rows 4 onward are per-class scores, sigmoid already applied. anchors is the cell count over strides 4, 8, 16 and 32, 34000 at 640 x 640. nc is 10 for LibreYOLO9P2s-visdrone. |
후처리
- Transpose to [anchors, 4 + nc].
- Keep every (anchor, class) pair whose score is above the confidence threshold (0.25 by default). One anchor can yield several classes.
- Run NMS per class with IoU 0.45 and keep at most 300 detections.
- Map boxes back to the original image: subtract the pad offset, divide by r, clip to the image.
- Drop boxes whose width or height is 0 after clipping.
직접 구현한 코드를 확인하려면 같은 파일을 LibreYOLO로 실행하세요. LibreYOLO("model.onnx").predict("image.jpg")가 기준 결과를 반환합니다. LibreYOLO 1.7.0으로 검증함.
체크포인트
이 계열에 공개된 모든 가중치 파일입니다.
| 파일 | 입력(px) | 가중치 라이선스 |
|---|---|---|
| Detection | ||
| LibreYOLO9t.pt | 640 | mit |
| LibreYOLO9s.pt | 640 | mit |
| LibreYOLO9m.pt | 640 | mit |
| LibreYOLO9c.pt | 640 | mit |
| LibreYOLO9E2Et.pt | 640 | mit |
| LibreYOLO9E2Es.pt | 640 | mit |
| LibreYOLO9E2Em.pt | 640 | mit |
| LibreYOLO9E2Ec.pt | 640 | mit |
| LibreYOLO9P2s-visdrone.pt | cc-by-nc-sa-3.0 | |
위의 모든 파일은 현재 LibreYOLO 조직에 있으며 처음 사용할 때 내려받습니다.
라이선스
내려받는 특정 가중치의 Hugging Face 저장소에서 라이선스를 확인하십시오. LibreYOLO 조직의 모든 체크포인트에는 라이선스가 있으며 한 계열 안에서도 항상 같지는 않습니다. 해당 저장소가 신뢰할 수 있는 기준입니다. 아래 요약은 이 페이지를 마지막으로 검증했을 때 적용된 내용을 설명합니다.
관련 라이선스에 관한 설명이며 법률 자문이 아닙니다. 상업적으로 중요한 사안이라면 라이선스를 직접 읽고 별도의 법률 자문을 받으십시오.
- 원작
- YOLOv9, MultimediaTechLab
- 업스트림 라이선스
- MIT
- LibreYOLO 코드
- MIT
- 가중치
- MIT, huggingface.co/LibreYOLO에 다시 게시됨
- 해석
- MIT is a permissive license, so these weights can be used in commercial and closed-source products. The one standing obligation is to keep the license text and the copyright notice, Kin-Yiu Wong and Hao-Tang Tsui, with any copy you redistribute. It places no condition on your own application code, and a model you train yourself on your own data is yours. Two things are worth knowing beyond that. The code is ported from the authors' MIT re-release of YOLOv9, MultimediaTechLab/YOLO at commit c4cb5f6f, not the GPL-3.0 repository that carries the same model, so the permissive terms come from the source LibreYOLO actually derives from. And one checkpoint in this family is not MIT: the weight repository of the stride-4 VisDrone model, LibreYOLO9P2s-visdrone.pt, declares CC BY-NC-SA 3.0, which rules out commercial use and requires share-alike on derivatives.
세 변형의 코드는 모두 MultimediaTechLab/YOLO의 커밋 c4cb5f6f(MIT)에서 포팅했습니다. 엔드투엔드 모델의 일대일 예측기는 Yiqun Chen의 DATE(Apache-2.0) 설계를 따르며, DATE 코드를 복사하지 않고 LibreYOLO용으로 구현했습니다. 스트라이드 4 레벨은 LibreYOLO 코드입니다.
스트라이드 4 항공 체크포인트는 VisDrone 클래스를 예측합니다. 가중치 저장소에 기록된 배포자 선언 라이선스를 따릅니다.
인용
@inproceedings{wang2024yolov9,
title={{YOLOv9}: Learning What You Want to Learn Using Programmable Gradient Information},
author={Wang, Chien-Yao and Yeh, I-Hau and Liao, Hong-Yuan Mark},
year={2024},
booktitle={Proceedings of the European Conference on Computer Vision (ECCV)},
}github.com/MultimediaTechLab/YOLO#citations에 있는 저자의 인용 블록에서 복사했습니다.