packaged ultralytics/yolov5
pip install yolo5
Overview
You can finally install YOLOv5 object detector using pip and integrate into your project easily.
Installation
- Install yolov5 using pip
(for Python >=3.7)
:
pip install yolo5
- 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
import yolov5
model = yolov5.load('yolov5s')
img = 'https://github.com/ultralytics/yolov5/raw/master/data/images/zidane.jpg'
results = model(img)
results = model(img, size=1280)
results = model(img, augment=True)
results.show()
results.save(save_dir='results/')
Alternative Usage
from yolov5 import YOLOv5
model_path = "yolov5/weights/yolov5s.pt"
device = "cuda"
yolov5 = YOLOv5(model_path, device)
image1 = 'https://github.com/ultralytics/yolov5/raw/master/data/images/zidane.jpg'
image2 = 'https://github.com/ultralytics/yolov5/blob/master/data/images/bus.jpg'
results = yolov5.predict(image1)
results = yolov5.predict(image1, size=1280)
results = yolov5.predict(image1, augment=True)
results = yolov5.predict([image1, image2], size=1280, augment=True)
results.show()
results.save(save_dir='results/')
Scripts
You can call yolo_train, yolo_detect and yolo_test commands 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).
$ yolo_train --data coco.yaml --cfg yolov5s.yaml --weights '' --batch-size 64
yolov5m 40
yolov5l 24
yolov5x 16
Inference
yolo_detect command runs inference on a variety of sources, downloading models automatically from the latest YOLOv5 release and saving results to runs/detect
.
$ yolo_detect --source 0
file.jpg
file.mp4
path/
path/*.jpg
rtsp://170.93.143.139/rtplive/470011e600ef003a004ee33696235daa
rtmp://192.168.1.105/live/test
http://112.50.243.8/PLTV/88888888/224/3221225900/1.m3u8
To run inference on example images in yolov5/data/images
:
$ yolo_detect --source yolov5/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
:
Status for the train/detect/test scripts: