Python image classification libraries

Updated Nov 2026

Python image classification libraries assign one or more labels to an image with a trained neural network. Most start from a model pretrained on a large dataset and fine-tune it on a smaller set of labeled images. These libraries let apps and AI agents sort photos and documents by what they show.

Popularity

Transformers has the most monthly downloads in this comparison, at 120.5M, a count that covers every model task in the library.

LibraryMonthly downloadsStarsLast releaseLicense
Transformers
120.5M
169.2KNov 2026Apache-2.0
TorchVision
18.1M
18.0KOct 2026BSD-3-Clause
Keras
12.1M
64.4KJul 2026Apache-2.0
timm
11.8M
37.3KNov 2026Apache-2.0
Ultralytics
5.1M
63.6KNov 2026AGPL-3.0
OpenCLIP
2.2M
14.3KNov 2026MIT
TF-Keras
2.1M
88Mar 2026Apache-2.0
vit-pytorch
552.8K
25.6KNov 2026MIT
Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

Classifies images with pretrained models and configurable image processors.

Downloads / mo
120.5M
Stars
169.2K
Last release
5.23.0
License
Apache-2.0

Strengths

  • Scores new labels without training. Use zero-shot-image-classification with a compatible image-text checkpoint.
  • Chooses image preprocessing backends. Select torchvision or PIL with the image processor’s backend option.

Limitations

  • ViT can rescale inputs twice. Set do_rescale=False for images already between zero and one.
  • PIL preprocessing is CPU-only. Select the torchvision backend when preprocessing must run on a GPU.

Quickstart

From vit.md
$ pip install "transformers[torch]" pillow
from transformers import pipeline

classifier = pipeline("image-classification", model="google/vit-base-patch16-224")
print(classifier("image.jpg"))

Transformers examples

From open-source projects on GitHub

Provides image-classification models, pretrained weights, and image transforms.

Downloads / mo
18.1M
Stars
18.0K
Last release
0.29.2
License
BSD-3-Clause

Strengths

  • Bundles preprocessing with each weight. Use the weight transforms to match the model’s expected input.
  • Provides label names with weights. Read the predicted class name from the weight metadata.

Limitations

  • Input transforms vary between weights. Match preprocessing to the exact model and weight version.
  • Training and inference modes differ. Call eval before classifying with a pretrained model.

Quickstart

From models.rst
$ pip install torch torchvision pillow
from PIL import Image
from torchvision.models import resnet50, ResNet50_Weights

weights = ResNet50_Weights.DEFAULT
model = resnet50(weights=weights).eval()
image = weights.transforms()(Image.open("image.jpg").convert("RGB")).unsqueeze(0)
print(model(image).argmax(1))

TorchVision examples

From open-source projects on GitHub

Provides Keras with multiple backends.

Downloads / mo
12.1M
Stars
64.4K
Last release
3.15.1
License
Apache-2.0

Quickstart

From index.md
$ pip install keras tensorflow pillow numpy
import keras
import numpy as np
from keras.applications.resnet50 import preprocess_input, decode_predictions

model = keras.applications.ResNet50(weights="imagenet")
image = keras.utils.load_img("image.jpg", target_size=(224, 224))
inputs = preprocess_input(np.expand_dims(keras.utils.img_to_array(image), 0))
print(decode_predictions(model.predict(inputs), top=3)[0])

Keras examples

From open-source projects on GitHub

Loads pretrained PyTorch image classifiers and supplies their data transforms.

Downloads / mo
11.8M
Stars
37.3K
Last release
1.0.31
License
Apache-2.0

Strengths

  • Selects pretrained models by name. Use create_model to load a named classifier with pretrained weights.
  • Replaces the classifier for finetuning. Set num_classes when adapting a pretrained model to new labels.

Limitations

  • New models start in training. Call eval before using the model for inference.
  • Custom datasets need training code. Write a PyTorch training loop or adapt timm’s training script.

Quickstart

From README.md
$ pip install timm pillow
import timm
from PIL import Image
from timm.data import resolve_data_config
from timm.data.transforms_factory import create_transform

model = timm.create_model("mobilenetv3_large_100", pretrained=True).eval()
transform = create_transform(**resolve_data_config(model.pretrained_cfg))
image = transform(Image.open("image.jpg").convert("RGB")).unsqueeze(0)
print(model(image).argmax(1))

timm examples

From open-source projects on GitHub

Runs YOLO models for detection, segmentation, classification, pose estimation, and tracking.

Downloads / mo
5.1M
Stars
63.6K
Last release
8.4.215
License
AGPL-3.0

Quickstart

From classify.md
$ pip install ultralytics
from ultralytics import YOLO

model = YOLO("yolo26n-cls.pt")
print(model("image.jpg")[0].probs.top1)

Ultralytics examples

From open-source projects on GitHub
def predict_regions(self, path) -> List[Dict]:
    results = self.model.predict(path)
    self.debug_plot(results[0].plot())
    return self.create_choices(results, path)

Reproduces contrastive language-image pretraining (CLIP) in the open.

Downloads / mo
2.2M
Stars
14.3K
Last release
4.2.2
License
MIT

Quickstart

From README.md
$ pip install open-clip-torch pillow
import torch
from PIL import Image
import open_clip

model, _, preprocess = open_clip.create_model_and_transforms("ViT-B-32", pretrained="laion2b_s34b_b79k")
model.eval()
text = open_clip.get_tokenizer("ViT-B-32")(["a dog", "a cat"])
image = preprocess(Image.open("image.jpg")).unsqueeze(0)
with torch.no_grad():
    print(model.get_logits(image, text)[0].softmax(-1))

OpenCLIP examples

From open-source projects on GitHub

Provides deep learning for humans.

Downloads / mo
2.1M
Stars
88
Last release
2.21.0
License
Apache-2.0

Quickstart

From resnet.py
$ pip install "tf-keras==2.21.0" pillow
import tf_keras as keras
from tf_keras.applications.resnet50 import preprocess_input, decode_predictions

model = keras.applications.ResNet50(weights="imagenet")
image = keras.utils.load_img("image.jpg", target_size=(224, 224))
inputs = preprocess_input(keras.utils.img_to_array(image)[None, ...])
print(decode_predictions(model.predict(inputs), top=3)[0])

TF-Keras examples

From open-source projects on GitHub

Implements the Vision Transformer (ViT) in PyTorch.

Downloads / mo
552.8K
Stars
25.6K
Last release
1.26.14
License
MIT

Quickstart

From README.md
$ pip install vit-pytorch
import torch
from vit_pytorch import ViT

model = ViT(image_size=256, patch_size=32, num_classes=1000, dim=1024, depth=6, heads=16, mlp_dim=2048)
print(model(torch.randn(1, 3, 256, 256)).shape)

vit-pytorch examples

From open-source projects on GitHub

FAQ

timm and TorchVision suit PyTorch projects that start from pretrained image classifiers. Transformers suits checkpoints from the Hugging Face Hub. Ultralytics suits YOLO training and export with little setup.

timm is a large registry of PyTorch image models and pretrained weights. Each model comes with its own preprocessing and classifier metadata.

TorchVision is the PyTorch library of image models, pretrained weights, and image transforms.

OpenCLIP is an open reproduction of CLIP that embeds images and text in one space. It classifies images zero-shot by comparing them to a list of candidate labels.

For coding agents

Found your image classification library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official