Skip to content

Commit

Permalink
Merge pull request #177 from andreramosfdc/allow_local_dir_download
Browse files Browse the repository at this point in the history
Enable local model snapshot downloads
  • Loading branch information
siriuz42 authored Nov 6, 2024
2 parents e3d45d6 + c1e2094 commit 9b302ae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/timesfm/timesfm_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class TimesFmCheckpoint:
huggingface_repo_id: str | None = None
type: Any = None
step: int | None = None
local_dir: str | None = None


class TimesFmBase:
Expand Down
5 changes: 3 additions & 2 deletions src/timesfm/timesfm_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ def load_from_checkpoint(
checkpoint_path = checkpoint.path
repo_id = checkpoint.huggingface_repo_id
if checkpoint_path is None:
checkpoint_path = path.join(snapshot_download(repo_id),
"torch_model.ckpt")
checkpoint_path = path.join(
snapshot_download(repo_id, local_dir=checkpoint.local_dir),
"torch_model.ckpt")
self._model = ppd.PatchedTimeSeriesDecoder(self._model_config)
loaded_checkpoint = torch.load(checkpoint_path, weights_only=True)
logging.info("Loading checkpoint from %s", checkpoint_path)
Expand Down

0 comments on commit 9b302ae

Please sign in to comment.