hysts / pytorch_mpiigaze

An unofficial PyTorch implementation of MPIIGaze and MPIIFaceGaze
MIT License
346 stars 85 forks source link

TypeError: 'NoneType' object is not subscriptable #33

Closed Kelly-ZH closed 3 years ago

Kelly-ZH commented 3 years ago

Hi hysts, Thank you for your work very much, And when I run "python train.py --config configs/mpiifacegaze/alexnet_train.yaml", there was this mistake like this:

Traceback (most recent call last): File "train.py", line 189, in main() File "train.py", line 169, in main tensorboard_writer, logger) File "train.py", line 100, in validate for step, (images, poses, gazes) in enumerate(val_loader): File "E:\Anaconda\envs\mpiigaze\lib\site-packages\torch\utils\data\dataloader.py", line 517, in next data = self._next_data() File "E:\Anaconda\envs\mpiigaze\lib\site-packages\torch\utils\data\dataloader.py", line 557, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration File "E:\Anaconda\envs\mpiigaze\lib\site-packages\torch\utils\data_utils\fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "E:\Anaconda\envs\mpiigaze\lib\site-packages\torch\utils\data_utils\fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File "E:\Anaconda\envs\mpiigaze\lib\site-packages\torch\utils\data\dataset.py", line 330, in getitem return self.dataset[self.indices[idx]] File "E:\Anaconda\envs\mpiigaze\lib\site-packages\torch\utils\data\dataset.py", line 219, in getitem return self.datasets[dataset_idx][sample_idx] File "C:\Users\Administrator.DESKTOP-TI37VJ6\Desktop\pytorch_mpiigaze-master\gaze_estimation\datasets\mpiifacegaze.py", line 20, in getitem image = f.get(f'{self.person_id_str}/image/{index:04}')[()] TypeError: 'NoneType' object is not subscriptable I tried my best to debug it, but it doesn't work. Can you help me? Thank you very much.

hysts commented 3 years ago

@Kelly-ZH

Hmm... It works on my Ubuntu machine, so I guess it's a Windows problem. I'm sorry, but I don't have a Windows environment, so I don't think I can help.

hysts commented 3 years ago

@Kelly-ZH

What is the file size of the MPIIFaceGaze.h5 created by tools/preprocess_mpiifacegaze.py? It should be about 26GB. And if so, what's the result of the following command?

f = h5py.File('MPIIFaceGaze.h5', 'r')
print(f.keys())
Kelly-ZH commented 3 years ago

@Kelly-ZH

What is the file size of the MPIIFaceGaze.h5 created by tools/preprocess_mpiifacegaze.py? It should be about 26GB. And if so, what's the result of the following command?

f = h5py.File('MPIIFaceGaze.h5', 'r')
print(f.keys())

The size of my MPIIFaceGaze.h5 is 10.1 GB, MPIIFaceGaze_normalized is 21.2GB, maybe I should run tools/preprocess_mpiifacegaze.py again. And the result of the following command

is<KeysViewHDF5 ['p00']>

hysts commented 3 years ago

@Kelly-ZH

The result of the aforementioned command should look like the following:

<KeysViewHDF5 ['p00', 'p01', 'p02', 'p03', 'p04', 'p05', 'p06', 'p07', 'p08', 'p09', 'p10', 'p11', 'p12', 'p13', 'p14']>

It seems the dataset you created only contains p00. Try deleting it and creating it again.

Kelly-ZH commented 3 years ago

@Kelly-ZH

The result of the aforementioned command should look like the following:

<KeysViewHDF5 ['p00', 'p01', 'p02', 'p03', 'p04', 'p05', 'p06', 'p07', 'p08', 'p09', 'p10', 'p11', 'p12', 'p13', 'p14']>

It seems the dataset you created only contains p00. Try deleting it and creating it again.

Oh ,I will check it. And the size of my MPIIFaceGaze_normalized.zip is 20.7 GB, is it true? If not, could you share me the MPIIFaceGaze_normalized.zip? It will takes several days for me to download the zip because of my terrible network. Thank you very much.

hysts commented 3 years ago

@Kelly-ZH

I think the size of your MPIIFaceGaze_normalized.zip is as expected. FYI, its md5sum is df2182d207a57818ebf17460dd9014d8, so you can check if it's corrupted.

Kelly-ZH commented 3 years ago

@Kelly-ZH

I think the size of your MPIIFaceGaze_normalized.zip is as expected. FYI, its md5sum is df2182d207a57818ebf17460dd9014d8, so you can check if it's corrupted.

I run

python tools/preprocess_mpiifacegaze.py --dataset datasets/MPIIFaceGaze_normalized -o datasets/ then an error has occured, that is

73%|█████████████████████████████████████████████████▊ | 11/15 [2:48:13<1:01:10, 917.59s/it] Traceback (most recent call last): File "D:\project\Code\pytorch_mpiigaze-master\tools\preprocess_mpiifacegaze.py", line 51, in main() File "D:\project\Code\pytorch_mpiigaze-master\tools\preprocess_mpiifacegaze.py", line 47, in main add_mat_data_to_hdf5(person_id, dataset_dir, output_path) File "D:\project\Code\pytorch_mpiigaze-master\tools\preprocess_mpiifacegaze.py", line 18, in add_mat_datato hdf5 images = images.transpose(0, 2, 3, 1).astype(np.uint8) MemoryError: Unable to allocate 1.68 GiB for an array with shape (3000, 448, 448, 3) and data type uint8 What's wrong with it? Thank you.

hysts commented 3 years ago

@Kelly-ZH

As you can see in the error message, I think your machine doesn't have enough memory.