A PyTorch implementation of YOLOv5

A PyTorch implementation of YOLOv5

A PyTorch implementation of YOLOv5.

A PyTorch implementation of YOLOv5.

This repository has two features:

  • It is pure python code and can be run immediately using PyTorch 1.4 without build
  • Simplified construction and easy to understand how the model works

The model is based on ultralytics' repo,

and the code is using the structure of TorchVision.


  • Windows or Linux, with Python ≥ 3.6
  • PyTorch** ≥ 1.4.0**
  • matplotlib - visualizing images and results
  • pycocotools - for COCO dataset and evaluation; Windows version is here

There is a problem with pycocotools for Windows. See Issue #356.

Besides, it's better to remove the prints in pycocotools.


  • nvidia dali (Linux) - a faster data loader


This repository supports VOC and COCO datasets.

If you want to train your own dataset, you may:

  • write the correponding dataset code
  • convert your dataset to COCO-style

PASCAL VOC 2012 (download): http://host.robots.ox.ac.uk/pascal/VOC/voc2012/

MS COCO 2017http://cocodataset.org/

Nvidia DALI is strongly recommended. It's much faster than the original data loader.

Currently this repository supports COCO-style dataset with DALI.


Train on COCO dataset, using 1 GPU (if you wanna use 2 GPUs, set --nproc_per_node=2):

python -m torch.distributed.launch --nproc_per_node=1 --use_env train.py --use-cuda --dali --mosaic \
--epochs 190 --data-dir "./data/coco2017" --ckpt-path "yolov5s_coco.pth"

A more concrete modification is in run.sh.

To run it:

bash ./run.sh

If you are using PyTorch ≥ 1.6.0 and RTX series GPUs, the code will enable automatic mixed training (AMP).

Demo and Evaluation

  • Run demo.ipynb.
  • Modify the parameters in eval.ipynb to test the model.


Test on COCO 2017 val set, on a single RTX 2080Ti GPU:

The weights is from ultralytics' repo.

modelbbox APFPSparamsYOLOv5s36.14107.5M


machine learning pytorch yolov5 python

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

PyTorch for Deep Learning | Data Science | Machine Learning | Python

PyTorch for Deep Learning | Data Science | Machine Learning | Python. PyTorch is a library in Python which provides tools to build deep learning models. What python does for programming PyTorch does for deep learning. Python is a very flexible language for programming and just like python, the PyTorch library provides flexible tools for deep learning.

Hire Machine Learning Developers in India

We supply you with world class machine learning experts / ML Developers with years of domain experience who can add more value to your business.

How To Plot A Decision Boundary For Machine Learning Algorithms in Python

How To Plot A Decision Boundary For Machine Learning Algorithms in Python, you will discover how to plot a decision surface for a classification machine learning algorithm.

How To Get Started With Machine Learning With The Right Mindset

You got intrigued by the machine learning world and wanted to get started as soon as possible, read all the articles, watched all the videos, but still isn’t sure about where to start, welcome to the club.

What is Supervised Machine Learning

What is neuron analysis of a machine? Learn machine learning by designing Robotics algorithm. Click here for best machine learning course models with AI