Label Studio ML Backend
The Label Studio ML backend is an SDK that lets you wrap your machine learning code and turn it into a web server. The web server can be connected to a running Label Studio instance to automate labeling tasks.
How to run it​
This is helper container, you don't need to interact with it directly. All operations are handled by Label Studio.
It's important to run this with GPU, as it's used for inference of your model.
cgc compute create -n auto-yolo -c 2 -m 8 autolabel-yolo -g 1 -gt a5000 -e label_studio_url=<LABEL_STUDIO_URL> -e label_studio_api_key=<LABEL_STUDIO_API_KEY>
Required parameters​
LABEL_STUDIO_URL
- URL to your Label Studio instance, you need running Label Studio instance to use this. Important: Don't use public URL to your Label Studio. Remember that you are working in close environment with private network. To set this up usehttp://<label-studio-name>:8080
(e.g.http://label-studio:8080
)LABEL_STUDIO_API_KEY
- API key to your Label Studio instance, you can generate it in Label Studio web interface. Please refer here.
Default configuration​
LOG_LEVEL=DEBUG
- Sets the logging level to DEBUG, which is useful for development and debugging.WORKERS=1
- Sets the number of worker processes to 1, which is suitable for low-load scenarios. You can increase this number based on your workload and available resources.THREADS=<number_of_cpu_cores>
- Sets the number of threads to the number of CPU cores available in the container. This allows the backend to utilize all available CPU resources for processing.MODEL_DIR=/data/models
- Specifies the directory where the model files are stored.PYTHONPATH=/app
- Sets the Python path to the application directory, allowing the backend to import necessary modules and packages.ANY=PARAMETER
- This is a placeholder for any additional parameters you might want to pass to the backend. You can customize this based on your specific requirements.ALLOW_CUSTOM_MODEL_PATH=true
- Allows the backend to accept custom model paths, enabling flexibility in model management.DEBUG_PLOT=false
- Disables debug plotting by default. You can enable it if you need to visualize the model's predictions during development.MODEL_SCORE_THRESHOLD=0.5
- Sets the threshold for model scoring. Predictions with scores below this threshold will be ignored.MODEL_ROOT=/app/models
- Specifies the full mount path for the model directory. This is where the backend will look for the model files.
Default port is 9090
- you are going to use ML Backend internaly so valid URL that must be provided into label studio project is
http://auto-yolo:9090
Load custom model​
To load a custom model into the ML backend, follow these steps:
- Create a volume - First, create a volume to store your model. If a suitable volume already exists, you can skip this step.
- Upload your model - Transfer or copy your model file into the created volume. Or mount this volume to ML Backend and Jupyter Notebook.
- Mount the volume - Mount the volume to your ML backend container to ensure the backend has access to the model. For instance:
cgc volume mount <model_volume_name> -t auto-yolo
Usually, you will want to mount the same volume that you use to store your dataset and train models.
This way you don't have to create a new volume just for the model.
What is more, if you're volume is mounted to ML Backend and Jupyter Notebook you can train your model and then use it in Label Studio instantely without need to transfer it to other volume.
Once the volume is mounted, the ML backend will have access to the models stored within it. You can store multiple models in the same volume. To ensure the ML backend knows which model to use, you will need to configure your project environment accordingly:
After completing these steps you should be able to see predictions on your dataset.
How to use it​
For further steps on how to use it go to Label Studio ML Backend