thuml / HashNet

Code release for "HashNet: Deep Learning to Hash by Continuation" (ICCV 2017)
MIT License
241 stars 84 forks source link

nus_wide dataset problem #24

Closed yhhhli closed 5 years ago

yhhhli commented 5 years ago

Hi, I followed the instructions in the markdown file, but i got some problem with the nus_wide dataset.

I noticed that you changed the directory ./data/nus_wide to .data/nuswide_81, so I change the code in train.py

elif config["dataset"] == "nus_wide":
    config["data"] = {"train_set1": {"list_path": "../data/nuswide_81/train.txt", "batch_size": 36}, \
                      "train_set2": {"list_path": "../data/nuswide_81/train.txt", "batch_size": 36}}

And when I run the train.py using the following command:

python train.py --gpu_id 0 --dataset nus_wide --prefix resnet50_hashnet --hash_bit 48 --net ResNet50 --lr 0.0003 --class_num 1.0

There is a no such file error:

  File "train.py", line 279, in <module>
    train(config)
  File "train.py", line 199, in train
    inputs1, labels1 = iter1.next()
  File "/home/yuhang/anaconda3/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 286, in __next__
    return self._process_next_batch(batch)
  File "/home/yuhang/anaconda3/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 307, in _process_next_batch
    raise batch.exc_type(batch.exc_msg)
FileNotFoundError: Traceback (most recent call last):
  File "/home/yuhang/anaconda3/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 57, in _worker_loop
    samples = collate_fn([dataset[i] for i in batch_indices])
  File "/home/yuhang/anaconda3/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 57, in <listcomp>
    samples = collate_fn([dataset[i] for i in batch_indices])
  File "/tmp/liyuhang/Hashnet/src/data_list.py", line 89, in __getitem__
    img = self.loader(path)
  File "/tmp/liyuhang/Hashnet/src/data_list.py", line 45, in default_loader
    return pil_loader(path)
  File "/tmp/liyuhang/Hashnet/src/data_list.py", line 26, in pil_loader
    with open(path, 'rb') as f:
FileNotFoundError: [Errno 2] No such file or directory: './data/nuswide_81/images/93478_2084149655_e5049606da_m.jpg'

And when I run it another time, it says another jpg that do not exist in images directory. However, I'm sure those jpg are in the images directory. Could you please help me fix that? Thank you!

And I use pytorch 0.4.0, would that be the reason?

caozhangjie commented 5 years ago

You may check the directory you running the code. It needs to be the . in ./data

yhhhli commented 5 years ago

Hi Josiane,

Sorry for the late reply. Yes, I've solved it, as the author said, the directory is wrong.

The error FileNotFoundError: [Errno 2] No such file or directory: './data/nuswide_81/images/93478_2084149655_e5049606da_m.jpg, is because of ./ does not return to the parent directory, but ../ do. So all you need to do is to write a python program, which adds . in the beginning of each line in the file nuswide81/images/train.txt

On Thu, Feb 21, 2019 at 2:27 AM Josiane Rodrigues da Silva < notifications@github.com> wrote:

Hi @LiYuhang20 https://github.com/LiYuhang20,

I had the same problem. Did you solve it?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/thuml/HashNet/issues/24#issuecomment-465698441, or mute the thread https://github.com/notifications/unsubscribe-auth/AqBmlIZMGbKeV51b7DBQPDGs648gl9oMks5vPZOlgaJpZM4Z6set .

josianerodrigues commented 5 years ago

thank you! :)