def from_checkpoint(cls, checkpoint: Checkpoint) -> "XGBoostPredictor": """Instantiate the predictor from a Checkpoint. The checkpoint is expected to be a result of ``XGBoostTrainer``. Args: checkpoint: The checkpoint to load the model and preprocessor from. It is expected to be from the result of a ``XGBoostTrainer`` run. """ checkpoint = XGBoostCheckpoint.from_checkpoint(checkpoint) model = checkpoint.get_model() preprocessor = checkpoint.get_preprocessor() return cls(model=model, preprocessor=preprocessor)
def from_checkpoint( cls, checkpoint: Checkpoint, model: Optional[torch.nn.Module] = None, use_gpu: bool = False, ) -> "TorchPredictor": """Instantiate the predictor from a Checkpoint. The checkpoint is expected to be a result of ``TorchTrainer``. Args: checkpoint: The checkpoint to load the model and preprocessor from. It is expected to be from the result of a ``TorchTrainer`` run. model: If the checkpoint contains a model state dict, and not the model itself, then the state dict will be loaded to this ``model``. use_gpu: If set, the model will be moved to GPU on instantiation and prediction happens on GPU. """ checkpoint = TorchCheckpoint.from_checkpoint(checkpoint) model = checkpoint.get_model(model) preprocessor = checkpoint.get_preprocessor() return cls(model=model, preprocessor=preprocessor, use_gpu=use_gpu)
def _load_checkpoint( self, checkpoint: Checkpoint ) -> Tuple[lightgbm.Booster, Optional["Preprocessor"]]: checkpoint = LightGBMCheckpoint.from_checkpoint(checkpoint) return checkpoint.get_model(), checkpoint.get_preprocessor()
def _load_checkpoint( self, checkpoint: Checkpoint ) -> Tuple[xgboost.Booster, Optional["Preprocessor"]]: checkpoint = XGBoostCheckpoint.from_checkpoint(checkpoint) return checkpoint.get_model(), checkpoint.get_preprocessor()