ruotianluo / DiscCaptioning

Code for Discriminability objective for training descriptive captions(CVPR 2018)
110 stars 21 forks source link

ValueError: sampler should be an instance of torch.utils.data.Sampler #10

Closed saigequn closed 5 years ago

saigequn commented 5 years ago

pytorch 1.0.0

bash eval.sh att_d1 test

Traceback (most recent call last): File "eval.py", line 146, in vars(opt)) File "/content/DiscCaptioning/eval_utils.py", line 92, in eval_split data = loader.get_batch(split) File "/content/DiscCaptioning/dataloader.py", line 137, in get_batch ix, tmp_wrapped = self._prefetch_process[split].get() File "/content/DiscCaptioning/dataloader.py", line 256, in get self.reset() File "/content/DiscCaptioning/dataloader.py", line 235, in reset collate_fn=lambda x: x[0])) File "/usr/local/lib/python2.7/dist-packages/torch/utils/data/dataloader.py", line 805, in init batch_sampler = BatchSampler(sampler, batch_size, drop_last) File "/usr/local/lib/python2.7/dist-packages/torch/utils/data/sampler.py", line 146, in init .format(sampler)) ValueError: sampler should be an instance of torch.utils.data.Sampler, but got sampler=[......] Terminating BlobFetcher

ruotianluo commented 5 years ago

This is because of you are using pytorch 0.4+.

Try to follow changes here https://github.com/ruotianluo/ImageCaptioning.pytorch/blob/master/dataloader.py#L207 .