open-mmlab / mmselfsup

OpenMMLab Self-Supervised Learning Toolbox and Benchmark
https://mmselfsup.readthedocs.io/en/latest/
Apache License 2.0
3.18k stars 429 forks source link

Reading data doesn't work (ImageNet) moco #9

Closed cxxgtxy closed 4 years ago

cxxgtxy commented 4 years ago

Thanks for this good work. I set up the envs as requirements. The pillow version is controlled under 6.2. However, it reprort errors when I trains moco on ImageNet. Have you met with such errors?

.local/lib/python3.6/site-packages/torchvision/transforms/transforms.py", line 636, in get_params area = img.size[0] * img.size[1] AttributeError: 'tuple' object has no attribute 'size'

XiaohangZhan commented 4 years ago

Did you use the latest code? If so, could you please provide more detailed logs? Thanks.

cxxgtxy commented 4 years ago

Yes, I use the latest code by last night. File "tools/train.py", line 141, in main 247 meta=meta) 248 File "/home/guest/OpenSelfSup-master/tools/../openselfsup/apis/train.py", line 95, in train_model 249 model, dataset, cfg, logger=logger, timestamp=timestamp, meta=meta) 250 File "/home/guest/OpenSelfSup-master/tools/../openselfsup/apis/train.py", line 219, in _dist_train 251 runner.run(data_loaders, cfg.workflow, cfg.total_epochs) 252 File "/home/guest/mmcv-master/mmcv/runner/epoch_based_runner.py", line 122, in run 253 epoch_runner(data_loaders[i], *kwargs) 254 File "/home/guest/mmcv-master/mmcv/runner/epoch_based_runner.py", line 27, in train 255 for i, data_batch in enumerate(data_loader): 256 File "/home/guest/.local/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 582, in next 257 return self._process_next_batch(batch) 258 File "/home/guest/.local/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 608, in _process_next_batch 259 raise batch.exc_type(batch.exc_msg) 260 AttributeError: Traceback (most recent call last): 261 File "/home/guest/.local/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 99, in _worker_loop 262 samples = collate_fn([dataset[i] for i in batch_indices]) 263 File "/home/guest/.local/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 99, in 264 samples = collate_fn([dataset[i] for i in batch_indices]) 265 File "/home/guest/OpenSelfSup-master/tools/../openselfsup/datasets/contrastive.py", line 17, in getitem 266 img1 = self.pipeline(img) 267 File "/home/guest/.local/lib/python3.6/site-packages/torchvision/transforms/transforms.py", line 61, in call 268 img = t(img) 269 File "/home/guest/.local/lib/python3.6/site-packages/torchvision/transforms/transforms.py", line 674, in call 270 i, j, h, w = self.get_params(img, self.scale, self.ratio) 271 File "/home/guest/.local/lib/python3.6/site-packages/torchvision/transforms/transforms.py", line 636, in get_params 272 area = img.size[0] img.size[1] 273 AttributeError: 'tuple' object has no attribute 'size'

XiaohangZhan commented 4 years ago

I guess the file train.txt is not correct. This file should contain filename\n in each line without the label. Please refer to: https://github.com/open-mmlab/OpenSelfSup/blob/master/docs/INSTALL.md#prepare-imagenet-and-places205

You may also refer to the ready-made lists: https://drive.google.com/drive/folders/1wYkJU_1qRHEt1LPVjBiG6ddUFV-t9hVJ

cxxgtxy commented 4 years ago

It works. Thanks!