Skip to main content

Signature verification package for verifying offline signatures using writer-independent features.

Project description

VerSign: Easy Signature Verification in Python

versign is a small Python package which can be used to perform verification of offline signatures.

It assumes no prior knowledge of any machine learning tools or machine learning itself, and therefore can be used by ML experts and anyone else who wants to quickly integrate this functionality into their project.

Getting Started

Requirements

versign relies on pre-trained models made available by Hafemann under the sigver project. Head over to this repository and perform the steps under Installation heading there.

Installation

This package requires python 3. Installation can be done with pip:

pip install versign

Installation inside a virtual environment is recommended.

Download Trained Models

Before you can get started with, there is one more step you need to complete. versign comes with some pre-trained models which give it its magic.

Download the compressed models here, and extract them to models/ directory in your project root. Your project directory should look something like this:

_ $PROJECT_ROOT
 |__ models/
 |   |__ signet.pth
 |   |__ versign_segment.pkl
 |__ ...

Organise Your Dataset

It is assumed that only positive samples (i.e. genuine signatures) are available during training, while both genuine and forged signatures can be present in the test data.

In general, your dataset should be structured something like below.

_ $PROJECT_ROOT
 |__ models/
 |__ data/
 |   |__ train/
 |   |   |__ 001/
 |   |   |   |__ R01.png
 |   |   |   |__ R02.png
 |   |   |   |__ ...
 |   |   |__ 002/
 |   |       |__ ...
 |   |__ test/
 |       |__ 001/
 |       |   |__ Q01.png
 |       |   |__ Q02.png
 |       |   |__ ...
 |       |__ 002/
 |           |__ ...
 |__ ...

Here, Ref/ folder contains your training data, with each sub-folder representing one person. In each of the sub-folders in Ref/ folder, there are images of only genuine signatures of that user.

Similarly, the Questioned/ folder contains your test data. The sub-folders in this folder should be same as those in the training folder, except that they can contain both positive and negative signature samples.

Write Your First Program with VerSign

import os

import joblib
import torch

from sigver.featurelearning.models import SigNet
from versign import VerSign


# Define paths to your data
data_path = 'data/'
train_path = data_path + 'train/'   # path to reference signatures
test_path = data_path + 'test/'     # path to questioned signatures
temp_path = data_path + 'temp/'     # temp path where extracted features will be saved
if not os.path.exists(temp_path):
    os.makedirs(temp_path)

# Load models
state_dict = torch.load('models/signet.pth')[0]
net = SigNet().eval()
net.load_state_dict(state_dict)

clf = joblib.load('models/versign_segment.pkl')
v = VerSign(input_size=(150, 220), extraction_model=net, segmentation_model=clf)

# Learn from genuine signatures
v.train_all(train_path, temp_path)

# Classify your test data
results = v.test_all(test_path, temp_path)

# Print out results
for y_test in results:
    print(y_test)

# Cleanup temp files
shutil.rmtree(temp_path) # comment this line if you want to keep extracted features

For a more complete example and additional features such as measuring test accuracy if groundtruth is known, see the example.py.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

versign-0.0.1.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

versign-0.0.1-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file versign-0.0.1.tar.gz.

File metadata

  • Download URL: versign-0.0.1.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.5

File hashes

Hashes for versign-0.0.1.tar.gz
Algorithm Hash digest
SHA256 ec208ea1a3155843eb4ae1f5365d815a12fa7b57e75dbbd06b4e6c9f68a88a25
MD5 86a498289875efcab1c60bd6c2c62725
BLAKE2b-256 e81e787c3ffcc9208e5efc5146ba6ec6aca516cd121c0fe6d6fb44fe6fea6e78

See more details on using hashes here.

File details

Details for the file versign-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: versign-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.5

File hashes

Hashes for versign-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3c490e8ca4f267dc94bee3a605a349e4783c12f3c058571e632531358d1659d3
MD5 b7b6308933906a2ef78701317d87d3ee
BLAKE2b-256 22fe0a3b976e8265576ce405cd4cac42a70a82c648310317f90a15e6b14302cb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page