Update Tracker docstrings (#15469)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
parent
da2797a182
commit
b7c5db94b4
10 changed files with 501 additions and 196 deletions
|
|
@ -21,10 +21,15 @@ def on_predict_start(predictor: object, persist: bool = False) -> None:
|
|||
|
||||
Args:
|
||||
predictor (object): The predictor object to initialize trackers for.
|
||||
persist (bool, optional): Whether to persist the trackers if they already exist. Defaults to False.
|
||||
persist (bool): Whether to persist the trackers if they already exist.
|
||||
|
||||
Raises:
|
||||
AssertionError: If the tracker_type is not 'bytetrack' or 'botsort'.
|
||||
|
||||
Examples:
|
||||
Initialize trackers for a predictor object:
|
||||
>>> predictor = SomePredictorClass()
|
||||
>>> on_predict_start(predictor, persist=True)
|
||||
"""
|
||||
if hasattr(predictor, "trackers") and persist:
|
||||
return
|
||||
|
|
@ -51,7 +56,12 @@ def on_predict_postprocess_end(predictor: object, persist: bool = False) -> None
|
|||
|
||||
Args:
|
||||
predictor (object): The predictor object containing the predictions.
|
||||
persist (bool, optional): Whether to persist the trackers if they already exist. Defaults to False.
|
||||
persist (bool): Whether to persist the trackers if they already exist.
|
||||
|
||||
Examples:
|
||||
Postprocess predictions and update with tracking
|
||||
>>> predictor = YourPredictorClass()
|
||||
>>> on_predict_postprocess_end(predictor, persist=True)
|
||||
"""
|
||||
path, im0s = predictor.batch[:2]
|
||||
|
||||
|
|
@ -84,6 +94,11 @@ def register_tracker(model: object, persist: bool) -> None:
|
|||
Args:
|
||||
model (object): The model object to register tracking callbacks for.
|
||||
persist (bool): Whether to persist the trackers if they already exist.
|
||||
|
||||
Examples:
|
||||
Register tracking callbacks to a YOLO model
|
||||
>>> model = YOLOModel()
|
||||
>>> register_tracker(model, persist=True)
|
||||
"""
|
||||
model.add_callback("on_predict_start", partial(on_predict_start, persist=persist))
|
||||
model.add_callback("on_predict_postprocess_end", partial(on_predict_postprocess_end, persist=persist))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue