This repository contains the deployment of a Machine Learning Image Recognition Model, and Machine Learning Random Forest Model. Predictions can be performed using API request methods.
-
Create and activate the virtual environment
python3 -m venv env source env/bin/activate
-
Install the packages and start the application
pip install -r requirements.txt flask run
Build the Docker image and run the Docker container
docker build -t ml-deployment .
docker run -p 8080:8080 -d ml-deployment
or Deploy to Cloud Run by configuring the cloudbuild.yaml
and .gcloudignore
, then submit it
gcloud builds submit --config=cloudbuild.yaml
Base URL (Require Authentication): https://ml-deployment-74e64w7rga-et.a.run.app
Route | HTTP Method | Description |
---|---|---|
/ | GET | Health check |
/ | POST | Perform image recognition |
- Method: GET
- Path:
/
- Status: 200 OK
{ "status": true, "message": "OK" }
-
Method: POST
-
Path:
/
-
Body:
- Form-Data with a single file field named
file
- Form-Data with a string of list (matrix) of gejala penyakit field named
gejala_matrix
"file": image.jpg "gejala_matrix": "[0, 0, 0, 0, 1, 1, 0, ...]"
- Form-Data with a single file field named
-
Status: 200 OK
{ "status": true, "prediction": { "penyakit": ["Masitis", "Penyakit 2"], "penanganan": [ "Menjaga kandang untuk tetap bersih. Memakai antiseptik ...", "Deskripsi penanganan dari penyakit 2", ] } }
-
Status: 400 Bad Request
{ "status": false, "error": "no file" }
-
Status: 500 Internal Server Error
{ "status": false, "error": "error message" }