2. API Usage
Overview
This page shows the API-based workflow as a sequence of practical steps.
Use this path when you want to work through the DEEPaaS browser UI or call the API endpoints directly.
API workflow
The common order is:
install the package
create a project
validate the config
optionally download the pretrained model
optionally build an inference Docker image
start the API
use the training endpoint or prediction endpoint
inspect the outputs written by the package
Step 1: Install the package
pip install planktonclass
Step 2: Create a project
planktonclass init my_project
This creates a local config.yaml and the standard project folders.
Step 3: Validate the config
planktonclass validate-config my_project
Step 4: Optional pretrained model
If you want to start from a published pretrained model:
planktonclass pretrained my_project --model FlowCam
Available published pretrained names currently include FlowCam, FlowCyto, and PI10.
Step 5: Optional inference Docker image
After training a model, you can package it into a Docker image for a more stable inference runtime:
planktonclass docker my_project
Then run the API from Docker:
docker run -p 5001:5000 planktonclass-inference:<timestamp>
Inside the container, the API listens on port 5000. You can map any free host port.
Step 6: Start the API
The DEEPaaS entry point is defined in pyproject.toml:
[project.entry-points."deepaas.v2.model"]
planktonclass = "planktonclass.api"
The simplest way to start the API is:
planktonclass api my_project
Then open:
http://127.0.0.1:5000/uihttp://127.0.0.1:5000/api#/
Use 127.0.0.1 in the browser. 0.0.0.0 is only the bind address.
After a repository install, you can also start the API directly:
$env:planktonclass_CONFIG = (Resolve-Path .\my_project\config.yaml)
$env:DEEPAAS_V2_MODEL = "planktonclass"
deepaas-run --listen-ip 0.0.0.0
Step 7: Train through the API
Typical browser flow:
start
planktonclass api my_projectopen
/uior/api#/find the
TRAINoperationedit the parameters you want
execute the request
The most important training parameters are:
images_directorymodelnameuse_pretrainedpretrained_namepretrained_versionimage_sizebatch_sizeepochsuse_validationuse_test
Important limitation:
images_directoryis a path field, not a browser folder pickerthe API cannot open a server-side folder chooser through Swagger UI
for local use, it is usually better to set the path in
config.yamlbefore starting the APIwith the standard project layout from
planktonclass init,planktonclass api my_projectautomatically usesmy_project/config.yaml
Step 8: Run prediction through the API
The prediction endpoint accepts:
image: a single uploaded imagezip: a ZIP archive containing one or more images
Typical browser flow:
start the API
open
/uior/api#/find the
PREDICTPOSTmethodclick
Try it outprovide either
imageorzipclick
Execute
Prediction response
The response contains:
filenamespred_labpred_probaphia_idswhen available
What the API exposes
The main public API functions are:
get_metadata()get_train_args()train(**args)get_predict_args()predict(**args)
Runtime behavior
prediction writes a JSON artifact to the configured predictions directory
ZIP prediction extracts the archive to a temporary directory and scans recursively for images
training validates
images_directorybefore startingif there are no models yet, the API can still be used for training, but not for inference