Python object detection libraries

Updated Nov 2026

Python object detection libraries find objects in images and video and return each one with a label, a confidence score, and a bounding box. A detector runs a trained neural network on each image and filters overlapping boxes before returning results. These libraries let cameras, robots, and AI agents locate what appears in a scene.

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
opencv-python-headless
64.1M
5.5KNov 2026Apache-2.0
TorchVision
18.1M
18.0KOct 2026BSD-3-Clause
Ultralytics
5.1M
63.6KNov 2026AGPL-3.0
ModelScope
4.3M
9.2KNov 2026Apache-2.0
MediaPipe
3.0M
37.7KNov 2026Apache-2.0
PaddleX
1.1M
6.3KJun 2026Apache-2.0
KerasHub
471.7K
999Nov 2026Apache-2.0
Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

Loads detection models and processors for box prediction and task-specific fine-tuning.

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

Strengths

  • Detects objects from text prompts. Use a zero-shot detector to search for named visual concepts.
  • Rescales boxes to image dimensions. Pass target_sizes when postprocessing model predictions.

Limitations

  • Custom labels need head replacement. Provide label mappings and replace the pretrained classification head during fine-tuning.
  • Evaluation needs separate box batches. Set eval_do_concat_batches=False when target-box counts differ across images.

Quickstart

From object_detection.md
$ pip install "transformers[torch,vision]==5.23.0" pillow
from PIL import Image
from transformers import pipeline
detector = pipeline("object-detection", model="facebook/detr-resnet-50", device=-1)
print(detector(Image.new("RGB", (640, 480))))

Transformers examples

From open-source projects on GitHub

opencv-python-headless

Wraps the OpenCV Python bindings.

Downloads / mo
64.1M
Stars
5.5K
Last release
5.1.0.95
License
Apache-2.0

Quickstart

From dnn.hpp
$ pip install opencv-python-headless==5.1.0.95
import json, sys, cv2
detector = cv2.dnn.DetectionModel(sys.argv[1])
detector.setInputParams(**json.loads(sys.argv[2]))
print(detector.detect(cv2.imread(sys.argv[3]), confThreshold=0.5, nmsThreshold=0.4))

opencv-python-headless examples

From open-source projects on GitHub

Provides models for object detection and instance segmentation.

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

Strengths

  • Pairs weights with preprocessing. Use the chosen weights’ transforms before running the detector.
  • Returns detection training losses. Inspect the classification and regression losses returned during training.

Limitations

  • Detection APIs can change. The detection module is beta and does not guarantee backward compatibility.
  • Requires scaled tensor inputs. Pass image tensors with values scaled between zero and one.

Quickstart

From models.html
$ pip install torchvision==0.29.2 "torch>=2.14.0" pillow
from PIL import Image
from torchvision.models.detection import fasterrcnn_resnet50_fpn, FasterRCNN_ResNet50_FPN_Weights
weights = FasterRCNN_ResNet50_FPN_Weights.DEFAULT
model = fasterrcnn_resnet50_fpn(weights=weights).eval()
print(model([weights.transforms()(Image.new("RGB", (640, 480)))]))

TorchVision examples

From open-source projects on GitHub

Runs YOLO detection and exposes structured results for images, batches, and streams.

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

Strengths

  • Streams results as they arrive. Use stream=True to process results without retaining the complete list.
  • Accepts custom text labels. Set the class vocabulary with a supported YOLO-World model.

Limitations

  • Default results retain every frame. Use stream=True for long videos instead of keeping every result in memory.
  • Threads need separate model instances. Instantiate a model inside each prediction thread.

Quickstart

From predict.md
$ pip install ultralytics==8.4.215 numpy
import numpy as np
from ultralytics import YOLO
model = YOLO("yolo26n.pt")
print(model.predict(np.zeros((640, 640, 3), dtype=np.uint8), device="cpu"))

Ultralytics examples

From open-source projects on GitHub

ModelScope

Provides models as a service.

Downloads / mo
4.3M
Stars
9.2K
Last release
1.40.3
License
Apache-2.0
$ pip install "modelscope[cv]==1.40.3" torch numpy
import sys, numpy as np
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
detector = pipeline(Tasks.image_object_detection, model=sys.argv[1], device="cpu")
print(detector(np.zeros((640, 640, 3), dtype=np.uint8)))

Builds machine learning solutions for mobile, edge, cloud, and web.

Downloads / mo
3.0M
Stars
37.7K
Last release
1.2.3
License
Apache-2.0

Quickstart

From README.md
$ pip install mediapipe==1.2.3
import sys, mediapipe as mp
options = mp.tasks.vision.ObjectDetectorOptions(base_options=mp.tasks.BaseOptions(model_asset_path=sys.argv[1]))
with mp.tasks.vision.ObjectDetector.create_from_options(options) as detector:
    print(detector.detect(mp.Image.create_from_file(sys.argv[2])))

MediaPipe examples

From open-source projects on GitHub

Develops models with low code on PaddlePaddle.

Downloads / mo
1.1M
Stars
6.3K
Last release
3.7.2
License
Apache-2.0

Quickstart

From object_detection.md
$ pip install "paddlex[base]==3.7.2" paddlepaddle numpy
import numpy as np
from paddlex import create_pipeline
pipeline = create_pipeline(pipeline="object_detection", device="cpu")
for result in pipeline.predict(np.zeros((640, 640, 3), dtype=np.uint8), threshold=0.5):
    result.print()

Provides pretrained models for Keras.

Downloads / mo
471.7K
Stars
999
Last release
0.33.0
License
Apache-2.0
$ pip install keras-hub==0.33.0 numpy torch
import os
os.environ["KERAS_BACKEND"] = "torch"
import numpy as np, keras_hub
detector = keras_hub.models.RetinaNetObjectDetector.from_preset("retinanet_resnet50_fpn_coco")
print(detector.predict(np.zeros((1, 800, 800, 3), dtype=np.uint8)))

FAQ

Ultralytics suits YOLO models with prediction, training, and export in one interface. Transformers suits pretrained transformer detectors and prompted detection models. TorchVision suits projects already built on PyTorch tensors and training code.

Ultralytics is a Python package for YOLO models that covers detection, segmentation, classification, and pose estimation. It loads published checkpoints automatically and runs on CPU or GPU.

ModelScope is a model hub with task pipelines that load a model by ID and return structured results. Its object detection pipeline runs registered detection models on PyTorch.

opencv-python-headless runs exported detection models through its DNN module, with preprocessing and non-maximum suppression. The application supplies the model files.

MediaPipe provides an on-device object detector for still images, video, and live streams, with score and category filters.

For coding agents

Found your object detection 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