filipradenovic / cnnimageretrieval-pytorch

CNN Image Retrieval in PyTorch: Training and evaluating CNNs for Image Retrieval in PyTorch
http://cmp.felk.cvut.cz/cnnimageretrieval
MIT License
1.43k stars 322 forks source link

from torchvision import get_image_backend ImportError: cannot import name 'get_image_backend' #4

Closed offbye closed 6 years ago

offbye commented 6 years ago

I run below script on torch 0.4.0, meet a error, any ideas ?

python3 -m cirtorch.examples.train ./test --gpu-id '5' --training-dataset 'retrieval-SfM-120k' >> './test/retrieval-SfM-120k_resnet101_gem_contrastive_m0.85_adam_lr1.0e-06_wd1.0e-04_nnum5_qsize2000_psize20000_bsize5_imsize362' --optimizer 'adam' --lr 1e-6 --neg-n>> Using pre-trained model 'resnet101'

imageretrievalnet.py: for 'resnet101' custom pretrained features 'imagenet-caffe-resnet101-features-10a101d.pth' are used Evaluating network on test datasets... roxford5k: Extracting... roxford5k: database images... Traceback (most recent call last): File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main "main", mod_spec) File "/usr/lib/python3.5/runpy.py", line 85, in _run_code exec(code, run_globals) File "/data5/zxt/downloads/cnnimageretrieval-pytorch-master/cirtorch/examples/train.py", line 507, in main() File "/data5/zxt/downloads/cnnimageretrieval-pytorch-master/cirtorch/examples/train.py", line 240, in main test(args.test_datasets, model) File "/data5/zxt/downloads/cnnimageretrieval-pytorch-master/cirtorch/examples/train.py", line 442, in test vecs = extract_vectors(net, images, image_size, transform) File "/data5/zxt/downloads/cnnimageretrieval-pytorch-master/cirtorch/networks/imageretrievalnet.py", line 174, in extract_vectors for i, input in enumerate(loader): File "/home/zxt/py3/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 286, in next return self._process_next_batch(batch) File "/home/zxt/py3/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 307, in _process_next_batch raise batch.exc_type(batch.exc_msg) ImportError: Traceback (most recent call last): File "/home/zxt/py3/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/zxt/py3/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 57, in samples = collate_fn([dataset[i] for i in batch_indices]) File "/data5/zxt/downloads/cnnimageretrieval-pytorch-master/cirtorch/datasets/genericdataset.py", line 50, in getitem img = self.loader(path) File "/data5/zxt/downloads/cnnimageretrieval-pytorch-master/cirtorch/datasets/datahelpers.py", line 36, in default_loader from torchvision import get_image_backend ImportError: cannot import name 'get_image_backend'

offbye commented 6 years ago

I have solved it by install torchvision 0.2.1 use the master branch in https://github.com/pytorch/vision

filipradenovic commented 6 years ago

Hello, you should also know that the code is tested with PyTorch 0.3.0, so if you end up having other issues you might want to install that version. In the future we will make the code compatible with the newest PyTorch version.