Skip to content

MatteoDeVita/OCR-AI

Repository files navigation

OCR AI :

This repository is cloned repository with added features to the API and the research section.

Please refer to the "research-and-experimentations" folder to see the research conducted

This project is a simple API making the AI servicces available over the HTTP protocol. It is made with flask and also uses numpy, Pillow as well as tensorflow for loading the AI model.

Here's the steps you must follow to make the API work :

All the examples are shown for Ubuntu/Debian

  1. Install python

sudo apt install python3

  1. Install pip, the python package manager

sudo apt install python3-pip

  1. Install the project dependencies. This is quite simple since the project has a requirements.txt file. You can install the dependencies by typing:

pip install - r requirements.txt

  1. Start the project

flask run

  1. You can see that the API start on port 5000.
  2. The API only has 2 routes :
  • /ping -> to check if the API is indeed running
  • /predict_image -> take an image in paramaters and returns the AI result
  1. To the preditc an image using Postman :

    1. Create a post request to http://{SERVER_IP}:5000/predict_image
    2. Go to body, select "form-data", name the Key "image" and select "file" as a type, then select your image in the "value" column
    3. Press send

    Image

  2. Here's the code generated by postman for an axios request (Node.js) :

var axios = require('axios');
var FormData = require('form-data');
var fs = require('fs');
var data = new FormData();
data.append('image', fs.createReadStream('image_test.jpeg'));

var config = {
  method: 'post',
maxBodyLength: Infinity,
  url: 'http://ocalhost:5000/predict_image',
  headers: { 
    ...data.getHeaders()
  },
  data : data
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});

About

Optical Character Recognition AI project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors