matthias-k / DeepGaze

pytorch implementation of the different DeepGaze models
111 stars 20 forks source link

RGBShapeNetC has corrupted pre-trained weight on DeepGaze IIE #20

Open dddddewang opened 8 hours ago

dddddewang commented 8 hours ago

RGBShapeNetC is ShapeNet whose weight is loaded from

"https://bitbucket.org/robert_geirhos/texture-vs-shape-pretrained-models/raw/60b770e128fffcbd8562a3ab3546c1a735432d03/resnet50_finetune_60_epochs_lr_decay_after_30_start_resnet50_train_45_epochs_combined_IN_SF-ca06340c.pth.tar"

But.... When I load pre-trained DeepGaze IIE, I've met a error.


RuntimeError Traceback (most recent call last) Cell In[2], line 12 9 DEVICE = 'cuda' 11 # you can use DeepGazeI or DeepGazeIIE ---> 12 model = deepgaze_pytorch.DeepGazeIIE(pretrained=True).to(DEVICE) 14 image = face() 16 # load precomputed centerbias log density (from MIT1003) over a 1024x1024 image 17 # you can download the centerbias from https://github.com/matthias-k/DeepGaze/releases/download/v1.0.0/centerbias_mit1003.npy 18 # alternatively, you can use a uniform centerbias via centerbias_template = np.zeros((1024, 1024)).

File c:\Users\asus\Desktop\Develope\Project\ISEF\DeepGaze\deepgaze_pytorch\deepgaze2e.py:142, in DeepGazeIIE.init(self, pretrained) 140 def init(self, pretrained=True): 141 # we average over 3 instances per backbone, each instance has 10 crossvalidation folds --> 142 backbone_models = [build_deepgaze_mixture(backbone_config, components=3 * 10) for backbone_config in BACKBONES] 143 super().init(backbone_models) 145 if pretrained:

File c:\Users\asus\Desktop\Develope\Project\ISEF\DeepGaze\deepgaze_pytorch\deepgaze2e.py:104, in build_deepgaze_mixture(backbone_config, components) 102 print(backbone_config['type']) 103 feature_class = import_class(backbone_config['type']) --> 104 features = feature_class() 106 feature_extractor = FeatureExtractor(features, backbone_config['used_features']) 108 saliency_networks = [] ... 1359 torch._utils._element_size(typed_storage.dtype)) 1360 if offset is not None: 1361 offset = f.tell()

RuntimeError: unexpected EOF, expected 1720323 more bytes. The file might be corrupted.

They said, there is EOF in the middle of weight file. So I couldn't run it now... help me

dddddewang commented 8 hours ago

I just run this code.

import numpy as np
from scipy.misc import face
from scipy.ndimage import zoom
from scipy.special import logsumexp
import torch

import deepgaze_pytorch

DEVICE = 'cuda'

# you can use DeepGazeI or DeepGazeIIE
model = deepgaze_pytorch.DeepGazeIIE(pretrained=True).to(DEVICE)

image = face()

# load precomputed centerbias log density (from MIT1003) over a 1024x1024 image
# you can download the centerbias from https://github.com/matthias-k/DeepGaze/releases/download/v1.0.0/centerbias_mit1003.npy
# alternatively, you can use a uniform centerbias via `centerbias_template = np.zeros((1024, 1024))`.
centerbias_template = np.load('centerbias_mit1003.npy')
# rescale to match image size
centerbias = zoom(centerbias_template, (image.shape[0]/centerbias_template.shape[0], image.shape[1]/centerbias_template.shape[1]), order=0, mode='nearest')
# renormalize log density
centerbias -= logsumexp(centerbias)

image_tensor = torch.tensor([image.transpose(2, 0, 1)]).to(DEVICE)
centerbias_tensor = torch.tensor([centerbias]).to(DEVICE)

log_density_prediction = model(image_tensor, centerbias_tensor)