This is the REST API service for the machine learning models for the WaterWise project.
POST /water-segmentation: Segment/extract the water from the image. Returns an image.POST /clean-water: Predict if the water is clean or not. Returns a float value from 0 to 1. Values above 0.5 indicate clean water.POST /clean-water/with-extraction: Predict if the water is clean or not and extract the water from the image. Returns a float value from 0 to 1. Values above 0.5 indicate clean water.POST /potability-iot: Predict if the water is drinkable or not (potability). Returns either 0 or 1. 1 indicate clean water.
Prepare the models. Place the models in the models folder.
wget "https://example.com/models/clean-water.h5" -O "clean-water.h5"
wget "https://example.com/models/water-segmentation.pth" -O "water-segmentation.pth"
wget "https://example.com/models/potability-iot.h5" -O "potability-iot.h5"Install the required packages using pip.
pip install -r requirements.txtRun the service.
python main.pyThe service will be running on http://localhost:5000.
The service can be deployed using Docker. Build the Docker image.
docker build -t ml-service .Run the Docker container.
docker run -p 5000:5000 ml-serviceDocker Compose can also be used.
docker compose up --buildYou can also use Buildpacks to deploy the service to Google Cloud.
gcloud builds submit --pack image=gcr.io/PROJECT_ID/ml-service
# run it on Google Cloud Run
gcloud run deploy --image gcr.io/PROJECT_ID/ml-service