|
@@ -58,25 +58,29 @@ def get_checkpoints_dir_path(experiment_name: str, ckpt_root_dir: str = None) ->
|
|
|
return os.path.join(ckpt_root_dir, experiment_name)
|
|
|
|
|
|
|
|
|
-def get_ckpt_local_path(source_ckpt_folder_name: str, experiment_name: str, ckpt_name: str, external_checkpoint_path: str):
|
|
|
+def get_ckpt_local_path(experiment_name: str, ckpt_name: str, external_checkpoint_path: str, ckpt_root_dir: str = None) -> str:
|
|
|
"""
|
|
|
Gets the local path to the checkpoint file, which will be:
|
|
|
- - By default: YOUR_REPO_ROOT/super_gradients/checkpoints/experiment_name.
|
|
|
+ - By default: YOUR_REPO_ROOT/super_gradients/checkpoints/experiment_name/ckpt_name.
|
|
|
+ - external_checkpoint_path when external_checkpoint_path != None
|
|
|
+ - ckpt_root_dir/experiment_name/ckpt_name when ckpt_root_dir != None.
|
|
|
- if the checkpoint file is remotely located:
|
|
|
when overwrite_local_checkpoint=True then it will be saved in a temporary path which will be returned,
|
|
|
otherwise it will be downloaded to YOUR_REPO_ROOT/super_gradients/checkpoints/experiment_name and overwrite
|
|
|
YOUR_REPO_ROOT/super_gradients/checkpoints/experiment_name/ckpt_name if such file exists.
|
|
|
- - external_checkpoint_path when external_checkpoint_path != None
|
|
|
|
|
|
- :param source_ckpt_folder_name: The folder where the checkpoint is saved. When set to None- uses the experiment_name.
|
|
|
- :param experiment_name: experiment name attr in trainer
|
|
|
- :param ckpt_name: checkpoint filename
|
|
|
- :param external_checkpoint_path: full path to checkpoint file (that might be located outside of super_gradients/checkpoints directory)
|
|
|
- :return:
|
|
|
+
|
|
|
+ :param experiment_name: experiment name attr in trainer :param ckpt_name: checkpoint filename
|
|
|
+ :param external_checkpoint_path: full path to checkpoint file (that might be located outside of
|
|
|
+ super_gradients/checkpoints directory)
|
|
|
+ :param ckpt_root_dir: Local root directory path where all experiment
|
|
|
+ logging directories will reside. When None, it is assumed that pkg_resources.resource_filename(
|
|
|
+ 'checkpoints', "") exists and will be used.
|
|
|
+
|
|
|
+ :return: local path of the checkpoint file (Str)
|
|
|
"""
|
|
|
if external_checkpoint_path:
|
|
|
return external_checkpoint_path
|
|
|
else:
|
|
|
- checkpoints_folder_name = source_ckpt_folder_name or experiment_name
|
|
|
- checkpoints_dir_path = get_checkpoints_dir_path(checkpoints_folder_name)
|
|
|
+ checkpoints_dir_path = get_checkpoints_dir_path(experiment_name, ckpt_root_dir)
|
|
|
return os.path.join(checkpoints_dir_path, ckpt_name)
|