Signature Classifier
Table of Contents
About
We created a deep learning model using TensorFlow to classify signatures as forged or genuine. We served the model by creating an api with Flask and deployed an easy to use web interface that allows you to submit an image of a signature and will return a prediction and a confidence level.
Prerequisites
In order run and modify our app you need to following tools:
- Python 3
- Docker desktop version
- Github desktop version
- An account on GitHub
- Flask 2.0.x
- Microsoft Azure Account
Quickstart
In order to only run the project locally you will only need a GitHub account:
-
The first step is to clone the branch titled "Local" to you machine. This can be done by entering the following command in a CLI.
git clone -b Local https://github.com/JasonFreeberg/image-classifier-example.git -
Next, you need to download the required packages. Run the following command to make sure all dependencies are installed in your environment.
pip install -r backend/image-upload-api/requirements.txt -
Now the Flask app is ready to run. To run the Flask app run the following command
python backend/image-upload-api/flask-api/main.py -
Now you should have a web interface that will allow you to submit images of signatures and return a prediction of whether it is real or fake at the following address!
http://127.0.0.1:5000
Details
The Model
Image pre-processing
- First we researched the different softwares used to process image data (ex.scikit-learn, tensorflow-keras) Import the packages for keras from tensorflow
- Next was writing the file path to access the images in the dataset
- Convert all images to color (some are black and white)
- Convert each individual image to a numpy array
- Append each image and their label (forged/genuine) to their respective lists
- To create more image data, we used image augmentations (color inversion, change contrast, gamma correction, logarithmic correction, sigmoid correction) *repeat steps 4-5 for each augmentation
- Convert the lists containing the image data and labels (image_data, labels) to numpy arrays
- Shuffle the image data and their respective labels randomly
- (optional) Create a function called drawImg(img) which visualizes the images, and checks that image augmentation was correctly applied
Keras Classification
- Create a Sequential model and research appropriate layers to add (Conv2D, MaxPooling2D, Dropout, Flatten, Dense)
- Split the image data and their labels into training and testing sets (we used a test size of 0.8)
- Compile the model, research optimizer, loss and metrics beforehand
- Fit the model, set epochs (we used 15)
- Print the test accuracy of the model (we got 0.622)
Serialization
- Create a json string for the model
- Write the model as a json string to a json file
- Dump the string to preview, check if it wrote correctly
Deserialization
- Open the json file with read access, print to check if it deserialized correctly
Backend
Flask API
- Learn the basics of Flask API
- Create a function to only allow jpeg, png, jpg file types as image inputs
- Create responses to different request file (no file in request, no image in request, and correct request)
- Deserialize the model
- Implement the model in the correct response handler API
- Create a function to properly determine the authenticity of the image based on the result of the model
Frontend
Deployment with Microsoft Azure
We deployed our website to the cloud using Microsoft Azure's app service. These are the steps you need to follow to deploy the web interface using Azure:
- Login in to or create an account with Microsoft Azure.
- Select "Create a resource" and create a "Web App"

- Select or create a resource group which acts as a folder for this resource and give the resource a name, this will act as the url.

- Select "Docker Container" and the region you want the server to based in.

- Select the App Service Plan and specs you need for the dashboard

Congrats!! Your web app has been deployed
Creating GitHub workflow
In order to make CI/CD easier, we made a GitHub Actions workflow to automate deployment on pushed to the main branch. Luckily, Azure makes this easy. Before beginning, if you cloned this repository you need to navigate to the workflows folder and delete main_shiny-dashboard.yml.
- Navigate to the resource overview page a select "Deployment Center"
- Select "GitHub Actions" and then click "Authorize" to allow Azure to connect to your GitHub account. The Authorize button will be a green button arounf the center of the screen.
- You might need to refresh after authorizing, but it should look like this. Now you need to fill in the necessary information about the GitHub repository, Your Docker Hub sign in information and image name.

- Click "save" at the top. This will create a workflow file named "main_shiny-dashboard" in the Github repository.
Now the dashboard will update when changes are pushed to the repository.






