Skip to content
Search

YOLO

lastmod 2026-10-11created 2016-03-1520 edits

You only look once (YOLO) is a state-of-the-art, real-time object detection system. On a Titan X it processes images at 40-90 FPS and has a mAP on VOC 2007 of 78.6% and a mAP of 48.1% on COCO test-dev.

Categories

ONNX conversion code

(As of January 19, 2026) Usable up to Python 3.13.xx.

Install packages:

pip3 install onnx onnxruntime onnxslim
  • onnx>=1.20.1
  • onnxruntime>=1.23.2
  • onnxslim>=0.1.82

Python code for the conversion:

"""YOLO 모델을 ONNX 형식으로 변환하는 스크립트."""

from pathlib import Path

from ultralytics import YOLO


def export_to_onnx(weights_path: str, opset: int = 12, simplify: bool = True, dynamic: bool = True) -> str:
    """
    YOLO 모델을 ONNX 형식으로 변환합니다.

    Args:
        weights_path: .pt 모델 파일 경로
        opset: ONNX opset 버전 (기본값: 12)
        simplify: onnx-simplifier 적용 여부 (기본값: True)
        dynamic: dynamic batch size 지원 여부 (기본값: True)

    Returns:
        변환된 ONNX 파일 경로
    """
    model = YOLO(weights_path)
    export_path = model.export(format="onnx", opset=opset, simplify=simplify, dynamic=dynamic)
    return export_path


def main():
    weights_dir = Path(__file__).parent / "weights"

    models = [
        weights_dir / "sh_weld_defect-20251113.pt",
        weights_dir / "sh_weld_zone-20251222.pt",
    ]

    for model_path in models:
        if not model_path.exists():
            print(f"모델 파일을 찾을 수 없습니다: {model_path}")
            continue

        print(f"변환 중: {model_path.name}")
        onnx_path = export_to_onnx(str(model_path))
        print(f"완료: {onnx_path}")


if __name__ == "__main__":
    main()

Troubleshooting

EarlyStopping: Training stopped early as no improvement observed in last N epochs

EarlyStopping: Training stopped early as no improvement observed in last 50 epochs.
Best results observed at epoch 9, best model saved as best.pt.

Validation performance (mAP50-95) peaked at epoch 9. After that, when it failed to beat that record 50 times in a row, up to epoch 9+50 = 59, training stopped automatically (early termination without completing all epochs).

If you intentionally want to run all the way to the maximum epoch, rerun with patience=0 (disabled) or with it increased to patience=100 or more.

Documentation

You Only Look Once: Unified, Real-Time Object Detection
http://pjreddie.com/darknet/yolo/
https://github.com/pjreddie/darknet
1506.02640v4.pdf
YOLO9000 - Better, Faster, Stronger
https://arxiv.org/abs/1612.08242v1

Projects

PyLabel
A Python library for computer vision labeling tasks. Its core feature is converting bounding box annotations between different formats (e.g., from coco to yolo).
https://github.com/pylabel-project/pylabel

See also

Favorite site

author Zer0 sitemap