sportslabkit.mot.callbacks#

Defines the Callback base class and utility decorators for use with the Trainer class.

The Callback class provides a dynamic way to hook into various stages of the Trainer’s operations. It uses Python’s __getattr__ method to dynamically handle calls to methods that are not explicitly defined, allowing it to handle arbitrary on_<event_name>_start and on_<event_name>_end methods.

Example

class MyPrintingCallback(Callback):
def on_train_start(self, trainer):

print(“Training is starting”)

Overview#

Classes#

TeamClassificationCallback

Base class for creating new callbacks.

Classes#

class sportslabkit.mot.callbacks.TeamClassificationCallback(vector_model: sportslabkit.vector_model.BaseVectorModel)[source]#

Bases: sportslabkit.mot.base.Callback

Base class for creating new callbacks.

This class defines the basic structure of a callback and allows for dynamic method creation for handling different events in the Trainer’s lifecycle.

__getattr__(name

str) -> callable: Returns a dynamically created method based on the given name.

Overview

Methods#

on_track_sequence_end(tracker)

Call the vector_model.predict method on each tracklet to classify it into a team ID.

Members

on_track_sequence_end(tracker: sportslabkit.mot.base.MultiObjectTracker) None[source]#

Call the vector_model.predict method on each tracklet to classify it into a team ID.

Method called at the end of a track sequence. During this phase, team classification is performed on each tracklet using the vector_model.predict.

Parameters:

tracker (MultiObjectTracker) – The instance of the tracker.

Notes

  • Team classification is applied to each tracklet.

  • An N-dimensional feature vector is extracted for each tracklet

using tracklet.get_observations(“feature”). - vector_model.predict is used to classify the tracklet into a team ID (0 or 1 in a 2-class problem).