Skip to content

Resnet50_places365.t7 Issues! #94

@Anteros123

Description

@Anteros123

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions