Skip to main content

Packaged version of the Yolov5 object detector

Project description

Packaged YOLOv5 Object Detector

Downloads CI CPU testing Package CPU testing

You can finally install YOLOv5 object detector using pip and integrate into your project easily.

Overview

This package is up-to-date with the latest release of ultralytics/yolov5.

Installation

  • Install yolov5 using pip (for Python >=3.7):
pip install yolov5
  • Install yolov5 using pip (for Python 3.6):
pip install "numpy>=1.18.5,<1.20" "matplotlib>=3.2.2,<4"
pip install yolov5

Basic Usage

from PIL import Image
from yolov5 import YOLOv5

# set model params
model_path = "yolov5/weights/yolov5s.pt" # it automatically downloads yolov5s model to given path
device = "cuda" # or "cpu"

# init yolov5 model
yolov5 = YOLOv5(model_path, device)

# load images
image1 = Image.open("yolov5/data/images/bus.jpg")
image2 = Image.open("yolov5/data/images/zidane.jpg")

# perform inference
results = yolov5.predict(image1)

# perform inference with higher input size
results = yolov5.predict(image1, size=1280)

# perform inference with test time augmentation
results = yolov5.predict(image1, augment=True)

# perform inference on multiple images
results = yolov5.predict([image1, image2], size=1280, augment=True)

Tutorials

Scripts

You can download and use train.py, detect.py and test.py scripts after installing the package via pip:

Training

Run commands below to reproduce results on COCO dataset (dataset auto-downloads on first use). Training times for YOLOv5s/m/l/x are 2/4/6/8 days on a single V100 (multi-GPU times faster). Use the largest --batch-size your GPU allows (batch sizes shown for 16 GB devices).

$ python train.py --data coco.yaml --cfg yolov5s.yaml --weights '' --batch-size 64
                                         yolov5m                                40
                                         yolov5l                                24
                                         yolov5x                                16

Inference

detect.py runs inference on a variety of sources, downloading models automatically from the latest YOLOv5 release and saving results to runs/detect.

$ python detect.py --source 0  # webcam
                            file.jpg  # image 
                            file.mp4  # video
                            path/  # directory
                            path/*.jpg  # glob
                            rtsp://170.93.143.139/rtplive/470011e600ef003a004ee33696235daa  # rtsp stream
                            rtmp://192.168.1.105/live/test  # rtmp stream
                            http://112.50.243.8/PLTV/88888888/224/3221225900/1.m3u8  # http stream

To run inference on example images in data/images:

$ python detect.py --source data/images --weights yolov5s.pt --conf 0.25

Status

Builds for the latest commit for Windows/Linux/MacOS with Python3.6/3.7/3.8: CI CPU testing

Status for the train/detect/test scripts: Package CPU testing

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yolov5-4.0.4.tar.gz (742.4 kB view details)

Uploaded Source

Built Distribution

yolov5-4.0.4-py36.py37.py38-none-any.whl (750.2 kB view details)

Uploaded Python 3.6Python 3.7Python 3.8

File details

Details for the file yolov5-4.0.4.tar.gz.

File metadata

  • Download URL: yolov5-4.0.4.tar.gz
  • Upload date:
  • Size: 742.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.1

File hashes

Hashes for yolov5-4.0.4.tar.gz
Algorithm Hash digest
SHA256 5ebc2b9a55e1a62766d8e72870d012ad4a80a9ea613afc86034a300ecc647caf
MD5 2ca0466f0fde1923c00d1ddb51dd70a1
BLAKE2b-256 aa96f320dfe8939fec3e7cfaa1c82ab48485e53f65f05b519af9e7c43df0a1b2

See more details on using hashes here.

File details

Details for the file yolov5-4.0.4-py36.py37.py38-none-any.whl.

File metadata

  • Download URL: yolov5-4.0.4-py36.py37.py38-none-any.whl
  • Upload date:
  • Size: 750.2 kB
  • Tags: Python 3.6, Python 3.7, Python 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.1

File hashes

Hashes for yolov5-4.0.4-py36.py37.py38-none-any.whl
Algorithm Hash digest
SHA256 6122115b2ff590c59e737e6924692dfc9df16990eb1f631f055b0f50add87a3a
MD5 703e578f188cd21e9d38c974ab592a13
BLAKE2b-256 13ed482f377c5679574bfd8cb34a8d096c140243b9c0e7b9b36e0757735490eb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page