Image Classification
Image classification is the simplest of the three tasks and involves classifying an entire image into one of a set of predefined classes.
The output of an image classifier is a single class label and a confidence score. Image classification is useful when you need to know only what class an image belongs to and don't need to know where objects of that class are located or what their exact shape is.
Watch: Explore Ultralytics YOLO Tasks: Image Classification using Ultralytics HUB
Tip
YOLO11 Classify models use the -cls
suffix, i.e. yolo11n-cls.pt
and are pretrained on ImageNet.
Models
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.
Models download automatically from the latest Ultralytics release on first use.
Model | size (pixels) |
acc top1 |
acc top5 |
Speed CPU ONNX (ms) |
Speed T4 TensorRT10 (ms) |
params (M) |
FLOPs (B) at 640 |
---|---|---|---|---|---|---|---|
YOLO11n-cls | 224 | 70.0 | 89.4 | 5.0 ± 0.3 | 1.1 ± 0.0 | 1.6 | 3.3 |
YOLO11s-cls | 224 | 75.4 | 92.7 | 7.9 ± 0.2 | 1.3 ± 0.0 | 5.5 | 12.1 |
YOLO11m-cls | 224 | 77.3 | 93.9 | 17.2 ± 0.4 | 2.0 ± 0.0 | 10.4 | 39.3 |
YOLO11l-cls | 224 | 78.3 | 94.3 | 23.2 ± 0.3 | 2.8 ± 0.0 | 12.9 | 49.4 |
YOLO11x-cls | 224 | 79.5 | 94.9 | 41.4 ± 0.9 | 3.8 ± 0.0 | 28.4 | 110.4 |
- acc values are model accuracies on the ImageNet dataset validation set.
Reproduce byyolo val classify data=path/to/ImageNet device=0
- Speed averaged over ImageNet val images using an Amazon EC2 P4d instance.
Reproduce byyolo val classify data=path/to/ImageNet batch=1 device=0|cpu
Train
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.
Example
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
Dataset format
YOLO classification dataset format can be found in detail in the Dataset Guide.
Val
Validate trained YOLO11n-cls model accuracy on the MNIST160 dataset. No arguments are needed as the model
retains its training data
and arguments as model attributes.
Example
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
Predict
Use a trained YOLO11n-cls model to run predictions on images.
Example
See full predict
mode details in the Predict page.
Export
Export a YOLO11n-cls model to a different format like ONNX, CoreML, etc.
Example
Available YOLO11-cls export formats are in the table below. You can export to any format using the format
argument, i.e. format='onnx'
or format='engine'
. You can predict or validate directly on exported models, i.e. yolo predict model=yolo11n-cls.onnx
. Usage examples are shown for your model after export completes.
Format | format Argument |
Model | Metadata | Arguments |
---|---|---|---|---|
PyTorch | - | yolo11n-cls.pt |
✅ | - |
TorchScript | torchscript |
yolo11n-cls.torchscript |
✅ | imgsz , optimize , batch |
ONNX | onnx |
yolo11n-cls.onnx |
✅ | imgsz , half , dynamic , simplify , opset , batch |
OpenVINO | openvino |
yolo11n-cls_openvino_model/ |
✅ | imgsz , half , int8 , batch |
TensorRT | engine |
yolo11n-cls.engine |
✅ | imgsz , half , dynamic , simplify , workspace , int8 , batch |
CoreML | coreml |
yolo11n-cls.mlpackage |
✅ | imgsz , half , int8 , nms , batch |
TF SavedModel | saved_model |
yolo11n-cls_saved_model/ |
✅ | imgsz , keras , int8 , batch |
TF GraphDef | pb |
yolo11n-cls.pb |
❌ | imgsz , batch |
TF Lite | tflite |
yolo11n-cls.tflite |
✅ | imgsz , half , int8 , batch |
TF Edge TPU | edgetpu |
yolo11n-cls_edgetpu.tflite |
✅ | imgsz |
TF.js | tfjs |
yolo11n-cls_web_model/ |
✅ | imgsz , half , int8 , batch |
PaddlePaddle | paddle |
yolo11n-cls_paddle_model/ |
✅ | imgsz , batch |
MNN | mnn |
yolo11n-cls.mnn |
✅ | imgsz , batch , int8 , half |
NCNN | ncnn |
yolo11n-cls_ncnn_model/ |
✅ | imgsz , half , batch |
IMX500 | imx |
yolo11n-cls_imx_model/ |
✅ | imgsz , int8 |
See full export
details in the Export page.
FAQ
What is the purpose of YOLO11 in image classification?
YOLO11 models, such as yolo11n-cls.pt
, are designed for efficient image classification. They assign a single class label to an entire image along with a confidence score. This is particularly useful for applications where knowing the specific class of an image is sufficient, rather than identifying the location or shape of objects within the image.
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
model on the MNIST160 dataset for 100 epochs at an image size of 64:
Example
For more configuration options, visit the Configuration page.
Where can I find pretrained YOLO11 classification models?
Pretrained YOLO11 classification models can be found in the Models section. Models like yolo11n-cls.pt
, yolo11s-cls.pt
, yolo11m-cls.pt
, etc., are pretrained on the ImageNet dataset and can be easily downloaded and used for various image classification tasks.
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:
Example
For detailed export options, refer to the Export page.
How do I validate a trained YOLO11 classification model?
To validate a trained model's accuracy on a dataset like MNIST160, you can use the following Python or CLI commands:
Example
For more information, visit the Validate section.