Giter Club home page Giter Club logo

bkataru / fake-currency-identification Goto Github PK

View Code? Open in Web Editor NEW
21.0 2.0 4.0 259.82 MB

Uses retrained MobileNetV2 classification models to determine whether an Indian currency note is fake or real (based on watermark and fluorescent strip)

License: GNU General Public License v3.0

Python 100.00%
currency-detection currency-images opencv deep-learning cnn-keras convolutional-neural-networks mobilenetv2 mobilenet vgg16 vgg16-model keras tensorflow fake-currency

fake-currency-identification's Introduction

Fake Currency Identification

Frontlight Backlight Ultraviolet light

Abstract

Uses Deep Learning Neural Networks to determine whether an Indian currency note is fake or real.

Technical

Uses retrained MobileNetV2 (and VGG16) image classification models to determine whether an Indian currency note is fake or real. The process happens in three steps:

  1. Currency Classification Model: Identifies the denomination, type (old or new), face orientation (front or back), and alignment (up or down) from a frontlight image of the note.
  2. Watermark Identification Model: Identifies whether the note contains the Gandhi watermark under backlight illumination from a backlight image of the note.
  3. Ultraviolet Strip Detection Model: Identifies whether the note contains a fluorescent strip or not and if yes then whether the strip is continuous or dashed under Ultraviolet illumination from a ultraviolet image of the note.

The models were meant to be integrated together to run on a Raspberry Pi (hence the choice of MobileNet for the architecture) but you can strip and use each model individually if you like.

Trained and tested on 16 GB of RAM, i7-8750H, and a GTX 1060 all at stock settings.

A Bit of History

Initially, I tried using KNN-based ORB feature matching to compare features of currency images and detect currency denominations but that ended up being highly inaccurate. I later tried running OCR using Tesseract in hopes of detecting the denomination which sort of worked but more often than not didn't. Eventually, I settled on using Convolutional Neural Networks for my task.

Getting Started

Explore around the folders in the project and check out the code. I've placed text files at appropriate places/folders to act as instructions that will guide you in case you want to do any sort of training yourself. This repo has all the code files you need for retraining, transfer learning, or testing any of my models.

The models were trained on Indian currency notes but you can retrain them for other note images provided you have sufficiently diverse data, regardless of how big it is. Take my setup as an example, I had five-seven unique images of every note which is not much considering the fact that there are only 10-12 varieties of Indian currency notes. So even though I only had about a 100 or so samples, with the help of randomized data augmentation, I strategically generated a vast and diverse dataset of 9000-12000 images using those very samples.

NOTE: The UV model must be supplied UV light images whereas the Watermark model must be supplied backlit images with the transparent features visible.

Cool things you can try when training/retraining

Some suggestions in case you feel experimental or are facing issues with accuracy and loss:

  • Freezing layers and adding more output layers. My model doesn't have any additional dense layers apart from the softmax output layer. You could try adding more layers or making certain layers untrainable.
  • Changing optimizers, loss functions, and their parameters. By default I use SGD with a learning rate of 0.001 for the MobileNet models and RMSProp for the VGG16 models with a learning rate of 0.0001 and a decay of 10^-4.
  • Adding Dropout and Batch Normalization to the output layers.
  • Adding/tuning regularizer and initializer parameters to the bias and kernel of layers.

Example usage

NOTE: I've only included my retrained MobileNetV2 models and not the VGG16 models because the former are much smaller in size (~17 mb) when compared to the 1 gb VGG16 models. If you intend to use VGG16 you will have to train a model from scratch using the code samples I've provided.

MobileNetV2

foo@bar:~$ cd CNN-based-classification-(PRIMARY)
foo@bar:~$ cd mobilenet-model

# Training a new classification model from scratch using data located in ./dataset/
foo@bar:~$ python3 retrained_mobilenet_train.py

# Testing a pretrained model
foo@bar:~$ python3 retrained_mobilenet_test.py

# Testing a lite version of the same model
foo@bar:~$ python3 lite_run.py

# Converting a Keras .h5 model to tflite
foo@bar:~$ python3 convert_to_lite.py

VGG16

foo@bar:~$ cd CNN-based-classification-(PRIMARY)
foo@bar:~$ cd vgg16-model

# Training a new classification model from scratch using data located in ./dataset/
foo@bar:~$ python3 pretrained_vgg16_train.py

# Running a pretrained model
foo@bar:~$ python3 pretrained_vgg16_test.py

# Running a lite version of the same model
foo@bar:~$ python3 lite_run.py

# Converting a Keras .h5 model to tflite
foo@bar:~$ python3 convert_to_lite.py

License

GNU GENERAL PUBLIC LICENSE

fake-currency-identification's People

Contributors

bkataru avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fake-currency-identification's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.