콘텐츠로 건너뛰기

다음을 사용하여 모델 내보내기 Ultralytics YOLO

Ultralytics YOLO 에코시스템 및 통합

소개

The ultimate goal of training a model is to deploy it for real-world applications. Export mode in Ultralytics YOLO11 offers a versatile range of options for exporting your trained model to different formats, making it deployable across various platforms and devices. This comprehensive guide aims to walk you through the nuances of model exporting, showcasing how to achieve maximum compatibility and performance.



Watch: How To Export Custom Trained Ultralytics YOLO Model and Run Live Inference on Webcam.

Why Choose YOLO11's Export Mode?

  • 다용도성: ONNX , TensorRT, CoreML, 등 다양한 형식으로 내보낼 수 있습니다.
  • 성능: TensorRT 으로 최대 5배 GPU 속도 향상, ONNX 또는 OpenVINO 로 3배 CPU 속도 향상 .
  • 호환성: 다양한 하드웨어 및 소프트웨어 환경에서 모델을 범용적으로 배포할 수 있습니다.
  • 사용 편의성: 간단한 CLI 및 Python API로 빠르고 간편하게 모델을 내보낼 수 있습니다.

내보내기 모드의 주요 기능

다음은 몇 가지 눈에 띄는 기능입니다:

  • 원클릭 내보내기: 다양한 형식으로 내보내기를 위한 간단한 명령어입니다.
  • 일괄 내보내기: 일괄 추론이 가능한 모델을 내보냅니다.
  • 추론 최적화: 내보낸 모델은 더 빠른 추론 시간을 위해 최적화되어 있습니다.
  • 튜토리얼 동영상: 원활한 내보내기 환경을 위한 심층 가이드 및 튜토리얼입니다.

  • 내보내기 ONNX 또는 OpenVINO 로 내보내면 CPU 속도가 최대 3배 빨라집니다.
  • 내보내기 TensorRT 로 내보내면 GPU 속도가 최대 5배 빨라집니다.

사용 예

Export a YOLO11n model to a different format like ONNX or TensorRT. See the Arguments section below for a full list of export arguments.

from ultralytics import YOLO

# Load a model
model = YOLO("yolo11n.pt")  # load an official model
model = YOLO("path/to/best.pt")  # load a custom trained model

# Export the model
model.export(format="onnx")
yolo export model=yolo11n.pt format=onnx  # export official model
yolo export model=path/to/best.pt format=onnx  # export custom trained model

인수

이 표에는 YOLO 모델을 다양한 형식으로 내보내는 데 사용할 수 있는 구성 및 옵션이 자세히 설명되어 있습니다. 이러한 설정은 내보낸 모델의 성능, 크기 및 다양한 플랫폼과 환경에서의 호환성을 최적화하는 데 매우 중요합니다. 적절한 구성을 통해 모델이 최적의 효율성으로 의도한 애플리케이션에 배포될 수 있도록 준비할 수 있습니다.

인수유형기본값설명
formatstr'torchscript'내보낸 모델의 대상 형식은 다음과 같습니다. 'onnx', 'torchscript', 'tensorflow'등을 사용하여 다양한 배포 환경과의 호환성을 정의합니다.
imgszint 또는 tuple640모델 입력에 사용할 원하는 이미지 크기입니다. 정사각형 이미지의 경우 정수 또는 튜플일 수 있습니다. (height, width) 를 입력합니다.
kerasboolFalseEnables export to Keras format for TensorFlow SavedModel, providing compatibility with TensorFlow serving and APIs.
optimizeboolFalseTorchScript 으로 내보낼 때 모바일 장치에 대한 최적화를 적용하여 모델 크기를 줄이고 성능을 개선할 수 있습니다.
halfboolFalseFP16(반정밀) 양자화를 활성화하여 모델 크기를 줄이고 지원되는 하드웨어에서 추론 속도를 높일 수 있습니다.
int8boolFalseActivates INT8 quantization, further compressing the model and speeding up inference with minimal accuracy loss, primarily for edge devices.
dynamicboolFalseONNX, TensorRT 및 OpenVINO 내보내기에 대한 동적 입력 크기를 허용하여 다양한 이미지 크기를 유연하게 처리할 수 있습니다.
simplifyboolTrue다음을 사용하여 ONNX 내보내기에 대한 모델 그래프를 단순화합니다. onnxslim를 사용하여 성능과 호환성을 개선할 수 있습니다.
opsetintNone다른 ONNX 파서 및 런타임과의 호환성을 위해 ONNX 옵셋 버전을 지정합니다. 설정하지 않으면 지원되는 최신 버전을 사용합니다.
workspacefloat4.0TensorRT 최적화를 위한 최대 작업 공간 크기를 GiB 단위로 설정하여 메모리 사용량과 성능의 균형을 맞춥니다.
nmsboolFalse정확하고 효율적인 탐지 후처리를 위해 필수적인 비최대 억제(NMS)를 CoreML 내보내기에 추가합니다.
batchint1내보내기 모델 일괄 추론 크기 또는 내보낸 모델이 동시에 처리할 최대 이미지 수를 지정합니다. predict 모드로 전환합니다.

Adjusting these parameters allows for customization of the export process to fit specific requirements, such as deployment environment, hardware constraints, and performance targets. Selecting the appropriate format and settings is essential for achieving the best balance between model size, speed, and accuracy.

내보내기 형식

Available YOLO11 export formats are in the table below. You can export to any format using the format 인수, 즉 format='onnx' 또는 format='engine'. 내보낸 모델에서 직접 예측하거나 유효성을 검사할 수 있습니다. yolo predict model=yolo11n.onnx. 내보내기가 완료된 후 모델에 대한 사용 예가 표시됩니다.

형식format 인수모델메타데이터인수
PyTorch-yolo11n.pt-
TorchScripttorchscriptyolo11n.torchscriptimgsz, optimize, batch
ONNXonnxyolo11n.onnximgsz, half, dynamic, simplify, opset, batch
OpenVINOopenvinoyolo11n_openvino_model/imgsz, half, int8, batch
TensorRTengineyolo11n.engineimgsz, half, dynamic, simplify, workspace, int8, batch
CoreMLcoremlyolo11n.mlpackageimgsz, half, int8, nms, batch
TF SavedModelsaved_modelyolo11n_saved_model/imgsz, keras, int8, batch
TF GraphDefpbyolo11n.pbimgsz, batch
TF Litetfliteyolo11n.tfliteimgsz, half, int8, batch
TF Edge TPUedgetpuyolo11n_edgetpu.tfliteimgsz
TF.jstfjsyolo11n_web_model/imgsz, half, int8, batch
PaddlePaddlepaddleyolo11n_paddle_model/imgsz, batch
NCNNncnnyolo11n_ncnn_model/imgsz, half, batch

자주 묻는 질문

How do I export a YOLO11 model to ONNX format?

Exporting a YOLO11 model to ONNX format is straightforward with Ultralytics. It provides both Python and CLI methods for exporting models.

from ultralytics import YOLO

# Load a model
model = YOLO("yolo11n.pt")  # load an official model
model = YOLO("path/to/best.pt")  # load a custom trained model

# Export the model
model.export(format="onnx")
yolo export model=yolo11n.pt format=onnx  # export official model
yolo export model=path/to/best.pt format=onnx  # export custom trained model

For more details on the process, including advanced options like handling different input sizes, refer to the ONNX section.

모델 내보내기에 TensorRT 을 사용하면 어떤 이점이 있나요?

Using TensorRT for model export offers significant performance improvements. YOLO11 models exported to TensorRT can achieve up to a 5x GPU speedup, making it ideal for real-time inference applications.

  • 다용도성: 특정 하드웨어 설정에 맞게 모델을 최적화하세요.
  • 속도: 고급 최적화를 통해 더 빠른 추론을 달성하세요.
  • 호환성: NVIDIA 하드웨어와 원활하게 통합됩니다.

To learn more about integrating TensorRT, see the TensorRT integration guide.

How do I enable INT8 quantization when exporting my YOLO11 model?

INT8 양자화는 특히 엣지 디바이스에서 모델을 압축하고 추론 속도를 높일 수 있는 훌륭한 방법입니다. INT8 양자화를 활성화하는 방법은 다음과 같습니다:

from ultralytics import YOLO

model = YOLO("yolo11n.pt")  # Load a model
model.export(format="onnx", int8=True)
yolo export model=yolo11n.pt format=onnx int8=True   # export model with INT8 quantization

INT8 quantization can be applied to various formats, such as TensorRT and CoreML. More details can be found in the Export section.

모델을 내보낼 때 동적 입력 크기가 중요한 이유는 무엇인가요?

동적 입력 크기를 사용하면 내보낸 모델이 다양한 이미지 크기를 처리할 수 있어 유연성을 제공하고 다양한 사용 사례에 맞게 처리 효율을 최적화할 수 있습니다. ONNX 또는 TensorRT 과 같은 형식으로 내보낼 때 동적 입력 크기를 활성화하면 모델이 다양한 입력 모양에 원활하게 적응할 수 있습니다.

이 기능을 사용하려면 dynamic=True 플래그를 내보내는 중입니다:

from ultralytics import YOLO

model = YOLO("yolo11n.pt")
model.export(format="onnx", dynamic=True)
yolo export model=yolo11n.pt format=onnx dynamic=True

자세한 내용은 동적 입력 크기 구성을 참조하세요.

모델 성능을 최적화하기 위해 고려해야 할 주요 내보내기 인수는 무엇인가요?

내보내기 인수를 이해하고 구성하는 것은 모델 성능을 최적화하는 데 매우 중요합니다:

  • format: 내보낸 모델의 대상 형식(예, onnx, torchscript, tensorflow).
  • imgsz: 모델 입력에 대한 원하는 이미지 크기(예 640 또는 (height, width)).
  • half: FP16 양자화를 지원하여 모델 크기를 줄이고 추론 속도를 높일 수 있습니다.
  • optimize: 모바일 또는 제한된 환경을 위한 특정 최적화를 적용합니다.
  • int8: INT8 정량화를 지원하여 엣지 배포에 매우 유용합니다.

For a detailed list and explanations of all the export arguments, visit the Export Arguments section.

📅 Created 11 months ago ✏️ Updated 20 days ago

댓글