项目作者: koushik-elite

项目描述 :
Signature Verification App for doodleblue
高级语言: Jupyter Notebook
项目地址: git://github.com/koushik-elite/Signature-Verification.git
创建时间: 2019-10-21T06:42:52Z
项目社区:https://github.com/koushik-elite/Signature-Verification

开源协议:MIT License

下载


Signature Verification

Signature Verification App for doodleblue

Task:

A person’s signature is representative of his identity. For us at the Bank, a signed document by a customer is an instruction from him for carrying out an approved transaction for him.

On on-boarding a customer we capture an image of his signature in our systems, and on receiving a signed document (Cheques, DDs, and others) from him we match the signature on the document with the one recorded in the database before proceeding with the instruction.

In the case of skilled forgeries, it becomes very difficult to verify the identity of the customer.

We want you to build a system that can help us distinguish forgeries from actual signatures. This system should be able to study signature parameters as strokes, curves, dots, dashes, writing fluidity & style, in a Writer-Independent manner and create features for identification of the signature.

The system should not use any existing APIs and should be completely self-developed.

How should it work?

The system shall work in 2 steps:

Step 1: Accept & Store Genuine Signature Image: Take actual signature scanned image of the onboarding customer and store it in a database against a unique Customer ID

Step 2: Accept & Compare Signature Images: Accept inputs of Customer ID and corresponding signature image. Compare with the signature stored in DB against the given Customer ID, and return a Confidence Match Score between the two signature images.

screenshot

Demo Video Youtube

Architecture

flow_1

Clone the repository, and navigate to the downloaded folder. This may take a minute or two to clone due to the included image data.

  1. git clone https://github.com/koushik-elite/Signature-Verification.git
  2. cd Signature-Verification

UI and Backend code with pretrained model is available in

/application

/application/model (Deep learning models)

/application/server (Python Flask Code)

/application/signatureVerify (Angular 6 Code)

Directory Structure

  1. .
  2. ├── application
  3. ├── model
  4. ├── model.pt
  5. └── model_v4.pt
  6. ├── server
  7. ├── data
  8. ├── data (copy).csv
  9. ├── data.csv
  10. └── uploads
  11. ├── compare
  12. └── original
  13. ├── dataset.py
  14. ├── model.py
  15. ├── persist.py
  16. ├── __pycache__
  17. ├── dataset.cpython-36.pyc
  18. ├── model.cpython-36.pyc
  19. └── persist.cpython-36.pyc
  20. └── server.py
  21. └── signatureVerify
  22. ├── angular.json
  23. ├── browserslist
  24. ├── e2e
  25. ├── protractor.conf.js
  26. ├── src
  27. ├── app.e2e-spec.ts
  28. └── app.po.ts
  29. └── tsconfig.json
  30. ├── karma.conf.js
  31. ├── package.json
  32. ├── package-lock.json
  33. ├── README.md
  34. ├── src
  35. ├── app
  36. ├── add-signature
  37. ├── add-signature.component.css
  38. ├── add-signature.component.html
  39. ├── add-signature.component.spec.ts
  40. ├── add-signature.component.ts
  41. └── image-preview.directive.ts
  42. ├── app.component.css
  43. ├── app.component.html
  44. ├── app.component.spec.ts
  45. ├── app.component.ts
  46. ├── app.module.ts
  47. ├── app-routing.module.ts
  48. ├── compare-signature
  49. ├── compare-signature.component.css
  50. ├── compare-signature.component.html
  51. └── compare-signature.component.ts
  52. └── services
  53. └── application.service.ts
  54. ├── assets
  55. ├── environments
  56. ├── environment.prod.ts
  57. └── environment.ts
  58. ├── favicon.ico
  59. ├── index.html
  60. ├── main.ts
  61. ├── polyfills.ts
  62. ├── styles.css
  63. └── test.ts
  64. ├── tsconfig.app.json
  65. ├── tsconfig.json
  66. ├── tsconfig.spec.json
  67. └── tslint.json
  68. ├── assets
  69. ├── flow.png
  70. ├── loss.jpg
  71. └── network-architecture.jpg
  72. ├── dataset.py
  73. ├── installation
  74. └── README.md
  75. ├── LICENSE
  76. ├── loss.py
  77. ├── model
  78. ├── model.py
  79. ├── prepare.py
  80. ├── README.md
  81. ├── requirements.txt
  82. ├── sample_Signature
  83. ├── forged
  84. └── NFI-08805004.png
  85. ├── genuine
  86. ├── NFI-00101001.png
  87. ├── README.txt.txt
  88. └── train_final.csv
  89. ├── Signature Training.ipynb
  90. ├── Signature Training kaggle.ipynb
  91. └── testfiles
  92. ├── 049
  93. ├── 01_049.png
  94. ├── 02_049.png
  95. ├── 03_049.png
  96. ├── 04_049.png
  97. ├── 05_049.png
  98. ├── 06_049.png
  99. ├── 07_049.png
  100. ├── 08_049.png
  101. ├── 09_049.png
  102. ├── 10_049.png
  103. ├── 11_049.png
  104. └── 12_049.png
  105. ├── 049_forg
  106. ├── 01_0114049.PNG
  107. ├── 01_0206049.PNG
  108. ├── 01_0210049.PNG
  109. ├── 02_0114049.PNG
  110. ├── 02_0206049.PNG
  111. ├── 02_0210049.PNG
  112. ├── 03_0114049.PNG
  113. ├── 03_0206049.PNG
  114. ├── 03_0210049.PNG
  115. ├── 04_0114049.PNG
  116. ├── 04_0206049.PNG
  117. └── 04_0210049.PNG
  118. ├── forg
  119. └── NFI-00301001.png
  120. └── gen
  121. └── NFI-00101001.png

Download the pretrained deep learning model from the google drive. since github is limited to 100mb only

Download Model.zip

Extract the model to

/application/model (Deep learning models)

API is in python and UI is in angular 6 so both the servers need to be started saperately.

Start Angular Server

got to /application/signatureVerify

install Node and NPM (both stable version)

run on command-prompt/shell

  1. npm install
  2. ng serve

Start Python Flask Server

got to /application/server

Create a environment and install python flask, follow installation document

run on command-prompt/shell

  1. python server.py

Background

Creating Deep Learning Model

This problem comes under One Shot Classification problem where 2 images will be compared directly and find similarity between them. these kind of clasification are mainly used to compare Human Faces, Signature etc.

Siamese Networks

Siamese networks are a special type of neural network architecture. Instead of a model learning to classify its inputs, the neural networks learns to differentiate between two inputs. It learns the similarity between them.

Networks architecture

architecture_1

Contrastive Loss function

Here i defined a custom loss function which is used to calculate the euclidean distance between 2 output from the model

loss_1

Equation 1.0 Explanation

Y is either 1 or 0. If the inputs are from the same class , then the value of Y is 0 , otherwise Y is 1

i used Softmax on the difference of 2 outputs and generate probability of Y, Sum of probability is 1

Training

The training is done in the jupyter notepad Signature Training.ipynb using the sample signature images given with the task sample task.zip in email

download and extract the “sample_Signature” folder in the same notebook folder

Folder Path

/sample_Signature

/sample_Signature/forged

/sample_Signature/genuine

/Signature Training.ipynb

/prepare.py

run the prepare.py python code for data preparation

A CSV file “train_final.csv” will be created in “sample_Signature” folder

Run the jupyter notebook Signature Training.ipynb for training.

Training Kaggle

model_v4 in the /application/model is trained in kaggle with large signature dataset to get more accurate model

Use the notebook Signature Training kaggle.ipynb upload it to kaggle and use this dataset signature-verification-dataset for training download the model and use it for production

Reference

One Shot Learning with Siamese Networks in PyTorch hackernoon

Siamese Neural Networks for One-shot Image Recognition PDF

Siamese Networks for Visual Tracking medium

Deploy your PyTorch model to Production medium