You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
with torch.no_grad():
outputs = model(img)
_, predicted = torch.max(outputs.data, 1)
print(predicted.item())
And am using the following version of Python & PyTorch using an anaconda env:
Python 3.9.16
PyTorch 1.12.1
The Error is the following, I've already tried everything in previous issues so there might be an issue with another part of my code or the fix might not work for my Python & PyTorch versions:
Exception has occurred: UnpicklingError
invalid load key, '\x04'.
in the line:
model = torch.load(model_path)
The text was updated successfully, but these errors were encountered:
I am trying to use Resnet50 CNN downloadable by the following link: http://places2.csail.mit.edu/models_places365/resnet50_places365.t7
I currently have the following code:
import torch
from torchvision import transforms
from PIL import Image
model_path = 'C:/Users/[name]/Desktop/[folder-name]/resnet50_places365.t7'
model = torch.load(model_path)
transform = transforms.Compose([
transforms.Resize(256),
transforms.CenterCrop(224),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225])
])
img = Image.open('C:/Users/[name]/Desktop/[folder-name/[folder-name]/1.jpg')
img = transform(img)
img = img.unsqueeze(0)
model.eval()
with torch.no_grad():
outputs = model(img)
_, predicted = torch.max(outputs.data, 1)
print(predicted.item())
And am using the following version of Python & PyTorch using an anaconda env:
Python 3.9.16
PyTorch 1.12.1
The Error is the following, I've already tried everything in previous issues so there might be an issue with another part of my code or the fix might not work for my Python & PyTorch versions:
Exception has occurred: UnpicklingError
invalid load key, '\x04'.
in the line:
model = torch.load(model_path)
The text was updated successfully, but these errors were encountered: