In deep learning, a convolution neural network (CNN/ConvNet) is a class of deep neural networks, most commonly applied to analyze visual imagery. Now when we think of a neural network we think about matrix multiplications but that is not the case with ConvNet. It uses a special technique called Convolution. Now in mathematics convolution is a mathematical operation on two functions that produces a third function that expresses how the shape of one is modified by the other.

Tiny Object Detection Using Yolo-V5

Reading Time: 3 minutes

What is Object Detection ?

Object detection involves detecting instances of objects from a particular class in an image. Background. Object detection has been widely used for face detection, vehicle detection, pedestrian counting, web images, security systems and driverless cars.


Object detection is a computer vision technique that allows us to identify and locate objects in an image or video.

Here in our case we have detected broken wheat and damaged wheat in the given image.

These objects have been detected by Yolo – V5 Model

Binary class Detection of Object

Images clearly shows the Broken Wheat grains by using Yolo-V5

Object Localization

The difference between object localization and object detection is subtle.

An image classification or image recognition model simply detect the probability of an object in an image. An object localization algorithm will output the coordinates of the location of an object with respect to the image. In computer vision, the most popular way to localize an object in an image is to represent its location with the help of bounding boxes.

Bounding box can be intilized with this steps

  • bx, by : coordinates of the center of the bounding box
  • bw : width of the bounding box w.r.t the image width
  • bh : height of the bounding box w.r.t the image height

How to do Object Detection Using Yolo V5 and what are the steps included in it?

To train a Yolo V5 model, a few things need to be download from the internet.

  • Collecting Our Training Images
  • Environment Setup
  • Set up the data and the directories
  • Set up the configuration YAML files
  • Use your custom Yolo V5 model to detect objects on the test data
  • Annotating Our Training Images
  • Define YOLO v5 Model Configuration and Architecture
  • Train the model to learn how to detect objects
  • Evaluate YOLO v5 performance
  • Run YOLO v5 Inference on test images
  • Export Saved YOLO v5 Weights for Future Inference

Object Detection is a task in Artificial Intelligence that focuses on detecting objects in images. Yolo V5 is one of the best available models for Object Detection at the moment. The great thing about this Deep Neural Network is that it is very easy to retrain the network on your own custom dataset.

Environment Setup to train Yolo V5 object Detection Model

1- Clone the yolo V5 repository from GitHub

!git clone

This will create a folder called ‘yolov5’ on your machine.


The repository has some requirements to make the codes run properly. First, I will insist that you manually install the latest PyTorch framework version.


%cd yolov5 %
pip install -r requirements.txt # install dependencies



These values needs to configured

With our data.yaml and custom_yolov5s.yaml files ready to go we are ready to train!

To initiate the training phase we need to write these steps

  • img: define input image size
  • batch: determine batch size
  • epochs: define the number of training epochs. (Note: often, 3000+ are common here!)
  • data: set the path to our yaml file
  • cfg: specify our model configuration
  • weights: specify a custom path to weights. (Note: you can download weights from the Ultralytics Google Drive folder)
  • name: result names
  • nosave: only save the final checkpoint
  • cache: cache images for faster training
  1. Go to yolov5/data/
  2. Open coco128.yaml
  1.   Training and Test file path
  2.   Number of classes and Class names.


!python –img 416 –batch 20 –epochs 70 –data coco128.yaml –weights –cache


%load_ext tensorboard
%tensorboard –logdir runs/train


!python –weights /content/yolov5/runs/train/exp/weights/ –data coco128.yaml –img 416

Run YOLO v5 Inference on test images

!python –weights /content/yolov5/runs/train/exp/weights/ –data coco128.yaml –img 416


!python –source /content –weights /content/yolov5/runs/train/exp/weights/ –img 416 –save-txt –save-conf


Official Github Link for Download of Yolo V5

My GitHub Profile


I hope you were able to follow along and was able to train successfully.

I have uploaded the notebook, config files, and weight to my Github repository.

If you have any questions, recommendations, or critiques, I can be reached via my mail .Feel free to reach out to me.

Leave a Reply