YOLO26 모델을 위한 TensorRT 내보내기
고성능 환경에 컴퓨터 비전 모델을 배포하려면 속도와 효율성을 극대화하는 형식이 필요할 수 있습니다. NVIDIA GPU에 모델을 배포할 때 특히 그렇습니다.
TensorRT 내보내기 형식을 사용하면 NVIDIA 하드웨어에서 빠르고 효율적인 추론을 수행하도록 Ultralytics YOLO26 모델을 최적화할 수 있습니다. 이 가이드에서는 변환 과정을 안내하고 딥러닝 프로젝트에서 NVIDIA GPU를 최대한 활용하는 방법을 설명합니다.
TensorRT#
NVIDIA가 개발한 TensorRT는 고속 딥러닝 추론을 위해 설계된 고급 소프트웨어 개발 키트(SDK)입니다. 객체 탐지와 같은 실시간 애플리케이션에 적합합니다.
이 툴킷은 NVIDIA GPU에 맞게 딥러닝 모델을 최적화하여 더 빠르고 효율적인 연산을 가능하게 합니다. TensorRT 모델에는 계층 융합, 정밀도 보정(INT8 및 FP16), 동적 텐서 메모리 관리, 커널 자동 튜닝 등의 기법을 포함한 TensorRT 최적화가 적용됩니다. 딥러닝 모델을 TensorRT 형식으로 변환하면 개발자가 NVIDIA GPU를 최대한 활용할 수 있습니다.
TensorRT는 TensorFlow, PyTorch, ONNX 등 다양한 모델 형식과 호환되므로, 여러 프레임워크의 모델을 통합하고 최적화할 수 있는 유연한 솔루션을 제공합니다. 이러한 다용도성은 다양한 하드웨어 및 소프트웨어 환경에서 효율적인 모델 배포를 지원합니다.
TensorRT는 엔진을 빌드한 GPU에서 프로파일링하고 튜닝합니다. 배포 대상 GPU 아키텍처에 맞춰 빌드하고 TensorRT/CUDA 런타임도 일치시켜야 합니다. .engine 파일을 이식 가능한 모델 형식으로 취급하지 마세요. 엣지 배포의 경우 Ultralytics Platform에서 Jetson 대상 장치 8가지를 선택할 수 있으며, 각 장치의 실제 빌드 및 검증 상태가 문서화되어 있습니다. 또는 대상 장치에서 로컬로 내보낼 수 있습니다.
TensorRT 모델의 주요 기능#
TensorRT 모델은 고속 딥러닝 추론의 효율성과 효과에 기여하는 여러 핵심 기능을 제공합니다.
-
정밀도 보정: TensorRT는 정밀도 보정을 지원하므로 특정 정확도 요구 사항에 맞게 모델을 세밀하게 조정할 수 있습니다. 여기에는 INT8 및 FP16과 같은 저정밀도 형식 지원이 포함되며, 이를 통해 허용 가능한 정확도 수준을 유지하면서 추론 속도를 더욱 높일 수 있습니다.
-
레이어 융합: TensorRT 최적화 과정에서는 여러 신경망 레이어를 하나의 연산으로 결합하는 레이어 융합을 수행합니다. 이를 통해 메모리 액세스와 연산을 최소화하여 계산 오버헤드를 줄이고 추론 속도를 높입니다.
-
동적 텐서 메모리 관리: TensorRT는 추론 중 텐서 메모리 사용량을 효율적으로 관리하여 메모리 오버헤드를 줄이고 메모리 할당을 최적화합니다. 그 결과 GPU 메모리를 더욱 효율적으로 활용할 수 있습니다.
-
커널 자동 튜닝: TensorRT는 모델의 각 레이어에 가장 최적화된 GPU 커널을 선택하도록 커널을 자동 튜닝합니다. 이러한 적응형 접근 방식은 모델이 GPU의 연산 능력을 최대한 활용하도록 합니다.
TensorRT의 배포 옵션#
YOLO26 모델을 TensorRT 형식으로 내보내는 코드를 살펴보기 전에 TensorRT 모델이 일반적으로 사용되는 분야를 소개합니다.
TensorRT는 여러 배포 옵션을 제공하며, 각 옵션은 통합 편의성, 성능 최적화, 유연성 사이에서 서로 다른 균형을 제공합니다.
- TensorFlow 내 배포: 이 방법은 TensorRT를 TensorFlow에 통합하여 익숙한 TensorFlow 환경에서 최적화된 모델을 실행합니다. TF-TRT가 지원 및 미지원 레이어가 혼합된 모델을 효율적으로 처리할 수 있어 유용합니다.
-
독립 실행형 TensorRT 런타임 API: 세밀한 제어 기능을 제공하므로 성능이 중요한 애플리케이션에 적합합니다. 더 복잡하지만 지원되지 않는 연산자를 사용자 지정 방식으로 구현할 수 있습니다.
-
NVIDIA Triton 추론 서버: 다양한 프레임워크의 모델을 지원하는 옵션입니다. 클라우드 또는 엣지 추론에 특히 적합하며, 동시 모델 실행 및 모델 분석과 같은 기능을 제공합니다.
지원 작업#
TensorRT 내보내기는 Ultralytics의 7가지 태스크를 모두 지원합니다. 시맨틱 세그멘테이션과 깊이 추정은 해당 헤드를 제공하는 유일한 제품군인 YOLO26에서만 사용할 수 있습니다.
YOLO26 모델을 TensorRT로 내보내기#
YOLO26 모델을 TensorRT 형식으로 변환하여 실행 효율성을 높이고 성능을 최적화할 수 있습니다.
설치#
필수 패키지를 설치하려면 다음을 실행하세요:
# Install the required package for YOLO26
pip install ultralytics설치 과정에 관한 자세한 지침과 모범 사례는 YOLO26 설치 가이드를 확인하세요. YOLO26에 필요한 패키지를 설치하는 중 문제가 발생하면 해결 방법과 팁이 담긴 일반적인 문제 가이드를 참조하세요.
사용법#
TensorRT 형식은 내보내기, 예측, 검증 모드를 지원합니다. 추론 및 검증에는 NVIDIA GPU가 필요합니다. 모델을 내보낸 다음 내보낸 모델을 로드하여 추론을 실행하거나 정확도를 검증하세요.
from ultralytics import YOLO
# YOLO26 모델 로드
model = YOLO("yolo26n.pt")
# 모델을 TensorRT 형식으로 내보내기
model.export(format="engine") # 'yolo26n.engine' 생성from ultralytics import YOLO
# 내보낸 TensorRT 모델 로드
model = YOLO("yolo26n.engine")
# 추론 실행
results = model("https://ultralytics.com/images/bus.jpg")from ultralytics import YOLO
# 내보낸 TensorRT 모델 로드
model = YOLO("yolo26n.engine")
# COCO8 데이터셋에서 정확도 검증
metrics = model.val(data="coco8.yaml")내보내기 인수#
| 인수 | 유형 | 기본값 | 설명 |
|---|---|---|---|
format | str | 'engine' | 내보낸 모델의 대상 형식으로, 다양한 배포 환경과의 호환성을 정의합니다. |
imgsz | int 또는 tuple | 640 | 모델 입력에 사용할 이미지 크기입니다. 정사각형 이미지에는 정수를 사용하고, 특정 크기에는 튜플 (height, width)을 사용할 수 있습니다. |
quantize | int 또는 str | None | 양자화 정밀도: 16(FP16) 또는 8(INT8/PTQ; 보정 data/fraction 필요); 32/미설정은 FP32입니다. quantize=8로 학습된 체크포인트는 보정 없이 체크포인트에 포함된 범위에서 항상 INT8로 내보냅니다. 사용 중단된 half/int8 플래그를 대체합니다. |
dynamic | bool | False | 동적 입력 크기를 허용하여 다양한 이미지 크기를 유연하게 처리할 수 있습니다. |
simplify | bool | True | onnxslim을 사용해 모델 그래프를 단순화하여 성능과 호환성을 높일 수 있습니다. |
opset | int | None | 중간 ONNX 그래프의 ONNX opset 버전을 지정합니다. 설정하지 않으면 opset 18을 사용하며(PyTorch < 2.4에서는 더 낮은 버전), 설치된 onnx 버전으로 제한됩니다. |
workspace | float 또는 None | None | TensorRT 최적화를 위한 최대 워크스페이스 크기를 GiB 단위로 설정하여 메모리 사용량과 성능 간 균형을 맞춥니다. TensorRT가 장치의 최대 용량까지 자동으로 메모리를 할당하도록 하려면 None을 사용하세요. |
nms | bool, 선택 사항 | None | 원시 출력(None, 기본값), 내장 NMS(True) 또는 NMS가 없는 head(False)를 선택합니다. |
batch | int | 1 | 내보내기 모델의 배치 추론 크기 또는 predict 모드에서 내보낸 모델이 동시에 처리할 최대 이미지 수를 지정합니다. |
data | str | None | 양자화에 필수적인 데이터 세트 YAML 경로입니다. 분류 작업에서는 데이터 세트 디렉터리 또는 내장 데이터 세트 이름을 사용합니다. quantize=8과 함께 생략하면 Ultralytics가 모델 태스크에 맞는 기본 보정 데이터 세트를 선택합니다. quantize=8로 학습된 체크포인트에는 필요하지 않습니다. |
fraction | float, int 또는 list | 1.0 | 비율, 이미지 수 또는 [train, val, test] 비율/개수로 지정하는 보정 하위 집합입니다. 항목이 두 개인 목록에서는 test이 전체로 설정되고, 0는 건너뜁니다. |
device | str | None | 내보내기에 사용할 장치를 지정합니다. GPU는 device=0, NVIDIA Jetson의 DLA는 device=dla:0 또는 device=dla:1입니다. |
TensorRT로 내보낼 때는 CUDA를 지원하는 GPU를 사용하세요.
Thor를 포함해 TensorRT 11은 JetPack을 지원하지 않으므로 사용 중인 JetPack 릴리스에서 지원하는 TensorRT 10.x 런타임을 사용하세요. device=dla:0 또는 device=dla:1의 경우 NVIDIA는 DLA를 지원하는 마지막 릴리스로 TensorRT 10.7을 명시합니다. TensorRT 11.x는 DLA를 지원하지 않습니다.
내보내기 프로세스에 관한 자세한 내용은 내보내기에 관한 Ultralytics 문서 페이지를 참조하세요.
INT8 양자화를 적용해 TensorRT로 내보내기#
INT8 정밀도를 사용하여 TensorRT로 Ultralytics YOLO 모델을 내보내면 학습 후 양자화(PTQ)가 수행됩니다. TensorRT는 PTQ를 위해 보정을 사용합니다. YOLO 모델이 대표 입력 데이터에 대한 추론을 처리할 때 각 활성화 텐서 내 활성화의 분포를 측정한 다음, 해당 분포를 사용해 각 텐서의 스케일 값을 추정합니다. 양자화 후보인 각 활성화 텐서에는 보정 과정에서 추론한 스케일이 연결됩니다. 양자화 인식 학습을 통해 quantize=8로 미세 조정된 체크포인트에는 이미 INT8 범위가 포함되어 있으므로 내보내기 시 해당 범위를 사용하고 보정을 건너뜁니다.
TensorRT 11에서는 암시적 양자화와 IInt8Calibrator 인터페이스가 제거되었습니다. TensorRT 11 이상에서 Ultralytics는 NVIDIA ModelOpt의 명시적 양자화를 사용하여 INT8 양자화를 수행합니다. 이 방식은 강한 타입의 엔진을 빌드하기 전에 ONNX 그래프에 Q/DQ 노드를 삽입하며, FP16은 ModelOpt AutoCast 혼합 정밀도 변환을 통해 적용됩니다. quantize=8, quantize=16, data 인수는 이전과 동일하게 작동하며, ModelOpt는 처음 사용할 때 자동으로 설치됩니다. TensorRT 7~10에서는 아래에 설명된 레거시 보정기가 대신 사용됩니다.
암시적으로 양자화된 네트워크를 처리할 때 TensorRT는 계층 실행 시간을 최적화하기 위해 INT8을 상황에 따라 사용합니다. 계층이 INT8에서 더 빠르게 실행되고 해당 데이터 입력 및 출력에 양자화 스케일이 지정되어 있으면 INT8 정밀도 커널이 해당 계층에 할당됩니다. 그렇지 않으면 TensorRT는 해당 계층의 실행 시간이 더 빠른 FP32 또는 FP16 정밀도를 커널에 선택합니다.
배포 시 TensorRT 모델 가중치를 사용할 장치와 동일한 장치를 INT8 정밀도 내보내기에도 사용해야 합니다. 보정 결과는 장치마다 다를 수 있기 때문입니다.
INT8 내보내기 구성#
Ultralytics YOLO 모델에서 내보내기를 사용할 때 지정하는 인수는 내보낸 모델의 성능에 큰 영향을 미칩니다. 사용 가능한 장치 리소스에 따라 인수를 선택해야 하지만, 기본 인수는 대부분의 Ampere(또는 그 이후 아키텍처) NVIDIA 외장 GPU에서 정상적으로 작동해야 합니다. GPU 내보내기에는 "MINMAX_CALIBRATION" 보정 알고리즘을 사용하고, NVIDIA Jetson의 DLA 내보내기에는 "ENTROPY_CALIBRATION_2"을 사용합니다. 사용 가능한 옵션에 대한 자세한 내용은 TensorRT 개발자 가이드를 참고하세요. Ultralytics 테스트 결과 GPU 내보내기에는 "MINMAX_CALIBRATION"가 가장 적합했으며, 내보내기 장치에 따라 알고리즘이 자동으로 선택됩니다.
-
workspace: 모델 가중치를 변환하는 동안 할당할 장치 메모리의 크기(GiB)를 제어합니다.-
보정 요구사항과 사용 가능한 리소스에 따라
workspace값을 조정하세요.workspace을 늘리면 보정 시간이 길어질 수 있지만, TensorRT가 더 다양한 최적화 전략을 탐색하여 모델 성능과 정확도를 향상시킬 수 있습니다. 반대로workspace을 줄이면 보정 시간은 단축될 수 있지만 최적화 전략이 제한되어 양자화된 모델의 품질에 영향을 줄 수 있습니다. -
기본값은
workspace=None이며, TensorRT가 메모리를 자동으로 할당하도록 합니다. 수동으로 구성하는 경우 보정 중 충돌이 발생하면(경고 없이 종료되면) 이 값을 높여야 할 수 있습니다. -
workspace값이 장치에서 사용 가능한 메모리보다 크면 TensorRT는 내보내기 중UNSUPPORTED_STATE을 보고합니다. 이는workspace값을 낮추거나None으로 설정해야 한다는 의미입니다. -
workspace을 최대값으로 설정했는데도 보정이 실패하거나 충돌하면 자동 할당을 위해None을 사용하거나 메모리 요구량을 줄이기 위해imgsz와batch의 값을 낮추는 방법을 고려하세요. -
INT8 보정은 장치마다 다르다는 점을 기억하세요. 보정에 "고성능" GPU를 빌려 사용하면 다른 장치에서 추론을 수행할 때 성능이 저하될 수 있습니다.
-
-
batch: 추론에 사용되는 최대 배치 크기입니다.dynamic=True을 사용하면 추론 중 더 작은 배치를 사용할 수 있지만, 지정된 크기보다 큰 배치는 허용되지 않습니다.
작은 배치를 사용하면 INT8 보정 중 스케일이 부정확해질 수 있습니다. 보정 과정은 입력 데이터에 따라 조정되기 때문입니다. 작은 배치로는 전체 값 범위를 포착하지 못해 최종 보정에 문제가 생길 수 있습니다. 더 대표성 있는 보정 결과를 얻으려면 더 큰 배치 크기를 사용하세요.
NVIDIA는 실험을 바탕으로 INT8 양자화 보정에 모델 데이터의 특성을 대표하는 보정 이미지 500장 이상을 사용할 것을 권장합니다. 이는 가이드라인일 뿐 엄격한 요구 사항은 아니며, 데이터셋에서 좋은 성능을 내는 데 필요한 조건을 실험을 통해 찾아야 합니다. quantize=8로 학습하지 않은 체크포인트를 TensorRT INT8로 내보내면 학습 후 양자화가 적용되므로, data 인수로 보정 데이터를 전달하세요. 예를 들어 data="my_dataset.yaml"는 검증 이미지를 보정에 사용합니다. quantize=8으로 학습한 체크포인트는 보정을 건너뛰므로 해당 체크포인트에는 data을 생략하세요. TensorRT로 INT8 양자화 내보내기를 수행할 때 data 값을 전달하지 않으면 오류가 발생하는 대신 모델 작업에 따라 "small" 예제 데이터셋 중 하나가 기본으로 사용됩니다.
from ultralytics import YOLO
model = YOLO("yolo26n.pt")
model.export(
format="engine",
dynamic=True, # (1)!
batch=8, # (2)!
workspace=4, # (3)!
quantize=8,
data="coco.yaml", # (4)!
)
# 내보낸 TensorRT INT8 모델 로드
model = YOLO("yolo26n.engine", task="detect")
# 추론 실행
result = model.predict("https://ultralytics.com/images/bus.jpg")- 동적 축을 사용해 내보내며, 입력 크기는 32픽셀부터 내보내기
imgsz의 두 배까지 허용됩니다.dynamic은 명시적으로 설정하지 않는 한False로 유지됩니다. T4와 같이 컴퓨팅 성능이 7.5 이하인 GPU에서는 TensorRT 11 INT8 내보내기와quantize=8로 학습한 체크포인트의 경우, 최소 입력 크기가 64픽셀( P6 모델은 128픽셀)로 높아지며 내보내기imgsz을 최댓값으로 적용합니다. 이러한 GPU에는 더 작은 입력 크기를 처리할 INT8 커널이 없을 수 있기 때문입니다. 자세한 내용은 내보내기 인수를 참조하세요. - 내보낸 모델과 INT8 보정에 사용할 최대 배치 크기를 8로 설정합니다.
- 변환 과정에서 장치 전체 메모리 대신 4 GiB를 할당합니다.
- 보정에는 COCO 데이터셋, 특히 검증에 사용되는 이미지(총 5,000장)가 사용됩니다.
YOLO와 TensorRT INT8 사용의 장점#
-
모델 크기 감소: FP32에서 INT8로 양자화하면 모델 크기를 4배 줄일 수 있습니다(디스크 또는 메모리 기준). 이에 따라 다운로드 시간이 단축되고, 저장 공간 요구량과 모델 배포 시 메모리 사용량이 감소합니다.
-
전력 소비 감소: INT8로 내보낸 YOLO 모델의 저정밀도 연산은 FP32 모델보다 전력을 적게 소비할 수 있으며, 특히 배터리 구동 기기에서 효과적입니다.
-
추론 속도 향상: TensorRT는 대상 하드웨어에 맞게 모델을 최적화하므로 GPU, 임베디드 기기 및 가속기에서 추론 속도가 향상될 수 있습니다.
추론 속도 관련 참고 사항
TensorRT INT8로 내보낸 모델을 사용하여 처음 몇 차례 추론을 실행할 때는 전처리, 추론 및/또는 후처리 시간이 평소보다 길 수 있습니다. 추론 중에 imgsz을 변경할 때도 이러한 현상이 발생할 수 있습니다. 특히 imgsz이 내보내기 시 지정한 값과 다르면 더욱 그렇습니다(내보내기 imgsz는 TensorRT의 "optimal" 프로필로 설정됩니다).
YOLO와 TensorRT INT8 사용의 단점#
-
평가 지표의 하락: 정밀도를 낮추면 mAP, 정밀도, 재현율 또는 모델 성능 평가에 사용되는 기타 지표가 다소 나빠질 수 있습니다. 점수 보정을 유지하기 위해 Sigmoid 레이어는 더 높은 정밀도로 유지하지만, INT8도 신뢰도 값을 바꿀 수 있으므로 INT8 모델 자체의 F1 곡선에서 운영 임계값을 선택합니다.
-
개발 시간 증가: 데이터셋과 기기에 맞는 INT8 보정의 "최적" 설정을 찾으려면 상당한 테스트 시간이 소요될 수 있습니다.
-
하드웨어 종속성: 보정 및 성능 향상은 하드웨어에 크게 좌우될 수 있으며, 모델 가중치의 이식성이 낮아집니다.
Ultralytics YOLO TensorRT 내보내기 성능#
NVIDIA A100#
Ubuntu 22.04.3 LTS, python 3.10.12, ultralytics==8.2.4, tensorrt==8.6.1.post1 환경에서 테스트했습니다.
COCO에서 학습되고 사전 학습된 클래스 80개를 포함하는 이 모델의 사용 예제는 탐지 문서를 참조하세요. COCO를 참조하세요.
각 테스트에서 사전 학습된 가중치 yolov8n.engine를 사용한 mean, min(가장 빠름), max(가장 느림)의 추론 시간입니다.
| 정밀도 | 평가 테스트 | 평균 (ms) | 최소 | 최대 (ms) | mAPval50(B) | mAPval50-95(B) | batch | 크기 (픽셀) |
|---|---|---|---|---|---|---|---|
| FP32 | 예측 | 0.52 | 0.51 | 0.56 | 8 | 640 | ||
| FP32 | COCOval | 0.52 | 0.52 | 0.37 | 1 | 640 | |
| FP16 | 예측 | 0.34 | 0.34 | 0.41 | 8 | 640 | ||
| FP16 | COCOval | 0.33 | 0.52 | 0.37 | 1 | 640 | |
| INT8 | 예측 | 0.28 | 0.27 | 0.31 | 8 | 640 | ||
| INT8 | COCOval | 0.29 | 0.47 | 0.33 | 1 | 640 |
소비자용 GPU#
Windows 10.0.19045, python 3.10.9, ultralytics==8.2.4, tensorrt==10.0.0b6 환경에서 테스트했습니다.
각 테스트에서 사전 학습된 가중치 yolov8n.engine를 사용한 mean, min(가장 빠름), max(가장 느림)의 추론 시간입니다.
| 정밀도 | 평가 테스트 | 평균 (ms) | 최소 | 최대 (ms) | mAPval50(B) | mAPval50-95(B) | batch | 크기 (픽셀) |
|---|---|---|---|---|---|---|---|
| FP32 | 예측 | 1.06 | 0.75 | 1.88 | 8 | 640 | ||
| FP32 | COCOval | 1.37 | 0.52 | 0.37 | 1 | 640 | |
| FP16 | 예측 | 0.62 | 0.75 | 1.13 | 8 | 640 | ||
| FP16 | COCOval | 0.85 | 0.52 | 0.37 | 1 | 640 | |
| INT8 | 예측 | 0.52 | 0.38 | 1.00 | 8 | 640 | ||
| INT8 | COCOval | 0.74 | 0.47 | 0.33 | 1 | 640 |
임베디드 기기#
JetPack 6.0 (L4T 36.3) Ubuntu 22.04.4 LTS, python 3.10.12, ultralytics==8.2.16, tensorrt==10.0.1 환경에서 테스트했습니다.
각 테스트에서 사전 학습된 가중치 yolov8n.engine를 사용한 mean, min(가장 빠름), max(가장 느림)의 추론 시간입니다.
| 정밀도 | 평가 테스트 | 평균 (ms) | 최소 | 최대 (ms) | mAPval50(B) | mAPval50-95(B) | batch | 크기 (픽셀) |
|---|---|---|---|---|---|---|---|
| FP32 | 예측 | 6.11 | 6.10 | 6.29 | 8 | 640 | ||
| FP32 | COCOval | 6.17 | 0.52 | 0.37 | 1 | 640 | |
| FP16 | 예측 | 3.18 | 3.18 | 3.20 | 8 | 640 | ||
| FP16 | COCOval | 3.19 | 0.52 | 0.37 | 1 | 640 | |
| INT8 | 예측 | 2.30 | 2.29 | 2.35 | 8 | 640 | ||
| INT8 | COCOval | 2.32 | 0.46 | 0.32 | 1 | 640 |
설정 및 구성에 대한 자세한 내용은 NVIDIA Jetson에서 Ultralytics YOLO를 사용하는 빠른 시작 가이드를 참조하세요.
설정 및 구성에 대한 자세한 내용은 NVIDIA DGX Spark에서 Ultralytics YOLO를 사용하는 빠른 시작 가이드를 참조하세요.
평가 방법#
위 표는 ultralytics 8.2에서 yolov8n 모델을 사용해 측정했습니다. 아래 섹션을 펼치면 최신 인수를 사용한 동일한 내보내기, 예측 및 검증 구성을 확인할 수 있습니다.
내보내기 구성
내보내기 구성 인수에 대한 자세한 내용은 내보내기 모드를 참조하세요.
from ultralytics import YOLO
model = YOLO("yolo26n.pt")
# TensorRT FP32
out = model.export(format="engine", imgsz=640, dynamic=True, verbose=False, batch=8, workspace=2)
# TensorRT FP16
out = model.export(format="engine", imgsz=640, dynamic=True, verbose=False, batch=8, workspace=2, quantize=16)
# 보정용 `data`를 사용하는 TensorRT INT8(즉, 해당 모델 작업에 적합한 COCO, ImageNet 또는 DOTAv1)
out = model.export(
format="engine", imgsz=640, dynamic=True, verbose=False, batch=8, workspace=2, quantize=8, data="coco8.yaml"
)예측 루프
자세한 내용은 예측 모드를 참조하세요.
import cv2
from ultralytics import YOLO
model = YOLO("yolo26n.engine")
img = cv2.imread("path/to/image.jpg")
for _ in range(100):
result = model.predict(
[img] * 8, # 동일한 이미지로 batch=8
verbose=False,
device="cuda",
)검증 구성
검증 구성 인수에 대한 자세한 내용은 val 모드를 참조하세요.
from ultralytics import YOLO
model = YOLO("yolo26n.engine")
results = model.val(
data="data.yaml", # 해당 모델 작업에 적합한 COCO, ImageNet 또는 DOTAv1
batch=1,
imgsz=640,
verbose=False,
device="cuda",
)내보낸 YOLO26 TensorRT 모델 배포#
Ultralytics YOLO26 모델을 TensorRT 형식으로 성공적으로 내보냈다면 이제 배포할 준비가 된 것입니다. 다양한 환경에서 TensorRT 모델을 배포하는 자세한 방법은 다음 리소스를 참조하세요.
-
Triton Server로 Ultralytics 배포: Ultralytics YOLO 모델에 NVIDIA Triton Inference(이전 명칭 TensorRT Inference) Server를 사용하는 방법을 안내합니다.
-
NVIDIA TensorRT를 사용한 심층 신경망 배포: 이 문서에서는 GPU 기반 배포 플랫폼에 심층 신경망을 효율적으로 배포하는 데 NVIDIA TensorRT를 사용하는 방법을 설명합니다.
-
NVIDIA 기반 PC를 위한 엔드투엔드 AI: NVIDIA TensorRT 배포: 이 블로그 게시물에서는 NVIDIA 기반 PC에서 AI 모델을 최적화하고 배포하기 위해 NVIDIA TensorRT를 사용하는 방법을 설명합니다.
-
NVIDIA TensorRT GitHub 저장소: NVIDIA TensorRT의 소스 코드와 문서가 포함된 공식 GitHub 저장소입니다.
요약#
이 가이드에서는 Ultralytics YOLO26 모델을 NVIDIA TensorRT 모델 형식으로 변환하는 방법을 살펴보았습니다. 이 변환을 통해 다양한 배포 환경의 NVIDIA 하드웨어에서 YOLO26 모델의 효율성과 속도를 향상할 수 있습니다.
사용 세부 정보는 TensorRT 공식 문서를 참조하세요.
자주 묻는 질문#
최적화된 NVIDIA GPU 추론을 위해 Ultralytics YOLO26 모델을 TensorRT 형식으로 변환하려면 다음 단계를 따르세요.
-
필수 패키지 설치:
pip install ultralytics -
YOLO26 모델 내보내기:
from ultralytics import YOLO model = YOLO("yolo26n.pt") model.export(format="engine") # 'yolo26n.engine' 생성 # 추론 실행 model = YOLO("yolo26n.engine") results = model("https://ultralytics.com/images/bus.jpg")
자세한 내용은 YOLO26 설치 가이드와 내보내기 문서를 참조하세요.
-
TensorRT로 YOLO26 모델을 최적화하면 다음과 같은 여러 이점을 얻을 수 있습니다.
- 추론 속도 향상: TensorRT는 모델 레이어를 최적화하고 정밀도 보정(INT8 및 FP16)을 사용하여 정확도를 크게 희생하지 않으면서 추론 속도를 높입니다.
- 메모리 효율성: TensorRT는 텐서 메모리를 동적으로 관리하여 오버헤드를 줄이고 GPU 메모리 활용도를 높입니다.
- 레이어 융합: 여러 레이어를 단일 연산으로 결합하여 계산 복잡성을 줄입니다.
- 커널 자동 튜닝: 각 모델 레이어에 최적화된 GPU 커널을 자동으로 선택하여 최대 성능을 보장합니다.
자세한 내용은 NVIDIA 공식 TensorRT 문서와 TensorRT 심층 개요를 확인하세요.
예. TensorRT에서 INT8 양자화를 사용하여 YOLO26 모델을 내보낼 수 있습니다. 이 과정에는 학습 후 양자화(PTQ)와 보정이 포함됩니다. 단, 체크포인트가
quantize=8(양자화 인식 학습)으로 학습된 경우에는 체크포인트에 저장된 범위를 보정 없이 내보냅니다.-
INT8로 내보내기:
from ultralytics import YOLO model = YOLO("yolo26n.pt") model.export(format="engine", batch=8, workspace=4, quantize=8, data="coco.yaml") -
추론 실행:
from ultralytics import YOLO model = YOLO("yolo26n.engine", task="detect") result = model.predict("https://ultralytics.com/images/bus.jpg")
자세한 내용은 INT8 양자화를 적용한 TensorRT 내보내기 섹션을 참조하세요.
-
다음 리소스를 활용하여 NVIDIA Triton Inference Server에 YOLO26 TensorRT 모델을 배포할 수 있습니다.
- Triton Server를 사용하여 Ultralytics YOLO26 배포: Triton Inference Server의 설정 및 사용 방법을 단계별로 안내합니다.
- NVIDIA TensorRT를 사용한 심층 신경망 배포: 세부적인 배포 옵션과 구성에 관한 NVIDIA의 TensorRT 기반 딥러닝 모델 배포 가이드입니다.
이 가이드를 통해 다양한 배포 환경에 YOLO26 모델을 효율적으로 통합할 수 있습니다.
TensorRT를 통한 성능 향상은 모델과 사용 하드웨어에 따라 달라질 수 있습니다. 다음은 YOLOv8n으로 측정한 일반적인 벤치마크이며, 정밀도별 상대적인 성능 향상을 보여줍니다.
-
NVIDIA A100:
- FP32 추론: 이미지당 ~0.52 ms
- FP16 추론: 이미지당 ~0.34 ms
- INT8 추론: 이미지당 ~0.28 ms
- INT8 정밀도에서는 mAP가 약간 낮아지지만 속도는 크게 향상됩니다.
-
소비자용 GPU(예: RTX 3080):
- FP32 추론: 이미지당 ~1.06 ms
- FP16 추론: 이미지당 ~0.62 ms
- INT8 추론: 이미지당 ~0.52 ms
다양한 하드웨어 구성의 상세 성능 벤치마크는 성능 섹션에서 확인할 수 있습니다.
-
댓글116
질문을 하거나 결과를 공유하거나 다른 사람을 도와주세요.
AgbajeAyomipo
Hi Ultralytics team, I’ve trained a YOLOv11 model on (1024x1024) images from a camera feed and now I’m trying to run real-time inference on live streams using a Jetson Orin Nano. I want to maintain full resolution for inference because of accuracy requirements, but currently I'm getting only 1-2 FPS. When I reduce the input size, the FPS improves significantly, but it's not acceptable due to missed detections at lower resolutions. I attempted to export the model to TensorRT using:
model.export(format="engine", imgsz=(2592, 1944), half=True) but it fails silently. If I use a dynamic=true without specifying the imgsz parameter, the export succeeds and uses (1024, 1024). My questions:
Is TensorRT export for such high-resolution input supported/recommended with YOLOv11? If not, is there any known limitation or workaround? Are there ways to improve performance with high-res inference on Jetson Orin Nano? What hardware would you recommend for real-time inference on 1-3 camera streams with 5MP inputs, assuming we need at least ~15-20 FPS per stream? Device: AAEON BOXER-8621AI Module: NVIDIA® Jetson Orin Nano™ (4GB LPDDR5, Super Mode Enabled) Memory: 4 GB LPDDR5 I/O: USB 3.2 Gen 2, M.2 Expansion Operating System: JetPack 5.1.4 (L4T 35.6.0, Ubuntu 20.04) Use Case: Real-time multi-stream 5MP video inference
1martinmclee
Have you gotten any workaround? Perhaps with the YOLO26?
AgbajeAyomipo
Hi Ultralytics team, I’ve trained a YOLOv11 model on full-size 5MP (2592x1944) images from a camera feed and now I’m trying to run real-time inference on live streams using a Jetson Orin Nano. I want to maintain full resolution for inference because of accuracy requirements, but currently I'm getting only 1-2 FPS. When I reduce the input size, the FPS improves significantly, but it's not acceptable due to missed detections at lower resolutions. I attempted to export the model to TensorRT using:
model.export(format="engine", imgsz=(2592, 1944), half=True)but it fails silently. If I use a dynamic=true, the export succeeds and uses (1024, 1024). My questions:- Is TensorRT export for such high-resolution input supported/recommended with YOLOv11? If not, is there any known limitation or workaround?
- Are there ways to improve performance with high-res inference on Jetson Orin Nano?
- What hardware would you recommend for real-time inference on 1-3 camera streams with 5MP inputs, assuming we need at least ~15-20 FPS per stream? Device: AAEON BOXER-8621AI Module: NVIDIA® Jetson Orin Nano™ (4GB LPDDR5, Super Mode Enabled) Memory: 4 GB LPDDR5 I/O: USB 3.2 Gen 2, M.2 Expansion Operating System: JetPack 5.1.4 (L4T 35.6.0, Ubuntu 20.04) Use Case: Real-time multi-stream 5MP video inference
1020423lzl
m的模型大小比n大的多,速度也慢了很多,输入图像尺寸越大,越吃显存,速度也越慢
李子乐控制工程 @.***
---Original--- From: @.> Date: Sat, May 9, 2026 10:30 AM To: @.>; Cc: @.@.>; Subject: Re: [ultralytics/ultralytics] zh/integrations/tensorrt/ (Discussion #9868)
现在有一个奇怪的现象,我导出的tensorrt模型的推理速度几乎和原来的.pt几乎没有差别甚至更慢,并且导出的tensorrt模型的推理结果和.pt模型的差别很大。 我的设备是i914900k+64G RAM+RTX A6000 我的环境是cuda12.4.131+tensorrt10.10.0.31+torch2.5.1+ultralytics8.3.252 导出命令: yolo export model=yolo11m.pt imgsz=1280 format='engine 推理代码为: model.predict(stream_path, imgsz=1280, classes=[14], conf=0.2, iou=0.5, stream=True, task='detect')
另外我试了下yolo11n.pt的640输入尺寸导出,推理速度就有明显提升,当然推理结果差别仍然较大。 请问这是什么道理,有什么解决办法?
— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.Message ID: @.***>
User能不能读完再说话,肯定是m和m比,n和n比,同样尺寸输入和同样尺寸输入的比啊。 该显卡的RT core算力是普通fp32算力的近两倍。
Glenn JocherUltralytics是的,性能应当在同一模型、同一
imgsz、同一batch、同一后处理参数下比较;m比n更大、1280比640更吃显存且更慢是正常现象。对 RTX A6000 来说,FP32的 TensorRT 往往不会比.pt明显更快,建议先按 TensorRT 导出文档 用half=True重新导出,并在相同输入上预热后再统计平均耗时;如果engine与.pt结果仍明显不一致,请贴出!yolo checks、完整控制台日志文本和一个最小可复现示例,我们好继续排查环境或后处理差异。
User现在有一个奇怪的现象,我导出的tensorrt模型的推理速度几乎和原来的.pt几乎没有差别甚至更慢,并且导出的tensorrt模型的推理结果和.pt模型的差别很大。 我的设备是i914900k+64G RAM+RTX A6000 我的环境是cuda12.4.131+tensorrt10.10.0.31+torch2.5.1+ultralytics8.3.252 导出命令:
yolo export model=yolo11m.pt imgsz=1280 format='engine推理代码为:model.predict(stream_path, imgsz=1280, classes=[14], conf=0.2, iou=0.5, stream=True, task='detect')另外我试了下yolo11n.pt的640输入尺寸导出,推理速度就有明显提升,当然推理结果差别仍然较大。 请问这是什么道理,有什么解决办法?
020423lzl
etson@yahboom:~/ultralytics/ultralytics$ yolo predict model=best.engine source=0 save=False show WARNING ⚠️ Unable to automatically guess model task, assuming 'task=detect'. Explicitly define task for your model, i.e. 'task=detect', 'segment', 'classify','pose' or 'obb'. Ultralytics 8.3.172 🚀 Python-3.10.12 torch-2.5.0a0+872d972e41.nv24.08 CUDA:0 (Orin, 7620MiB) Loading best.engine for TensorRT inference... [12/18/2025-17:11:05] [TRT] [I] Loaded engine size: 75 MiB [12/18/2025-17:11:05] [TRT] [I] [MS] Running engine with multi stream info [12/18/2025-17:11:05] [TRT] [I] [MS] Number of aux streams is 7 [12/18/2025-17:11:05] [TRT] [I] [MS] Number of total worker streams is 8 [12/18/2025-17:11:05] [TRT] [I] [MS] The main stream provided by execute/enqueue calls is the first worker stream [12/18/2025-17:11:05] [TRT] [I] [MemUsageChange] TensorRT-managed allocation in IExecutionContext creation: CPU +1, GPU +88, now: CPU 1, GPU 158 (MiB)
[ WARN:0@2.771] global cap_gstreamer.cpp:1777 open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1 1/1: 0... Success ✅ (inf frames of shape 1920x1080 at 5.00 FPS)
Traceback (most recent call last): File "/home/jetson/.local/bin/yolo", line 7, in sys.exit(entrypoint()) File "/home/jetson/Downloads/ultralytics-main/ultralytics/cfg/init.py", line 983, in entrypoint getattr(model, mode)(**overrides) # default args from model File "/home/jetson/Downloads/ultralytics-main/ultralytics/engine/model.py", line 555, in predict return self.predictor.predict_cli(source=source) if is_cli else self.predictor(source=source, stream=stream) File "/home/jetson/Downloads/ultralytics-main/ultralytics/engine/predictor.py", line 247, in predict_cli for _ in gen: # sourcery skip: remove-empty-nested-block, noqa File "/usr/local/lib/python3.10/dist-packages/torch/utils/_contextlib.py", line 36, in generator_context response = gen.send(None) File "/home/jetson/Downloads/ultralytics-main/ultralytics/engine/predictor.py", line 351, in stream_inference s[i] += self.write_results(i, Path(paths[i]), im, s) File "/home/jetson/Downloads/ultralytics-main/ultralytics/engine/predictor.py", line 434, in write_results string += f"{result.verbose()}{result.speed['inference']:.1f}ms" File "/home/jetson/Downloads/ultralytics-main/ultralytics/engine/results.py", line 694, in verbose return "".join(f"{n} {self.names[i]}{'s' * (n > 1)}, " for i, n in enumerate(counts) if n > 0) File "/home/jetson/Downloads/ultralytics-main/ultralytics/engine/results.py", line 694, in return "".join(f"{n} {self.names[i]}{'s' * (n > 1)}, " for i, n in enumerate(counts) if n > 0) KeyError: 171 terminate called without an active exception Aborted (core dumped) jetson@yahboom:~/ultralytics/ultralytics$ How to solve it
Glenn JocherUltralyticsKeyError: 171表示模型输出了类别171,但当前names里没有这个索引(通常是自定义数据集的标签类别编号不在0..nc-1范围内、data.yaml里的names数量与nc不匹配,或导出/推理用的模型与数据配置不一致导致的元数据错配);请先把所有标注.txt的 class id 修正为连续的0..nc-1,同步修正data.yaml的nc/names,修正后删除数据集labels/下的*.cache,再用同一套环境从best.pt重新导出.engine(参考 TensorRT 导出文档),并在推理时显式加上task=detect。另外请把下面命令的完整输出(文本)贴在这个 discussion 里,以及你当时的导出命令,方便我们确认是否有多环境/路径冲突:yolo checks020423lzl
Thank you for your reply. The issue has been resolved. I was using the RT-DETR model, but I mistakenly used "from ultralytics import YOLO" when exporting
Glenn JocherUltralyticsGlad you found it — RT-DETR models should be loaded/exported with
RTDETR(...)(mixing them withYOLO(...)can produce mismatched metadata likenames), see the RT-DETR model docs for details:from ultralytics import RTDETR model = RTDETR("best.pt") model.export(format="engine") # creates best.engine
fly2skyToEnjoy
May I ask : The following command exports the file, whether the box and mask are both nmsed at the same time ???
from ultralytics import YOLO
Load the YOLO11 model
model = YOLO("yolo11n.pt")
Export the model to TensorRT format
model.export(format="engine") # creates 'yolo11n.engine'
Load the exported TensorRT model
tensorrt_model = YOLO("yolo11n.engine")
Run inference
results = tensorrt_model("https://ultralytics.com/images/bus.jpg")
AK993
这个方法适用于rt-detr吗
dilanpatel195
I am trying to prediction model for the YOLOv11n-seg, I have exported the .py to .engine to back it run faster but keep getting a KEY error message:
KeyError Traceback (most recent call last) Cell In[4], line 109 106 # Inside the main loop after grabbing a frame 107 if inference_active and not inpainting_active: 108 # Perform YOLO inference --> 109 results = model(rgb_frame)[0] 110 masked_image = rgb_frame.copy() # Make a copy for masking 112 # Process YOLO masks (original functionality remains unchanged)
File c:\ProgramData\miniconda3\Lib\site-packages\ultralytics\engine\model.py:176, in Model.call(self, source, stream, **kwargs) 147 def call( 148 self, 149 source: Union[str, Path, int, Image.Image, list, tuple, np.ndarray, torch.Tensor] = None, 150 stream: bool = False, 151 **kwargs, 152 ) -> list: 153 """ 154 Alias for the predict method, enabling the model instance to be callable for predictions. 155 (...) 174 ... print(f"Detected {len(r)} objects in image") 175 """ --> 176 return self.predict(source, stream, **kwargs)
File c:\ProgramData\miniconda3\Lib\site-packages\ultralytics\engine\model.py:554, in Model.predict(self, source, stream, predictor, **kwargs) 552 if prompts and hasattr(self.predictor, "set_prompts"): # for SAM-type models 553 self.predictor.set_prompts(prompts) --> 554 return self.predictor.predict_cli(source=source) if is_cli else self.predictor(source=source, stream=stream)
File c:\ProgramData\miniconda3\Lib\site-packages\ultralytics\engine\predictor.py:168, in BasePredictor.call(self, source, model, stream, *args, **kwargs) 166 return self.stream_inference(source, model, *args, **kwargs) 167 else: --> 168 return list(self.stream_inference(source, model, *args, **kwargs))
File c:\ProgramData\miniconda3\Lib\site-packages\torch\utils_contextlib.py:36, in _wrap_generator..generator_context(*args, **kwargs) 33 try: 34 # Issuing None to a generator fires it up 35 with ctx_factory(): ---> 36 response = gen.send(None) 38 while True: 39 try: 40 # Forward the response to our caller and get its next request
File c:\ProgramData\miniconda3\Lib\site-packages\ultralytics\engine\predictor.py:274, in BasePredictor.stream_inference(self, source, model, *args, **kwargs) 268 self.results[i].speed = { 269 "preprocess": profilers[0].dt * 1e3 / n, 270 "inference": profilers[1].dt * 1e3 / n, 271 "postprocess": profilers[2].dt * 1e3 / n, 272 } 273 if self.args.verbose or self.args.save or self.args.save_txt or self.args.show: --> 274 s[i] += self.write_results(i, Path(paths[i]), im, s) 276 # Print batch results 277 if self.args.verbose:
File c:\ProgramData\miniconda3\Lib\site-packages\ultralytics\engine\predictor.py:334, in BasePredictor.write_results(self, i, p, im, s) 332 result = self.results[i] 333 result.save_dir = self.save_dir.str() # used in other locations --> 334 string += f"{result.verbose()}{result.speed['inference']:.1f}ms" 336 # Add predictions to image 337 if self.args.save or self.args.show:
File c:\ProgramData\miniconda3\Lib\site-packages\ultralytics\engine\results.py:663, in Results.verbose(self) 661 for c in boxes.cls.unique(): 662 n = (boxes.cls == c).sum() # detections per class --> 663 log_string += f"{n} {self.names[int(c)]}{'s' * (n > 1)}, " 664 return log_string
KeyError: 2
Any help would be greatly appreciated!
Ranjith3436
Now, My TensorRT Sengment model used for track. if any detections not there the processing FPS is 75-80 in jetson. But once the person or people detected suddenly reused to 15-20. processing time going to 40ms. only when the object detected. What's the issue in model.track(), could i run all the tracking thing on GPU.
Glenn JocherUltralytics(수정됨)@Ranjith3436 the performance drop when objects are detected is expected behavior, as tracking introduces additional computational overhead. When objects are detected, the model.track() method performs several CPU-bound operations including feature extraction, association, and trajectory management.
To improve performance:
- Try using a smaller model variant (like YOLO26n-seg instead of larger variants)
- Consider reducing the image resolution for tracking
- Optimize tracking parameters by setting
persist=Trueand adjustingconfthresholds higher to track fewer objects - Use
half=True(FP16) orint8=Truewhen exporting your model to TensorRT for maximum GPU acceleration
For the tracking components specifically, the BoT-SORT or ByteTrack algorithms used by Ultralytics do have some CPU-bound operations, but you can minimize their impact with the above optimizations. For more details on tracking optimization, check our tracking documentation.
1
Ranjith3436
I convert Classification model that i retrained. But it throw the error "amax(): Expected reduction dim 1 to have non-zero size."
Glenn JocherUltralytics@Ranjith3436 this error typically occurs when TensorRT encounters an empty dimension during model conversion. For classification models, this could happen if:
- Your model architecture was modified or if you're using a custom architecture
- There might be an issue with batch normalization layers during export
- The class count in your retrained model might be causing dimension mismatches
Try these solutions:
- Ensure your model's forward pass works correctly before export
- Try exporting with
simplify=Falseto preserve the original graph structure - Check if your classification model has the correct output dimension for your number of classes
If the issue persists, share more details about your model architecture and export command for better assistance. For more guidance, refer to our TensorRT integration documentation.
Ranjith3436
The model trained use yolov8l-cls.pt and the error come from jetson device.
(model): ClassificationModel( (model): Sequential( (0): Conv( (conv): Conv2d(3, 64, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False) (bn): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) (act): SiLU(inplace=True) ) (1): Conv( (conv): Conv2d(64, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False) (bn): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) (act): SiLU(inplace=True) ) (2): C2f( (cv1): Conv( (conv): Conv2d(128, 128, kernel_size=(1, 1), stride=(1, 1), bias=False) (bn): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) (act): SiLU(inplace=True) ) (cv2): Conv( (conv): Conv2d(320, 128, kernel_size=(1, 1), stride=(1, 1), bias=False) (bn): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) (act): SiLU(inplace=True) ) (m): ModuleList( (0-2): 3 x Bottleneck( (cv1): Conv( (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False) (bn): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) (act): SiLU(inplace=True) ) (cv2): Conv( (conv): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False) (bn): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) (act): SiLU(inplace=True) ) ) ) ) (3): Conv( (conv): Conv2d(128, 256, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False) (bn): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) (act): SiLU(inplace=True) ) (4): C2f( (cv1): Conv( (conv): Conv2d(256, 256, kernel_size=(1, 1), stride=(1, 1), bias=False) (bn): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) (act): SiLU(inplace=True) ) (cv2): Conv( (conv): Conv2d(1024, 256, kernel_size=(1, 1), stride=(1, 1), bias=False) (bn): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) (act): SiLU(inplace=True) ) (m): ModuleList( (0-5): 6 x Bottleneck( (cv1): Conv( (conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False) (bn): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) (act): SiLU(inplace=True) ) (cv2): Conv( (conv): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False) (bn): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) (act): SiLU(inplace=True) ) ) ) ) (5): Conv( (conv): Conv2d(256, 512, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False) (bn): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) (act): SiLU(inplace=True) ) (6): C2f( (cv1): Conv( (conv): Conv2d(512, 512, kernel_size=(1, 1), stride=(1, 1), bias=False) (bn): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) (act): SiLU(inplace=True) ) (cv2): Conv( (conv): Conv2d(2048, 512, kernel_size=(1, 1), stride=(1, 1), bias=False) (bn): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) (act): SiLU(inplace=True) ) (m): ModuleList( (0-5): 6 x Bottleneck( (cv1): Conv( (conv): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False) (bn): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) (act): SiLU(inplace=True) ) (cv2): Conv( (conv): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False) (bn): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) (act): SiLU(inplace=True) ) ) ) ) (7): Conv( (conv): Conv2d(512, 1024, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False) (bn): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) (act): SiLU(inplace=True) ) (8): C2f( (cv1): Conv( (conv): Conv2d(1024, 1024, kernel_size=(1, 1), stride=(1, 1), bias=False) (bn): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) (act): SiLU(inplace=True) ) (cv2): Conv( (conv): Conv2d(2560, 1024, kernel_size=(1, 1), stride=(1, 1), bias=False) (bn): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) (act): SiLU(inplace=True) ) (m): ModuleList( (0-2): 3 x Bottleneck( (cv1): Conv( (conv): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False) (bn): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) (act): SiLU(inplace=True) ) (cv2): Conv( (conv): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False) (bn): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) (act): SiLU(inplace=True) ) ) ) ) (9): Classify( (conv): Conv( (conv): Conv2d(1024, 1280, kernel_size=(1, 1), stride=(1, 1), bias=False) (bn): BatchNorm2d(1280, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) (act): SiLU(inplace=True) ) (pool): AdaptiveAvgPool2d(output_size=1) (drop): Dropout(p=0.0, inplace=True) (linear): Linear(in_features=1280, out_features=2, bias=True) ) ) ) )
model architecture
Ranjith3436
This error sorted out