add back checkpoint_path

This commit is contained in:
Kashif Rasul
2024-05-10 12:23:25 +02:00
parent 4a2b0ae837
commit 2a83a0f82d
+7 -4
View File
@@ -18,7 +18,7 @@ import logging
import multiprocessing import multiprocessing
from os import path from os import path
import time import time
from typing import Any, Literal, Sequence from typing import Any, Literal, Optional, Sequence
import einshape as es import einshape as es
import jax import jax
@@ -224,6 +224,7 @@ class TimesFm:
def load_from_checkpoint( def load_from_checkpoint(
self, self,
checkpoint_path: Optional[str] = None,
repo_id: str = "google/timesfm-1.0-200m", repo_id: str = "google/timesfm-1.0-200m",
checkpoint_type: checkpoints.CheckpointType = checkpoints.CheckpointType.FLAX, checkpoint_type: checkpoints.CheckpointType = checkpoints.CheckpointType.FLAX,
step: int | None = None, step: int | None = None,
@@ -231,12 +232,14 @@ class TimesFm:
"""Loads a checkpoint and compiles the decoder. """Loads a checkpoint and compiles the decoder.
Args: Args:
checkpoint_path: path to the checkpoint directory. checkpoint_path: Optional path to the checkpoint directory.
repo_id: Hugging Face Hub repo id.
checkpoint_type: type of PAX checkpoint checkpoint_type: type of PAX checkpoint
step: step of the checkpoint to load. If `None`, load lastest checkpoint. step: step of the checkpoint to load. If `None`, load lastest checkpoint.
""" """
# Download the checkpoint from Hugging Face Hub # Download the checkpoint from Hugging Face Hub if not given
checkpoint_path = path.join(snapshot_download(repo_id), "checkpoints") if checkpoint_path is None:
checkpoint_path = path.join(snapshot_download(repo_id), "checkpoints")
# Initialize the model weights. # Initialize the model weights.
self._logging("Constructing model weights.") self._logging("Constructing model weights.")