Ultralytics YOLO27: 대기자 명단에 등록해 주십시오.

Intel OpenVINO 내보내기

OpenVINO Intel AI inference toolkit

이 가이드에서는 Ultralytics YOLO26 모델을 OpenVINO 형식으로 내보내는 방법을 다룹니다. 이를 통해 CPU 속도를 최대 3배 높이고, Intel GPU 및 NPU 하드웨어에서 YOLO 추론을 가속할 수 있습니다.

OpenVINO는 Open Visual Inference & Neural Network Optimization toolkit의 약자로, AI 추론 모델을 최적화하고 배포하기 위한 Intel의 툴킷입니다. 이름에 Visual이 포함되어 있지만 OpenVINO는 언어, 오디오, 시계열 등 다양한 추가 작업도 지원합니다.



시청: 더 빠른 추론을 위해 Ultralytics YOLO26을 Intel OpenVINO 형식으로 내보내는 방법 🚀

지원 작업#

OpenVINO 내보내기는 Ultralytics의 7가지 작업을 모두 지원합니다. 시맨틱 분할과 깊이 추정은 해당 헤드를 제공하는 유일한 제품군인 YOLO26에서만 사용할 수 있습니다.

작업YOLOv8YOLO11YOLO26
탐지✅✅✅
세그멘테이션✅✅✅
시맨틱❌❌✅
깊이❌❌✅
분류✅✅✅
포즈✅✅✅
OBB✅✅✅

설치#

다음 명령어로 OpenVINO 내보내기 종속 항목을 설치하세요.

pip install "ultralytics[export-openvino]"

이러한 종속 항목은 ultralytics[export]에도 포함되어 있으며 내보내기 시 필요한 경우 자동으로 설치됩니다.

사용 예시#

OpenVINO 형식은 내보내기, 예측, 검증 모드를 지원합니다. 모델을 내보낸 다음 내보낸 모델을 불러와 추론을 실행하거나 Intel CPU, 통합/독립 GPU 또는 NPU에서 정확도를 검증하세요.

내보내기
from ultralytics import YOLO

# YOLO26 모델 로드
model = YOLO("yolo26n.pt")

# 모델을 OpenVINO 형식으로 내보내기
model.export(format="openvino")  # creates 'yolo26n_openvino_model/'
예측
from ultralytics import YOLO

# 내보낸 OpenVINO 모델 불러오기
model = YOLO("yolo26n_openvino_model/")

# 추론 실행
results = model("https://ultralytics.com/images/bus.jpg")

# 특정 디바이스에서 추론 실행, 사용 가능한 디바이스: ["intel:gpu", "intel:npu", "intel:cpu"]
results = model("https://ultralytics.com/images/bus.jpg", device="intel:gpu")
검증
from ultralytics import YOLO

# 내보낸 OpenVINO 모델 불러오기
model = YOLO("yolo26n_openvino_model/")

# COCO8 데이터셋에서 정확도 검증
metrics = model.val(data="coco8.yaml")

내보내기 인수#

인수유형기본값설명
formatstr'openvino'내보낸 모델의 대상 형식으로, 다양한 배포 환경과의 호환성을 정의합니다.
imgszint 또는 tuple640모델 입력에 사용할 이미지 크기입니다. 정사각형 이미지에는 정수를 사용하고, 특정 크기에는 튜플 (height, width)을 사용할 수 있습니다.
quantizeint 또는 strNone양자화 정밀도: 16(FP16) 또는 8(INT8/PTQ, 보정용 data/fraction 필요)입니다. 32/미설정은 FP32입니다. 더 이상 사용되지 않는 half/int8 플래그를 대체합니다.
dynamicboolFalse동적 입력 크기를 허용하여 다양한 이미지 크기를 유연하게 처리할 수 있습니다.
nmsbool, 선택 사항None원시 출력(None, 기본값), 내장 NMS(True) 또는 NMS가 없는 head(False)를 선택합니다.
batchint1내보내기 모델의 배치 추론 크기 또는 predict 모드에서 내보낸 모델이 동시에 처리할 최대 이미지 수를 지정합니다.
datastrNone양자화에 필수적인 데이터셋 YAML 경로입니다. 분류 작업의 경우 데이터셋 디렉터리 또는 기본 제공 데이터셋 이름을 사용합니다. quantize=8이 지정되지 않으면 Ultralytics가 모델 작업에 맞는 기본 보정 데이터셋을 선택합니다.
fractionfloat, int 또는 list1.0비율, 이미지 수 또는 [train, val, test] 비율/개수로 지정하는 보정 하위 집합입니다. 항목이 두 개인 목록에서는 test이 전체로 설정되고, 0는 건너뜁니다.
devicestrNone내보내기에 사용할 디바이스를 지정합니다. CPU는 device=cpu, Apple 실리콘용 MPS는 device=mps입니다.

내보내기 프로세스에 관한 자세한 내용은 내보내기에 관한 Ultralytics 문서 페이지를 참조하세요.

경고

OpenVINO™는 대부분의 Intel® 프로세서와 호환됩니다. 최적의 성능을 보장하려면 다음을 확인하세요.

  1. OpenVINO™ 지원 확인 Intel 호환성 목록을 참조하여 사용 중인 Intel® 칩이 OpenVINO™에서 공식 지원되는지 확인하세요.

  2. 가속기 확인 Intel 하드웨어 가이드를 참조하여 프로세서에 통합 NPU(신경망 처리 장치) 또는 통합 GPU가 포함되어 있는지 확인하세요.

  3. 최신 드라이버 설치 칩에서 NPU 또는 GPU를 지원하지만 OpenVINO™가 이를 감지하지 못하는 경우 관련 드라이버를 설치하거나 업데이트해야 할 수 있습니다. 전체 가속 기능을 사용하려면 드라이버 설치 안내를 따르세요.

이 세 단계를 따르면 Intel® 하드웨어에서 OpenVINO™가 최적으로 실행되도록 할 수 있습니다.

OpenVINO의 이점#

  1. 성능: OpenVINO는 Intel CPU, 통합 및 외장 GPU, NPU에서 고성능 추론을 제공합니다.
  2. 이기종 실행 지원: OpenVINO는 한 번 작성한 코드를 지원되는 모든 Intel 하드웨어(CPU, GPU, NPU)에 배포할 수 있는 API를 제공합니다.
  3. 모델 변환: OpenVINO의 모델 변환 API는 PyTorch, TensorFlow, TensorFlow Lite, ONNX 및 PaddlePaddle과 같은 널리 사용되는 딥러닝 프레임워크의 모델을 가져와 변환하고 최적화합니다.
  4. 사용 편의성: 이 툴킷에는 툴킷의 다양한 측면을 설명하는 여러 튜토리얼 노트북(YOLO26 최적화 포함)이 제공됩니다.

OpenVINO 내보내기 구조#

모델을 OpenVINO 형식으로 내보내면 다음 항목이 포함된 디렉터리가 생성됩니다.

  1. XML 파일: 네트워크 토폴로지를 설명합니다.
  2. BIN 파일: 가중치와 편향의 바이너리 데이터를 포함합니다.
  3. 메타데이터 파일: metadata.yaml에는 클래스 이름, 이미지 크기, 작업 등 모델 메타데이터가 저장되며, Ultralytics가 모델을 불러올 때 이를 읽습니다.

이러한 파일을 사용하여 OpenVINO Runtime으로 추론을 실행할 수 있습니다.

배포에서 OpenVINO 내보내기 사용하기#

모델을 OpenVINO 형식으로 성공적으로 내보낸 후에는 추론을 실행하는 두 가지 주요 방법이 있습니다.

  1. 고수준 API를 제공하고 OpenVINO Runtime을 래핑하는 ultralytics 패키지를 사용합니다.

  2. 추론 동작을 더 고급 방식으로 제어하거나 사용자 지정하려면 네이티브 openvino 패키지를 사용합니다.

Ultralytics를 사용한 추론#

ultralytics 패키지는 predict 메서드를 통해 내보낸 OpenVINO 모델에서 추론을 실행합니다. device 인수를 사용해 대상 기기(예: intel:gpu, intel:npu, intel:cpu)를 지정할 수도 있습니다.

from ultralytics import YOLO

# 내보낸 OpenVINO 모델 불러오기
ov_model = YOLO("yolo26n_openvino_model/")  # 내보낸 OpenVINO 모델의 경로
# 내보낸 모델로 추론 실행
ov_model.predict(device="intel:gpu")  # 추론을 실행할 디바이스 지정

이 방식은 추론 파이프라인을 완전히 제어할 필요가 없는 빠른 프로토타이핑이나 배포에 적합합니다.

OpenVINO Runtime을 사용한 추론#

OpenVINO Runtime은 지원되는 모든 Intel 하드웨어에서 추론을 수행하기 위한 통합 API를 제공합니다. 또한 Intel 하드웨어 간 부하 분산 및 비동기 실행과 같은 고급 기능도 제공합니다.

Runtime에서 모델을 올바르게 설정하고 사용하려면 XML 및 BIN 파일과 입력 크기, 정규화 스케일 팩터 등 애플리케이션별 설정이 필요합니다.

배포 애플리케이션에서는 일반적으로 다음 단계를 수행합니다.

  1. core = Core()을 생성하여 OpenVINO를 초기화합니다.
  2. core.read_model() 메서드를 사용하여 모델을 불러옵니다.
  3. core.compile_model() 함수를 사용하여 모델을 컴파일합니다.
  4. 입력(이미지, 텍스트, 오디오 등)을 준비합니다.
  5. compiled_model(input_data)을 사용하여 추론을 실행합니다.

더 자세한 단계와 코드 예제는 OpenVINO 문서 또는 API 튜토리얼을 참조하세요.

OpenVINO YOLO26 벤치마크#

Ultralytics 팀은 OpenVINO와 호환되는 다양한 Intel 기기에서 속도와 정확도를 평가하기 위해 여러 모델 형식과 정밀도(FP32, FP16, INT8)를 사용하여 YOLO26을 벤치마킹했습니다.

참고
  • 아래 벤치마크 결과는 참고용이며, 시스템의 정확한 하드웨어 및 소프트웨어 구성과 벤치마크 실행 당시의 시스템 작업 부하에 따라 달라질 수 있습니다.

  • 모든 벤치마크는 openvino Python 패키지 버전 2026.2.1로 실행했습니다.

  • NPU에서 YOLO26 모델은 2xxV 시리즈 및 3xx 시리즈 이상을 탑재한 Intel® Core™ Ultra™ 시스템에서만 지원됩니다.

Intel® Core™ Ultra#

Intel® Core™ Ultra™ 시리즈는 CPU 코어, 통합 GPU 및 전용 신경망 처리 장치(NPU)를 하나의 칩에 결합하여 단일 시스템에서 기존 처리, GPU 가속 워크로드 및 온디바이스 AI 추론을 처리할 수 있습니다.

이 하이브리드 설계를 통해 OpenVINO는 애플리케이션의 지연 시간, 처리량 및 전력 요구 사항에 따라 CPU, GPU 또는 NPU에서 추론을 실행할 수 있습니다. 제품군은 에너지 효율적인 설계부터 더 많은 연산 성능이 필요한 노트북 및 소형 폼팩터용으로 "H" 표기가 붙은 고성능 제품까지 다양합니다.

아래 벤치마크는 Intel® Core™ Ultra™ X7 358H, Intel® Core™ Ultra™ 7 258V 및 Intel® Core™ Ultra™ 7 155H에서 FP32, FP16 및 INT8 정밀도로 실행한 결과입니다.

Intel® Core™ Ultra™ X7 358H#

벤치마크
YOLO26 OpenVINO benchmarks on the Intel Core Ultra X7 358H integrated Arc GPU
상세 벤치마크 결과
모델형식정밀도상태크기(MB)metrics/mAP50-95(B)추론 시간(ms/이미지)
YOLO26nPyTorch(CPU)FP32✅5.30.476529.28
YOLO26nOpenVINOFP32✅9.70.47624.09
YOLO26nOpenVINOFP16✅5.10.47624.03
YOLO26nOpenVINOINT8✅3.20.46344.24
YOLO26sPyTorch(CPU)FP32✅19.50.570359.32
YOLO26sOpenVINOFP32✅36.70.56165.08
YOLO26sOpenVINOFP16✅18.70.56165.14
YOLO26sOpenVINOINT8✅10.00.54624.47
YOLO26mPyTorch(CPU)FP32✅42.20.6196143.21
YOLO26mOpenVINOFP32✅78.40.61667.1
YOLO26mOpenVINOFP16✅39.50.61667.06
YOLO26mOpenVINOINT8✅20.60.60555.61
YOLO26lPyTorch(CPU)FP32✅50.70.6215181.16
YOLO26lOpenVINOFP32✅95.30.62058.45
YOLO26lOpenVINOFP16✅48.10.62058.49
YOLO26lOpenVINOINT8✅25.20.59386.25
YOLO26xPyTorch(CPU)FP32✅113.20.6512379.75
YOLO26xOpenVINOFP32✅213.30.656813.03
YOLO26xOpenVINOFP16✅107.10.656812.98
YOLO26xOpenVINOINT8✅54.80.63858.74

Intel® Core™ Ultra™ 7 258V#

벤치마크
YOLO26 OpenVINO benchmarks on the Intel Core Ultra 7 258V integrated Arc GPU
상세 벤치마크 결과
모델형식정밀도상태크기(MB)metrics/mAP50-95(B)추론 시간(ms/이미지)
YOLO26nPyTorch(CPU)FP32✅5.30.476527.33
YOLO26nOpenVINOFP32✅9.60.47643.33
YOLO26nOpenVINOFP16✅5.10.47643.34
YOLO26nOpenVINOINT8✅3.20.46343.46
YOLO26sPyTorch(CPU)FP32✅19.50.570360.2
YOLO26sOpenVINOFP32✅36.70.56164.66
YOLO26sOpenVINOFP16✅18.60.56164.65
YOLO26sOpenVINOINT8✅10.00.54623.99
YOLO26mPyTorch(CPU)FP32✅42.20.6196152.87
YOLO26mOpenVINOFP32✅78.40.61689.03
YOLO26mOpenVINOFP16✅39.50.61688.98
YOLO26mOpenVINOINT8✅20.60.60555.7
YOLO26lPyTorch(CPU)FP32✅50.70.6215201.57
YOLO26lOpenVINOFP32✅95.30.620311.32
YOLO26lOpenVINOFP16✅48.10.620311.36
YOLO26lOpenVINOINT8✅25.20.59387.45
YOLO26xPyTorch(CPU)FP32✅113.20.6512431.04
YOLO26xOpenVINOFP32✅213.20.656819.08
YOLO26xOpenVINOFP16✅107.10.656819.63
YOLO26xOpenVINOINT8✅54.80.638513.69

Intel® Core™ Ultra™ 7 155H#

벤치마크
YOLO26 OpenVINO benchmarks on the Intel Core Ultra 7 155H integrated Arc GPU
상세 벤치마크 결과
모델형식정밀도상태크기(MB)metrics/mAP50-95(B)추론 시간(ms/이미지)
YOLO26nPyTorch(CPU)FP32✅5.30.476533.19
YOLO26nOpenVINOFP32✅9.60.47589.13
YOLO26nOpenVINOFP16✅5.10.47589.07
YOLO26nOpenVINOINT8✅3.20.45735.79
YOLO26sPyTorch(CPU)FP32✅19.50.570370.92
YOLO26sOpenVINOFP32✅36.70.561616.37
YOLO26sOpenVINOFP16✅18.60.561616.65
YOLO26sOpenVINOINT8✅10.00.5459.27
YOLO26mPyTorch(CPU)FP32✅42.20.6196192.45
YOLO26mOpenVINOFP32✅78.40.616734.47
YOLO26mOpenVINOFP16✅39.50.616735.71
YOLO26mOpenVINOINT8✅20.60.603915.46
YOLO26lPyTorch(CPU)FP32✅50.70.6215239.19
YOLO26lOpenVINOFP32✅95.30.62143.24
YOLO26lOpenVINOFP16✅48.10.62143.4
YOLO26lOpenVINOINT8✅25.20.599919.72
YOLO26xPyTorch(CPU)FP32✅113.20.6512511.89
YOLO26xOpenVINOFP32✅213.20.655279.49
YOLO26xOpenVINOFP16✅107.10.655279.45
YOLO26xOpenVINOINT8✅54.80.64234.66

결과 재현하기#

모든 내보내기 형식에서 위 Ultralytics 벤치마크를 재현하려면 다음 코드를 실행하세요.

예제
from ultralytics import YOLO

# YOLO26n PyTorch 모델 로드
model = YOLO("yolo26n.pt")

# 모든 내보내기 형식에서 COCO128 데이터셋으로 YOLO26n의 속도와 정확도 벤치마크 수행
results = model.benchmark(data="coco128.yaml")

벤치마킹 결과는 시스템의 구체적인 하드웨어 및 소프트웨어 구성과 벤치마크 실행 시점의 시스템 워크로드에 따라 달라질 수 있습니다. 가장 신뢰할 수 있는 결과를 얻으려면 COCO(data='coco.yaml', 검증 이미지 5000개)와 같이 이미지 수가 많은 데이터셋을 사용하세요.

결론#

벤치마크 결과는 YOLO26 모델을 OpenVINO 형식으로 내보낼 때 얻을 수 있는 이점을 보여줍니다. 다양한 모델 크기와 Intel 하드웨어에서 OpenVINO는 유사한 정확도를 유지하면서 PyTorch보다 훨씬 빠르게 추론을 실행합니다.

모델을 OpenVINO 형식으로 변환하면 개발자는 Intel CPU, GPU 및 NPU에서 상당한 성능 향상을 얻을 수 있어 실제 애플리케이션에 모델을 더 쉽게 배포할 수 있습니다.

OpenVINO 사용 방법과 자세한 안내는 OpenVINO 공식 문서를 참조하세요.

자주 묻는 질문#

  • YOLO26 모델을 OpenVINO 형식으로 내보내면 CPU 속도를 크게 높이고 Intel 하드웨어에서 GPU 및 NPU 가속을 활용할 수 있습니다. 아래 예시처럼 Python 또는 CLI를 사용해 내보낼 수 있습니다:

    예제
    from ultralytics import YOLO
    
    # YOLO26n PyTorch 모델 로드
    model = YOLO("yolo26n.pt")
    
    # 모델을 내보냅니다
    model.export(format="openvino")  # creates 'yolo26n_openvino_model/'

    자세한 내용은 내보내기 형식 문서를 참조하세요.

  • YOLO26 모델에 Intel의 OpenVINO 툴킷을 사용하면 다음과 같은 여러 이점을 얻을 수 있습니다:

    1. 성능: CPU 추론 속도를 최대 3배 높이고 Intel GPU와 NPU를 사용해 가속할 수 있습니다.
    2. 모델 변환: PyTorch, TensorFlow, ONNX와 같은 널리 사용되는 프레임워크의 모델을 변환하고 최적화한 후 실행할 수 있습니다.
    3. 사용 편의성: YOLO26 관련 노트북을 포함해 사용자가 시작하는 데 도움이 되는 다양한 튜토리얼 노트북을 이용할 수 있습니다.
    4. 이기종 실행: 통합 API를 사용해 다양한 Intel 하드웨어에 모델을 배포할 수 있습니다.

    자세한 성능 비교는 벤치마크 섹션을 참조하세요.

  • YOLO26n 모델을 OpenVINO 형식으로 내보낸 후 Python 또는 CLI를 사용해 추론을 실행할 수 있습니다:

    예제
    from ultralytics import YOLO
    
    # 내보낸 OpenVINO 모델 불러오기
    ov_model = YOLO("yolo26n_openvino_model/")
    
    # 추론 실행
    results = ov_model("https://ultralytics.com/images/bus.jpg")

    자세한 내용은 predict 모드 문서를 참조하세요.

  • Ultralytics YOLO26은 높은 정확도와 속도를 바탕으로 실시간 객체 탐지에 최적화되어 있습니다. 특히 OpenVINO와 함께 사용하면 YOLO26은 다음과 같은 이점을 제공합니다:

    • Intel CPU에서 최대 3배 속도 향상
    • Intel GPU 및 NPU에 배포
    • 다양한 내보내기 형식에서 일관되고 비슷한 정확도

    심층적인 성능 분석은 다양한 하드웨어에서 수행한 상세 YOLO26 벤치마크를 확인하세요.

  • 예. PyTorch, TorchScript, ONNX, OpenVINO를 비롯한 다양한 형식의 YOLO26 모델을 벤치마크할 수 있습니다. 선택한 데이터셋에서 벤치마크를 실행하려면 다음 코드 스니펫을 사용하세요:

    예제
    from ultralytics import YOLO
    
    # YOLO26n PyTorch 모델 로드
    model = YOLO("yolo26n.pt")
    
    # 모든 내보내기 형식에서 COCO8 데이터셋을 사용해 YOLO26n의 속도와 정확도 벤치마크 실행
    results = model.benchmark(data="coco8.yaml")

    자세한 벤치마크 결과는 벤치마크 섹션과 내보내기 형식 문서를 참조하세요.

댓글23

질문을 하거나 결과를 공유하거나 다른 사람을 도와주세요.

  1. EduardoNewGitHub

    I encountered some difficulties while trying to run the official video demo. Here is my code:

    from ultralytics import YOLO

    def main(): # Load a YOLOv8n PyTorch model model = YOLO("yolov8n.pt")

    # Export the model
    model.export(format="openvino")  # creates 'yolov8n_openvino_model/'
    
    # Load the exported OpenVINO model with explicit task definition
    ov_model = YOLO("yolov8n_openvino_model\\", task='detect')  # Explicitly define task as 'detect'
    
    # Run inference
    results_original = model("D:\\python_YOLO_test\\bus.jpg")
    
    # Run ov inference
    results_ov = ov_model("D:\\python_YOLO_test\\bus.jpg")

    if name == "main": main() Additional notes: My environment is openvino==2024.0.0, and I executed pip install --upgrade torch ultralytics.

    The issue I encountered is as follows:

    Results saved to D:\python_YOLO_test Ultralytics YOLOv8.2.57 🚀 Python-3.11.9 torch-2.1.1+cu118 CPU (11th Gen Intel Core(TM) i7-11800H 2.30GHz) YOLOv8n summary (fused): 168 layers, 3,151,904 parameters, 0 gradients, 8.7 GFLOPs

    PyTorch: starting from 'yolov8n.pt' with input shape (1, 3, 640, 640) BCHW and output shape(s) (1, 84, 8400) (6.2 MB)

    OpenVINO: starting export with openvino 2024.0.0-14509-34caeefd078-releases/2024/0... OpenVINO: export success ✅ 2.8s, saved as 'yolov8n_openvino_model' (12.3 MB)

    Export complete (5.2s) Results saved to D:\python_YOLO_test Predict: yolo predict task=detect model=yolov8n_openvino_model imgsz=640
    Validate: yolo val task=detect model=yolov8n_openvino_model imgsz=640 data=coco.yaml
    Visualize: https://netron.app

    image 1/1 D:\python_YOLO_test\bus.jpg: 640x480 4 persons, 1 bus, 1 stop sign, 324.0ms Speed: 24.0ms preprocess, 324.0ms inference, 21.0ms postprocess per image at shape (1, 3, 640, 480) Loading yolov8n_openvino_model for OpenVINO inference... Using OpenVINO LATENCY mode for batch=1 inference...

    Process finished with exit code -1073741819 (0xC0000005)

    Process finished with exit code -1073740791 (0xC0000409) The model was successfully exported but did not perform inference, instead, it terminated directly. How should I resolve this issue?

    1. Glenn JocherUltralytics(수정됨)

      @EduardoNew the exit code 0xC0000005 often indicates a memory access violation. Let's address this step-by-step:

      1. Path Format: Try using forward slashes in your OpenVINO model path: "yolov8n_openvino_model/" instead of backslashes.

      2. OpenVINO Version: Ultralytics requires openvino>=2024.0.0. Try upgrading to a recent release:

      pip install -U openvino
      1. Hardware Compatibility: Ensure you have the latest Intel drivers installed from Intel's official site.

      If issues persist, please create a Minimum Reproducible Example and open a GitHub Issue following our bug report guidelines. We'll be happy to investigate further!

  2. Ranjith3436GitHub

    You mentioned that the core CPU inference model takes 23.53 ms. I would like to know if the processing time decreases when we increase the number of CPU cores ? currently i am using 12 thread CPU.

    1. Glenn JocherUltralytics

      @Ranjith3436 increasing the number of CPU cores can potentially reduce processing time, as it allows for parallel processing, but the actual speedup will depend on the model's ability to leverage multi-threading effectively.

    2. Glenn JocherUltralytics

      To assess a model's ability to utilize multiple CPU cores, you can check its support for multi-threading or parallel processing in the documentation or by running benchmarks on your hardware configuration.

  3. kimchi2020GitHub

    hey i am working on object detection in videos and came across openvino that helps in increasing speed. how can i use openvino and yolov8 together to find objects in a video

    1. Glenn JocherUltralytics

      @kimchi2020 hi there! It's great to hear that you're exploring OpenVINO to enhance the speed of your object detection tasks in videos. OpenVINO can indeed provide significant performance improvements, especially on Intel hardware.

      To get started with using YOLOv8 and OpenVINO together, follow these steps:

      Exporting YOLOv8 to OpenVINO Format
      1. Export the Model: You can export your YOLOv8 model to the OpenVINO format using the following Python code:

        from ultralytics import YOLO
        
        # Load a YOLOv8n PyTorch model
        model = YOLO("yolov8n.pt")
        
        # Export the model to OpenVINO format
        model.export(format="openvino")  # creates 'yolov8n_openvino_model/'

        Alternatively, you can use the CLI:

        yolo export model=yolov8n.pt format=openvino  # creates 'yolov8n_openvino_model/'
      2. Run Inference with the Exported Model: After exporting, you can run inference using the exported OpenVINO model. Here’s how you can do it in Python:

        from ultralytics import YOLO
        
        # Load the exported OpenVINO model
        ov_model = YOLO("yolov8n_openvino_model/")
        
        # Run inference
        results = ov_model("https://ultralytics.com/images/bus.jpg")

        Or using the CLI:

        yolo predict model=yolov8n_openvino_model source='https://ultralytics.com/images/bus.jpg'
      Running Inference on Videos

      To process videos, you can modify the inference code to read frames from a video file and run the model on each frame. Here’s an example in Python:

      import cv2
      from ultralytics import YOLO
      
      # Load the exported OpenVINO model
      model = YOLO("yolov8n_openvino_model/")
      
      # Open the video file
      video_path = "path/to/your/video.mp4"
      cap = cv2.VideoCapture(video_path)
      
      # Loop through the video frames
      while cap.isOpened():
          ret, frame = cap.read()
          if not ret:
              break
      
          # Run inference on the frame
          results = model(frame)
      
          # Visualize the results on the frame
          annotated_frame = results[0].plot()
      
          # Display the annotated frame
          cv2.imshow("YOLOv8 OpenVINO Inference", annotated_frame)
      
          # Break the loop if 'q' is pressed
          if cv2.waitKey(1) & 0xFF == ord('q'):
              break
      
      # Release the video capture object and close the display window
      cap.release()
      cv2.destroyAllWindows()
      Additional Resources

      For more detailed information and advanced usage, you can refer to the OpenVINO documentation. This guide covers everything from exporting models to running inference and optimizing performance.

      Feel free to reach out if you have any more questions. Happy coding! 🚀

    2. kimchi2020GitHub

      Traceback (most recent call last): File "/home/kimchi/Desktop/yolov8/onnx.py", line 18, in results = model(frame) ^^^^^^^^^^^^ File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/ultralytics/engine/model.py", line 174, in call return self.predict(source, stream, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/ultralytics/engine/model.py", line 442, in predict return self.predictor.predict_cli(source=source) if is_cli else self.predictor(source=source, stream=stream) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/ultralytics/engine/predictor.py", line 168, in call return list(self.stream_inference(source, model, *args, **kwargs)) # merge list of Result into one ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 35, in generator_context response = gen.send(None) ^^^^^^^^^^^^^^ File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/ultralytics/engine/predictor.py", line 234, in stream_inference self.model.warmup(imgsz=(1 if self.model.pt or self.model.triton else self.dataset.bs, 3, *self.imgsz)) File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/ultralytics/nn/autobackend.py", line 626, in warmup import torchvision # noqa (import here so torchvision import time not recorded in postprocess time) ^^^^^^^^^^^^^^^^^^ File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/torchvision/init.py", line 6, in from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/torchvision/models/init.py", line 2, in from .convnext import * File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/torchvision/models/convnext.py", line 8, in from ..ops.misc import Conv2dNormActivation, Permute File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/torchvision/ops/init.py", line 1, in from ._register_onnx_ops import _register_custom_op File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/torchvision/ops/_register_onnx_ops.py", line 5, in from torch.onnx import symbolic_opset11 as opset11 File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/torch/onnx/init.py", line 59, in from ._internal.onnxruntime import ( File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/torch/onnx/_internal/onnxruntime.py", line 36, in import onnx File "/home/kimchi/Desktop/yolov8/onnx.py", line 18, in results = model(frame) ^^^^^^^^^^^^ File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/ultralytics/engine/model.py", line 174, in call return self.predict(source, stream, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/ultralytics/engine/model.py", line 442, in predict return self.predictor.predict_cli(source=source) if is_cli else self.predictor(source=source, stream=stream) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/ultralytics/engine/predictor.py", line 168, in call return list(self.stream_inference(source, model, *args, **kwargs)) # merge list of Result into one ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 35, in generator_context response = gen.send(None) ^^^^^^^^^^^^^^ File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/ultralytics/engine/predictor.py", line 261, in stream_inference self.results = self.postprocess(preds, im, im0s) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/ultralytics/models/yolo/detect/predict.py", line 25, in postprocess preds = ops.non_max_suppression( ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/ultralytics/utils/ops.py", line 291, in non_max_suppression i = torchvision.ops.nms(boxes, scores, iou_thres) # NMS ^^^^^^^^^^^^^^^ AttributeError: partially initialized module 'torchvision' has no attribute 'ops' (most likely due to a circular import). Did you mean: 'os'?

      I am getting this error, how to get rid of it and what does it mean

    3. Glenn JocherUltralytics

      Hi @kimchi2020,

      Thank you for reaching out! The error you're encountering seems to be related to a circular import issue with the torchvision library. This can happen if there's a naming conflict or an import loop in your code.

      Steps to Resolve the Issue:
      1. Check for Naming Conflicts: Ensure that your script name (onnx.py) is not conflicting with any library names. Rename your script to something unique, like run_inference.py.

      2. Verify Installation: Make sure you have the latest versions of torch, torchvision, and ultralytics installed. You can update them using:

        pip install --upgrade torch torchvision ultralytics
      3. Reproduce the Issue: If the issue persists, please provide a minimum reproducible example. This helps us diagnose the problem more effectively. You can refer to our guide on creating a reproducible example here: Minimum Reproducible Example.

      Example Code for Inference with OpenVINO:

      Here's a quick example of how to export your YOLOv8 model to OpenVINO and run inference on a video:

      import cv2
      from ultralytics import YOLO
      
      # Load a YOLOv8n PyTorch model
      model = YOLO("yolov8n.pt")
      
      # Export the model to OpenVINO format
      model.export(format="openvino")  # creates 'yolov8n_openvino_model/'
      
      # Load the exported OpenVINO model
      ov_model = YOLO("yolov8n_openvino_model/")
      
      # Open the video file
      video_path = "path/to/your/video.mp4"
      cap = cv2.VideoCapture(video_path)
      
      # Loop through the video frames
      while cap.isOpened():
          ret, frame = cap.read()
          if not ret:
              break
      
          # Run inference on the frame
          results = ov_model(frame)
      
          # Visualize the results on the frame
          annotated_frame = results[0].plot()
      
          # Display the annotated frame
          cv2.imshow("YOLOv8 OpenVINO Inference", annotated_frame)
      
          # Break the loop if 'q' is pressed
          if cv2.waitKey(1) & 0xFF == ord('q'):
              break
      
      # Release the video capture object and close the display window
      cap.release()
      cv2.destroyAllWindows()

      For more detailed information on exporting and using OpenVINO, please refer to our OpenVINO Integration Guide.

      Feel free to reach out if you have any more questions or need further assistance. Happy coding! 🚀

    4. YA12SHYAMGitHub

      Hi @glenn-jocher , what if i want to use intel GPU's for the inference, using device=GPU doesn't seems to works , it looks for cuda i.e nvidia gpu

    5. Glenn JocherUltralytics(수정됨)

      To use Intel GPUs for inference, export your YOLOv8 model to OpenVINO format with model.export(format="openvino"), then run inference with the exported model and select the GPU with device="intel:gpu", for example ov_model("bus.jpg", device="intel:gpu"). For more details, please refer to the OpenVINO integration guide.

    6. YA12SHYAMGitHub

      ok, just to confirm i can't use ultralytics python api for inference with intel gpu like i usually do within the ultralytics ecosystem for example ?

      from ultralytics import YOLO
      model =  YOLO(path/to/model)

      here the path/to/model works with onnx, engine, opnevino;s xml , but it use cpu in case of openvino , i want to use my intel GPU

    7. Glenn JocherUltralytics(수정됨)

      @YA12SHYAM to use Intel GPUs with YOLOv8, export your model to OpenVINO format and select the GPU at inference with device="intel:gpu", e.g. model("bus.jpg", device="intel:gpu"). For detailed steps, refer to the OpenVINO integration guide.

  4. kanishkaswGitHub

    Hi Im getting the following error when attempting to convert the model to openVino. Tried with both 2024.1.0 and 2024.0.0. Im on ubuntu 20.04 with python 3.8 $ yolo export model=runs/classify/train/weights/best.pt format=openvino Ultralytics YOLOv8.2.31 🚀 Python-3.8.10 torch-2.3.1+cu121 CPU (Intel Core(TM) i9-7900X 3.30GHz) YOLOv8n-cls summary (fused): 73 layers, 1438723 parameters, 0 gradients, 3.3 GFLOPs

    PyTorch: starting from 'runs/classify/train/weights/best.pt' with input shape (1, 3, 320, 320) BCHW and output shape(s) (1, 3) (2.8 MB) OpenVINO: export failure ❌ 0.0s: module 'openvino' has no attribute 'version' Traceback (most recent call last): File "/home/Kanishka/v5.0/YOLOV8_classification/.venv/bin/yolo", line 8, in sys.exit(entrypoint()) File "/home/Kanishka/v5.0/YOLOV8_classification/.venv/lib/python3.8/site-packages/ultralytics/cfg/init.py", line 591, in entrypoint getattr(model, mode)(**overrides) # default args from model File "/home/Kanishka/v5.0/YOLOV8_classification/.venv/lib/python3.8/site-packages/ultralytics/engine/model.py", line 602, in export return Exporter(overrides=args, _callbacks=self.callbacks)(model=self.model) File "/home/Kanishka/v5.0/YOLOV8_classification/.venv/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context return func(*args, **kwargs) File "/home/Kanishka/v5.0/YOLOV8_classification/.venv/lib/python3.8/site-packages/ultralytics/engine/exporter.py", line 308, in call f[3], _ = self.export_openvino() File "/home/Kanishka/v5.0/YOLOV8_classification/.venv/lib/python3.8/site-packages/ultralytics/engine/exporter.py", line 142, in outer_func raise e File "/home/Kanishka/v5.0/YOLOV8_classification/.venv/lib/python3.8/site-packages/ultralytics/engine/exporter.py", line 137, in outer_func f, model = inner_func(*args, **kwargs) File "/home/Kanishka/v5.0/YOLOV8_classification/.venv/lib/python3.8/site-packages/ultralytics/engine/exporter.py", line 454, in export_openvino LOGGER.info(f"\n{prefix} starting export with openvino {ov.version}...") AttributeError: module 'openvino' has no attribute 'version'

    1. Paula DerrengerUltralytics(수정됨)

      @kanishkasw hi there,

      Thank you for reaching out and providing detailed information about the issue you're encountering. It looks like you're experiencing an error when attempting to export your model to OpenVINO format. Let's work through this together.

      First, let's ensure that you are using the latest versions of torch and ultralytics. Please run the following commands to update your packages:

      pip install --upgrade torch ultralytics

      Next, it seems the error is related to the OpenVINO package. The error message module 'openvino' has no attribute '__version__' suggests there might be an issue with the OpenVINO installation. Please make sure you have a recent version of OpenVINO installed (Ultralytics requires openvino>=2024.0.0). You can install it using the following command:

      pip install -U openvino

      Once you've updated the packages, try exporting the model again:

      yolo export model=runs/classify/train/weights/best.pt format=openvino

      If the issue persists, could you please provide a minimum reproducible example? This will help us investigate the problem more effectively. You can find guidance on creating a minimum reproducible example here: Minimum Reproducible Example.

      Additionally, here's a Python example to ensure everything is set up correctly:

      from ultralytics import YOLO
      
      # Load a YOLOv8n PyTorch model
      model = YOLO("runs/classify/train/weights/best.pt")
      
      # Export the model to OpenVINO format
      model.export(format="openvino")  # creates 'best_openvino_model/'
      
      # Load the exported OpenVINO model
      ov_model = YOLO("best_openvino_model/")
      
      # Run inference
      results = ov_model("https://ultralytics.com/images/bus.jpg")

      For more detailed instructions on using OpenVINO, please refer to our OpenVINO Integration Guide.

      Feel free to reach out if you have any further questions or run into any other issues. We're here to help! 😊

  5. renato-rodrigGitHub

    hello everything is fine? I have a question about the results exposed in the article above. Is the time shown in the graphs in relation to the inference time that the model takes to return the detections or is it the time for image reading, image pre-processing and model inference? I ask this because on my computer (intel core i7 12 generation CPU) the yolov8n model ran with an inference time of 40ms and the gain from using OpenVINO was not that great.

    1. Paula DerrengerUltralytics

      @renato-rodrig hello! 👋 Regarding your question about the times shown in the graphs, they typically refer to the total inference time, which includes the actual model inference as well as the time taken for pre-processing the input data (like image reading and resizing).

      The difference you observed with OpenVINO on your Intel Core i7 may vary due to several factors such as the specific configuration of your system, the type of tasks being run, and the optimizations that the YOLOv8n model can leverage on that platform. Generally, OpenVINO tends to show more significant performance gains on integrated Intel GPUs and some specific CPU configurations.

      If you haven't seen a major performance improvement, you might want to look into further tuning your OpenVINO deployment or explore using other optimization techniques provided by OpenVINO. Additionally, ensure all drivers and software components are up to date for optimal performance.

      Here’s a quick example of ensuring you're using the model in the most optimized manner:

      from ultralytics import YOLO
      
      # Load YOLOv8n PyTorch model
      model = YOLO('yolov8n.pt')
      
      # Export the model to OpenVINO
      model.export(format='openvino')  # Creates 'yolov8n_openvino_model/'
      
      # Load the exported OpenVINO model
      ov_model = YOLO('yolov8n_openvino_model/')
      
      # Run inference to see if performance improves
      results = ov_model('https://ultralytics.com/images/bus.jpg')

      Feel free to experiment with different configurations and settings! 😊

      1
  6. YouROS12GitHub

    I wanna do inferences with my exported pre-trained yolov8 model using Raspberry PI with a Neural Network Computing 2 (NCS2) plugged in.. but its doesn't support opset 11 or above.. only opset10.. I specified onnx opset to 10 and convert it to Openvino but it didn't work.

    Anyway please to export openvino model directly in opset10 ? Does even yolov8 support this specified opset format ?

    Thank you.

    1. Glenn JocherUltralytics(수정됨)

      @YouROS12 the current OpenVINO export no longer goes through ONNX: Ultralytics converts the PyTorch model directly to OpenVINO IR with openvino.convert_model, so the ONNX opset argument does not apply and the old mo Model Optimizer step isn't needed. Export with:

      from ultralytics import YOLO
      
      # Load a pretrained YOLOv8 model
      model = YOLO('yolov8n.pt')
      
      # Export the model to OpenVINO
      model.export(format='openvino')  # creates 'yolov8n_openvino_model/'

      The export requires openvino>=2024.0.0. If your target requires an older OpenVINO that cannot load these models, you can still try model.export(format='onnx', opset=10) and convert the ONNX file with that toolkit's own tools, but some YOLOv8 operations may not be supported in older opsets, which could lead to errors during export or inference.

    2. YouROS12GitHub

      Where can I find documentation about YOLOv8's operations with opset 10 ? Updating OpenVINO toolkit is not an option because NCS2 works only at opset 10 and lower.

    3. Paula DerrengerUltralytics

      @YouROS12 the documentation for ONNX opset versions and the operations they support can be found on the ONNX GitHub repository or the official ONNX documentation. However, there isn't specific documentation for YOLOv8's operations with opset 10, as this would be a combination of YOLOv8's implementation details and ONNX's opset specifications.

      To check which operations are supported in opset 10, you can refer to the ONNX Operators documentation for that specific version. This documentation lists all the operators available in opset 10 and their details.

      For YOLOv8, you would need to look at the model's architecture and identify which operations are used. Then, cross-reference these operations with the ONNX opset 10 documentation to see if they are supported. If certain operations are not supported in opset 10, you might need to modify the model or the export script to use alternative operations that are compatible with opset 10.

      Since updating OpenVINO is not an option for you, if you find that YOLOv8 uses operations not supported in opset 10, you might need to consider using a different model architecture that is compatible with opset 10, or reach out to the community or Ultralytics for further assistance on how to proceed with your specific use case and hardware constraints.