peal.architectures.predictors.get_predictor¶
- peal.architectures.predictors.get_predictor(predictor, device='cuda')[source]¶
Resolve a predictor reference into a model on
device.Accepts the different ways a predictor is referred to throughout PEAL:
an
nn.Moduleor any callable, which is returned unchanged;a path ending in
.cpl, loaded withtorch.load(retried withweights_only=Falsefor full-pickle checkpoints);a path ending in
.onnx, converted to a trainable torch module bypeal.architectures.onnx_predictor.load_onnx_predictor;anything else, which is read as a predictor config. The config either names
weights_path(aTorchvisionModelofconfig.architecturewithconfig.task.output_channelsoutputs is built and the state dict loaded into it), selects the pretrainedtorchvision_resnet18_imagenet, or points at a run directory whosemodel.cplis loaded.
- Parameters:
- Returns:
model (
nn.Moduleorcallable) – The resolved predictor.config (
PredictorConfigorNone) – The config it was built from, orNonewhen the predictor was given directly or as a checkpoint path.