Image Classification
Image classification assigns a whole image one label from a fixed set of classes. How classifiers turn pixels into probabilities, key models, and uses.
Image classification is a computer vision task in which a model looks at an entire image and assigns it one label from a fixed set of classes, along with a confidence score for every class. It answers the question "what is this image of?": cat or dog, defective or good, pneumonia or normal. It is the simplest of the core vision tasks and also the foundation of the others, because backbones first trained to classify images on large datasets are reused as feature extractors for detection and segmentation through transfer learning.
How Image Classification Works#
A classifier turns pixels into class probabilities in three stages. A backbone, either a convolutional neural network (CNN) or a vision transformer (ViT), extracts features layer by layer, from edges and textures in early layers to object parts and whole objects in deeper ones. A pooling step collapses the final feature maps into a single vector that summarizes the whole image. A fully connected layer then produces one score, or logit, per class, and the softmax function converts those scores into probabilities that sum to 1.
Models learn this mapping through supervised learning on labeled images, minimizing cross-entropy loss between predicted probabilities and the true class. Single-label (multi-class) classification picks exactly one class per image with softmax. Multi-label classification, used when an image can show several things at once, scores each class independently with a sigmoid and keeps every class above a threshold.
Ultralytics YOLO26 classification models, marked by the -cls suffix, are single-label classifiers pretrained on ImageNet at 224×224 pixels, where the smallest, YOLO26n-cls, reaches 71.4% top-1 accuracy with 2.8 million parameters. They train on any dataset arranged as one folder of images per class:
from ultralytics import YOLO
# Load a YOLO26 classification model pretrained on the 1,000 ImageNet classes
model = YOLO("yolo26n-cls.pt")
# Classify the whole image
results = model("https://ultralytics.com/images/bus.jpg")
probs = results[0].probs
# Show the five most likely classes and their softmax probabilities
for class_id, confidence in zip(probs.top5, probs.top5conf.tolist()):
print(f"{results[0].names[class_id]}: {confidence:.2f}")The five probabilities come from one softmax over all 1,000 classes, so they show how confident the model is in its top choice relative to similar classes.
Classification vs. Detection and Segmentation#
Classification describes the whole image and says nothing about where things are or how many there are:
- Object detection: Finds each object, labels it, and locates it with a bounding box, so it can count three cars in one photo.
- Image segmentation: Labels pixels, tracing the exact outline of each object or region.
- Image recognition: A broader umbrella term for identifying content in images, often used loosely as a synonym for classification.
Choosing between them depends on how much spatial detail an application needs:
Real-World Applications#
- Manufacturing inspection: Cameras on a production line photograph each part, and a classifier labels it pass or fail so defective items are rejected automatically.
- Medical triage: Models triage chest X-rays, skin lesion photos, and retinal scans into normal and abnormal categories so clinicians review urgent cases first.
- Agriculture: Farmers photograph leaves with a phone, and a classifier identifies the crop disease or nutrient deficiency.
- Content organization: Photo libraries and marketplaces tag millions of images by scene and product category so they can be searched and moderated.
Benchmarks and Models#
Classifiers are compared by top-1 accuracy, the share of images whose highest-probability class is correct, and top-5 accuracy, the share whose true class appears among the five most likely. Modern classification grew out of the ImageNet Large Scale Visual Recognition Challenge, whose 1,000-class subset with about 1.28 million training images remains the standard benchmark. In 2012, AlexNet cut the top-5 error rate to 15.3% from 26.2% for the runner-up, starting the deep learning era in vision. ResNet made networks with more than 100 layers trainable in 2015, and Vision Transformers showed in 2020 that attention-based models match or beat CNNs once pretrained on 14 million to 300 million images.










