Skip to content

WebCOOS/seal_detection

Repository files navigation

Seal Detection

Pre-trained ML models to detect seals in images, and APIs to use the models.

Seal

Local setup

It is recommended to create a new Python virtual environment using conda, or its faster alternative, micromamba.

conda environment creation and activation:

conda env create -f environment.yml
conda activate webcoos_seal_detection

micromamba environment creation and activation:

micromamba create -f environment.yml
micromamba activate webcoos_seal_detection

FastAPI Serving

The models can be served using a FastAPI server. The server allows the POSTing of image URLs and raw image (file uploads). The model to use is supplied as URL path parameters.

POST /{model_name}/{model_version}/upload - Image file upload endpoint

The server can be started with

uvicorn api:app

The server can be tested with the test_api.py file. It will save images to the output folder based on the model and version requested.

python ./test/test_api.py

The FastAPI server can also be served using Docker:

docker build -t seal_det_api .
docker run --gpus all --rm --name seal_detector -v $(pwd)/outputs/docker:/outputs -p 8000:8000 seal_det_api

And then tested the same as running it outside of Docker

python ./test/test_api.py

Tensorflow Serving

The models can be served with Tensorflow Serving:

# Location of demo models
export MODEL_NAME="seal_detector"

# Start TensorFlow Serving container and open the REST API port
docker run -t --rm -p 8501:8501 \
    -v "$(pwd)/${MODEL_NAME}:/models/${MODEL_NAME}" \
    -e MODEL_NAME=${MODEL_NAME} \
    tensorflow/serving

The HTTP endpoint can then be used to pass in JSON image data and write out results to files. See the test_tf_serving.py file for an example.

Stream Processing

The model can also be applied to a live stream using one of the test/stream_*.py files.

Run model version 2

python ./test/stream_effdet2.py

Run model version 3

python ./test/stream_effdet3.py

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •