Skip to content

AritmaPlay/aritmaplay-ml-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AritmaPlay - Handwriting Digit Recognizer Model REST API

Installation

Requirement

  • Docker
  • Curl / REST API Client (Postman)

Installation Step

  1. Clone the repository to your local device.
git clone https://github.com/AritmaPlay/aritmaplay-ml-api.git
cd aritmaplay-ml-api
  1. Create .env file
  • If you host your own model, set your URL value in your .env according to the example in .env.example

  • If not, set the .env file and comment these lines in main.py and then save

.env

DESTINATION_MODEL_PATH=model/model.h5

main.py

# LATEST_MODEL_URL = os.getenv("LATEST_MODEL_URL")
DESTINATION_MODEL_PATH = os.getenv("DESTINATION_MODEL_PATH")

# response = requests.get(LATEST_MODEL_URL)

# with open(DESTINATION_MODEL_PATH, 'wb') as f:
    # f.write(response.content)

model = load_model(DESTINATION_MODEL_PATH)
  1. Build the docker image.
docker build -t ml-api .
  1. Run the docker container.
docker run -d --name api-container --env-file .env -p 8080:8080 ml-api

Api Endpoints

GET Health

Endpoint to check the status of the Rest API app.

Endpoint

/health

Response

curl -X GET http://localhost:8080/health
{
    "status":"healthy"
}

POST Predict

Endpoint to predict/recognize the digit 0-9 of a handwriting image.
Makesure your image spesification is:

  1. Size 48x48 pixels.
  2. JPEG/JPG format.

Endpoint

/predict

Response

curl -X POST -F "image=@[PATH/TO/YOUR/IMAGE.JPG]" http://localhost:8080/predict
{
    "data": {
        "digit": 3,
        "probabilities": [
            2.76264107425933e-20,
            2.0730851450904046e-31,
            3.7685306264467755e-11,
            1.0,
            7.193383360587104e-19,
            5.878114401475232e-12,
            1.1354770578376593e-14,
            7.980349020497712e-12,
            7.5117299533356e-12,
            7.348617374336452e-12
        ]
    },
    "message": "Image recognized successfully",
    "response_code": 200,
    "success": true
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published