Signature Verification System Using Siamese Neural Network

Mahesh Chatpatil
7 min readMay 14, 2021

--

Hello ! I am writing this blog so that this blog would be greatly useful for all the AI enthusiasts . I made it more informative and concise so that most concepts will be cleared in very less reading time . I kept the language simple and easy explanations. Happy reading !

Photo by Possessed Photography on Unsplash

Table of Contents:-

1. Motivation

2.Introduction

3.Problem statement

4.Architecture

5.Code explanation

6.Results

7.Conclusion

1. Motivation:-

In this article , I have explained how we can solve computer vision problems or we can also say Convolutional Neural Network problems using Siamese Neural Network.So, in this article we are going to see how signature verification system works using the siamese neural network. I have explained the problem statement below.

Deep Convolutional Neural Networks have become the state of the art methods for image classification tasks. However, one of the biggest limitations is they require a lots of labelled data. In many applications, collecting this much data is sometimes not feasible. One Shot Learning aims to solve this problem and One Shot Learning is implemented using Siamese neural network.

2. Introduction :-

Signatures continue to play an important role in financial, commercial and legal transaction for account openings, withdrawals and transaction payments. In contractual matters, signatures also play a vital role.On the other hand, the threats and monetary losses continue to rise dramatically

We will see what is signature verification and how it can be implemented step by step. We will go briefly over the theory of signature verification and then jump on to the coding section. At the end of this article, we will build signature verification and the results .

3. Problem statement :-

A student at Emily Carr University of Art and Design lost $600 from his bank account through fraudulent cheques. In this case, the most surprising factor was that the money got deducted through half a dozen cheques worth $100 each, and none of them had matching signatures. Of course, we should blame the bank staff for authorizing payments without validating the signatures accurately. But if you are a bank employee who has to deal with hundreds of cheque clearances per day, it could be a tedious task to perform due diligence with greater precision.

Solution :-

Deep learning can be used to make a signature verification system using CNN(convolutional neural network) . But the problem with the CNN it requires lots of data for training . In our case we require lots of signature sample of each account holder which is practically hard to achieve.

For this we have one shot learning which can be implemented using siamese neural network. It requires only one image of signature .This signature will be stored in the database. Sample image will be compared with all the images in the database . if none of the image is matching then manualchecking can be done. in case of matching , account holder is identified .

4. Architecture of Siamese Neural Network :-

1.Siamese network takes two different inputs passed through two similar subnetworks with the same architecture, parameters, and weights.

2.The two subnetworks are a mirror image of each other, just like the Siamese twins. Hence, any change to any subnetworks architecture, parameter, or weights is also applied to the other subnetwork.

3.The two subnetwork outputs an encoding to calculate the difference between the two inputs.

4.The Siamese network’s objective is to classify if the two inputs are the same or different using the Similarity score. The Similarity score can be calculated using Binary cross-entropy, Contrastive function, or Triplet loss, which are techniques for the general distance metric learning approach.

5.Siamese network is a one-shot classifier that uses discriminative features to generalize the unfamiliar categories from an unknown distribution.

5. Code explanation:-

The complete code for signature verification model using a siamese network can be found at this link:-

Datset :-

Dataset has two folders :- one folder contains the forged signatures while another folder contains the real signatures .

In real signature folder , there are 5 signatures from the same person.while forge signature folder contains 5 signatures from different persons.

The dataset is mainly used for the testing purpose as we are using pre trained model .

Working :-

Training the Siamese Neural Network:-

  1. Load the dataset containing the different classes
  2. Create positive and negative data pairs. Positive data pair is when both the inputs are the same, and a negative pair is when the two inputs are dissimilar.
  3. Build the Convolutional neural network, which outputs the feature encoding using a fully connected layer. This is the sister CNN’s through which we will pass the two inputs. The sister CNN’s should have the same architecture, hyperparameters, and weights.
  4. Build the differencing layer to calculate the Euclidian distance between the two sister CNN networks encoding output.
  5. The final layer is a fully-connected layer with a single node using the sigmoid activation function to output the Similarity score.

Testing the Siamese Neural Network:-

1.Send two inputs to the trained model to output the Similarity score.

2. As the last layer uses the sigmoid activation function, it outputs a value in the range 0 to 1. A Similarity score close to 1 implies that the two inputs are similar. A Similarity score close to 0 implies that the two inputs are dissimilar. A good rule of thumb is to use a similarity cutoff threshold value of 0.5.

Tkinter Library :-

1.Tkinter is the standard GUI library for Python.

2.Python when combined with Tkinter provides a fast and easy way to create GUI applications.

3. Tkinter package is the standard Python interface to the Tk GUI toolkit .

Files present in the project :-

  1. Main folder :- it contains the main.py file and the the actual simese network code .
  2. Pre-trained_model :- It contains two 4 files
    a) model.meta :- It contains meta graph(computational graph) which stores the all the computations of the graph.
    b)model .index and model.data :- also called as checkpoint files. these files contain the values of the parameters after training the model.
    c)checkpoint :- it simply keeps a record of latest checkpoint files saved.
  3. Dataset:- contains signature images for testing .

6.Results:-

Some results i got i am attaching here.as i have checked already , Model is showing very good results. Model is able to recognise the signatures from the same person or we can say genuine signatures and forged signatures . I have used Tkinter library for GUI application as it is fast and easy to use. For more detailed working and results please visit my github profile and run on it on your local machine.

7. Conclusion :-

I hope this helped you in understanding the complete article .Mainly, my goal is to solve computer vision problems also called as CNN problems using siamese network.

In this article, we discussed how Siamese networks are different from normal deep learning networks and implemented a Signature verification system using Siamese networks .The results are very good and some of them i have attached above .

For the network to perform well with real-world signatures, the SigComp dataset can be augmented by adding noise and random blur to force the network to generalize well since the dataset was collected using a digital tablet with little to no artifacts.

Source Code: You can find the complete code on my GitHub Repository here.

Let me know if you are facing any issues to understand . Also, please let me know if it was helpful for you on your projects or if I should change the way of explaining things.

Photo by Kelly Sikkema on Unsplash

--

--

Mahesh Chatpatil
Mahesh Chatpatil

Responses (1)