This project focuses on detecting fake and real Indian currency notes using deep learning. The goal was to build an end-to-end system that can accurately classify currency images as real or fake, utilizing both image data and extracted note features.
The project consists of four major notebooks:
01_Base_Model_Training.ipynb— Builds and trains the base model using transfer learning.02_Two_Branch_Model_Training.ipynb— Enhances the model using a two-branch architecture combining image and feature embeddings.03_Feature_Enhancements.ipynb— Fine-tunes the base model for improved performance.04_Attention_Enhanced_Model.ipynb— Implements attention mechanisms (CBAM) for further performance improvement.
To train a baseline convolutional neural network using MobileNetV2 as a pretrained feature extractor for classifying real vs fake currency notes.
- Loaded the dataset of real and fake currency images using OpenCV.
- Preprocessed images (resizing to 224×224, normalization, RGB conversion).
- Created TensorFlow datasets for efficient loading and batching.
- Used MobileNetV2 (ImageNet pretrained) as a frozen feature extractor.
- Added custom classification layers on top of the base model.
- Trained the model using Adam optimizer with callbacks like EarlyStopping, ModelCheckpoint, and ReduceLROnPlateau.
- Architecture: MobileNetV2 + Dense layers
- Input Shape: (224, 224, 3)
- Loss: Binary Cross-Entropy
- Optimizer: Adam
- Best Validation Accuracy: ~99.06%
Epoch 20/20
187/187 ━━━━━━━━━━━━━━━━━━━━ 10s 44ms/step - accuracy: 0.9991 - loss: 0.0065 - val_accuracy: 0.9906 - val_loss: 0.0322
Models/best_model.h5
To improve classification accuracy by integrating both main image features and currency-specific precomputed feature embeddings into a unified two-branch neural network.
- Loaded the pretrained base model (
best_model.h5) and froze its layers. - Built a feature extractor from the last convolutional layer of the base model.
- Precomputed embeddings for all feature images (e.g., watermark, security thread, color patterns) and stored them as
.npyfiles. - Designed a custom data generator (
TwoBranchEmbeddingGenerator) to load both the main image and precomputed embeddings during training. - Created a Two-Branch Neural Network:
- Branch 1: Image branch (MobileNetV2 + dense layers)
- Branch 2: Feature embedding branch (fully connected layers)
- Combined using concatenation followed by dense layers.
- Trained using similar callbacks as the base model.
- Architecture: Two-Branch CNN (Image + Embedding)
- Feature Extractor: MobileNetV2 (frozen)
- Loss: Binary Cross-Entropy
- Optimizer: Adam
- Best Validation Accuracy: ~98.59%
Epoch 11/15
745/745 ━━━━━━━━━━━━━━━━━━━━ 260s 350ms/step - accuracy: 0.9949 - loss: 0.0158 - val_accuracy: 0.9859 - val_loss: 0.0567
Models/best_two_branch_model.keras
Fine-tune the base MobileNetV2 model to improve accuracy and generalization.
- Loaded the pretrained base model (
best_model.h5) and unfroze deeper layers for fine-tuning. - Compiled the model with a very low learning rate to prevent catastrophic forgetting.
- Used EarlyStopping, ReduceLROnPlateau, and ModelCheckpoint callbacks.
- Trained the fine-tuned model on the original dataset.
- Visualized training accuracy and loss.
- Architecture: MobileNetV2 (fine-tuned) + Dense layers
- Input Shape: (224, 224, 3)
- Loss: Binary Cross-Entropy
- Optimizer: Adam (low learning rate)
- Best Validation Accuracy: ~99.66%
Epoch 10/10
187/187 ─ 9s 49ms/step - accuracy: 0.9984 - loss: 0.0060 - val_accuracy: 0.9832 - val_loss: 0.0504
Models/fine_tuned_base_model.keras
Further improve model performance using attention mechanisms (CBAM) to focus on key regions of currency images.
- Loaded fine-tuned base model and applied CBAM blocks to enhance feature representation.
- Added GlobalAveragePooling and Dense layers after attention.
- Compiled and trained the attention-enhanced model with callbacks.
- Evaluated the model using accuracy, confusion matrix, precision, recall, f1-score, and ROC-AUC.
- Achieved robust classification performance with minimal misclassifications.
- Architecture: MobileNetV2 + CBAM + Dense layers
- Loss: Binary Cross-Entropy
- Optimizer: Adam
- Evaluation Metrics: Accuracy, Precision, Recall, F1-score, ROC-AUC
- Best Validation Accuracy: ~98–99%
Confusion Matrix:
[[489 13]
[ 18 969]]
Classification Report:
precision recall f1-score support
Fake 0.96 0.97 0.97 502
Real 0.99 0.98 0.98 987
ROC-AUC Score: 0.9986
Models/attention_enhanced_model.keras
Below plots will be added in future updates:
- Accuracy and Loss curves for both models
- Confusion Matrix
- Sample Predictions Visualization
- ROC-AUC Curve
├── 01_Base_Model_Training.ipynb
├── 02_Two_Branch_Model_Training.ipynb
├── 03_Feature_Enhancements.ipynb
├── 04_Attention_Enhanced_Model.ipynb
├── Models
│ ├── best_model.h5
│ ├── best_two_branch_model.keras
│ ├── fine_tuned_base_model.keras
│ └── attention_enhanced_model.keras
└── README.md
- TensorFlow / Keras
- OpenCV (cv2)
- NumPy
- scikit-learn
- matplotlib
- tqdm