Simple YOLOv5 Part 1 : Deploy YOLOv5 on Windows

Chanon Krittapholchai
5 min readDec 25, 2021

--

This Article is about how to deploy object detection with YOLOv5 on Windows, without any installation.

Ultralytics’s YOLOv5 Logo from their Github repository.

This Article is the 1st part of 2 parts about “Simple YOLOv5” ;

  1. Deploy YOLOv5 on Windows
  2. Train Custom YOLOv5 Model

This “Simple YOLOv5” is refer to the case that I deployed a trial object detection for my friend who want to improve a process of his family’s business without much investment and coding.

And I’m going to use Mr.Pompompurin as a target for this article instead of the real target in my case.

Actually, he is not a bear….

Because this case should avoid any installation, I’ll use WinPython to deploy.

If you want to know more about my use cases with WinPython, you can read more in my article about how to use WinPython to deploy ETL job in this link below ;

I’ll put links to every source at the end of this article.

This article will be divided into 3 part ;

  1. Prepare WinPython for YOLOv5
  2. Coding the YOLOv5’s object detection script
  3. Make it easy for operation

1. Prepare WinPython for YOLOv5

a) Download WinPython’s specific version from this link >> HERE
*Use 64 bit is a lot easier

I used WinPython 64bit version 3.9.8 — dot

b) Extract the WinPython file to your project folder and your folder should look like this ;

My project’s folder

c) Inside folder WPyXX-XXXX, open the WinPython Command Prompt ;

Open WinPython Command Prompt for WinPython’s CMD

d) From that CMD, change directory to you project folder and git clone YOLOv5 from Ultralytics’ Github repository ;

cd ..
cd ..
git clone https://github.com/ultralytics/yolov5.git
Git clone from Ultralytics’ repository

e) Change directory to yolov5 and install YOLOv5’s dependencies
*These dependencies will install in the WinPython’s folder

cd yolov5
pip install -r requirements.txt
Install YOLOv5’s dependencies to WinPython’s folder
Finish install

f) Test our WinPython by create a new python script file like this ;
*You can read more about this code in the link at the end of this article

import torch# Model
model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
# Images
img = 'https://ultralytics.com/images/zidane.jpg'
# Inference
results = model(img)
# Results
results.print()
Create a test python script

g) Run that script from WinPython’s CMD ;
*this process will also download a model from Ultralytics

python test.py
Run the test script
It will also download a model

2. Coding the YOLOv5’s object detection script

This section is quite simple, just create a new python script like this ;
*I think I explained a lot in this code’s comments

And this process will show your object detection like this picture ;

Actually, he is a dog,….

3. Make it easy for operation

Now, one final touch to make it easy for operation.

a) Currently, your folder should look like this ;

Your folder

b) We will create a text file with content inside like this ;

WPyXX-XXXX\python-XXXXXXXXXX\python.exe main.py
The new text file’s content

c) Then rename it as RUN.cmd to make it executable ;

d) You can test by open RUN.cmd to execute your script ;

Actually, they are dogs….

And Done!! Now, you can just copy this folder to run in any Windows PC.

This is the end of this article, hopefully this article will be useful for you.

The next part will be about how to train your custom model for YOLOv5 in the simple way that I teach non-coders to train their model by themselves and how to combine that custom model with this 1st part > HERE .

--

--