Git Product home page Git Product logo

signature-recognition's Introduction

Tensorflow-Signature-Recognition

A siamese network implementation for signature recognition. A Resnet50 based siamese network is trained with triplet loss with the choice of online semi-hard negative mining or hard negative mining. [Blog for triplet loss] [Blog for simaese] [Trained Model]

The network is trained on open-source signature dataset. Please note that this code is not explicitly written for signature detection and can be used for any siamese task such as Face-Recognition (Face alignment logic should be implemented), writer recognition using handwritten text, etc. See Notes Section.

Dependencies

  • Python 2.7 || 3.5 - 3.8
  • Tensorflow == 1.12.0 (Should work on lower versions with minor changes)

The code is tested on :- Ubuntu 14.04 LTS with CPU architecture x86_64 + Nvidia Titan X 1070 + cuda9.0.

Getting Started

Training

First download the dataset and extract it to appropriate folder (divide dataset in two subsets train and val). The code is not data format dependent, thus can be used with any custom data.

To run training, edit and run train.sh:

#!/usr/bin/env bash
CUDA_VISIBLE_DEVICES=0 python main.py \
    --output_dir /handwritten-data/experiment_sign_semi_reg \
    --summary_dir /handwritten-data/experiment_sign_semi_reg/log/ \
    --mode train \
    --train_dir /handwritten-data/signatures/full_org \
    --val_dir /handwritten-data/signatures/val \
    --val_dataset_name kaggle_signature \
    --learning_rate 0.0001 \
    --loss semi-hard \
    --decay_step 50000 \
    --decay_rate 0.1 \
    --stair True \
    --beta 0.9 \
    --loss_margin 0.5 \
    --max_iter 200000

For all available options, check main.py.

To observe the training losses, learning rate, graph and images, use tensorboard:

tensorboard --logdir [summary_dir]

Inference

I have implemented a spring boot Java application with react frontend to serve the model for inference, which is available here. To use your model with Java app. Use graph_serialize_utils to convert (and visualize) tf model to (frozen) pb file. and follow instruction on above repo.

Notes

  • The pretrained model is not explicitly trained for signature fraud detection.
  • This code can be trained for any other siamese task by just providing appropriate train and val folder. No code change required.
  • Other signature dataset
  • Writer recognition dataset
  • face dataset (For face reco training, face alignment logic would be required)

signature-recognition's People

Contributors

rmalav15 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.