Model architecture

Model architecture#

YOLOtrack11 adds an extra task called "zaxis", that contains the logic for the \(x,y\) and \(z\)-regression of particles. It extends the "pose" task which is used identify specific points in the image, with the \(z\)-regression branch.

Below, a depiction of the YOLO processing pipeline. It includes a branched detection head receiving feature maps at different scales from the neck.

This architecture is defined in the file yolo11-zaxis.yaml, while the file default.yaml contains a comprehensive list of parameters and settings.

Modes#

The model has several modes it can be used in.

train#

Defined in train.py. Train the model on a given Dataset

Usage:

from YOLOtrack11 import YOLOtrack11

model = YOLOtrack11("yolo11n-zaxis.yaml") # load the zaxis model with scale 'n'
results = model.train(data="datasets/dataset.yaml", epochs=40, <other-arguments>) # train the model for 40 epochs on dataset.yaml
model.save("path/to/my-trained-model.pt") # save the model

where the file dataset.yaml contains metadata about the dataset. See the chapter on Spots or on z-Axis particle detection for a tutorial on how to create a dataset and train a model with it.

val#

Defined in val.py. Provides a list of performance metrics for the model.


model = YOLOtrack11("path/to/my-trained-model.pt") # load a trained model
results = model.val(data="datasets/dataset.yaml", epochs=40, <other-arguments>)

predict#

Defined in predict.py.

import matplotlib.pyplot as plt

results = model.predict("image.tif") #load in an image, can be file path, PIL.Image, numpy array,...
results.plot()
plt.show() #plot the results

df = results.to_df() #convert results to pandas dataframe

Loss Function#

The detection head is defined in the file model.py. Each prediction is governed by a term in the loss function (i.e. mean-square-error for the z-axis regression). The loss function is defined in loss.py.

Further reading:#