Implementing AI Document Authenticity Check (Anti-Fraud) in Mobile Apps
Fake passports printed on laser printers pass basic OCR checks in 30–40% of cases according to industry reports. This is not a theoretical threat—it's real loan applications, account registrations, and employee onboarding with forged documents. We see that classic rules (MRZ matching visual zone, date format) are insufficient. An ML layer is needed to detect what rules miss. Our experience shows that the best results come from combining a CNN model with geometric verification. You can order a turnkey integration from 3 weeks.
What Exactly Does the AI Model Check?
Document authenticity verification on a mobile device combines several independent signals:
Texture and printing artifact analysis. A genuine passport is printed on an intaglio press with tactile elements and a specific halftone structure. A scan or photo of a printout has JPEG artifacts typical of household printers: blocking on guilloche, loss of microprinting, uniform brightness where relief shadows should be. A CNN trained on such examples outputs forgery_score as a continuous value—not binary "fake/real".
Geometric consistency. Text fields in a real passport are positioned at precise pixels relative to physical markers. Homography transformation aligns the document to a standard plane, then MRZ fields, photo, date of birth are compared with a template via affine matrix. Deviation >2px from the template is a warning; >5px indicates high probability of editing.
Cross-field verification. Name in MRZ must match visual zone, date of birth must match MRZ check digit (ISO 7501-1 algorithm), document number must be checked against lost/invalid databases (if connected to external API, e.g., Interpol I-24/7 or national registries).
How to Choose Between On-Device and Server-Side?
Choice depends on privacy and latency requirements:
| Aspect | On-device (CoreML / TFLite) | Server-side |
|---|---|---|
| Latency | 300–800 ms | 1–3 s |
| Privacy | Data never leaves device | Requires image transfer |
| Model size | 5–50 MB in app | No constraints |
| Model freshness | OTA via CoreML Model Deployment | Server deployment |
| Offline | Yes | No |
For most KYC scenarios we use a hybrid approach: on-device model does fast initial checks (capture quality, basic artifacts), heavy anti-forgery inference on server with GPU. The user sees a progress indicator instead of waiting 3 seconds before any action.
Typical Forgery Indicators and Their Detection
| Forgery indicator | Detection method | Sensitivity |
|---|---|---|
| JPEG artifacts on guilloche | CNN texture analysis | High |
| Text field shift >2px | Homography + affine comparison | Medium |
| MRZ and visual zone mismatch | Cross-field NLP verification | High |
| Missing microprinting | High-frequency pattern detection | Medium |
Deploying CoreML Model on iOS
Basic pipeline for iOS:
// Load model let config = MLModelConfiguration() config.computeUnits = .cpuAndNeuralEngine let model = try DocumentAuthenticityModel(configuration: config) // Preprocessing — normalization and crop to Region of Interest let input = try MLMultiArray(shape: [1, 3, 224, 224], dataType: .float32) // ... fill pixels from CVPixelBuffer // Inference let prediction = try model.prediction(image: pixelBuffer) let forgeryScore = prediction.forgery_score // Float, 0.0 – 1.0 ANE (Apple Neural Engine) on A14+ processes a 224×224 document in ~40 ms. On iPhone SE 2nd gen without ANE — ~350 ms. The difference is significant; computeUnits threshold should be adapted to the minimum supported device.
Model updates via CoreML Model Deployment in CloudKit or a custom endpoint with signed .mlmodel file. Avoid hardcoding the model in the bundle if updates are planned—IPA size increases and each model update requires a release.
TensorFlow Lite on Android
Android implementation via TFLite + GPU Delegate or NNAPI:
val options = Interpreter.Options().apply { addDelegate(GpuDelegate()) setNumThreads(4) } val interpreter = Interpreter(loadModelFile(assets, "doc_auth_v2.tflite"), options) val inputBuffer = TensorImage.fromBitmap(preprocessedBitmap) val outputBuffer = TensorBuffer.createFixedSize(intArrayOf(1, 2), DataType.FLOAT32) interpreter.run(inputBuffer.buffer, outputBuffer.buffer) val forgeryScore = outputBuffer.floatArray[1] // index 1 — class "forgery" GPU Delegate reduces latency on Snapdragon 8 Gen 1 from ~600 ms to ~90 ms for EfficientNet-B2. On budget devices without GPU Delegate the difference is less noticeable—NNAPI with automatic accelerator selection is better there.
Model Training and Fine-Tuning
Public anti-forgery models are limited and quickly become obsolete—fraudsters adapt. We train on synthetic data: real documents + augmented forgeries (JPEG-compress, Gaussian noise, PrintScan simulation via albumentations). Architecture—EfficientNet-B0 or MobileNetV3 for balance of accuracy and speed.
After deployment a feedback loop is crucial: documents with borderline forgery_score (0.4–0.6) are sent for manual labeling by operators and retraining. Without this, the model degrades on new forgery patterns within 3–6 months.
What's Included
- Audit of document types and usage scenarios.
- Dataset collection and labeling (real + synthetic samples).
- Model training and validation (EfficientNet/MobileNet).
- Conversion to CoreML / TFLite with optimization for target devices.
- Integration into mobile app (iOS/Android).
- Setup of model update pipeline (OTA).
- Documentation and team training.
- Technical support for 3 months after launch.
Implementation Stages
Audit of document types and scenarios → dataset collection → training/validation → conversion to CoreML / TFLite → integration into mobile client → A/B test with human verifier → threshold tuning → production → drift monitoring.
Timelines: integration of a ready model without retraining — from 3 weeks. Full cycle (dataset, training, mobile integration, feedback loop) — 2–4 months. Cost is calculated individually.
We have completed more than 50 anti-fraud projects with over 5 years of experience. Contact us for a project assessment—get a free consultation.







