Unanswered
Using
Loading part from task B:
` def get_models_from_task(task: clearml.Task, model_artifact_substring: str = 'iter_') -> dict:
"""
Extract all models saved as artifacts with the specified substring
:param task: Task to fetch from
:param model_artifact_substring: Substring for recognizing models among artifacts
:return: Mapping between iter number and model instance
"""
# Extract models from task (models are named iter-XXX where XXX is the iteration number)
model_paths = {int(k.split('_')[-1].split('.')[0]): v.get_local_copy() for k, v in task.artifacts.items() if
model_artifact_substring in k}
# Read from pickle
models = dict()
for iter_num, pickle_path in model_paths.items():
with open(pickle_path, 'rb') as f:
models[iter_num] = pickle.load(f)
return models `
162 Views
0
Answers
3 years ago
one year ago