CSAILVision / CSAILVision/places365

Resnet50_places365.t7 Issues!

Open
#94 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
2.1k
Forks
538
PR merge metrics
No merged PRs in 30d

Description

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)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the failure at torch.load(model_path) with Python 3.9.16, PyTorch 1.12.1, and the downloaded resnet50_places365.t7 file. Check the model file and the loading step before examining the image transforms; done means the model loads and the shown inference reaches model.eval() without the UnpicklingError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.