if we train signature forgery detectors on indic scripts, do they work on english?
siamese networks from scratch, one experiment on hindi and bengali signatures, and a model you can run on your own signature in the browser
People still sign a lot of paperwork: cheques, contracts, exam forms, property deeds. Someone, or something, has to check that each signature really belongs to the person named.
I wanted to train a model that spots forged signatures. When I looked for data, I noticed something odd. The biggest free signature dataset with real forgeries is BHSig260. It has 260 people signing in Hindi and Bengali. The classic English dataset, CEDAR, has only 55 people. So this post asks one simple question:
If you train a forgery detector only on Hindi and Bengali signatures, can it catch forgeries of English signatures it has never seen?
To answer it, we will build Siamese networks step by step. Then we run the experiment carefully and look at the results. All the interactive figures use real data and real model outputs. At the end, the trained model runs in your browser, so you can try it on your own signature.
The short version. A Siamese network trained only on Hindi and Bengali signatures got a 19.1% equal error rate on English signatures it never saw. The same network trained on 38 English writers got 22.9% on the same 11 test people. So the number of writers mattered more than the script. When we also added Chinese signatures, the English error fell to about 15%. That model still used no English training data.
Part 1: Siamese networks
Verification, not recognition
A signature checker answers one question: I have a few signatures I know are real. Did the same person write this new one? This is called verification. We don't ask "who signed this?". We ask "did this person sign this?".
There are two kinds of fakes. A random forgery is someone else's signature, or a fake by someone who never saw the real one. These are easy to catch. A skilled forgery comes from someone who studied the real signature and practised copying it. These are hard to catch, and this post is about them.
First, you try. Below are five real signatures of one person from the CEDAR dataset. Under them are four more signatures, and two of those are skilled forgeries. Click each one to mark it.
Loading signatures…
Was that harder than you expected? That's normal. The forgers in these datasets had time to practise. The signs of a forgery are small: shaky strokes from writing slowly, sizes that are a bit off, and the pen lifting in odd places.
Why not just train a classifier?
The obvious first idea is a normal image classifier with one output for each person. This breaks down fast:
- Every new person means retraining. A bank can't retrain its model each time someone opens an account.
- There are very few signatures per person. A bank might have five on file. That is far too few to learn a new class.
- There are no forgeries of new people. You will almost never have skilled forgeries of a new customer to train on.
So we don't teach the model who signed. We teach it how similar two signatures are. If it gets good at that, it works for anyone, even people it has never seen. This is called writer-independent verification.
A fun fact: the first Siamese network was built for this exact problem. Bromley, LeCun and their colleagues at Bell Labs made it in 1993 to check signatures written on a pen tablet. So we are going back to where the idea began.
The architecture
A Siamese network is one neural network that we use twice. Each signature goes through the same network \(f_\theta\). The network turns it into a list of numbers called an embedding. Then we measure how far apart the two embeddings are.
A small distance means "probably the same person". A large distance means "probably not". Pick a pair below to send it through the network. These are real signatures from English writers the model never trained on. The distances are the trained model's real outputs.
Loading diagram…
Why must both sides use the same weights? There are three reasons:
- Fairness both ways. The distance from A to B should be the same as from B to A. With two different networks, it wouldn't be.
- One ruler for everything. Every signature goes into the same space. So we can compare any two signatures, even from people the model has never seen.
- Half the parameters. We only train one network.
Our \(f_\theta\) is a ResNet-18 that starts from ImageNet weights. Signatures have one colour channel, so we add the first layer's three colour filters into one. The last layer turns 512 features into an embedding of 256 numbers. Then we scale the embedding to length 1. This puts every embedding on the surface of a sphere. It keeps all distances between 0 and 2, and it stops the network from cheating by making every number huge.
Training it: contrastive and triplet losses
The network needs a training signal that says "pull these together, push those apart". The oldest version is the contrastive loss (Hadsell, Chopra and LeCun, 2006). Each pair gets a label. \(y = 1\) means both are real signatures of the same person. \(y = 0\) means anything else:
Real pairs get pulled together. Other pairs get pushed apart until they are at least a margin \(m\) away. After that, the loss leaves them alone.
There is a problem. Contrastive loss demands exact distances, and that is an odd thing to ask. Some people sign the same way every time and some don't. The triplet loss, made famous by FaceNet, only asks for the right order. It uses three signatures. The anchor \(a\) is a real signature. The positive \(p\) is another real signature by the same person. The negative \(n\) is a skilled forgery of that person, or someone else's signature:
In plain words: the forgery should be further from the anchor than the real signature is, by at least \(m\). Drag the points below to get a feel for it. The negative has to get outside the dashed circle. Press "take a gradient step" to see what training does.
Loading playground…
Once the negative is outside the circle, the loss is exactly zero and nothing moves. That is why the margin exists. Easy triplets stop counting, and training spends its effort on the ones that are still wrong.
Which triplets? Batch-hard mining
With thousands of signatures, there are billions of possible triplets. Almost all of them are easy. If you pick triplets at random, most of your batch has zero loss and teaches nothing. Hermans, Beyer and Leibe (2017) fixed this with batch-hard mining. Each batch holds \(P\) people. For each person, it holds \(K_g\) real signatures and \(K_f\) skilled forgeries. For every anchor, we use only the hardest positive and the hardest negative in that batch:
Here is what that looks like in the real embedding space. Each point is a real signature from three English writers the model never trained on. We squashed the 256 numbers down to two with t-SNE, so we can draw them. Click any real signature (a filled circle) to make it the anchor. The lines show its hardest positive and hardest negative. These are measured using all 256 numbers.
Loading embeddings…
We used \(P = 16\) people per batch. Each person had \(K_g = 6\) real signatures and \(K_f = 4\) forgeries, so each batch had 160 images. The forgeries are important. They are the hardest negatives the network will ever see. Having them in every batch keeps training focused on what we care about.
From distances to a verdict
At test time, we don't compare against just one signature. We compare against \(K = 5\) known real ones, called the "references", and take the average:
If \(s(q)\) is at or below a threshold \(\tau\), we accept the signature. We can make two kinds of mistakes. The false acceptance rate (FAR) is the share of forgeries we wrongly accept. The false rejection rate (FRR) is the share of real signatures we wrongly reject. Raising \(\tau\) lowers one and raises the other. The equal error rate (EER) is the error at the threshold where the two are equal. It is the standard single number for comparing signature checkers. Lower is better: 0% is perfect, and 50% is a coin toss.
Part 2: The idea
Here is the data I had. Every person has skilled forgeries:
| Dataset | Script | People | Per person |
|---|---|---|---|
| BHSig260 Hindi | Devanagari | 160 | 24 genuine + 30 forged |
| BHSig260 Bengali | Bengali | 100 | 24 genuine + 30 forged |
| CEDAR | Latin (English) | 55 | 24 genuine + 24 forged |
| ChiSig | Chinese | 83 volunteers signing 500 names | ~5 genuine per name, some forged |
There are almost five times as many Indic signers as English ones. Maybe spotting a forgery mostly depends on things that have nothing to do with the alphabet. If so, all that Indic data should help with English.
There are good reasons to think it might. Forgers usually write slowly. They are copying a shape, not making a movement they have made a thousand times. Slow writing leaves the same marks in any script: shaky lines, blunt stroke ends, uneven pressure, odd pen lifts, and sizes that are almost right but not quite. A model that learns these signs on Hindi should be able to spot them in English.
So the hypothesis is:
A writer-independent Siamese network trained only on Hindi and Bengali signatures will verify English signatures at least as well as the same network trained on the English data that's available.
Testing "at least as well" fairly takes care. Both models must be scored on exactly the same English test people, in exactly the same way.
Part 3: Methodology
Splits: never the same person twice
We always split the data by person, never by image. Say one person's signatures end up in both training and testing. Then the model can just recognise their handwriting instead of learning to spot forgeries, and the results look much better than they really are. We split each training dataset into 70% / 10% / 20% of the people for training, validation and testing.
For English, there are two set-ups:
- Indic-only models never see CEDAR. We test them on all 55 English writers.
- The English-only model trains on 38 CEDAR writers. It picks its best epoch using 6 more. We test it on the last 11.
To compare the two fairly, we score every model on those same 11 English writers.
Preprocessing
Scans come in all sizes, with grey paper, smudges and different pens. Every image goes through the same steps:
- Turn it greyscale.
- Pick a cut-off that separates ink from paper. We use Otsu's method. It picks the cut-off \(t\) that splits the pixels into two groups that are as different as possible: \(\sigma_b^2(t) = \omega_0(t)\,\omega_1(t)\,\big(\mu_0(t) - \mu_1(t)\big)^2\).
- Make every ink pixel black and everything else white.
- Crop to the ink. Resize it to fit 220 × 155 without stretching, and put it in the centre.
- Flip the colours, so ink is 1 and paper is 0.
The figure below runs this exact code in your browser, the same code the model in this post uses. Move the cut-off to see what goes wrong without Otsu.
Loading scans…
A shortcut we had to remove
Step 3 throws away how dark the ink is. My first version didn't do that. I added it after a result that looked too good: on the Chinese dataset, an early model had under 1% error.
The reason was simple. ChiSig's forgeries were written with a darker pen, or scanned in a different way, than the real signatures. So the network didn't need to read the handwriting. It could just check how dark the ink was. The "detector" below only measures the average darkness of the ink. It never looks at the shape of a single stroke.
Loading…
CEDAR has a milder form of the same problem. This is probably one reason many papers report near-perfect results on it. Making every image pure black and white drops the ink-only detector to chance on every dataset. So all the results below use black-and-white images. This costs a little accuracy on Hindi and Bengali. In return, the model judges handwriting, not stationery.
Training
- ResNet-18 starting from ImageNet weights, with a 256-number embedding.
- Batch-hard triplet loss with margin \(m = 0.3\). Each batch has 16 people × (6 genuine + 4 forged).
- AdamW with learning rate \(10^{-4}\) and weight decay 0.05. Two warm-up epochs, then cosine decay.
- Light augmentation: up to 5° of rotation, small shifts, scaling and shear, and strokes made randomly thicker or thinner.
- 150 steps per epoch and up to 40 epochs. We keep the epoch with the lowest validation EER, and stop after 15 epochs with no improvement.
- One laptop RTX 4060, about 20 seconds per epoch.
We ran every Indic-only result with 3 random seeds. Each seed also picks a different set of Hindi and Bengali people for training. Every EER is an average over 5 random choices of which real signatures act as the 5 references.
One threshold for every person
There is one more problem, and it gets worse in a new script. Some people sign almost the same way every time. Others vary a lot. With raw distances, one threshold is too strict for people who vary and too loose for people who don't.
The fix is to compare each new signature with how much the person's own references vary. Let \(\bar d_{\text{refs}}\) be the average distance between the 5 references:
A normalised score of 1 means "this signature is about as far from the references as they are from each other". That is what a real signature should look like. This fix needs no retraining.
The figure below shows every English test signature, scored by the Indic-only model. We picked the threshold using Hindi and Bengali validation people, then used it on English without changing it. Switch between raw and normalised scores and watch where that threshold lands.
Loading scores…
With raw distances, the threshold from Indic signatures accepts almost every English forgery. The model does separate real signatures from forgeries quite well, but on a different scale. After normalising, the same threshold lands close to the best possible one for English. When a model has to work on a script it has never seen, this matters as much as the network itself.
Part 4: Results
Here is every model, scored on English skilled forgeries. You can switch between raw and normalised scores. You can also switch between two test sets: the 11 English writers that every model can be compared on, and all 55. The 55-writer set only works for models that never trained on English. Hover over a point to see its exact value.
Loading results…
Three things stand out.
1. Indic-only training works on English. On the same 11 English test people, the Indic-only and English-only models tie on raw scores (25.6% vs 25.7%). With normalised scores, the Indic-only model is ahead (19.1% vs 22.9%). The English-only number comes from one run on 11 people. So I'd call the Indic model "at least as good", not "clearly better". On all 55 English writers, the Indic-only model gets 18.9% ± 0.9, which agrees.
2. The number of people matters more than the script. 182 Indic training writers beat 38 English ones. The English-only model memorised its 38 writers within 3 epochs, and then it stopped getting better on new people. The Indic models kept improving for longer, with best epochs of 5, 11 and 17. They had more variety to learn from.
3. More scripts help even more. Adding Chinese signatures to Hindi and Bengali brought English down to 14.9% on all 55 writers. That model still had no English training data. Fine-tuning it on the 38 English writers helped only a little more (13.9% on the 11). 38 writers just don't hold much information.
This isn't free, though. The same Indic-only model gets about 7% EER on new Hindi writers and about 10% on new Bengali writers. So English is still harder for it than its own scripts. The transfer works, but it doesn't close the whole gap.
Part 5: Try it yourself
This is the Indic-only model from the experiment. It is seed 1, the middle of the three. We converted it to ONNX, and it runs in your browser with ONNX Runtime Web. It has never seen an English signature. Nothing you draw or upload leaves your device.
The first tab uses real test signatures. In the second tab, you sign five times as references and then sign once more. Or you can hand your device to a friend and ask them to forge your signature. The model uses the normalised score and the threshold picked on Hindi and Bengali validation people.
Loading…
One warning about the drawing tab. The model learned from ink signatures scanned from paper. A mouse or a finger on glass makes much smoother, more even strokes, so it is a different kind of input. If you have pen and paper, sign on paper and upload photos. That works better.
Limitations
- Small English test sets. The head-to-head uses 11 people, and the full test uses 55. A gap of 2 or 3 points between two single runs doesn't prove much.
- Only one English dataset. All CEDAR signatures were collected for one study, under the same conditions. Real English signatures will vary more.
- EER is a summary, not a real-world setting. A bank would pick a threshold that lets very few forgeries through, even if it rejects more real signatures. The numbers would look different.
- Images only. We only see the finished signature. Signature pads that record pen speed and pressure are much harder to fool.
Wrapping up
So, does training on Indic scripts work for English? Yes. It works at least as well as training on the English data that exists, and adding more scripts works even better. Clever architecture wasn't what helped most. Three things did: more people to learn from, removing a shortcut the network found by itself, and putting scores on a scale that carries over from one script to another.
If your language has little signature data, this is good news. Data from other scripts helps.
References
- J. Bromley, I. Guyon, Y. LeCun, E. Säckinger, R. Shah. Signature Verification using a "Siamese" Time Delay Neural Network. NeurIPS 1993.
- R. Hadsell, S. Chopra, Y. LeCun. Dimensionality Reduction by Learning an Invariant Mapping. CVPR 2006.
- F. Schroff, D. Kalenichenko, J. Philbin. FaceNet: A Unified Embedding for Face Recognition and Clustering. CVPR 2015.
- A. Hermans, L. Beyer, B. Leibe. In Defense of the Triplet Loss for Person Re-Identification. 2017.
- S. Dey et al. SigNet: Convolutional Siamese Network for Writer Independent Offline Signature Verification. 2017.
- S. Pal et al. Performance of an Off-Line Signature Verification Method Based on Texture Features on a Large Indic-Script Signature Dataset (BHSig260). DAS 2016.
- M. K. Kalera, S. Srihari, A. Xu. Offline Signature Verification and Identification Using Distance Statistics (CEDAR). IJPRAI 2004.
- K. Yan et al. Signature Detection, Restoration, and Verification: A Novel Chinese Document Signature Forgery Detection Benchmark (ChiSig). CVPR Workshops 2022.
The signature samples on this page come from the BHSig260 and CEDAR research datasets. They are shown only as examples.