imatge-upc / salgan

SalGAN: Visual Saliency Prediction with Generative Adversarial Networks
https://imatge-upc.github.io/salgan
MIT License
368 stars 106 forks source link

Error converting raw image to PKL format data #27

Open rainbowbird07 opened 6 years ago

rainbowbird07 commented 6 years ago

Dear author: When I run the code 'python 01-data_preprocessing.py', I always meet this mistake:

File "****/saliency-salgan-2017-master/scripts/eliaLib/dataRepresentation.py", line 49, in load

self.data = (scipy.io.loadmat(self.filePath)['I']).astype(np.uint8)

KeyError: 'I'

 I was miserable. Eager for your help!
 Thank you very much anyway!
 Best!
mocordel commented 6 years ago

I solved this issue knowing that i converted the saliency maps from jpg to mat file just to suit the requirement of the data preprocessing code that the saliency map must be in mat file. When i changed the jpg to mat file, the variable that i used for the image was im i.e. im = imread('saliencymap.jpg'); . So when I saved it as xxxx.mat file and load it again, it becomes struct that contains the variable im.

In short, change 'I' to the container that you used when you saved the image as mat file. In my case, I changed 'I' to 'im'.