Download GeometryForcing/utils/storage_utils.py from BonanDing/worldmem-baseline-evals: direct link, hf CLI and curl.
- Browser
- Download file 533 Bytes
-
https://huggingface.co/BonanDing/worldmem-baseline-evals/resolve/main/GeometryForcing/utils/storage_utils.py
- Command line
-
hf download hf://BonanDing/worldmem-baseline-evals/GeometryForcing/utils/storage_utils.py
-
curl -L -o storage_utils.py https://huggingface.co/BonanDing/worldmem-baseline-evals/resolve/main/GeometryForcing/utils/storage_utils.py
533 Bytes
| """ | |
| This repo is forked from [Boyuan Chen](https://boyuan.space/)'s research | |
| template [repo](https://github.com/buoyancy99/research-template). | |
| By its MIT license, you must keep the above sentence in `README.md` | |
| and the `LICENSE` file to credit the author. | |
| """ | |
| import torch | |
| from pathlib import Path | |
| def safe_torch_save(obj, path: Path): | |
| """ | |
| Safely save a torch object to disk. | |
| If the path does not exist, create folders as needed. | |
| """ | |
| path.parent.mkdir(parents=True, exist_ok=True) | |
| torch.save(obj, path) | |