This project contains an ML backend for classifying pills in Label Studio. It uses the YOLOv8 model and can segment and classify pills as capsules or tablets. This project is a fork of label-studio-yolov8-backend written by seblful.
-
Dockerfile: The Dockerfile for building the backend container.
-
docker-compose.yml: The docker-compose file for running the backend.
-
model.py: The Python code for the ML backend model.
-
models/: The pre-trained YOLOv8 models for classification.
best-detect.ptwas trained on video frames from the entrance of the AppMAIS hives to detect and classify drone and worker honeybees.stripe-seg.ptwas trained on segmented bee images to segment the stripes from the bee abdomens. -
config_files/: The config files associated with each model.
config-detect.yamlspecifies the required attributes for thebest-detect.pttrained model andconfig-seg.yamldoes the same forstripe-seg.pt. The required attributes are:MODEL_PATH: Path to the model, such as"./models/best-detect.pt".MODEL_TYPE: Model output type, currently only supports "segment" or "detect", with polygon labels and rectangle labels respectively.MODEL_NAME: Any name for the model, only used to concatenate with theMDOEL_VERSIONto record what model gave the annotation. Annotation information recorded as<MODEL_NAME>-<MDOEL_VERSION>.MODEL_VERSION: Any string for the model version, only used to concatenate with theMDOEL_NAMEto record what model gave the annotation. Annotation information recorded as<MODEL_NAME>-<MDOEL_VERSION>.MODEL_CLASSES: List of strings for the names of the model classes. Case-sensitivity applies here for matching model classes to the label classes in Label Studio.
-
uwsgi.ini: The uWSGI configuration file for running the backend.
-
supervisord.conf: The supervisord configuration file for running the backend processes.
-
requirements.txt: The list of Python dependencies for the backend.
-
credentials.yaml: Not saved in the repo, but required to run! this file is similar to the
config.yamlfiles, with only two fields. The fields areLS_URLwritten as"http://<host>:<port>", andLS_API_TOKENwritten as"<API_KEY>".
-
Clone the Label Studio Machine Learning Backend git repository.
-
Import or create a new
credentials.yamlfile -
Navigate into the
label-studio-yolov8-backenddirectory if you have not already. -
Run the command:
label-studio-ml start . -p <port> --kwarg config_path=<path_to_config_file> credentials_path=<path_to_credentials_file>The
.refers to starting the yolov8 backend in the current directory. The two kwargs allow you to specify a destination for your configuration and credentials yaml files, and default to./config.yamland./credentials.yaml. The port defaults to 9090. This will start the backend.Check if the backend is running (on port 9090 for example):
$ curl http://localhost:9090/health{"status":"UP"} -
Connect running backend to Label Studio:
label-studio start --init new_project --ml-backends http://localhost:9090 -
Start the labeling process.
This backend supports running multiple backends at a time through the keyword arguments. For example you could run:
label-studio-ml start . -p 9090 --kwarg config_path=./config_files/config-seg.yaml credentials_path=./credentials.yaml
And
label-studio-ml start . -p 9091 --kwarg config_path=./config_files/config-detect.yaml credentials_path=./credentials.yaml
And you would have the segmentation model on port 9090 and the detect model on port 9091. The only value that must change is the port, as port 9090 would be busy after running the first command, but you most likely need to change the config path as well if you would like to have a different model running.
Model training is not included in this project. This may be added later.