Sitemap
Red Buffer

Turning your AI vision into a success story. Our medium page is a premium selection of articles about developments and practices in artificial intelligence and machine learning, written by our engineers, who love to code and talk tech.

Follow publication

Signature Detection and Localization using YOLOV5 Algorithm

--

In this blog, you will learn how to detect and localize the signatures in scanned documents using the pre-trained model of YOLOV5 Algorithm. The blog is divided into the following parts:

  1. Introduction to Yolo Algorithm
  2. How to use a pre-trained model for signature detection

1. YOLO Algorithm

YOLO stands for “You Only Looks Once”. It is a Deep Learning architecture proposed by Joseph Redmon, Santosh Divvala, Ross Girshick, and Ali Farhadi.

YOLOv5 is a state-of-the-art object-detection algorithm that’s being widely used in academia and industry alike. It is one of the fastest and most accurate object detection algorithms used for the real-time detection of objects. It is the latest version of the versatile and powerful object detection algorithm called YOLO.

Why is Yolo Faster?

The reason why it is faster is that within a single propagation it can classify as well localize the object in a frame or image.

It works in such a way that it divides an image into a grid system, and each grid detects objects within itself. It also predicts the bounding box coordinates of the target class. Non-max suppression helps to decide whether the predicted bounding box is giving us a good outcome (or a bad one). It calculates the intersection over the union of the actual bounding box and the predicted bounding box. By using the Non-max suppression technique, it only retains the high predicted class result and removes other bounding boxes.

You Only Look Once

2. Using a Pre-trained Model for Signature Detection

To get a trained model and test your dataset on the trained model, you have to follow these steps:

  1. Git clone project’s repo
  2. Clone the YOLOv5 model’s repo and install the requirements
  3. Download the pre-trained weights
  4. Test the model
  5. Results

1. Git Clone Project’s repo

First of all, reach this git repo.

source git repo
git clone https://github.com/amaljoseph/Signature-Verification_System_using_YOLOv5-and-CycleGAN.git

a. You will get this folder after cloning the above rep. Open this folder

b. Open up the “Training” folder

c. Open up the “YOLOv5” folder

d. Open up the terminal in this directory

2. Clone the YOLOv5 model’s repo and install the requirements

git clone https://github.com/ultralytics/yolov5cd yolov5pip install -r requirements.txtcd ..
Yolov5 model

3. Download the Pre-trained weights

The weights of the trained model of the signature detection model can be accessed from here. This contains two folders

Dataset and trained model folders

a. Yolo’s weights path

Model_Artifacts →yolo_model →best.pt

Trained Model

best.pt is a trained model. Download and place this file where you opened the terminal

b. Dataset path

Data → yolo_model → Dataset

dataset on google drive

The dataset consists of two zip files.

  1. tobacco_dataset_original: It contains original scanned images of signature and without signature.
  2. tobacco_yolo_format: It contains the labeled dataset in the form of Html files.

4. Test the model.

a. For a single image:

Use the following command to test single image

python3 “path_of_detect.py” — source “path_of_image” — weights “path_of_best.pt” — hide-labels — hide-conf — classes 1 — line-thickness 2

path_of_detect.py: when you clone yolov5 git rep. yolov5 folder contains the detect.py.

` — hide-labels` is used to hide the labels in the detected images.

` — hide-conf` is used to hide the confidence scores in the detected images.

` — classes 0, 1`, etc used to detect only the classes mentioned here. For our use case we need only a signature class, so use ` — classes 1`.

` — line-thickness` integer is used to set the thickness of the bounding box.

b. For image folder:

Use the following command to test the image folder

python3 “path_of_detect.py” — source “path_of_image_folder”/ — weights “path_of_best.pt” — hide-labels — hide-conf — classes 1 — line-thickness 2

5. Results

The result can be visualized by following this path

yolov5 → runs → detect →exp

input to Trained model
output of model
Output on terminal

References

  1. https://github.com/amaljoseph/Signature-Verification_System_using_YOLOv5-and-CycleGAN
  2. https://docs.ultralytics.com/quick-start/
  3. https://www.analyticsvidhya.com/blog/2021/06/implementation-of-yolov3-simplified/

--

--

Red Buffer
Red Buffer

Published in Red Buffer

Turning your AI vision into a success story. Our medium page is a premium selection of articles about developments and practices in artificial intelligence and machine learning, written by our engineers, who love to code and talk tech.

No responses yet