Image Classification

From PRIMO.ai
Jump to navigation Jump to search

Youtube search... ...Google search


Image classification is the task of assigning a label, or a set of labels, to a whole image: "cat," "malignant," "ripe," "spiral galaxy." It's one of the oldest problems in computer vision and the training ground for most of the ideas that power today's vision systems. A classifier takes pixels in and returns a probability for each category it knows about. Models trained on classification also become general-purpose image encoders, so the same backbone that sorts vacation photos can be fine-tuned for pathology slides, satellite imagery or a factory inspection line.

Classification answers "what is in this image?" Related tasks go further: object detection answers "what and where?" with bounding boxes (see Getting Started & Project: Object Detection), and segmentation labels every pixel. Common flavors of classification include:

  • Binary: two classes, such as defect or no defect.
  • Multi-class: exactly one label from many, as in the 1,000 ImageNet categories.
  • Multi-label: several labels can be true at once, such as "dog," "grass" and "frisbee" in the same photo.
  • Fine-grained: telling apart very similar categories, like bird species (see Bird Identification) or car models.
  • Zero-shot or open-vocabulary: sorting images into categories described in plain text at run time, with no task-specific training.

How Image Classification Works

Almost every image classifier follows the same pipeline:

  • Input: the image is resized (commonly to 224 x 224 pixels) and normalized into a grid of numbers, with three values per pixel for red, green and blue.
  • Feature extraction: a backbone network turns those pixels into a compact embedding that captures shapes, textures and objects. In a convolutional neural network (CNN), stacked filters learn edges first, then parts, then whole objects. In a Vision Transformer (ViT), the image is cut into small patches that are treated like words in a sentence, and attention relates every patch to every other patch.
  • Classification head: a final layer maps the embedding to one score per class, and softmax turns those scores into probabilities that add up to 1. Multi-label models use an independent sigmoid for each class instead, so several classes can be "on" at once.
  • Training: the model compares its prediction with the correct label using a loss function, usually cross-entropy, and backpropagation plus an optimizer nudge millions of weights to shrink the error. Dropout, regularization and data augmentation (random crops, flips and color shifts) help the model generalize instead of memorizing its training set, which is the overfitting challenge.
  • Inference: the trained model returns the most likely class, or the top few, along with a confidence score.

Before deep learning, classifiers relied on hand-designed features, such as edge and color histograms, fed into models like support vector machines or k-nearest neighbors. Deep learning replaced hand-crafted features with features learned directly from data (see Feature Exploration/Learning), and that's why accuracy jumped so sharply after 2012.

Evolution of Image Classification Models

Image classification has been deep learning's proving ground for more than a decade, and progress on the ImageNet benchmark tracks the field's biggest shifts.

Year Model Why it mattered
1998 LeNet-5 and MNIST Convolutional networks learned to read handwritten digits, and MNIST became the field's "hello world" dataset.
2012 AlexNet A GPU-trained CNN cut top-5 error in the ImageNet challenge to 15.3%, versus about 26% for the runner-up, and kicked off the deep learning boom.
2015 ResNet Residual "skip" connections made very deep networks (up to 152 layers) trainable; an ensemble reached 3.57% top-5 error. See (Deep) Residual Network (DRN) - ResNet and ResNet-50.
2019 EfficientNet Scaled depth, width and resolution together; EfficientNet-B7 hit 84.3% top-1 while being 8.4x smaller and 6.1x faster than the best earlier ConvNet.
2020 Vision Transformer (ViT) Showed that a pure Transformer that treats image patches as tokens can match or beat CNNs when it's pretrained on enough data.
2021 CLIP Learned from 400 million image-text pairs and classified images zero-shot from text prompts, matching the original ResNet-50 on ImageNet without using any of its 1.28 million labeled training images.
2022 ConvNeXt Modernized the ResNet with Transformer-era design choices and reached 87.8% top-1, proving CNNs were still competitive.
2022 CoCa Combined contrastive and captioning training to reach 86.3% zero-shot and 91.0% fine-tuned top-1 accuracy on ImageNet.
2023 DINOv2 Self-supervised training on curated images produced general-purpose features that work on new tasks without retraining.
2025 DINOv3 and SigLIP 2 Label-free pretraining scaled to 7 billion parameters and about 1.7 billion images, alongside multilingual image-text encoders with better localization.
2026 ReImageNet A full re-annotation found that about 13% of the original ImageNet-1k validation labels were wrong, changing how progress is measured.

Convolutional Neural Networks

CNNs dominated image classification from 2012 until about 2020 and are still the workhorse for many real deployments. Their built-in assumptions (nearby pixels matter together, and a cat is a cat wherever it appears in the frame) make them data-efficient and fast. ResNet's skip connections solved the problem of training very deep networks, and ResNet-50 remains the default baseline in papers and tutorials. Efficiency-focused families brought classification to phones and cameras: MobileNetV4 (2024) is designed to run well across mobile CPUs, GPUs, DSPs and dedicated accelerators.

Vision Transformers

The Vision Transformer borrowed the Transformer architecture from language models. It splits an image into patches, turns each patch into a token, and lets attention learn how every part of the image relates to every other part. ViTs have weaker built-in assumptions than CNNs, so they need more data or heavier pretraining, but they scale extremely well and share an architecture with large language models. That shared design is a big reason multimodal models can "see."

Zero-Shot Classification with Image-Text Models

CLIP changed what a classifier could be. Instead of learning a fixed list of classes, it learns to place images and text in the same embedding space. To classify, you write the candidate labels as text prompts (for example, "a photo of a golden retriever"), embed the image and each prompt, and pick the closest match. You can add a new category by typing it, with no retraining. Successors such as Google's SigLIP 2 and Meta's Perception Encoder improved accuracy, multilingual support and robustness, and these encoders now serve as the "eyes" of many multimodal assistants.

Self-Supervised Foundation Models

Self-supervised models learn from huge collections of unlabeled images by solving tasks they set for themselves, like matching different crops of the same picture. Meta's DINO family is the best-known example. DINOv3 was trained on about 1.7 billion images with no labels and scales to 7 billion parameters. These foundation models produce features good enough that a simple linear classifier on top, a "linear probe," often rivals a fully trained specialist model, which makes them ideal starting points when labeled data is scarce.

Multimodal LLMs as Classifiers

General-purpose multimodal models such as Gemini, Claude and OpenAI's GPT models can classify an image when you simply ask, and they explain their answers in plain language. They're flexible but slower and more expensive per image than a dedicated classifier. Researchers found that these models underperform CLIP on standard classification benchmarks, mainly because of how they're trained. Later work showed that part of that gap was an artifact of noisy labels and flawed evaluation: on corrected ImageNet labels, multimodal LLMs gained up to 10.8% and closed much of the distance to supervised models.

Benchmarks and Evaluation

Common Datasets

  • MNIST: 70,000 small grayscale images of handwritten digits. It's too easy for modern models but still the classic first project.
  • CIFAR-10 and CIFAR-100: 32 x 32 color images. CIFAR-10 has 60,000 images in 10 classes, and CIFAR-100 has 100 classes of 600 images each.
  • ImageNet-1k: about 1.28 million training images and 50,000 validation images across 1,000 everyday categories. For more than a decade it has been the benchmark nearly every new model reports.
  • Robustness test sets: ImageNet-C applies common corruptions such as noise, blur and weather effects, and ImageNet-P checks whether predictions stay stable under small everyday perturbations. Related test sets use sketches, artistic renditions and unusual viewpoints.
  • Domain datasets: medical, satellite, agricultural and wildlife collections test whether a model works outside everyday photos. Kaggle competitions are a good source of these.

Metrics

  • Top-1 accuracy: the share of images where the model's single best guess is correct.
  • Top-5 accuracy: the share where the correct answer appears among the model's five best guesses. It's useful when classes are very close, like dog breeds.
  • Precision and recall: precision asks "when the model says tumor, how often is it right?" Recall asks "of all the real tumors, how many did it catch?" The F1 score balances the two.
  • Confusion matrix: a table showing which classes get mistaken for which. It's often the fastest way to see what's going wrong.
  • Calibration: whether a model's confidence matches reality. A well-calibrated model that says it's 90% sure should be right about 90% of the time.
  • Efficiency: parameter count, latency and memory use matter as much as accuracy when a model runs on a phone or camera.

See Evaluation, Evaluating Machine Learning Models and Benchmarks for more.

Is ImageNet Saturated?

Top ImageNet scores are now above 90% top-1 accuracy (CoCa reported 91.0% back in 2022), and new models usually gain only fractions of a percent. Part of the remaining "error" isn't the models' fault. A 2021 study found that label errors average at least 3.3% across ten popular test sets and reach at least 6% in the ImageNet validation set. In 2026, the ReImageNet project re-annotated the ImageNet-1k validation set and found that about 13% of the original labels were incorrect and 32.7% of images actually contain more than one valid label. Scored against the corrected labels, supervised models gain 0.7 to 1.4 points of top-1 accuracy, and multimodal LLMs gain 6 to 8 points. The lesson for practitioners: data quality matters as much as architecture, and a single accuracy number on an old benchmark can hide a lot.

Building an Image Classifier Today

The right approach depends on how much labeled data you have, how unusual your images are and where the model will run. Here's a practical ladder, from least to most effort:

  • Zero-shot: start with an image-text model such as CLIP or SigLIP 2 and list your class names as text prompts. You don't need any training data, and it's a quick baseline that works well for everyday categories. Hugging Face's zero-shot image classification pipeline gets you running in a few lines of Python.
  • Ask a multimodal LLM: for low volumes, or when you want an explanation alongside the label, prompt a model such as Gemini or Claude with the image and your list of categories.
  • Linear probe or few-shot: freeze a strong pretrained backbone (DINOv3, SigLIP 2 or ConvNeXt, for example), extract embeddings for your images and train a small classifier on top. A modest number of labeled examples per class is often enough (see Few Shot Learning).
  • Fine-tuning: transfer learning by fine-tuning some or all of a pretrained model's layers on your own labeled data. This is the standard choice for specialized domains such as medical imaging or industrial inspection. See also Image/Video Transfer Learning.
  • Training from scratch: rarely needed today. It makes sense mainly when you have a very large labeled dataset or images unlike anything in public pretraining data.

Tools and Frameworks

  • PyTorch with timm (PyTorch Image Models), a large collection of pretrained image backbones, including ResNet, EfficientNet and Vision Transformer families, with training, evaluation, inference and export scripts.
  • Hugging Face Transformers and the Hugging Face Hub for pretrained classifiers and ready-made zero-shot pipelines.
  • TensorFlow and Keras, which include built-in image models and transfer learning tutorials.
  • Google Colab and Kaggle notebooks for free GPU time while you experiment.

Deploying to Phones and Edge Devices

Once a model works, it often needs to get smaller and faster. Quantization stores weights as 8-bit or 4-bit numbers instead of 32-bit floats. Knowledge distillation trains a compact "student" model to mimic a larger "teacher." Efficient architectures such as MobileNetV4 are designed for mobile hardware from the start. Ensembles go the other way, combining several models for extra accuracy when compute isn't a constraint.

Practical Tips

  • Check your labels before you tune your model. Mislabeled training and test images are common, and cleaning them up is often the cheapest accuracy boost you'll find.
  • Keep a held-out test set that reflects real-world conditions: different cameras, lighting, locations and time periods.
  • Watch for class imbalance. If 99% of your images are "normal," a model that always answers "normal" is 99% accurate and completely useless, so track precision and recall for each class.
  • Use data augmentation that matches reality. Horizontal flips are fine for photos of animals but can break text and road signs.
  • Look at the mistakes. A confusion matrix and a gallery of misclassified images will tell you more than any single accuracy number.

Challenges and Limitations

  • Shortcut learning: models can latch onto easy cues that happen to correlate with the label, such as snowy backgrounds behind wolves or a hospital's marker on X-rays, instead of the object itself. Shortcut learning lets a model score well on a benchmark and then fail when conditions change slightly.
  • Distribution shift: accuracy can drop sharply when real-world images differ from the training data because of new cameras, lighting, seasons or patient populations. Robustness benchmarks such as ImageNet-C measure how well models hold up under blur, noise and weather.
  • Adversarial examples: tiny, carefully crafted pixel changes that people can't see can flip a model's prediction. See Offense - Adversarial Threats/Attacks and Defenses Against Adversarial Attacks.
  • Bias and fairness: when some groups, regions or skin tones are underrepresented in the training data, accuracy will be uneven across them. That's a particular concern in healthcare and facial recognition. See Ethics.
  • Label quality and ambiguity: many images legitimately belong to more than one class, and human annotators often disagree. Single-label benchmarks penalize models for answers that are actually reasonable.
  • Explainability: a confident prediction says nothing about why the model made it. Tools such as Grad-CAM produce heatmaps that highlight the image regions that drove a decision, which helps catch shortcuts and builds trust. See Explainable / Interpretable AI.
  • Overconfidence on unknowns: a classifier trained on 10 classes will still pick one of them when it's shown something completely different. Production systems need confidence thresholds or anomaly detection so they can say "none of the above."
  • Privacy: classifiers that recognize people, places or sensitive attributes raise privacy questions, especially when they're applied to images people didn't expect to be analyzed.

Applications

  • Healthcare and Pathology: flagging suspicious skin lesions, signs of diabetic eye disease, tumors in pathology slides and abnormalities on X-rays, usually as a second reader that supports clinicians.
  • Agriculture: identifying crop diseases from leaf photos and sorting produce by type, ripeness and quality (see the fruit classification video below).
  • Environmental Science and conservation: classifying species in camera-trap photos, land cover in satellite imagery and damage after disasters (see Assessing Damage).
  • Astronomy: sorting galaxies by shape and screening telescope images at a scale no human team could manage.
  • Manufacturing and quality control: spotting defective parts on production lines, often with only a handful of defect examples, which pairs naturally with anomaly detection.
  • Retail and Fashion: visual product search, automatic tagging of catalog images and shelf monitoring.
  • Content moderation and photo organization: screening uploads for policy violations and grouping personal photos by people, pets, places and things.
  • Robotics and Drones: helping machines recognize what they're looking at so they can grasp, sort, navigate or inspect.
  • Nature apps and bird identification: naming plants, birds and insects from a smartphone photo.

Recent Developments (2025 to 2026)

  • SigLIP 2 (February 2025): Google's SigLIP 2 image-text encoders improved multilingual understanding, localization and dense features, with variants that handle multiple resolutions and native aspect ratios. They're a popular choice for zero-shot classification and as the vision component of multimodal models.
  • Perception Encoder (April 2025): Meta's Perception Encoder showed that the best visual features often sit in a network's intermediate layers rather than its final output, and it posted strong zero-shot image and video classification results.
  • DINOv3 (August 2025): Meta released DINOv3, a self-supervised vision backbone trained on about 1.7 billion images without labels and scaled to 7 billion parameters. The DINOv3 paper reports that it outperforms specialized state-of-the-art methods in many settings without fine-tuning.
  • New vision encoders (2026): OpenVision 3 (January) offers a single open encoder for both image understanding and image generation. ViT-5 (February) modernizes the plain Vision Transformer with updated normalization, activations, positional encoding and gating, reaching 84.2% top-1 on ImageNet-1k at Base size. Xray-Visual (February) scales a unified image and video model on more than 15 billion image-text pairs and 10 billion video-hashtag pairs from Facebook and Instagram. TIPSv2 (April) improves how well individual image patches line up with text.
  • Fixing ImageNet (2026): the ReImageNet project (NeurIPS 2026) found that about 13% of the original ImageNet-1k validation labels were wrong and 32.7% of the images have more than one valid label, and it released corrected annotations, class definitions, guidelines and analysis code. A companion study, Multimodal Large Language Models as Image Classifiers (CVPR 2026 Findings), showed that much of the reported gap between multimodal LLMs and supervised classifiers came from noisy labels and flawed evaluation protocols.
  • Classification moves inside bigger systems: image classification is increasingly a capability inside larger models rather than a standalone product. The same vision encoders now power multimodal assistants and vision-language-action models for robots and vehicles. XPENG's TuringViT (July 2026), for example, is a vision encoder built for its smart driving, smart cockpit and humanoid robot programs.

Video Tutorials and Lectures

Classify Images Using Python & Machine Learning
Classify Images Using Machine Learning & Convolutional Neural Networks (CNN)

Using Machine Learning to Classify Multispectral Imagery
Watch this informational webinar and learn about how MicaSense and Picterra can help you solve complex image classification problems. MicaSense’s precise and accurate multispectral sensors help capture radiometrically accurate drone-based imagery, while Picterra’s “image analysis made easy” approach offers users a straightforward solution for creating and training machine-learning algorithms; no background in data science or coding required!

Lecture 2: Image Classification
Lecture 2 introduces image classification as a core computer vision problem. We see that the image classification task is made challenging by the semantic gap, but that solutions to this task can be used as a building block in other more complicated computer vision systems. We introduce machine learning as a data-driven approach to solving hard problems like image classification. We discuss several common classification datasets in computer vision. Finally we introduce K-Nearest Neighbors (KNN) as our first machine learning algorithm. This leads to a discussion of hyperparameters and cross-validation strategies that will be crucial for all the machine learning algorithms we will later use. Slides: https://myumi.ch/ovgw7

Image Classification using PyTorch in 2020
A virtual hands-on interactive PyTorch workshop, organized by People In Data together with Facebook DevC Stockholm. You will be guided through the code and implement your own CNN model! The only thing you need to bring is your Google account (as we will be using Google Colab) and your curiosity. This webinar will be led by Pranjal Chaubey who is an AI mentor at Udacity and has done workshops for Developer Circles Hyderabad. He is a keen learner of anything data and always eager to share his knowledge.

Deep Learning for Fruit Classification | CNN | Flask | Project | Code Warriors
Hello Everyone, Code Warriors brings the opportunity to build Deep learning-based Fruit Classification. It's going to be amazing and full of knowledge because mentors are going to teach you it from scratch and the session is completely project-based. The specialty of this event is that while learning to make a model for the classification of fruits, you will also be able to know whether the fruits are fresh or rotten. The ability for a computer to be able to analyze an image and tell you what’s in it (image classification), whether it’s a banana, apple, or orange. Moreover, it will also predict that the fruit is fresh or rotten. This is a hands-on workshop. Certification of Completion will be provided. Pie & AI is a series of deeplearning.ai meetups. This time Code Warriors is going to host this event for you. That you all will learn some new skills. After the event is over, we will provide a survey link by filling in this survey, you are going to get a 50% discount promo code for your first-month membership for any deeplearning.ai course at Coursera.

How to Make an Image Classifier - Intro to Deep Learning #6
Siraj Raval We're going to make our own Image Classifier for cats & dogs in 40 lines of Python! First we'll go over the history of image classification, then we'll dive into the concepts behind convolutional networks and why they are so amazing.

Microsoft Lobe

  • Lobe was built to make it easy for anyone to train machine learning models. It was a free, private desktop application with everything you needed to take a machine learning idea from prototype to production, and it learned to look at images using image classification: categorizing an image into a single label overall. Microsoft had planned to expand it to more types of problems and data, but it has since stopped work on the app. The Lobe GitHub page now says the desktop application "is no longer under development." The video below still shows the basic no-code workflow (collect labeled examples, train, test and export) that today's tools follow, and the Building an Image Classifier Today section above covers current options.

Introducing Lobe | Build your first machine learning model in ten minutes.
Lobe has everything you need to train machine learning in a free, easy to use app. Just show it examples of what you want it to learn, and it automatically trains a custom machine learning model that can be shipped in your app. Start training your machine learning model today with Lobe.