Skip to content

Utils

Source

Lightning utils.

load_config_from_checkpoint(checkpoint_path)

Load a CAREamics config from a checkpoint.

Some fields, if missing, will be populated by defaults. Namely, version, training_config and experiment_name.

The default for experiment_name will be "loaded_from_<checkpoint_filename>".

Parameters:

  • checkpoint_path (Path) –

    Path to the PyTorch Lightning checkpoint file.

Returns:

Raises:

  • ValueErrors:

    If certain required information is not found in the checkpoint.

load_module_from_checkpoint(checkpoint_path)

Load a trained CAREamics module from checkpoint.

Automatically detects the algorithm type from the checkpoint and loads the appropriate module with trained weights.

Parameters:

  • checkpoint_path (Path) –

    Path to the PyTorch Lightning checkpoint file.

Returns:

  • CAREamicsModule

    Lightning module with loaded weights.

Raises:

  • ValueError

    If the algorithm type cannot be determined from the checkpoint.

read_csv_logger(experiment_name, log_folder)

Return the loss curves from the csv logs.

Parameters:

  • experiment_name (str) –

    Name of the experiment.

  • log_folder (Path or str) –

    Path to the folder containing the csv logs.

Returns:

  • dict

    Dictionary containing the loss curves, with keys "train_epoch", "val_epoch", "train_loss" and "val_loss".