Upload inference.py
Browse files72 unmodified lines7374757677787980818283848586878889909172 unmodified lines"""return torch.cuda.is_available()def load_model(self, device_str: str = 'cpu') -> None:"""Load the TorchScript model and class labels.Args:device_str: Device to load the model on ('cpu' or 'cuda')Raises:FileNotFoundError: If model file or pickle file not foundRuntimeError: If model loading fails"""# Set deviceself.device = torch.device(device_str)# Load TorchScript modelif not self.model_path.exists():72 unmodified lines73747576777879808182838485868788899091929394959672 unmodified lines"""return torch.cuda.is_available()def load_model(self) -> None:"""Load the TorchScript model and class labels.Raises:FileNotFoundError: If model file or pickle file not foundRuntimeError: If model loading fails"""# Detect the device here rather than take it as an argument. The# worker calls load_model() with no argument, so the previous# device_str='cpu' default pinned this model to CPU on every# machine, including CUDA boxes, while check_gpu() still reported a# GPU. This architecture is not MPS-compatible, so it is CUDA or# CPU only, matching the legacy hex-data-pt adapter.if torch.cuda.is_available():self.device = torch.device("cuda")else:self.device = torch.device("cpu")# Load TorchScript modelif not self.model_path.exists():
inference.py+11-6