Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resnet50_places365.t7 Issues! #94

Open
Anteros123 opened this issue Mar 12, 2023 · 0 comments
Open

Resnet50_places365.t7 Issues! #94

Anteros123 opened this issue Mar 12, 2023 · 0 comments

Comments

@Anteros123
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant