Complete Technical Paper Content β Ai Fingerprint Recognition
1. Executive Abstract, Problem Formulation & Background
A Unified Fingerprint Matching Algorithm for Fast, Robust Identification Introduction Fingerprint recognition remains one of the most reliable biometrics for authentication and identification. Modern applications range from real-time smartphone unlocking and access control to large-scale forensic searches in criminal databases. These scenarios impose strict requirements: speed (for real-time use), scalability (for 1:N searches in millions of records), and robust accuracy across various fingerprint capture methods (optical sensors, capacitive sensors, as well as latent crime-scene prints). Traditional fingerprint systems rely on minutiae (unique ridge ending and bifurcation points) as features, which are highly discriminative but yield variable-length templates and require complex matching algorithms. Recent advances in deep learning enable fixed-length vector embeddings of fingerprints, offering fast comparison and easy storageβ [arxiv.org]{.underline} . However, purely deep learning approaches may ignore the rich domain knowledge (like minutiae and ridge flow patterns) that has proven effective over decades. To meet all the requirements, we propose a hybrid fingerprint matching algorithm that combines the strengths of classical minutiae features with modern deep neural network embeddings. The result is a system capable of accurate one-to-one verification and one-to-many identification (even at very large scales) in a fraction of the time of conventional methodsβ [arxiv.org]{.underline} , while handling diverse fingerprint types and qualities. Key Idea: By integrating handcrafted biometric features (minutiae, ridge orientation, etc.) into a deep learning model, we obtain a compact fixed-length template that retains interpretability and discriminative powerβ [ar5iv.org]{.underline} . This template can be searched using high-dimensional vector indexing for speed, and augmented with minutiae-based matching for additional accuracy when needed. In the following sections, we detail the system architecture, pipeline from image preprocessing to matching, the embedding generation model, template formation, and the strategies used to optimize both speed and accuracy. System Architecture Overview Figure: High-level architecture of the proposed fingerprint recognition system (inspired by DeepPrint). The pipeline first normalizes the input fingerprint (alignment), then extracts features via a convolutional neural network (Base Network). Two branches capture complementary information: a texture-based global feature extractor (purple) and a minutiae-based local feature module (red). The outputs -- a fixed-length vector embedding (blue/red bars) -- form the fingerprint template. This template can be stored in a vector database for 1:N search, and minutiae data (if needed) can be used to refine matches. {width="6.5in" height="2.1944444444444446in"} At a high level, our system consists of the following modules (illustrated above): Fingerprint Acquisition & Preprocessing: Captures the fingerprint image (from a sensor or image of a latent print) and enhances it for feature extraction. Alignment (Normalization): Optionally align/normalize the fingerprint orientation and position to a canonical pose, to ease feature matching across impressions. Feature Extraction Network: A deep neural network that processes the fingerprint image and outputs a fixed-length feature representation. This network is designed with two interconnected parts: one focusing on holistic texture/ridge patterns, and another guided by minutiae (domain-specific features)β [ar5iv.org]{.underline} . Template Generation: The outputs of the network are combined into a compact fingerprint template -- essentially a vector (embedding) representing the fingerprint. This template may also include ancillary data like a binary hash or a quality mask, and is stored for later matching. Matching Engine: Performs comparisons between fingerprint templates. For 1:1 verification , it compares two templates and computes a match score. For 1:N identification , it efficiently searches a database of templates (using a vector similarity search) to find the closest matches. A minutiae-level comparison can be applied on top of the initial search for higher accuracy on close candidates. Decision Module: Applies thresholds or decision logic to accept or reject a match (in 1:1), or to output an identified subject or ranked candidate list (in 1:N), possibly with a confidence measure. This architecture blends fast vector operations with biometric expertise. Next, we dive into each stage of the pipeline in detail. Preprocessing and Image Enhancement Before feature extraction, the fingerprint image is preprocessed to improve quality and consistency. First, the system performs segmentation to isolate the fingerprint ridges from the background. For optical or capacitive sensor images (e.g. those from phones or scanners), this may involve thresholding or machine learning segmentation to create a mask of the fingerprint area. For latent prints (fingerprints lifted from surfaces in crime scenes), preprocessing is more complex: latent images often have noise, distortions, or partial prints. In such cases, image enhancement techniques like ridge smoothing, contrast normalization, and noise reduction are appliedβ [arxiv.org]{.underline} . For example, a specialized convolutional network or filtering algorithm (akin to a fingerprint-oriented denoising U-Net ) can enhance ridge clarity in a latent print, since traditional enhancement designed for minutiae extraction may not directly suit a deep networkβ [arxiv.org]{.underline} . The goal is to produce a cleaned, high-contrast ridge pattern image. Fingerprint segmentation and enhancement may include steps such as: Normalization: Adjust image intensity and contrast to standard ranges. Orientation and Frequency Estimation: Compute the ridge orientation field and frequency, which can guide contextual filtering (especially for poor-quality areas). Contextual Filtering: Apply Gabor filters or deep network filters tuned to the local ridge orientation to enhance ridge-valley contrast and fill gaps. Binarization/Thinning (if minutiae to be extracted): (Optional) Produce a binary ridge map and thin ridges to single-pixel width for classical minutiae detection algorithms. In our system, explicit minutiae detection is handled by the learning model later, so thinning may not be necessary in the pipeline. Notably, we maintain flexibility in preprocessing based on input type. For example, latent fingerprints might skip global normalization steps that assume a clear core or delta, because such prints may not contain those reference pointsβ [pmc.ncbi.nlm.nih.gov]{.underline} . Instead, the system will let the feature extractor handle alignment invariance (described below) or use only local features. By tailoring preprocessing to the fingerprint source, we ensure the input to the feature extraction network is as robust as possible. Alignment and Normalization A crucial step for improving matching is to align the fingerprint image to a standard orientation and position. Misaligned or rotated fingerprints decrease matching accuracy, as features won't line up when compared. Our algorithm includes an alignment module that can operate in two ways depending on the scenario: Explicit Alignment via Pose Estimation: For full or plain fingerprints (from sensors), we employ a pose estimation technique to find the fingerprint's core position and orientation angle. We use a dense voting algorithm (a state-of-the-art pose estimator) to detect the likely center of the fingerprint and the direction of the ridgesβ [arxiv.org]{.underline} . This algorithm analyzes the orientation field of the print and votes on the most probable singular point (core) and alignment angle. Once the pose is determined, the fingerprint image is rotated and translated so that the core is centered and the ridges are vertically orientedβ [arxiv.org]{.underline} . This normalization puts all prints in a common coordinate frame (e.g., core at image center, upward orientation), which simplifies downstream feature matching. If multiple singular points (cores/deltas) exist, a consistent rule (e.g., using the upper core) is applied. Alignment-Free (Local Features Only): In cases where a reliable global alignment is not possible (e.g., partial latent prints with no clear core/delta), the system can bypass the explicit alignment. Instead, the feature extraction network and matching stage are designed to handle rotations and translations inherently. We achieve this by focusing on local relationships between features that are invariant to global pose. For instance, the network can be trained with data augmentation (random rotations/scaling) so that its embeddings are rotationally robust. Moreover, our use of local minutiae neighborhoods (discussed below) provides rotation- and scale-invariant descriptors β [pmc.ncbi.nlm.nih.gov]{.underline} , mitigating the need for pre-alignment. In other words, even if the fingerprint is not aligned, the template it produces will be comparable in a pose-invariant manner to those from other prints. In summary, whenever possible, we align the fingerprint to reduce variance and improve matching (especially beneficial for consistent sensor-captured prints)β [arxiv.org]{.underline} . When alignment is not feasible, our feature extraction and matching strategies ensure the system remains robust to pose differencesβ [pmc.ncbi.nlm.nih.gov]{.underline} . This dual approach guarantees the algorithm can handle a wide range of inputs -- from well-centered slap fingerprints to off-angle latent fragments -- without sacrificing accuracy. Feature Extraction with Deep Learning and Domain Knowledge Once the image is preprocessed (and aligned if applicable), it is fed into the feature extraction network . The goal of this stage is to distill the fingerprint's distinguishing information into a fixed-length vector (embedding). Our approach uses a convolutional neural network (CNN) architecture that is enhanced with fingerprint domain knowledge: Base CNN Architecture: We employ a deep CNN (such as a ResNet-based model) to process the fingerprint image and extract feature maps. In our prototype, a ResNet-34 backbone is used, which provides a good balance of depth and efficiency. We modify the network by removing the initial downsampling (no first max-pool) to preserve high-resolution ridge detailsβ [arxiv.org]{.underline} . The CNN produces rich feature maps that encode textures, ridge flow, and other complex patterns. To inject some global context, we add a 2D positional embedding to the feature maps, so that the network can discern where on the fingerprint features are located (important because a ridge break near the core may signify different identity info than one at the periphery)β [arxiv.org]{.underline} . The output of the base CNN is a dense feature representation of the fingerprint image. Dual-Branch Feature Learning: A single CNN by itself can learn an embedding, but we improve its discriminative power by splitting the high-level layers into two branches , as illustrated earlier. One branch focuses on global texture features and the other on local minutiae features β [ar5iv.org]{.underline} β [ar5iv.org]{.underline} . Both branches take input from the shared base network's feature maps (ensuring they analyze the same image regions, just with different emphasis): Texture-Based Branch: This branch (upper path in the diagram) processes the CNN features through additional layers to capture global appearance information -- overall ridge flow pattern, pore distribution, and other subtle textures that aren't explicitly captured as minutiae. It effectively learns a fixed-length descriptor of the fingerprint's macro and medium-scale features (sometimes referred to as Level-1 and Level-2 features in fingerprint terminology). For example, it can encode the orientation field implicitly, or the presence of a whorl vs. loop pattern, etc. This branch outputs a feature vector $T(x)$ of a certain dimension (e.g., 96-dim)β [ar5iv.org]{.underline} . Minutiae-Guided Branch: The second branch (lower path) explicitly incorporates minutiae information into the representation. We achieve this by using a multi-task learning approach: the network is trained not only to produce an embedding, but also to predict a minutia heatmap as an auxiliary taskβ [ar5iv.org]{.underline} . Specifically, one part of this branch generates a minutiae map -- essentially a 2D map the size of the fingerprint image (downsampled) with channels that encode minutia probability, orientation, and possibly type. During training, this map is supervised by ground-truth minutia locations (extracted from training images), forcing the network to learn features correlated with minutiae points. The branch then processes the base features and the intermediate minutiae map through further layers to distill a vector $M(x)$ that represents minutiae-based characteristics of the fingerprintβ [ar5iv.org]{.underline} . Importantly, at inference (matching) time, we do not need to run a separate minutiae extractor -- the network has learned to embed that information. The minutiae prediction task is dropped during deployment to save computationβ [arxiv.org]{.underline} , so the extraction still runs quickly. The output of this branch is another fixed-length vector (also, say, 96-dim). Fusion of Features: The texture and minutiae feature vectors are then concatenated to form one comprehensive embedding. For example, combining a 96-dim texture vector and a 96-dim minutiae vector yields a 192-dimensional fingerprint representationβ [ar5iv.org]{.underline} . This fusion means the template contains both globally learned features and specific minutiae-oriented features, marrying the strengths of deep learning and human-understandable featuresβ [ar5iv.org]{.underline} . Past research has shown that such hybrid representations can be both compact and highly discriminative: our design is influenced by the DeepPrint model, which demonstrated that a 192-length representation can rival full minutiae-based matchers in accuracy while being drastically fasterβ [arxiv.org]{.underline} . Handling Partial Regions: Because not all parts of a fingerprint may be present (especially in latent or slaps where edges are cut off), the network also outputs a valid region mask alongside the embedding. This mask indicates which portions of the fingerprint image contained actual fingerprint ridges (versus background or missing areas). We derive it from the segmentation or from an internal layer that computes fingerprint presence. This mask will later be used to adjust matching scores, ensuring that comparisons focus on overlapping areas only (to avoid penalizing partial prints)β [arxiv.org]{.underline} . Model Training: We train the feature extraction network on a large corpus of fingerprint images from varied sources (optical rolled prints, capacitive touch prints, different ethnicities, ages, etc., and augmented with synthetic distortions to mimic latent noise). The training uses a combination of objectives: a classification loss (softmax cross-entropy across person IDs) to encourage discrimination, and a metric learning loss (e.g., contrastive or triplet loss) to ensure the learned embeddings of the same finger are close while different fingers are far apart. The auxiliary minutiae prediction uses a binary cross-entropy or focal loss on the minutia map. By jointly training these, the network learns an embedding space where each finger's prints cluster together. We also incorporate techniques like online hard negative mining (presenting difficult imposter pairs) to further refine the embedding separation. Through this architecture, the system extracts a fixed-length template that encodes multi-level fingerprint features. This approach addresses the core challenges: it retains the discriminative minutiae details used by forensic experts while also capturing broader patterns that help in poor quality situations where minutiae might be missedβ [ar5iv.org]{.underline} β [ar5iv.org]{.underline} . The fixed dimensionality makes the next steps -- template storage and matching -- much more efficient than variable-length minutiae lists used in traditional systems. Fingerprint Template Generation and Storage After the CNN and its dual branches produce the raw feature vectors, the system constructs the final fingerprint template . This template is what gets stored in a database for enrolled fingerprints, or is computed for a query fingerprint at match time. Several considerations are important in template generation: size, format, and inclusion of auxiliary data. Fixed-Length Embedding: The core of the template is the fixed-length numeric vector output by the feature extractor. In our design this might be a 192-dimensional floating-point vector (if using the example above), which in 32-bit floating point would be 192Γ4 = 768 bytes. We apply a compression step to reduce this size without significant loss of accuracy. Specifically, we scale and quantize the vector values to 8-bit integers (0--255 range) and pack them, storing also a small scaling factor. This technique was demonstrated in prior work to compress a 768-byte deep fingerprint into ~200 bytes with negligible impact on accuracyβ [ar5iv.org]{.underline} . Our template thus consists of a fixed-length byte vector on the order of a few hundred bytes. This compact size is ideal for memory and speed -- it's even smaller than many minutiae templates used in industry (which often store 20-60 minutiae points with coordinates and angles, plus metadata). The fixed format also means templates can be compared with simple vector operations (dot products, etc.) instead of complex graph matching. Minutiae Data (Optional): Even though the embedding itself encodes minutiae information, we have the option to include an explicit minutiae list in the template for certain use-cases. For instance, in forensic databases it might be desirable to store the actual minutiae (coordinates, angles) alongside the learned embedding, to allow examiners to visualize the matching points or to interface with legacy AFIS systems. If included, these could be stored in a standardized format (e.g., ISO/ANSI minutiae format) and compressed. However, it's important to note that this is not required for the matching algorithm to function; it's an extra that can be toggled. In many real-time authentication scenarios, we would omit the explicit minutiae list to keep the template minimal. Quality and Mask Bits: The template can also contain a few bytes of metadata, such as a quality score (rating the fingerprint image quality) and the valid region mask mentioned earlier (which can be efficiently stored as a bounding box or bitmask). The quality score can be computed during feature extraction (the network can estimate how reliable the print is), and could be used to reject extremely poor prints or adjust matching thresholds. The mask helps in comparing only the overlapping areas of two prints during matching, which is particularly useful in latent or partial matchesβ [arxiv.org]{.underline} . Storage in Vector Database: Once generated, templates are stored in a database. Instead of a traditional relational database, our system leverages a vector database/index -- a data structure optimized for similarity searches on high-dimensional vectors. Each template is essentially a point in a high-D space. We index them using algorithms like Product Quantization (PQ) or IVF (Inverted File) as implemented in libraries such as Facebook's FAISS, or we use an ANN (Approximate Nearest Neighbor) service (like Milvus, ScaNN, etc.). These indexes partition the space or compress vectors such that searching for nearest neighbors (most similar prints) is extremely fast, even with millions of entries. The storage of templates can thus be thought of in two forms: (1) persistent storage (disk or cloud) of the raw template bytes per fingerprint, and (2) an in-memory or on-disk index structure that accelerates searches. The templates are also small enough to allow memory caching of entire databases for speed if needed. By standardizing the template representation to a vector, we also make the system amenable to secure storage and comparison techniques . For example, since the template is essentially a fixed-length number array, one could apply fully homomorphic encryption to perform comparisons in the encrypted domainβ [ar5iv.org]{.underline} or use secure sketch techniques to protect the templates -- approaches that are not straightforward with unordered minutiae sets. All these considerations mean our template design is compact, interoperable, and secure . Each template encapsulates the fingerprint's essence in a way that is convenient for large-scale computation. Matching and Retrieval Strategies The matching stage is where the algorithm either verifies a claimed identity by comparing two templates (1:1), or identifies an unknown fingerprint by searching a database (1:N). Our algorithm supports both modes efficiently: 1:1 Verification (Authentication) For verification, the system compares a probe fingerprint (the one being verified) to a reference fingerprint (e.g., an enrolled template for the claimed user). The steps are: Template Extraction: The probe fingerprint image goes through the full pipeline described above, producing a probe template (embedding vector, and possibly minutiae or mask auxiliary data). The reference template would typically be pre-stored from an earlier enrollment of the user. Vector Similarity Computation: The primary comparison is done by computing a distance or similarity between the probe and reference embedding vectors. We use a metric like cosine similarity or Euclidean distance in the embedding space. Cosine similarity (or equivalently, normalized dot product) is particularly effective since the network can be trained to produce discriminative features under that metricβ [ar5iv.org]{.underline} . This involves a series of multiplications and additions between the two 192-D vectors -- a very fast operation on modern processors (can be done in microseconds). If the vectors were stored as binary hashes, a Hamming distance could be computed with even greater speed (bit XOR and count of differences). In contrast to minutiae matchers, which require complex geometric alignment and graph matching, this vector distance is computationally trivial β [ar5iv.org]{.underline} . The result is a similarity score (e.g., higher if more similar). Threshold Decision: The similarity score is compared against a pre-determined threshold to decide match vs. non-match. The threshold is tuned based on desired security (FAR/FRR requirements). Because our embedding has a well-behaved distance distribution (thanks to training), we can model the genuine vs impostor score distribution and pick a threshold that meets, say, 0.001% FAR. If the score indicates the probe and reference are the same finger, the system outputs a match (authentication successful); otherwise a non-match (authentication fails). (Optional) Minutiae Match Fusion: In high-security applications, or in cases where an extra layer of assurance is needed (e.g., forensic validation), the system can perform a secondary minutiae-based matching on the same pair. Since the template may include a minutiae set or the network can generate a minutiae map for the probe, a classical minutiae alignment algorithm (like aligning by a few top minutiae and computing a match score based on overlapping minutiae) can be run. This is slower than the vector comparison, but since it's just between one pair, it's still quite feasible in real-time (typically <0.1 seconds with optimized code). We can then fuse the scores from the embedding similarity and the minutiae matcher. For instance, the system might require both the vector similarity to exceed a threshold and the minutiae match score to exceed some threshold, or it may take a weighted average. This fusion can drastically reduce false accepts because it's unlikely for two different fingers to be close in the embedding space and have many minutiae coincide by chanceβ [arxiv.org]{.underline} . In practice, we often find the vector comparison is sufficient for day-to-day use (with FAR on the order of 1e-6 or better), but the minutiae check is available for edge cases (such as very similar fingerprints or for auditing a match decision). The verification process is extremely fast: the heavy-lifting (feature extraction) is done once on the probe. The comparison itself is a vector operation and a threshold check. In fact, prior art has shown that even with the extra overhead of minutiae extraction and alignment folded into a network, such a verification can be done in a split second on a CPUβ [arxiv.org]{.underline} . Our design's use of quantized vectors and potential binary embeddings further accelerates the matchingβ [arxiv.org]{.underline} , making the solution well-suited to devices like smartphones (which may not have powerful CPUs -- here a smaller CNN model like MobileNet can be substituted for extraction, still yielding a comparable fixed-length embedding). 1:N Identification (Search in Database) For identification, the task is: given a probe fingerprint, find the best match(es) in a large database of fingerprint templates. The challenge here is scale -- $N$ might be millions (e.g., national ID or criminal databases). Our algorithm handles 1:N with a multi-stage approach optimized for speed: Probe Template Extraction: Similar to verification, we first obtain the probe's template via the preprocessing and feature extraction pipeline. This yields the probe's embedding vector (and possibly minutiae data). Fast Candidate Retrieval (Vector DB Search): Instead of comparing the probe against each database template one by one (which would be infeasible in real-time for large $N$ ), we leverage the vector index built on the templates. The probe vector is submitted as a query to this ANN (Approximate Nearest Neighbor) search structure. The vector database quickly finds the closest entries in terms of cosine similarity or Euclidean distance. Algorithms like inverted file with product quantization (IVF-PQ) compress the search space and can retrieve top candidates in sub-linear time. For example, in experiments similar to ours, searching a gallery of 1.1 million fingerprints took only 0.3 seconds to retrieve the correct match at rank-1β [arxiv.org]{.underline} -- this is orders of magnitude faster than traditional approaches that required 20+ seconds for the same taskβ [arxiv.org]{.underline} . We typically ask the vector DB for the top K nearest neighbors (e.g., $K=200$ or $K=500$ ) as initial candidates. This step dramatically narrows down the search from millions to a few hundred likely matches. Candidate Re-ranking (Detailed Matching): The small set of candidate templates returned by the ANN search are then examined more closely. We take each candidate and perform a more precise matching against the probe: We compute the exact similarity score with the probe using the full-precision embeddings (if the index used compressed ones). This corrects any slight loss of precision from ANN approximation or quantization. If available, we utilize the minutiae information for these top candidates. For each candidate, we can retrieve its minutiae (either stored or by regenerating the minutiae map via the network) and perform a minutiae matching between the probe and candidate. Because $K$ is small (a few hundred at most), doing a graph-based minutiae match for each is tractable. We then can combine the embedding similarity score and the minutiae match score for a final fused scoreβ [ar5iv.org]{.underline} . For instance, a simple scheme is to add a certain bonus to the similarity score for every minutia pair that matches after alignment. We also consider the overlap mask : if the probe is partial, we ignore differences in areas where the probe has no ridge data and focus only on the overlapping region between probe and candidateβ [arxiv.org]{.underline} . We normalize scores by the effective area compared, so that a probe that matches well on the area it has isn't penalized for being small. The outcome of this stage is a re-ranked list of the candidates sorted by their final match score to the probe. Ideally, the true identity's template (if present in the database) will now rise to the top of this list. Decision or Output: Depending on the application, the system can either automatically select the top match if its score is confidently above others (identification mode), or present the top N candidates to an examiner (forensic investigation mode). In an automated identification setting (like unlocking a phone from a set of enrolled prints or identifying a person in an ID database), one would declare a match if the top score exceeds a threshold and/or the gap to the second score is large. For forensic use, an expert might inspect the top few candidates, with the aid of the system highlighting correspondences. Our use of vector-based retrieval ensures that even large-scale 1:N searches are fast and scalable . The complexity essentially becomes O(log N) or similar (due to the ANN index) for the search part, plus a fixed cost for re-ranking $K$ candidates. This is a massive improvement over naive brute force matching which is $O(N)$ . Moreover, by offloading the heavy work to vector math , we reduce CPU load: as noted, matching via descriptor distance calculations is far less resource-intensive than minutiae graph matching across a large databaseβ [arxiv.org]{.underline} . This makes the system suitable for real-time identification in applications like border control or access systems, and it can linearly scale by adding more compute for parallel searches if needed. Crucially, the combination of the deep embedding search with minutiae re-checking brings high accuracy . The deep embedding serves as a very effective filter -- it has a low false negative rate (it rarely misses the true mate in the top $K$ ) and a manageable false positive rate that is then addressed by minutiae verification. Prior research has shown that this approach can achieve accuracy on par with the best commercial systems. For instance, DeepPrint's search of 1.1M had a Rank-1 accuracy of ~98.8% which was comparable to a top commercial matcher, while being 90Γ fasterβ [arxiv.org]{.underline} . In our design, any remaining false matches at large scales can further be mitigated by techniques like score normalization across the database (to adjust for score distribution shifts when searching millions of templates)β [arxiv.org]{.underline} . The result is a system that doesn't significantly degrade as the database grows -- experiments have shown false match rates remaining extremely low even up to databases of 5 million by using such normalization schemesβ [arxiv.org]{.underline} . Optimizations for Speed and Accuracy Designing for both speed and accuracy is a balancing act. Here we summarize how our algorithm meets both requirements and the optimizations employed: Efficient Neural Network Inference: The CNN architecture can be optimized using techniques like model quantization (using 8-bit integers for inference), pruning (removing redundant channels), or using a smaller backbone (e.g., MobileNetV3 or EfficientNet lite) for deployment on resource-constrained devices. We also can leverage hardware acceleration -- GPUs or NPUs (Neural Processing Units) available on modern smartphones -- to compute the embedding quickly. The feature extraction can be done in tens of milliseconds on a GPU for a single fingerprint. Batch processing and asynchronous pipeline (processing next fingerprint while waiting for I/O) further improve throughput for identification systems. Parallelism: Many stages can run in parallel. In identification mode, after extracting the probe template, the similarity search against the index can be distributed across multiple threads or even machines (since ANN search structures like IVF can be partitioned). Moreover, the re-ranking minutiae matches for top $K$ candidates can be done in parallel on multiple cores. This parallel treatment ensures that even worst-case scenarios (very large $K$ or many close matches to verify) can meet time requirements. Binarized Templates for Fast Matching: We mentioned quantizing the template to bytes. We can push this further to binary strings -- known as binarized embeddings . If we enforce the network to output binary-like codes (via techniques such as adding a sigmoid and rounding or using a hashing layer), the comparison between templates can be done with Hamming distance, which is extremely fast using bit operations. The LDRF method demonstrated that a binary representation significantly reduces matching timeβ [arxiv.org]{.underline} . We can adopt a similar approach where the real-valued 192-d vector is optionally converted to, say, a 1536-bit binary code. This yields fast bit-level comparisons and also saves storage (1536 bits is 192 bytes). In practice, there is a trade-off: perfectly binarizing without loss is hard, but even a slight drop in accuracy might be acceptable for the gain in speed in certain applications. Our system is flexible: high-security mode might use full precision floats for maximal accuracy; high-speed mode might use binary templates for instantaneous matching. Adaptive Matching Workflow: The system can adjust its workflow based on context to optimize performance. For example, in a real-time authentication scenario (like phone unlock), we know the number of enrolled templates is small (just the owner's fingers). In this case, we might skip the vector database search entirely and just compare to the handful of stored templates directly -- which is trivial. We may also decide that minutiae re-check is unnecessary if the network embedding is confident. This cuts down latency. Conversely, in a forensic search scenario , we might accept a slightly longer processing time per query (say a few seconds) to maximize accuracy. So we could use a larger $K$ for candidate retrieval and perform minutiae matching on all of them, and perhaps even use different algorithms (like use both our algorithm's score and a traditional matcher's score in fusion). Thus, the pipeline can be tuned per use-case. Robustness and Accuracy Enhancements: Accuracy is maintained through several means. The hybrid feature approach ensures even if the ridges are poor and minutiae can't be reliably extracted, the texture branch may still identify the fingerprint (e.g., via scars, pores, or partial patterns)β [ar5iv.org]{.underline} . Conversely, if two different fingerprints have very similar global patterns, the minutiae detail will help differentiate them. The system is also robust across sensors -- optical vs. capacitive differences are minimized by training on both and by the network's learned features focusing on intrinsic patterns rather than sensor-specific artifacts. It was observed that a deep representation trained on diverse data is resilient to different impression types and sensing technologiesβ [arxiv.org]{.underline} . Furthermore, by using alignment or alignment-invariant methods, we handle finger rotation and pressure differences. In large-scale settings, as mentioned, score normalization can be applied: for instance, adjusting scores based on how common or rare a fingerprint's features are in the database to reduce false matchesβ [arxiv.org]{.underline} . Scalability: We have essentially ensured scalability by design. The search complexity grows sub-linearly with database size due to ANN indexing. Empirically, systems like this have been shown to scale to millions of fingerprints without significant slow-downβ [arxiv.org]{.underline} . If needed, one can distribute the database across servers (since comparing an embedding to parts of the database can be done independently and then merged). Our approach also drastically simplifies adding new records: one just computes the template and inserts it into the index, rather than dealing with complex gallery update for minutiae (which might involve reorganizing tree structures or such in some traditional AFIS). Fallback to Minutiae Matching: In edge cases such as **severely distorted fingerprints** or incorrect alignment that confound the network (which can happen, as slight alignment errors can affect fixed-length rep more than minutiae matchingβ [arxiv.org]{.underline} ), the system could detect the anomaly (e.g., low similarity scores across the board) and fallback to a full minutiae-based search on those rare cases. This ensures no fingerprint fails to match due to an artifact of the representation. Over time, such cases would also guide improvements in the network (re-training with those failure cases). In conclusion, by combining careful system design (for speed) and the fusion of deep learning with domain-specific features (for accuracy), our fingerprint matching algorithm achieves a state-of-the-art balance. It is capable of running on a smartphone for instant user verification, and equally capable of searching a national fingerprint database with millions of entries in seconds. The use of a learned embedding (vector template) dramatically simplifies and accelerates the matching process, addressing the key limitations of minutiae-only systems (complexity and poor performance on low-quality inputs)β [arxiv.org]{.underline} , while integrating minutiae ensures we do not lose the proven discriminative detail those systems offerβ [ar5iv.org]{.underline} . This synergy yields a fast, scalable, and accurate fingerprint recognition solution for both real-time and forensic contexts. Conclusion We have introduced a novel fingerprint matching and template generation algorithm that unifies traditional biometrics and modern machine learning. The system architecture was detailed from preprocessing to matching, highlighting how each component contributes to either speed or accuracy (and often both). By leveraging a deep CNN to produce fixed-length fingerprint embeddings, we gain computational efficiency -- large-scale searches can be executed with simple vector operationsβ [ar5iv.org]{.underline} -- and by embedding minutiae information into this network, we maintain the fine-grained accuracy needed for distinguishing even very similar fingerprints. The algorithm handles various fingerprint image types (optical, capacitive, latent) through adaptive preprocessing and robust feature extraction, and it supports both verification and identification modes. This approach is in line with the latest advances in the field: for example, fixed-length deep representations have been shown to outperform or match traditional matchers on huge databases while being much fasterβ [arxiv.org]{.underline} , and researchers have noted that a deeper integration of learned features with minutiae can further boost performanceβ [arxiv.org]{.underline} -- our system realizes this integration. In practical terms, the algorithm's use of vector databases and ANN search makes it readily deployable in cloud or edge environments where rapid identification is required. The template design is compact and can be secured with encryption, addressing privacy concerns. Overall, the proposed algorithm is a cutting-edge solution aimed at real-world deployments: it can authenticate a user via fingerprint in real-time on a mobile device, and just as easily sift through millions of fingerprints in a forensic database. This fusion of deep learning embeddings with classical fingerprint features represents a new generation of fingerprint recognition systems that are both fast and accurate , meeting the demands of modern biometric applications. References: The design and rationale of our approach are supported by existing studies and results in the literature. For instance, our hybrid feature strategy is inspired by DeepPrint's network which combines minutiae and deep featuresβ [ar5iv.org]{.underline} β [ar5iv.org]{.underline} , and the robustness across sensors and partial prints is evidenced by studies like LDRF which emphasize localized representations and pose normalizationβ [arxiv.org]{.underline} β [arxiv.org]{.underline} . The performance claims (speed and accuracy) are grounded in reported benchmarks where deep learning-based templates achieved fast search in large databases with accuracy on par with top commercial systemsβ [arxiv.org]{.underline} . By building on these insights and adding novel contributions (such as an improved fusion and vector-index integration), we formulated an algorithm that pushes the envelope in fingerprint recognition technology. {width="4.760416666666667in" height="5.0625in"} Global (Level-1) fingerprint features: an example fingerprint with ridge flow patterns and singular points ( cores marked by red dots, deltas by blue triangles). These global features aid in alignment and classification of fingerprintsβ [ar5iv.org]{.underline} β [ar5iv.org]{.underline} . {width="5.010416666666667in" height="5.020833333333333in"} Local (Level-2) fingerprint features: the same fingerprint with minutiae (ridge endings/bifurcations) marked in blue. Minutiae are the primary features used in traditional fingerprint matching due to their permanence and uniquenessβ [arxiv.org]{.underline} . Our algorithm leverages both levels of features by encoding minutiae information within a deep neural network's learned representation.
2. Related Work, Literature Survey & Algorithmic Foundations
Fingerprint Matching Using AI in Python This project demonstrates a secure, AI-driven fingerprint recognition system implemented in Python. It explores classical machine learning and deep learning models such as SVM, CNN, and Siamese Networks for accurate, fast, and scalable biometric authentication. Focus: AI, ML, Pattern Recognition, Biometrics Author: Yuvaraj β 2022504554 Abstract Fingerprint matching is one of the most widely used biometric authentication methods. This project integrates AI techniques with Python to build a fingerprint matching system that can: Compare fingerprint images Classify match vs. no-match Handle real-world noise and variations It uses traditional feature extraction (minutiae, ridge flow) and modern deep learning models (CNNs, Siamese Networks) for robust performance. Technologies Used Python 3.x TensorFlow / Keras OpenCV Scikit-learn FVC / SOCOFing Dataset Methodology Data Collection β Public datasets (Kaggle, NIST, SOCOFing) Preprocessing β Grayscale, normalization, enhancement, filtering Feature Extraction Minutiae (ridges, bifurcations) CNN-based auto-features Model Training SVM, Random Forest CNN / Siamese Network Evaluation Accuracy, FAR, FRR, Precision/Recall Folder Structure fingerprint-matching-ai/ βββ fingerprint_matching.py βββ Fingerprint_Matching_Report.pdf βββ dataset/ β βββ sample1_real.png, sample2_altered.png βββ images/ β βββ system_flowchart.png β βββ matching_result.png Sample Flowchart Results High-accuracy CNN-based model Siamese network for similarity matching Score-based output showing fingerprint pair match quality Future Scope Multimodal biometrics (face + fingerprint + voice) One-shot learning using Siamese Networks Spoofing detection with AI Edge computing deployment (on-device recognition) Explainable AI (XAI) for decision transparency References Jain, A. K., et al. Handbook of Biometrics, Springer. Goodfellow, I. β GANs for Fingerprint Matching Kaggle Dataset: SOCOFing Author Yuvaraj V β 2022504554 MIT Campus, Anna University License This project is shared for educational and academic use.
3. Dataset Ingestion, Preprocessing & Stochastic Augmentations
Fingerprint Recognition System A research-grade fingerprint recognition system implementing both traditional computer vision approaches (ORB features) and modern deep learning methods for biometric authentication and analysis. Overview This project demonstrates a comprehensive fingerprint recognition pipeline suitable for research and educational purposes. It combines: Traditional CV : ORB (Oriented FAST and Rotated BRIEF) feature detection and matching Deep Learning : CNN-based embedding extraction using ResNet/EfficientNet backbones Ensemble Methods : Combined approach for robust fingerprint matching Biometric Metrics : EER, DET curves, FAR/FRR analysis, and ROC evaluation Interactive Demo : Streamlit web interface for enrollment and verification Features Core Capabilities Fingerprint enrollment and verification Multiple matching algorithms (ORB, Deep Learning, Ensemble) Synthetic fingerprint generation for testing Comprehensive biometric evaluation metrics Real-time interactive web interface Technical Highlights Modern Python 3.10+ with type hints PyTorch 2.x with device auto-detection (CUDA/MPS/CPU) Deterministic seeding for reproducibility Comprehensive logging and error handling Modular, extensible architecture Installation Prerequisites Python 3.10 or higher CUDA-compatible GPU (optional, for acceleration) macOS with Apple Silicon (optional, for MPS acceleration) Setup Clone the repository git clone https://github.com/kryptologyst/Fingerprint-Recognition-System.git cd Fingerprint-Recognition-System Create virtual environment python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate Install dependencies pip install -e . Install development dependencies (optional) pip install -e " .[dev] " Quick Start 1. Generate Demo Data python scripts/generate_demo_data.py 2. Run Interactive Demo streamlit run demo/app.py 3. Train Models (Optional) python scripts/train_model.py --config configs/config.yaml 4. Evaluate Performance python scripts/evaluate_model.py --config configs/config.yaml Usage Interactive Web Interface Launch the Streamlit demo: streamlit run demo/app.py The web interface provides: Enrollment : Upload and register fingerprint images Verification : Test fingerprint matching against enrolled users Analysis : View performance metrics and visualizations Demo Data : Generate synthetic fingerprints for testing Programmatic Usage from src . utils import load_config , detect_device , set_seed from src . models import FingerprintMatcher from src . data import DataManager # Load configuration config = load_config ( "configs/config.yaml" ) # Set up device and seeding device = detect_device () set_seed ( config . reproducibility . seed ) # Initialize matcher matcher = FingerprintMatcher ( config , device ) # Load images import cv2 img1 = cv2 . imread ( "fingerprint1.jpg" , cv2 . IMREAD_GRAYSCALE ) img2 = cv2 . imread ( "fingerprint2.jpg" , cv2 . IMREAD_GRAYSCALE ) # Match fingerprints is_match , similarity = matcher . match_fingerprints_deep ( img1 , img2 ) print ( f"Match: { is_match } , Similarity: { similarity :.3f } " ) Project Structure fingerprint-recognition/ βββ src/ # Source code β βββ data/ # Data pipeline and synthetic generation β βββ models/ # Fingerprint recognition models β βββ eval/ # Evaluation metrics and visualization β βββ utils/ # Utility functions β βββ viz/ # Visualization tools βββ configs/ # Configuration files βββ data/ # Data directories β βββ raw/ # Raw fingerprint images β βββ processed/ # Processed data β βββ synthetic/ # Generated synthetic data βββ scripts/ # Training and evaluation scripts βββ demo/ # Streamlit demo application βββ tests/ # Unit tests βββ assets/ # Model weights and results β βββ models/ # Saved model checkpoints β βββ results/ # Evaluation results and plots βββ notebooks/ # Jupyter notebooks for analysis βββ docs/ # Documentation Configuration The system is configured via YAML files in the configs/ directory. Key configuration areas: Data Configuration Image preprocessing parameters Data augmentation settings Train/validation/test splits Synthetic data generation parameters Model Configuration ORB feature detector parameters Deep learning backbone selection Embedding dimensions Matching thresholds Evaluation Configuration Biometric metrics (EER, FAR/FRR targets) Cross-validation settings Visualization parameters Models ORB Feature Matching Traditional computer vision approach using: Oriented FAST keypoint detection Rotated BRIEF descriptors Brute-force Hamming distance matching RANSAC-based geometric verification Deep Learning Embeddings Modern CNN-based approach using: ResNet/EfficientNet backbones Triplet/contrastive loss training L2-normalized embeddings Cosine similarity matching Ensemble Method Combined approach that: Weights ORB and deep learning scores Provides robust matching across conditions Balances speed and accuracy Evaluation Metrics Biometric-Specific Metrics EER (Equal Error Rate) : Point where FAR = FRR FAR (False Acceptance Rate) : Rate of impostor acceptance FRR (False Rejection Rate) : Rate of genuine rejection DET Curves : Detection Error Trade-off visualization ROC Curves : Receiver Operating Characteristic analysis Performance Metrics AUC : Area Under ROC Curve Precision/Recall : Classification performance Processing Time : Latency analysis Memory Usage : Resource consumption Dataset Schema Synthetic Fingerprint Generation The system generates realistic synthetic fingerprints using: Mathematical ridge pattern models Noise injection for realism Multiple samples per identity Configurable image sizes and quality Data Format Images : Grayscale PNG/JPEG format Labels : Integer user IDs Metadata : Timestamps, quality scores, augmentation info Security and Privacy Data Handling No real biometric data included Synthetic data generation only PII removal and hashing Secure file handling Model Security No production credentials Research-only implementations Defensive simulation focus No exploitation capabilities Limitations and Disclaimers Research Purpose Only This system is designed for research and educational purposes only. It is NOT suitable for: Production security operations Real-world biometric authentication Security-critical applications Commercial deployment Accuracy Limitations Synthetic data may not reflect real-world performance Models are not trained on production datasets Performance metrics are for demonstration only No guarantee of accuracy or reliability Privacy Considerations No real biometric data is processed All examples use synthetic or anonymized data System includes privacy-preserving features Compliant with research ethics guidelines Contributing Development Setup Install development dependencies: pip install -e ".[dev]" Set up pre-commit hooks: pre-commit install Run tests: pytest tests/ Format code: black src/ tests/ Lint code: ruff check src/ tests/ Code Style Follow PEP 8 guidelines Use type hints throughout Include comprehensive docstrings Write unit tests for new features License This project is licensed under the MIT License. See LICENSE file for details. Citation If you use this code in your research, please cite: @software { fingerprint_recognition_2024 , title = { Fingerprint Recognition System: Research-Grade Biometric Authentication } , author = { Kryptologyst } , year = { 2026 } , url = { https://github.com/kryptologyst/Fingerprint-Recognition-System } } Support For questions, issues, or contributions: Create an issue on GitHub Check the documentation in docs/ Review example notebooks in notebooks/ Changelog Version 1.0.0 Initial release with ORB and deep learning models Interactive Streamlit demo Comprehensive evaluation framework Synthetic data generation Research-grade implementation Disclaimer : This is a research demonstration system. Not suitable for production security operations or real-world biometric authentication systems. Fingerprint-Recognition-System
4. Neural Network Backbone, Layer Specifications & Loss Formulations
This repository contains a project for Biometrics Recognition Reconstructing Fingerprint Images Using Deep Learning (Convolutional Autoencoder). Systems for recognizing fingerprints have been used extensively to implement precise and trustworthy biometric identification between people. Pattern recognition in computer vision has greatly benefited from deep learning, particularly Convolutional Neural Networks (CNN). In this work, fingerprint images have been reconstructed using a convolutional neural network autoencoder. An autoencoder is a method that can reproduce information in pictures. The advantage of convolutional neural networks makes it suitable for feature extraction. Note This project utilizes deep learning techniques for fingerprint image reconstruction. The code has been executed using an NVIDIA L40S GPU with 48 gigabytes (GB) of memory capacity, which provides the necessary computational power for training the convolutional autoencoder model. Ensure your system has appropriate GPU capabilities to run this project efficiently. torch . cuda . get_device_name () 'NVIDIA L40S' Table of Contents Data Exploration The Convolutional Autoencoder Save Model Going Further Data Exploration The datasets used in this project are from a collection of human fingerprint datasets suitable for research and evaluation of fingerprint recognition algorithms. While there are several datasets available from various sensors, this project utilizes the following: Public rectangular datasets FVC2000 DB1 B FVC2000 DB2 B FVC2000 DB3 B FVC2000 DB4 B FVC2002 DB1 B FVC2002 DB2 B FVC2002 DB3 B FVC2002 DB4 B FVC2004 DB1 B FVC2004 DB2 B FVC2004 DB3 B FVC2004 DB4 B Neurotechnology CrossMatch Neurotechnology UareU FVS dataset Licensed rectangular datasets FVC2002 DB3 A The data is split into three sets: training, validation, and testing. For training and validation, I use the FVC and Neurotechnology datasets. The test data, which is never seen during training, comes from the FVS dataset. This ensures a fair evaluation of the model's performance on unseen data. If you want to access the complete collection of datasets used in this project, please visit my fingerprint-datasets repository. # Shapes of training set print ( "Dataset (images) shape: {shape}" . format ( shape = images_arr . shape )) # Output Dataset ( images ) shape : ( 2688 , 224 , 224 ) As we can see, we have a total of 2688 images for training and validation, excluding the test set. The images in our dataset are grayscale with pixel values ranging from 0 to 255 and dimensions of 224 x 224. Before feeding the data into the model, we reshape each image into a matrix of size 224 x 224 x 1: images_arr = images_arr . reshape ( - 1 , 224 , 224 , 1 ) # Output New shape : ( 2688 , 224 , 224 , 1 ) We ensure the data type of the NumPy array is float32 and rescale the pixel values to the range 0-1 inclusive. Next, in data partitioning we split the data into 80% for training and 20% for validation. from sklearn . model_selection import train_test_split train_X , valid_X , train_ground , valid_ground = train_test_split ( images_arr , images_arr , test_size = 0.2 , random_state = 13 ) Important For this autoencoder task, we don't need separate labels. The training images serve as both input and ground truth, similar to the labels in a classification task. The Convolutional Autoencoder An encoder and a decoder are the two components that make up the autoencoder, as you may already be aware. The encoder The first layer will have 32 filters of size 3 x 3, which will be followed by a downsampling (max-pooling) layer. The second layer will have 64 filters of size 3 x 3, and still another downsampling layer. The final layer of encoder will have 128 filters of size 3 x 3. The decoder The first layer will have 128 filters of size 3 x 3 followed by an upsampling layer. The second layer will have 64 filters of size 3 x 3 followed by another upsampling layer. The final layer of encoder will have one filter of size 3 x 3. In this model, we use a batch size of 128. Depending on your system's capabilities, using a higher batch size of 256 or 512 may also be preferable. The batch size significantly contributes to determining the learning parameters and affects prediction accuracy and we train the model for 200 epochs. batch_size = 128 epochs = 200 inChannel = 1 x , y = 224 , 224 input_img = Input ( shape = ( x , y , inChannel )) Note The number of layers, the number of filters, the filter size, and the number of epochs you train your model are all hyperparameters that should be chosen based on your own intuition. You can experiment with these values to see how your model performs. You will gradually master the art of deep learning in this way! def autoencoder ( input_img ): #encoder #input = 28 x 28 x 1 (wide and thin) conv1 = Conv2D ( 32 , ( 3 , 3 ), activation = 'relu' , padding = 'same' )( input_img ) #28 x 28 x 32 pool1 = MaxPooling2D ( pool_size = ( 2 , 2 ))( conv1 ) #14 x 14 x 32 conv2 = Conv2D ( 64 , ( 3 , 3 ), activation = 'relu' , padding = 'same' )( pool1 ) #14 x 14 x 64 pool2 = MaxPooling2D ( pool_size = ( 2 , 2 ))( conv2 ) #7 x 7 x 64 conv3 = Conv2D ( 128 , ( 3 , 3 ), activation = 'relu' , padding = 'same' )( pool2 ) #7 x 7 x 128 (small and thick) #decoder conv4 = Conv2D ( 128 , ( 3 , 3 ), activation = 'relu' , padding = 'same' )( conv3 ) #7 x 7 x 128 up1 = UpSampling2D (( 2 , 2 ))( conv4 ) # 14 x 14 x 128 conv5 = Conv2D ( 64 , ( 3 , 3 ), activation = 'relu' , padding = 'same' )( up1 ) # 14 x 14 x 64 up2 = UpSampling2D (( 2 , 2 ))( conv5 ) # 28 x 28 x 64 decoded = Conv2D ( 1 , ( 3 , 3 ), activation = 'sigmoid' , padding = 'same' )( up2 ) # 28 x 28 x 1 return decoded After creating the model, I compile it using the RMSprop optimizer. The loss parameter is set to 'mean_squared_error', as the loss after each batch will be calculated using mean squared error pixel by pixel between the batch of predicted output and the ground truth: autoencoder_model = Model ( input_img , autoencoder ( input_img )) autoencoder_model . compile ( loss = 'mean_squared_error' , optimizer = RMSprop ()) Here's a summary of the model architecture: Model : "functional_1" βββββββββββββββββββββββββββββββββββ³βββββββββββββββββββββββββ³ββββββββββββββββ β Layer ( type ) β Output Shape β Param # β β‘βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ© β input_layer_1 ( InputLayer ) β ( None , 224 , 224 , 1 ) β 0 β βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββΌββββββββββββββββ€ β conv2d_6 ( Conv2D ) β ( None , 224 , 224 , 32 ) β 320 β βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββΌββββββββββββββββ€ β max_pooling2d_2 ( MaxPooling2D ) β ( None , 112 , 112 , 32 ) β 0 β βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββΌββββββββββββββββ€ β conv2d_7 ( Conv2D ) β ( None , 112 , 112 , 64 ) β 18 , 496 β βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββΌββββββββββββββββ€ β max_pooling2d_3 ( MaxPooling2D ) β ( None , 56 , 56 , 64 ) β 0 β βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββΌββββββββββββββββ€ β conv2d_8 ( Conv2D ) β ( None , 56 , 56 , 128 ) β 73 , 856 β βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββΌββββββββββββββββ€ β conv2d_9 ( Conv2D ) β ( None , 56 , 56 , 128 ) β 147 , 584 β βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββΌββββββββββββββββ€ β up_sampling2d_2 ( UpSampling2D ) β ( None , 112 , 112 , 128 ) β 0 β βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββΌββββββββββββββββ€ β conv2d_10 ( Conv2D ) β ( None , 112 , 112 , 64 ) β 73 , 792 β βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββΌββββββββββββββββ€ β up_sampling2d_3 ( UpSampling2D ) β ( None , 224 , 224 , 64 ) β 0 β βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββΌββββββββββββββββ€ β conv2d_11 ( Conv2D ) β ( None , 224 , 224 , 1 ) β 577 β βββββββββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββ΄ββββββββββββββββ Total params : 314 , 625 ( 1.20 MB ) Trainable params : 314 , 625 ( 1.20 MB ) Non - trainable params : 0 ( 0.00 B ) Finally, it's time to use Keras' fit() function to train the model! Before that, I have trained the model using 200 epochs, and the validation loss and training loss are both in sync. This shows that my model is not overfitting: the validation loss is decreasing and not increasing. Then, I trained for another 200 epochs using the previously trained model, which means I tried to train for a total of 400 epochs. autoencoder_train = autoencoder_model . fit ( train_X , train_ground , batch_size = batch_size , epochs = epochs , verbose = 1 , validation_data = ( valid_X , valid_ground )) Training output: Epoch 1 / 200 17 / 17 ββββββββββββββββββββ 4 s 179 ms / step - loss : 0.0080 - val_loss : 0.0070 Epoch 2 / 200 17 / 17 ββββββββββββββββββββ 2 s 104 ms / step - loss : 0.0069 - val_loss : 0.0062 Epoch 3 / 200 17 / 17 ββββββββββββββββββββ 2 s 104 ms / step - loss : 0.0065 - val_loss : 0.0063 ... Epoch 198 / 200 17 / 17 ββββββββββββββββββββ 2 s 104 ms / step - loss : 0.0053 - val_loss : 0.0050 Epoch 199 / 200 17 / 17 ββββββββββββββββββββ 2 s 105 ms / step - loss : 0.0052 - val_loss : 0.0052 Epoch 200 / 200 17 / 17 ββββββββββββββββββββ 2 s 105 ms / step - loss : 0.0053 - val_loss : 0.0052 Now, let's plot the loss plot between training and validation data to visualize the model performance after 400 epochs. The performance of the model after training is quantified by its mean_squared_error metric: # Calculate loss on validation data loss = autoencoder_model . evaluate ( valid_X , valid_ground ) # This will return the loss # If the model was compiled with loss='mean_squared_error', this value is the metric you're looking for. print ( f'Validation Loss: { loss :.4f } ' ) 17 / 17 ββββββββββββββββββββ 1 s 7 ms / step - loss : 0.0055 Validation Loss : 0.0052 Note Keep in mind that autoencoders are typically used for reconstruction tasks, and the more commonly used metric is loss (such as Mean Squared Error) rather than accuracy. The autoencoder model demonstrates effective reconstruction with low loss (0.0055) and a slightly higher validation loss (0.0052), indicating good generalization without significant overfitting. The small difference between the two suggests the model is stable and performs well on unseen data, utilizing RMSprop and Mean Squared Error (MSE) for optimization and error measurement. Now we validate the model using validation data for predicting on the model that you trained just now. decoded_imgs = autoencoder_model . predict ( valid_X ) # Using validation for prediction n = 10 # number of images to display plt . figure ( figsize = ( 20 , 4 )) for i in range ( n ): # Original image ax = plt . subplot ( 2 , n , i + 1 ) plt . imshow ( valid_X [ i ]. reshape ( 224 , 224 ), cmap = 'gray' ) plt . title ( "Original" ) plt . axis ( 'off' ) # Reconstructed image ax = plt . subplot ( 2 , n , i + 1 + n ) plt . imshow ( decoded_imgs [ i ]. reshape ( 224 , 224 ), cmap = 'gray' ) plt . title ( "Reconstructed" ) plt . axis ( 'off' ) plt . show () From the above figures, we can see that the model successfully reconstructed the validation images. So after that, we test the model using test data. For your information, the trained data uses image type .tiff and in test data we can use another sensor and different type which in test data uses image type .bmp. But before using test data, make sure the image for testing has been preprocessed like the code above. After that: # Use the trained model to predict predicted_images = autoencoder_model . predict ( new_images_arr ) # Sample a random subset of indices sample_indices = random . sample ( range ( len ( new_images_arr )), 10 ) plt . figure ( figsize = ( 20 , 4 )) for i , index in enumerate ( sample_indices ): # Original Image ax = plt . subplot ( 2 , 10 , i + 1 ) plt . imshow ( new_images_arr [ i ]. reshape ( 224 , 224 ), cmap = 'gray' ) plt . title ( "Original" ) plt . axis ( 'off' ) # Reconstructed Image ax = plt . subplot ( 2 , 10 , i + 1 + 10 ) plt . imshow ( predicted_images [ i ]. reshape ( 224 , 224 ), cmap = 'gray' ) plt . title ( "Reconstructed" ) plt . axis ( 'off' ) plt . show () From the above figures, we can observe that our model did a great job in reconstructing the Secugen test images that can be predicted using the trained model. as we all know, to evaluate how well the reconstruction result of the autoencoder model performs, in addition to MSE, I want to use Gradient-weighted Class Activation Mapping (Grad-CAM) to visualize which parts of the input images contribute most to the model's output, even in the context of autoencoders. Although Grad-CAM is typically used for classification models, it can be adapted for use with autoencoders to understand the features that the model has learned and how they relate to the reconstruction process. How Grad-CAM Works: Gradient Computation: Using the feature maps of the last convolutional layer, Grad-CAM calculates the gradients of the class scores. The significance of each feature map for class prediction is indicated by these gradients. Weighted Feature Maps: The feature maps are weighted using the gradients to highlight the regions that have a greater impact on the choice. Heatmap Generation: The areas of the image that the model concentrated on for its reconstruction are then highlighted in a heatmap. def generate_gradcam ( model , img_array , layer_name , class_index ): grad_model = tf . keras . models . Model ( inputs = model . input , outputs = [ model . get_layer ( layer_name ). output , model . output ]) with tf . GradientTape () as tape : conv_outputs , predictions = grad_model ( tf . expand_dims ( img_array , axis = 0 )) loss = predictions [ 0 ][ class_index ] # Change to the appropriate class index grads = tape . gradient ( loss , conv_outputs ) pooled_grads = tf . reduce_mean ( grads , axis = ( 0 , 1 )) conv_outputs = conv_outputs [ 0 ] heatmap = conv_outputs @ pooled_grads [..., tf . newaxis ] heatmap = tf . maximum ( heatmap , 0 ) heatmap /= tf . reduce_max ( heatmap ) return heatmap . numpy () layer_name = 'conv2d_5' # Specify the convolutional layer name class_index = 0 # Placeholder value since autoencoders don't have classes heatmap = generate_gradcam ( autoencoder_model , new_images_arr [ 0 ], layer_name , class_index ) # Display the heatmap plt . imshow ( heatmap , cmap = 'jet' ) plt . colorbar () plt . show () In the above Grad-CAM image, the red color indicates areas with high activation, while the blue color indicates areas with low activation. This indicates the parts of the image that contribute most to the model's decision to classify the fingerprint. Save Model So last but not least, let's now save the trained model. It is an important step when you are working with Deep Learning. Since the weights are the heart of the solution to the problem you are tackling at hand! You can anytime load the saved weights in the same model and train it from where your training stopped. For example, the above model if trained again, the parameters like weights, biases, the loss function, etc. will not start from the beginning and it will no longer be a fresh training. # Save the complete model with architecture and weights autoencoder_model . save ( 'autoencoder_complete_model.h5' ) # Load the complete model from the .h5 file loaded_model = load_model ( 'autoencoder_complete_model.h5' ) Going Further So this project was a good start to understanding how to read images from scratch, analyze, preprocess and feed them into the model using a fingerprint dataset. It showed you one of the nice applications of autoencoders practically. If you were able to follow along easily or even with a little more effort, well done! If this project is useful, star the repo and don't forget to follow me to look forward to the next projects. Don't forget to support me π₯Ίππ:
5. Training Protocol, Convergence Behavior & Experimental Evaluation
Model Figures & Evaluation Curves (4 Images)
Deep Learning Execution Pipeline
(Preprocessing)
(Feature Extraction)
(Self-Attention)
(Loss Optimization)