콘텐츠로 건너뛰기

이미지 분류

이미지 분류 예시

Image classification is the simplest of the three tasks and involves classifying an entire image into one of a set of predefined classes.

이미지 분류기의 출력은 단일 클래스 레이블과 신뢰도 점수입니다. 이미지 분류는 이미지가 속한 클래스만 알고 싶고 해당 클래스의 객체가 어디에 있는지 또는 정확한 모양이 무엇인지 알 필요가 없을 때 유용합니다.



Watch: Ultralytics YOLO 작업 살펴보기: Ultralytics HUB를 사용한 이미지 분류

YOLO11 Classify models use the -cls 접미사, 즉 yolo11n-cls.pt 에 대해 사전 교육을 받았으며 이미지넷.

모델

YOLO11 pretrained Classify models are shown here. Detect, Segment and Pose models are pretrained on the COCO dataset, while Classify models are pretrained on the ImageNet dataset.

모델은 처음 사용할 때 최신 Ultralytics 릴리스에서 자동으로 다운로드됩니다.

모델크기
(픽셀)
acc
top1
ACC
TOP5
속도
CPU ONNX
(ms)
Speed
T4 TensorRT10
(ms)
매개변수
(M)
FLOPs
(B) at 640
YOLO11n-cls22470.089.45.0 ± 0.31.1 ± 0.01.63.3
YOLO11s-cls22475.492.77.9 ± 0.21.3 ± 0.05.512.1
YOLO11m-cls22477.393.917.2 ± 0.42.0 ± 0.010.439.3
YOLO11l-cls22478.394.323.2 ± 0.32.8 ± 0.012.949.4
YOLO11x-cls22479.594.941.4 ± 0.93.8 ± 0.028.4110.4
  • acc 값은 모델 정확도입니다. 이미지넷 데이터 세트 유효성 검사 집합.
    복제 대상 yolo val classify data=path/to/ImageNet device=0
  • 속도 이미지넷 값 이미지에 대해 평균을 구합니다. Amazon EC2 P4d 인스턴스.
    복제 대상 yolo val classify data=path/to/ImageNet batch=1 device=0|cpu

기차

Train YOLO11n-cls on the MNIST160 dataset for 100 epochs at image size 64. For a full list of available arguments see the Configuration page.

from ultralytics import YOLO

# Load a model
model = YOLO("yolo11n-cls.yaml")  # build a new model from YAML
model = YOLO("yolo11n-cls.pt")  # load a pretrained model (recommended for training)
model = YOLO("yolo11n-cls.yaml").load("yolo11n-cls.pt")  # build from YAML and transfer weights

# Train the model
results = model.train(data="mnist160", epochs=100, imgsz=64)
# Build a new model from YAML and start training from scratch
yolo classify train data=mnist160 model=yolo11n-cls.yaml epochs=100 imgsz=64

# Start training from a pretrained *.pt model
yolo classify train data=mnist160 model=yolo11n-cls.pt epochs=100 imgsz=64

# Build a new model from YAML, transfer pretrained weights to it and start training
yolo classify train data=mnist160 model=yolo11n-cls.yaml pretrained=yolo11n-cls.pt epochs=100 imgsz=64

데이터 집합 형식

YOLO 분류 데이터셋 형식은 데이터셋 가이드에서 자세히 확인할 수 있습니다.

Val

Validate trained YOLO11n-cls model accuracy on the MNIST160 dataset. No arguments are needed as the model 교육 유지 data 및 인수를 모델 속성으로 사용합니다.

from ultralytics import YOLO

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

# Validate the model
metrics = model.val()  # no arguments needed, dataset and settings remembered
metrics.top1  # top1 accuracy
metrics.top5  # top5 accuracy
yolo classify val model=yolo11n-cls.pt  # val official model
yolo classify val model=path/to/best.pt  # val custom model

예측

Use a trained YOLO11n-cls model to run predictions on images.

from ultralytics import YOLO

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

# Predict with the model
results = model("https://ultralytics.com/images/bus.jpg")  # predict on an image
yolo classify predict model=yolo11n-cls.pt source='https://ultralytics.com/images/bus.jpg'  # predict with official model
yolo classify predict model=path/to/best.pt source='https://ultralytics.com/images/bus.jpg'  # predict with custom model

전체 보기 predict 모드 세부 정보에서 예측 페이지로 이동합니다.

내보내기

Export a YOLO11n-cls model to a different format like ONNX, CoreML, etc.

from ultralytics import YOLO

# Load a model
model = YOLO("yolo11n-cls.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-cls.pt format=onnx  # export official model
yolo export model=path/to/best.pt format=onnx  # export custom trained model

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

형식format 인수모델메타데이터인수
PyTorch-yolo11n-cls.pt-
TorchScripttorchscriptyolo11n-cls.torchscriptimgsz, optimize, batch
ONNXonnxyolo11n-cls.onnximgsz, half, dynamic, simplify, opset, batch
OpenVINOopenvinoyolo11n-cls_openvino_model/imgsz, half, int8, batch
TensorRTengineyolo11n-cls.engineimgsz, half, dynamic, simplify, workspace, int8, batch
CoreMLcoremlyolo11n-cls.mlpackageimgsz, half, int8, nms, batch
TF SavedModelsaved_modelyolo11n-cls_saved_model/imgsz, keras, int8, batch
TF GraphDefpbyolo11n-cls.pbimgsz, batch
TF Litetfliteyolo11n-cls.tfliteimgsz, half, int8, batch
TF Edge TPUedgetpuyolo11n-cls_edgetpu.tfliteimgsz
TF.jstfjsyolo11n-cls_web_model/imgsz, half, int8, batch
PaddlePaddlepaddleyolo11n-cls_paddle_model/imgsz, batch
NCNNncnnyolo11n-cls_ncnn_model/imgsz, half, batch

전체 보기 export 세부 정보에서 내보내기 페이지로 이동합니다.

자주 묻는 질문

What is the purpose of YOLO11 in image classification?

YOLO11 models, such as yolo11n-cls.pt는 효율적인 이미지 분류를 위해 설계되었습니다. 신뢰도 점수와 함께 전체 이미지에 단일 클래스 레이블을 할당합니다. 이는 이미지 내 물체의 위치나 모양을 식별하는 대신 이미지의 특정 클래스만 알면 충분한 애플리케이션에 특히 유용합니다.

How do I train a YOLO11 model for image classification?

To train a YOLO11 model, you can use either Python or CLI commands. For example, to train a yolo11n-cls 모델을 이미지 크기 64의 100개 에포크에 대해 MNIST160 데이터 세트에 적용했습니다:

from ultralytics import YOLO

# Load a model
model = YOLO("yolo11n-cls.pt")  # load a pretrained model (recommended for training)

# Train the model
results = model.train(data="mnist160", epochs=100, imgsz=64)
yolo classify train data=mnist160 model=yolo11n-cls.pt epochs=100 imgsz=64

더 많은 구성 옵션을 보려면 구성 페이지를 방문하세요.

Where can I find pretrained YOLO11 classification models?

Pretrained YOLO11 classification models can be found in the 모델 섹션으로 이동합니다. 다음과 같은 모델 yolo11n-cls.pt, yolo11s-cls.pt, yolo11m-cls.pt등에 대해 사전 교육을 받은 후 이미지넷 데이터 세트를 쉽게 다운로드하여 다양한 이미지 분류 작업에 사용할 수 있습니다.

How can I export a trained YOLO11 model to different formats?

You can export a trained YOLO11 model to various formats using Python or CLI commands. For instance, to export a model to ONNX format:

from ultralytics import YOLO

# Load a model
model = YOLO("yolo11n-cls.pt")  # load the trained model

# Export the model to ONNX
model.export(format="onnx")
yolo export model=yolo11n-cls.pt format=onnx  # export the trained model to ONNX format

내보내기 옵션에 대한 자세한 내용은 내보내기 페이지를 참조하세요.

How do I validate a trained YOLO11 classification model?

MNIST160과 같은 데이터 세트에서 학습된 모델의 정확도를 검증하려면 다음 Python 또는 CLI 명령을 사용할 수 있습니다:

from ultralytics import YOLO

# Load a model
model = YOLO("yolo11n-cls.pt")  # load the trained model

# Validate the model
metrics = model.val()  # no arguments needed, uses the dataset and settings from training
metrics.top1  # top1 accuracy
metrics.top5  # top5 accuracy
yolo classify val model=yolo11n-cls.pt  # validate the trained model

자세한 내용은 유효성 검사 섹션을 참조하세요.

📅 Created 11 months ago ✏️ Updated 21 days ago

댓글