Saltar al contenido

Referencia para ultralytics/utils/callbacks/base.py

Nota

Este archivo est谩 disponible en https://github.com/ultralytics/ ultralytics/blob/main/ ultralytics/utils/callbacks/base .py. Si detectas alg煤n problema, por favor, ayuda a solucionarlo contribuyendo con una Pull Request 馃洜锔. 隆Gracias 馃檹!



ultralytics.utils.callbacks.base.on_pretrain_routine_start(trainer)

Se activa antes de que comience la rutina de preentrenamiento.

C贸digo fuente en ultralytics/utils/callbacks/base.py
def on_pretrain_routine_start(trainer):
    """Called before the pretraining routine starts."""
    pass



ultralytics.utils.callbacks.base.on_pretrain_routine_end(trainer)

Se activa una vez finalizada la rutina de preentrenamiento.

C贸digo fuente en ultralytics/utils/callbacks/base.py
def on_pretrain_routine_end(trainer):
    """Called after the pretraining routine ends."""
    pass



ultralytics.utils.callbacks.base.on_train_start(trainer)

Se llama cuando empieza el entrenamiento.

C贸digo fuente en ultralytics/utils/callbacks/base.py
def on_train_start(trainer):
    """Called when the training starts."""
    pass



ultralytics.utils.callbacks.base.on_train_epoch_start(trainer)

Se activa al inicio de cada 茅poca de entrenamiento.

C贸digo fuente en ultralytics/utils/callbacks/base.py
def on_train_epoch_start(trainer):
    """Called at the start of each training epoch."""
    pass



ultralytics.utils.callbacks.base.on_train_batch_start(trainer)

Se activa al principio de cada lote de entrenamiento.

C贸digo fuente en ultralytics/utils/callbacks/base.py
def on_train_batch_start(trainer):
    """Called at the start of each training batch."""
    pass



ultralytics.utils.callbacks.base.optimizer_step(trainer)

Se ejecuta cuando el optimizador da un paso.

C贸digo fuente en ultralytics/utils/callbacks/base.py
def optimizer_step(trainer):
    """Called when the optimizer takes a step."""
    pass



ultralytics.utils.callbacks.base.on_before_zero_grad(trainer)

Se invoca antes de poner a cero los gradientes.

C贸digo fuente en ultralytics/utils/callbacks/base.py
def on_before_zero_grad(trainer):
    """Called before the gradients are set to zero."""
    pass



ultralytics.utils.callbacks.base.on_train_batch_end(trainer)

Llamada al final de cada lote de entrenamiento.

C贸digo fuente en ultralytics/utils/callbacks/base.py
def on_train_batch_end(trainer):
    """Called at the end of each training batch."""
    pass



ultralytics.utils.callbacks.base.on_train_epoch_end(trainer)

Llamada al final de cada 茅poca de entrenamiento.

C贸digo fuente en ultralytics/utils/callbacks/base.py
def on_train_epoch_end(trainer):
    """Called at the end of each training epoch."""
    pass



ultralytics.utils.callbacks.base.on_fit_epoch_end(trainer)

Llamada al final de cada 茅poca de ajuste (tren + val).

C贸digo fuente en ultralytics/utils/callbacks/base.py
def on_fit_epoch_end(trainer):
    """Called at the end of each fit epoch (train + val)."""
    pass



ultralytics.utils.callbacks.base.on_model_save(trainer)

Se ejecuta cuando se guarda el modelo.

C贸digo fuente en ultralytics/utils/callbacks/base.py
def on_model_save(trainer):
    """Called when the model is saved."""
    pass



ultralytics.utils.callbacks.base.on_train_end(trainer)

Se activa cuando finaliza el entrenamiento.

C贸digo fuente en ultralytics/utils/callbacks/base.py
def on_train_end(trainer):
    """Called when the training ends."""
    pass



ultralytics.utils.callbacks.base.on_params_update(trainer)

Se ejecuta cuando se actualizan los par谩metros del modelo.

C贸digo fuente en ultralytics/utils/callbacks/base.py
def on_params_update(trainer):
    """Called when the model parameters are updated."""
    pass



ultralytics.utils.callbacks.base.teardown(trainer)

Llamada durante el desmontaje del proceso de entrenamiento.

C贸digo fuente en ultralytics/utils/callbacks/base.py
def teardown(trainer):
    """Called during the teardown of the training process."""
    pass



ultralytics.utils.callbacks.base.on_val_start(validator)

Se activa cuando se inicia la validaci贸n.

C贸digo fuente en ultralytics/utils/callbacks/base.py
def on_val_start(validator):
    """Called when the validation starts."""
    pass



ultralytics.utils.callbacks.base.on_val_batch_start(validator)

Llamada al inicio de cada lote de validaci贸n.

C贸digo fuente en ultralytics/utils/callbacks/base.py
def on_val_batch_start(validator):
    """Called at the start of each validation batch."""
    pass



ultralytics.utils.callbacks.base.on_val_batch_end(validator)

Llamada al final de cada lote de validaci贸n.

C贸digo fuente en ultralytics/utils/callbacks/base.py
def on_val_batch_end(validator):
    """Called at the end of each validation batch."""
    pass



ultralytics.utils.callbacks.base.on_val_end(validator)

Se llama cuando finaliza la validaci贸n.

C贸digo fuente en ultralytics/utils/callbacks/base.py
def on_val_end(validator):
    """Called when the validation ends."""
    pass



ultralytics.utils.callbacks.base.on_predict_start(predictor)

Se activa cuando se inicia la predicci贸n.

C贸digo fuente en ultralytics/utils/callbacks/base.py
def on_predict_start(predictor):
    """Called when the prediction starts."""
    pass



ultralytics.utils.callbacks.base.on_predict_batch_start(predictor)

Se activa al principio de cada lote de predicci贸n.

C贸digo fuente en ultralytics/utils/callbacks/base.py
def on_predict_batch_start(predictor):
    """Called at the start of each prediction batch."""
    pass



ultralytics.utils.callbacks.base.on_predict_batch_end(predictor)

Llamada al final de cada lote de predicci贸n.

C贸digo fuente en ultralytics/utils/callbacks/base.py
def on_predict_batch_end(predictor):
    """Called at the end of each prediction batch."""
    pass



ultralytics.utils.callbacks.base.on_predict_postprocess_end(predictor)

Llamada tras finalizar el postprocesado de la predicci贸n.

C贸digo fuente en ultralytics/utils/callbacks/base.py
def on_predict_postprocess_end(predictor):
    """Called after the post-processing of the prediction ends."""
    pass



ultralytics.utils.callbacks.base.on_predict_end(predictor)

Se activa cuando finaliza la predicci贸n.

C贸digo fuente en ultralytics/utils/callbacks/base.py
def on_predict_end(predictor):
    """Called when the prediction ends."""
    pass



ultralytics.utils.callbacks.base.on_export_start(exporter)

Se ejecuta cuando se inicia la exportaci贸n del modelo.

C贸digo fuente en ultralytics/utils/callbacks/base.py
def on_export_start(exporter):
    """Called when the model export starts."""
    pass



ultralytics.utils.callbacks.base.on_export_end(exporter)

Se ejecuta cuando finaliza la exportaci贸n del modelo.

C贸digo fuente en ultralytics/utils/callbacks/base.py
def on_export_end(exporter):
    """Called when the model export ends."""
    pass



ultralytics.utils.callbacks.base.get_default_callbacks()

Devuelve una copia del diccionario default_callbacks con listas como valores por defecto.

Devuelve:

Tipo Descripci贸n
defaultdict

Un defaultdict con claves de default_callbacks y listas vac铆as como valores por defecto.

C贸digo fuente en ultralytics/utils/callbacks/base.py
def get_default_callbacks():
    """
    Return a copy of the default_callbacks dictionary with lists as default values.

    Returns:
        (defaultdict): A defaultdict with keys from default_callbacks and empty lists as default values.
    """
    return defaultdict(list, deepcopy(default_callbacks))



ultralytics.utils.callbacks.base.add_integration_callbacks(instance)

A帽ade devoluciones de llamada de integraci贸n de varias fuentes a las devoluciones de llamada de la instancia.

Par谩metros:

Nombre Tipo Descripci贸n Por defecto
instance (Trainer, Predictor, Validator, Exporter)

Un objeto con un atributo 'callbacks' que es un diccionario de listas de llamadas de retorno.

necesario
C贸digo fuente en ultralytics/utils/callbacks/base.py
def add_integration_callbacks(instance):
    """
    Add integration callbacks from various sources to the instance's callbacks.

    Args:
        instance (Trainer, Predictor, Validator, Exporter): An object with a 'callbacks' attribute that is a dictionary
            of callback lists.
    """

    # Load HUB callbacks
    from .hub import callbacks as hub_cb

    callbacks_list = [hub_cb]

    # Load training callbacks
    if "Trainer" in instance.__class__.__name__:
        from .clearml import callbacks as clear_cb
        from .comet import callbacks as comet_cb
        from .dvc import callbacks as dvc_cb
        from .mlflow import callbacks as mlflow_cb
        from .neptune import callbacks as neptune_cb
        from .raytune import callbacks as tune_cb
        from .tensorboard import callbacks as tb_cb
        from .wb import callbacks as wb_cb

        callbacks_list.extend([clear_cb, comet_cb, dvc_cb, mlflow_cb, neptune_cb, tune_cb, tb_cb, wb_cb])

    # Add the callbacks to the callbacks dictionary
    for callbacks in callbacks_list:
        for k, v in callbacks.items():
            if v not in instance.callbacks[k]:
                instance.callbacks[k].append(v)





Creado 2023-11-12, Actualizado 2024-05-18
Autores: glenn-jocher (4), Burhan-Q (1), Laughing-q (1)