Signature similarity: ConvNeXt-Tiny
A model that looks at two handwritten signatures and says how likely it is that the same person wrote both. It gives a score from 0 to 1 (1 = very likely the same person). It works on people it has never seen, which is what "writer-independent" means.
Headline result: 81.5% accuracy on the test set (95% range 78.8% to 84.2%), EER 18.5%, F1 0.821, ROC-AUC 0.902. The test writers were never used for training, validation or model selection. This is Kaggle version 19 of the kernel
iscientist10/signature-similarity-train-vc-hamza(seed 7).
Quick start
pip install torch torchvision numpy pillow huggingface_hub
from huggingface_hub import snapshot_download
import sys
root = snapshot_download("izamscientist/signature-similarity-convnext-tiny")
sys.path.insert(0, root)
import inference
model = inference.load_model()
score = inference.compare(model, "signature_a.png", "signature_b.png") # 0 to 1
print(score, inference.decide(score)) # ACCEPT / REJECT / REVIEW
inference.py preprocesses the pictures the same way as the training data, so you can give it ordinary scans or photos.
Decisions use the thresholds chosen on the validation set only:
| Threshold | Value | Meaning |
|---|---|---|
| main | 0.7785 | one yes/no answer: at or above = same person |
| accept | 0.9106 | at or above = ACCEPT (kept false accepts at 1% or less on validation) |
| reject | 0.5376 | below = REJECT (kept false rejects at 1% or less on validation) |
Scores between reject and accept mean REVIEW: a person should check.
Files in this repository
| File or folder | What it is |
|---|---|
model/best.pt, model/config.json | The trained weights (112 MB) and the settings and thresholds |
inference.py | Compare two pictures: preprocessing, model and decision |
results/ | All evaluation numbers: all_evaluation_metrics.json, threshold_tradeoff_validation.csv, training_history.csv, locked test result, saved scores |
figures/ | Every figure shown below |
kaggle_version_19_train.py | The exact file Kaggle ran to train this model |
train_signature_v19.py, signature_similarity_shared_v19.ipynb | The same code, with the settings in a notebook cell, to reproduce the run on Kaggle or Colab |
signature_similarity_colab_try_model_v19.ipynb, signature_similarity_kaggle_try_model_v19.ipynb | Try the model on two of your own pictures |
DATASET_STEPS_v3.md / .docx | How the dataset was built, step by step |
Results on the test set
The test set has 3,000 pairs from 99 writers (HMS, CEDAR and BHSig260) that were never used for training, validation or choosing a model. The thresholds above were chosen on validation. The test was run once for the reported result, and has since been made public so that other models can be compared on it.
| Metric | Test |
|---|---|
| Accuracy | 81.5% |
| Balanced accuracy | 81.5% |
| Precision | 79.5% |
| Recall | 84.8% |
| F1 score | 0.8209 |
| Specificity | 78.2% |
| False accept rate (FAR) | 21.8% |
| False reject rate (FRR) | 15.2% |
| MCC | 0.6314 |
| ROC-AUC | 0.9017 |
| Average precision | 0.9032 |
| Equal error rate (EER) | 18.5% |
| mAP per writer | 0.9126 |
95% confidence range (resampling whole writers 1,000 times): accuracy 78.8% to 84.2%, EER 15.7% to 21.5%.
Confusion matrix (test)

| predicted different | predicted same | |
|---|---|---|
| truly different | 1173 (correct) | 327 (forgery or other person accepted) |
| truly same | 228 (genuine rejected) | 1272 (correct) |
Reading it: of the 1500 different-person pairs, 21.8% were wrongly accepted. Of the 1500 same-person pairs, 15.2% were wrongly rejected. The model catches genuine matches better than it rejects forgeries.
Accuracy by data group

| Group | Validation accuracy | Validation EER | Test accuracy | Test EER |
|---|---|---|---|---|
| bhsig_bengali | 89.3% | 11.0% | 82.3% | 17.5% |
| bhsig_hindi | 85.0% | 16.5% | 86.3% | 12.9% |
| cedar | 82.9% | 16.7% | 81.4% | 16.9% |
| hms_bengali | 74.5% | 27.0% | 79.5% | 19.9% |
| hms_english | 75.4% | 23.6% | 76.4% | 22.6% |
| hms_s | 72.0% | 28.0% | 79.8% | 20.1% |
The BHSig260 and CEDAR groups are strongest. The HMS groups (especially HMS English) are weaker and are below 80%.
Results on the validation set
Validation has 3,000 pairs from 96 writers and was used to pick the best epoch, the model settings and the thresholds, so these numbers are slightly optimistic compared with the test.
| Metric | Validation |
|---|---|
| Accuracy | 81.3% |
| Balanced accuracy | 81.3% |
| Precision | 80.3% |
| Recall | 82.9% |
| F1 score | 0.8160 |
| Specificity | 79.7% |
| False accept rate (FAR) | 20.3% |
| False reject rate (FRR) | 17.1% |
| MCC | 0.6263 |
| ROC-AUC | 0.8976 |
| Average precision | 0.9000 |
| Equal error rate (EER) | 19.0% |
| mAP per writer | 0.9019 |

All figures
Curves. ROC and DET curves for validation and test (the DET curve is the standard plot for biometric systems):

Score distributions. The model gives higher scores to same-person pairs (green) than to different-person pairs (red). The overlap in the middle is where the mistakes come from. Lines mark the three thresholds:

Raising the threshold. A higher threshold accepts fewer forgeries but rejects more genuine signatures (validation):

| Threshold | False accept rate | False reject rate | Accuracy |
|---|---|---|---|
| 0.500 | 72.6% | 0.8% | 63.3% |
| 0.550 | 62.8% | 1.2% | 68.0% |
| 0.600 | 55.0% | 2.3% | 71.4% |
| 0.650 | 46.4% | 4.1% | 74.7% |
| 0.700 | 36.5% | 7.6% | 77.9% |
| 0.750 | 27.3% | 13.3% | 79.7% |
| 0.800 | 16.6% | 22.2% | 80.6% |
| 0.850 | 8.1% | 35.1% | 78.4% |
| 0.900 | 2.0% | 57.3% | 70.4% |
| 0.950 | 0.2% | 84.9% | 57.5% |
Training curves. Training accuracy rises above validation accuracy after about epoch 8, which is the overfitting that early stopping guards against. The best epoch (12) was chosen by validation EER:

How the model was made, step by step
1. The data
- Sources: HMS (Mendeley Data; Bangla, English and "S" scripts), CEDAR (Latin script) and BHSig260 (Bengali and Hindi).
- Training: 14,556 images from 452 writers. Validation: 3,118 images from 96 writers. Test: 3,199 images from 99 writers.
- Split by writer, so no person appears in more than one split.
- Full build description:
DATASET_STEPS_v3.md.
2. Preprocessing (every image, the same steps)
- Transparent background to white; convert to grayscale.
- If the background is dark, invert so the ink is dark on white.
- Contrast stretch between the 1st and 90th percentile of brightness.
- Ink = pixels darker than 160 after the stretch; everything else becomes white.
- Remove printed box lines (rows and columns that are more than 40% ink).
- Crop tightly around the ink with a 4% margin.
- Pad to a square so the signature is not stretched.
- Resize to 224 x 224 (Lanczos) and save as a lossless PNG.
3. Cleaning
Exact copies, near copies (64-bit difference hash plus a pixel check), blank files and writers with too few images were removed. Two BHSig260 Hindi writers were excluded (one with no genuine samples, one with a mismatched count).
4. Training pairs
The model learns from pairs of signatures. Half are the same person (two different genuine signatures of one writer). Half are different: 70% a genuine signature against a skilled forgery of the same writer (the hard case), and 30% against a different writer. A different writer is never from the same group. Sources alternate so each is represented. Each epoch draws 8,000 fresh pairs.
5. The network
- Backbone: ConvNeXt-Tiny pretrained on ImageNet (torchvision weights). Its 1,000-class layer is removed.
- Head: dropout (0.2), then a linear layer that gives a 256-number embedding (a fingerprint of the signature).
- Siamese: both signatures go through the same network. Each embedding is scaled to length 1, and the similarity is the cosine of the two embeddings rescaled to 0 to 1.
6. The loss
Contrastive loss with margin 0.3: same-person pairs are pushed toward similarity 1; different-person pairs are pushed below 0.3. Errors are squared, so large mistakes count more.
7. Optimisation and regularisation (these fight overfitting)
| Setting | Value |
|---|---|
| Optimiser | AdamW, weight decay 5e-4 |
| Learning rate | head 1e-4; backbone 0.03 x that (3e-6) |
| Schedule | cosine decay over 30 planned epochs |
| Frozen layers | the stem and first stages of ConvNeXt stay frozen for the whole run; the whole backbone is frozen for epochs 1 and 2 |
| Batch | 32 pairs; 8,000 fresh pairs per epoch |
| Augmentation (training only) | small rotation (3 degrees), shift (3%), scale (5%); brightness and contrast jitter (0.2); light random erasing |
| Dropout | 0.2 on the embedding layer |
| Stopping | stop after 8 epochs without a better validation EER; keep the best epoch |
| Seed | 7 |
| Hardware | Kaggle GPU, mixed precision |
The run stopped after 20 epochs; the best was epoch 12 (validation accuracy 81.3%).
8. Choosing the thresholds
Thresholds were chosen on the validation set only: main gives the best balance of the two error types, accept keeps false accepts at 1% or
less, and reject keeps false rejects at 1% or less.
9. Model selection history (nothing here used the test set)
| Model | Backbone learning rate (x head) | Validation accuracy | Train-validation gap |
|---|---|---|---|
| ResNet-18, full | 1.0 | 78.3% | 13.5 points |
| ResNet-18 | 0.1 | 78.7% | 5.9 |
| ResNet-18 | 0.03 | 78.8% | 4.8 |
| ResNet-18 | 0.01 | 78.1% | 3.5 |
| ResNet-18, backbone frozen | 0 | 75.4% | 1.5 |
| ResNet-34 | 0.01 | 77.2% | 4.2 |
| EfficientNet-B0 | 0.03 | 76.0% | 1.2 |
| ConvNeXt-Tiny, seed 42 (Kaggle version 18) | 0.03 | 80.8% | 4.6 |
| ConvNeXt-Tiny, seed 7 (Kaggle version 19, this model) | 0.03 | 81.3% | 6.5 |
The seed-7 run was picked over seed 42 because its validation accuracy and EER were slightly higher.
What the metrics mean
- Accuracy: share of pairs called correctly. Precision: of the pairs called "same", how many really were. Recall: of the really-same pairs, how many were found.
- F1: the balance of precision and recall. Specificity: of the really-different pairs, how many were rejected.
- FAR (false accept rate): share of different-person pairs wrongly accepted. FRR (false reject rate): share of same-person pairs wrongly rejected.
- EER: the error rate at the point where FAR equals FRR; lower is better and it does not depend on the threshold.
- MCC: a balanced score from -1 to 1 (0 is guessing). ROC-AUC / average precision: how well the scores rank same pairs above different pairs.
- mAP per writer: average precision inside each writer's own pairs.
Limitations and responsible use
- Not a sole decision-maker. At the main threshold about 21.8% of different-person pairs (including forgeries) are accepted. Use the three-way decision and keep a person in the loop for anything that matters.
- Scans, not photos. It was trained on scanned signatures from three datasets. Phone photos, unusual paper or other scripts may score lower.
- Weaker groups. HMS English and HMS Bengali are below 80% on the test set.
- The confidence range is wide. The true accuracy could be just under 80% (78.8% to 84.2%).
- Test set is public. It was used for this result and is now public, so honest testing of a new model needs new writers.
- Privacy. Signatures are personal data; follow the law and the consent rules that apply to you.
Data and licences
Trained on HMS (Mendeley Data), CEDAR and BHSig260. Each source keeps its own terms, which also apply to this model and its use.
The train and validation data are in izamscientist/signature-similarity-v3-train-val; the test set is in izamscientist/signature-similarity-v3-test.