Skip to main content

A package for signature classification with HOG features and KNN classifier, also for forg signatures detection

Project description

Signature-Classifier

A module for quick learning and using the signature classification model

Static Badge GitHub top language GitHub GitHub Repo stars

icon

Usage (Linux)

  1. Create a virtual environment
python -m venv venv
  1. Activate the virtual environment
source venv/bin/activate
  1. Install dependencies
pip install Signature-Classifier
  1. Run the script to demonstrate the capabilities of the library

Check out the usage examples to learn how to properly use the library. Ensure that your dataset is in the same format and has the same class names. Use the built-in or online documentation.

Training

Training the final model can be done either after optimizing hyperparameters or directly by adding custom values in the following format:

custom_params = {
    'resize_shape': (128, 256),
    'nns': 3,
    'orientations': 12,
    'cells_per_block': 3,
    'pixels_per_cell': 16,
}

You can also save plots that visualize the heatmap and confusion matrix. Example:

classification_report_heatmap confusion_matrix_heatmap


After training, all parameters, including custom ones, and the trained model are saved. You can then use only the predict method.

Prediction

The predict method allows you to select the number of nearest neighbors to return and whether to return the forgery probability (use only if there are such data in the training set). It returns a list of tuples, where each tuple consists of:

[('003', 1.0, 0.5347718688045583)]
  1. Class number.
  2. Probability of belonging to this class.
  3. Probability of forgery from 0 to 1, where 0 is a forgery and 1 is a genuine signature.

Why these methods?

HOG (Histogram of Oriented Gradients) - is a feature extraction method that transforms an image into a set of histograms of gradients, allowing the capture of shape and structure.

  • Robustness to Scale and Rotation: Signatures can be written at different angles and sizes, but HOG retains the essential characteristics of the image regardless of these changes.
  • Focus on Edge Features: Signatures consist of lines and curves, which are well represented by gradients. HOG effectively captures these edge features, crucial for accurate recognition.

hog example

KNN (k-Nearest Neighbors) - is a simple and efficient machine learning algorithm for classification tasks. It is based on the idea that objects close to each other in feature space are likely to belong to the same class. Since there is likely a small amount of data and signatures are relatively easy to distinguish, KNN is well-suited for this task.

Thank you for using Signature Classifier and star this project!

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

signature_classifier-1.0.1.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Signature_Classifier-1.0.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file signature_classifier-1.0.1.tar.gz.

File metadata

  • Download URL: signature_classifier-1.0.1.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.19

File hashes

Hashes for signature_classifier-1.0.1.tar.gz
Algorithm Hash digest
SHA256 dd284e0b1c3a6fc0ae809ef7b4ca8ec338614ba177625ee0373c82efe7a954c9
MD5 3a633efa9818c507539d5a2a95131125
BLAKE2b-256 e334857c85807132eda1e0fbd053ab70f5b1346d80567683026f452dc135db39

See more details on using hashes here.

File details

Details for the file Signature_Classifier-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for Signature_Classifier-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 80f8cc35db048057fef655f1dfd0ddbf86a8710d21b9fb5baca31e3fdb40a327
MD5 d8569bf040d21f9f36d389b6b414a7c6
BLAKE2b-256 65f221efd6291d33c752015ac213dcae92a986381be2028b0aa2ae883befcd2d

See more details on using hashes here.

Supported by

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