Restore a file, such as a model checkpoint, into your local run folder to access in your script


Calling wandb.restore(filename)will restore a file into your local run directory. Typicallyfilename refers to a file generated by an earlier experiment run and uploaded to our cloud. This call will make a local copy of the file and return a local file stream open for reading.

wandb.restore accepts a few optional keyword arguments:

  • run_path — string referring to the earlier run from which to pull the file, formatted as '$ENTITY_NAME/$PROJECT_NAME/$RUN_ID' or '$PROJECT_NAME/$RUN_ID' (default: current entity, project name, and run id)

  • replace — boolean specifying whether to overwrite a local copy of filename with the cloud copy, if a local copy turns out to be available (default: False)

  • root — string specifying the directory in which to store the local copy of the file. This defaults to the current working directory, or thewandb.run.dirif wandb.init was called earlier (default: ".")

Common use cases:

  • restore the model architecture or weights generated by past runs

  • resume training from the last checkpoint in the case of failure (see the section on resuming for crucial details)


See this report for a complete working example.

# restore a model file from a specific run by user "vanpelt" in "my-project"
best_model = wandb.restore('model-best.h5', run_path="vanpelt/my-project/a1b2c3d")
# restore a weights file from a checkpoint
# (NOTE: resuming must be configured if run_path is not provided)
weights_file = wandb.restore('weights.h5')
# use the "name" attribute of the returned object
# if your framework expects a filename, e.g. as in Keras

If you don't specify a run_path, you'll need to configure resuming for your run. If you want access to files programmatically outside of training, use the Run API.