Package: ultralytics-yolov5
YOLOv5 🚀 is a family of object detection architectures and models pretrained on the COCO dataset, and representsUltralyticsopen-source research into future vision AI methods, incorporating lessons learned and best practices evolved over thousands of hours of research and development.DocumentationSee theYOLOv5 Docsfor full documentation on training, testing and deployment.Quick Start ExamplesInstallClone repo and installrequirements.txtin aPython>=3.7.0environment, includingPyTorch>=1.7.gitclonehttps://github.com/ultralytics/yolov5# clonecdyolov5
pipinstall-rrequirements.txt# installInferenceYOLOv5PyTorch Hubinference.Modelsdownload automatically from the latest
YOLOv5release.importtorch# Modelmodel=torch.hub.load('ultralytics/yolov5','yolov5s')# or yolov5n - yolov5x6, custom# Imagesimg='https://ultralytics.com/images/zidane.jpg'# or file, Path, PIL, OpenCV, numpy, list# Inferenceresults=model(img)# Resultsresults.print()# or .show(), .save(), .crop(), .pandas(), etc.Inference with detect.pydetect.pyruns inference on a variety of sources, downloadingmodelsautomatically from
the latest YOLOv5releaseand saving results toruns/detect.pythondetect.py--source0# webcamimg.jpg# imagevid.mp4# videopath/# directorypath/*.jpg# glob'https://youtu.be/Zgi9g1ksQHc'# YouTube'rtsp://example.com/media.mp4'# RTSP, RTMP, HTTP streamTrainingThe commands below reproduce YOLOv5COCOresults.Modelsanddatasetsdownload automatically from the latest
YOLOv5release. Training times for YOLOv5n/s/m/l/x are
1/2/4/6/8 days on a V100 GPU (Multi-GPUtimes faster). Use the
largest--batch-sizepossible, or pass--batch-size -1for
YOLOv5AutoBatch. Batch sizes shown for V100-16GB.pythontrain.py--datacoco.yaml--cfgyolov5n.yaml--weights''--batch-size128yolov5s64yolov5m40yolov5l24yolov5x16TutorialsTrain Custom Data🚀 RECOMMENDEDTips for Best Training Results☘️
RECOMMENDEDWeights & Biases Logging🌟 NEWRoboflow for Datasets, Labeling, and Active Learning🌟 NEWMulti-GPU TrainingPyTorch Hub⭐ NEWTFLite, ONNX, CoreML, TensorRT Export🚀Test-Time Augmentation (TTA)Model EnsemblingModel Pruning/SparsityHyperparameter EvolutionTransfer Learning with Frozen Layers⭐ NEWArchitecture Summary⭐ NEWEnvironmentsGet started in seconds with our verified environments. Click each icon below for details.IntegrationsWeights and BiasesRoboflow ⭐ NEWAutomatically track and visualize all your YOLOv5 training runs in the cloud withWeights & BiasesLabel and export your custom datasets directly to YOLOv5 for training withRoboflowWhy YOLOv5YOLOv5-P5 640 Figure (click to expand)Figure Notes (click to expand)COCO AP valdenotes mAP@0.5:0.95 metric measured on the 5000-imageCOCO val2017dataset over various inference sizes from 256 to 1536.GPU Speedmeasures average inference time per image onCOCO val2017dataset using aAWS p3.2xlargeV100 instance at batch-size 32.EfficientDetdata fromgoogle/automlat batch size 8.Reproducebypython val.py --task study --data coco.yaml --iou 0.7 --weights yolov5n6.pt yolov5s6.pt yolov5m6.pt yolov5l6.pt yolov5x6.ptPretrained CheckpointsModelsize(pixels)mAPval0.5:0.95mAPval0.5SpeedCPU b1(ms)SpeedV100 b1(ms)SpeedV100 b32(ms)params(M)FLOPs@640 (B)YOLOv5n64028.045.7456.30.61.94.5YOLOv5s64037.456.8986.40.97.216.5YOLOv5m64045.464.12248.21.721.249.0YOLOv5l64049.067.343010.12.746.5109.1YOLOv5x64050.768.976612.14.886.7205.7YOLOv5n6128036.054.41538.12.13.24.6YOLOv5s6128044.863.73858.23.612.616.8YOLOv5m6128051.369.388711.16.835.750.0YOLOv5l6128053.771.3178415.810.576.8111.4YOLOv5x6+TTA1280153655.055.872.772.73136-26.2-19.4-140.7-209.8-Table Notes (click to expand)All checkpoints are trained to 300 epochs with default settings. Nano and Small models usehyp.scratch-low.yamlhyps, all others usehyp.scratch-high.yaml.mAPvalvalues are for single-model single-scale onCOCO val2017dataset.Reproduce bypython val.py --data coco.yaml --img 640 --conf 0.001 --iou 0.65Speedaveraged over COCO val images using aAWS p3.2xlargeinstance. NMS times (~1 ms/img) not included.Reproduce bypython val.py --data coco.yaml --img 640 --task speed --batch 1TTATest Time Augmentationincludes reflection and scale augmentations.Reproduce bypython val.py --data coco.yaml --img 1536 --iou 0.7 --augmentContributeWe love your input! We want to make contributing to YOLOv5 as easy and transparent as possible. Please see ourContributing Guideto get started, and fill out theYOLOv5 Surveyto send us feedback on your experiences. Thank you to all our contributors!ContactFor YOLOv5 bugs and feature requests please visitGitHub Issues. For business inquiries or
professional support requests please visithttps://ultralytics.com/contact.