from pathlib import Path from torch_uncertainty.models.resnet import resnet18 from safetensors.torch import load_file def load_model(version: int): """Load the model corresponding to the given version.""" model = resnet18( num_classes=10, in_channels=3, style="cifar", conv_bias=False, ) path = Path( f"cifar10-resnet18/cifar10-resnet18-0-1023/version_{version}.safetensors" ) if not path.exists(): raise ValueError("File does not exist") state_dict = load_file(path) model.load_state_dict(state_dict=state_dict) return model