Home

Awesome

Faulty Image API

This API combines the image classification models (i.e. empty, sticky notes, folded corner and writing type classifiers) trained in Dalai project. Using this API one can predict whether the document is empty, contains sticky notes or folded corners and the writing type of the document. This API is also used in Arkkiivi backend.

Installation

conda create -n faulty_api_env python=3.7

conda activate faulty_api_env

conda install -c conda-forge poppler

pip install -r requirements.txt

How to use

flask --app api.py run

flask --app api.py --debug run

The API assumes that the models are found in './models' folder. The models are named 'post_it_model.onnx', 'corner_model.onnx', 'empty_model_v4.onnx' ja 'writing_type_v1.onnx'.

The trained models are transformed into the ONNX format in order to speed up inference and to make the use of the model less dependent on specific frameworks and libraries.

curl http://127.0.0.1:5000/detect?postit=1"&"corner=1"&"empty=1"&"writing_type=1 -F image=@/path/img.jpg

NB! Windows users might encounter following error Invoke-WebRequest : A parameter cannot be found that matches parameter name 'F'.. This can be bypassed by running a command Remove-item alias:curl.

How to interpret API responses

The API returns a Flask response that contains a list of dictionary.

With corner, empty and postit, 0 means that the model has not detected any flaws and 1 means that the model found a fault. In writing type model, the classification goes as followed: 0 means handwritten, 1 means type written and 2 means a combination of those two.