I have trained the ResNet152 on a custom dataset. When I try to load it this way:
trained_model = torch.nn.Module.load_state_dict(torch.load('/content/drive/My Drive/X-Ray-pneumonia-with-CV/X-ray-pytorch-model.pth'))
trained_model.eval()
i got an error: RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.
And when I add map_location:
trained_model = torch.nn.Module.load_state_dict(torch.load('/content/drive/My Drive/X-Ray-pneumonia-with-CV/X-ray-pytorch-model.pth',
map_location = torch.device('cpu')))
trained_model.eval()
I got another error: TypeError: load_state_dict() missing 1 required positional argument: 'state_dict'
So what did I do wrong? Please, help