elias-ramzi / HAPPIER

This repo contains the official implementation of HAPPIER: Hierarchical Average Precision Training for Pertinent Image Retrieval (ECCV'22).
https://arxiv.org/abs/2207.04873
MIT License
20 stars 4 forks source link

IndexError: index 0 is out of bounds for dimension 0 with size 0 #4

Closed jian-rookie closed 1 year ago

jian-rookie commented 1 year ago

Hello,thanks to your nice work! I tried to reproduce the results on iNaturalist-base and SOP with a 32G V100. We ran the default commands and the model was trained in the first few epochs. However, there was a IndexError in the 20th epoch both on iNaturalist-base and SOP. The specific error information is as follows: Traceback (most recent call last): File "happier/run.py", line 173, in run restore_epoch=restore_epoch, File "/home/yangjian/retrieval/HAPPIER-main/happier/engine/train.py", line 108, in train epoch=e, File "/home/yangjian/retrieval/HAPPIER-main/happier/lib/get_set_random_state.py", line 43, in wrapper output = func(*args, **kwargs) File "/home/yangjian/retrieval/HAPPIER-main/happier/engine/accuracy_calculator.py", line 227, in evaluate epoch=epoch, File "/home/yangjian/retrieval/HAPPIER-main/happier/engine/accuracy_calculator.py", line 144, in evaluate features, labels, relevances = self.get_embeddings(net, dts) File "/home/yangjian/retrieval/HAPPIER-main/happier/engine/accuracy_calculator.py", line 69, in get_embeddings self.convert_to_cuda, File "/home/yangjian/retrieval/HAPPIER-main/happier/engine/compute_embeddings.py", line 20, in compute_embeddings for i, batch in enumerate(tqdm(loader, disable=os.getenv("TQDM_DISABLE"))): File "/home/yangjian/anaconda3/envs/happier/lib/python3.7/site-packages/tqdm/std.py", line 1178, in iter for obj in iterable: File "/home/yangjian/anaconda3/envs/happier/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 517, in next data = self._next_data() File "/home/yangjian/anaconda3/envs/happier/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1199, in _next_data return self._process_data(data) File "/home/yangjian/anaconda3/envs/happier/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1225, in _process_data data.reraise() File "/home/yangjian/anaconda3/envs/happier/lib/python3.7/site-packages/torch/_utils.py", line 429, in reraise raise self.exc_type(msg) IndexError: Caught IndexError in DataLoader worker process 0. Original Traceback (most recent call last): File "/home/yangjian/anaconda3/envs/happier/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 202, in _worker_loop data = fetcher.fetch(index) File "/home/yangjian/anaconda3/envs/happier/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/yangjian/anaconda3/envs/happier/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/yangjian/retrieval/HAPPIER-main/happier/datasets/base_dataset.py", line 119, in getitem relevances = self.relevances[idx, :] IndexError: index 0 is out of bounds for dimension 0 with size 0

Could you please help us find out the possible reasons?

elias-ramzi commented 1 year ago

Hi,

It seems that the relevances have not been computed. Have you change something in the code? It should have been computed automatically. If not I will investigate why it was not the case!

jian-rookie commented 1 year ago

I didn't change anything in the code. And the problem also happens when I reproduce the ROADMAP.

elias-ramzi commented 1 year ago

Ok, I will try to run the code myself and will check if there are any issues. I will let you know.

Edit: After running the code it worked for me. Did you change the configuration that would make that the relevances are computed?

could you print test_dts.relevances in run.py?

jian-rookie commented 1 year ago

Sorry for the late response. I re-run the code on SOP twice without any change. It surprisingly works. Now I can successfully reproduce this project. Thanks.

elias-ramzi commented 1 year ago

Great to hear it works! I will close this issue as the problem seems to be fixed. Do not hesitate to re-open this or another issue if you face any problems.