wfs123456/CCTrans

大佬你好,当我读取上海A数据集时找不到mat文件

Opened this issue · 2 comments

cjl09 commented

2022-04-28 13:40:01,751 - INFO - data_dir : /home/cctrans/part_A_final
2022-04-28 13:40:01,751 - INFO - dataset : sha
2022-04-28 13:40:01,751 - INFO - lr : 1e-05
2022-04-28 13:40:01,751 - INFO - weight_decay : 0.0001
2022-04-28 13:40:01,751 - INFO - resume :
2022-04-28 13:40:01,751 - INFO - max_epoch : 4000
2022-04-28 13:40:01,751 - INFO - val_epoch : 1
2022-04-28 13:40:01,751 - INFO - val_start : 0
2022-04-28 13:40:01,751 - INFO - batch_size : 16
2022-04-28 13:40:01,751 - INFO - device : 0
2022-04-28 13:40:01,751 - INFO - num_workers : 16
2022-04-28 13:40:01,751 - INFO - crop_size : 256
2022-04-28 13:40:01,751 - INFO - wot : 0.1
2022-04-28 13:40:01,751 - INFO - wtv : 0.01
2022-04-28 13:40:01,752 - INFO - reg : 10.0
2022-04-28 13:40:01,752 - INFO - num_of_iter_in_ot: 100
2022-04-28 13:40:01,752 - INFO - norm_cood : 0
2022-04-28 13:40:01,752 - INFO - run_name : CCTrans
2022-04-28 13:40:01,752 - INFO - wandb : 0
2022-04-28 13:40:01,769 - INFO - using 1 gpus
number of img [train]: 300
number of img [val]: 182
load transformer pretrained
2022-04-28 13:40:07,991 - INFO - random initialization
2022-04-28 13:40:07,991 - INFO - -----Epoch 0/4000-----
Traceback (most recent call last):
File "/home/cctrans/train.py", line 68, in
trainer.train()
File "/home/cctrans/train_helper_ALTGVT.py", line 178, in train
self.train_epoch()
File "/home/cctrans/train_helper_ALTGVT.py", line 194, in train_epoch
for step, (inputs, points, gt_discrete) in enumerate(self.dataloaders["train"]):
File "/home/anaconda3/envs/py38/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 435, in next
data = self._next_data()
File "/home/anaconda3/envs/py38/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1085, in _next_data
return self._process_data(data)
File "/home/anaconda3/envs/py38/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1111, in _process_data
data.reraise()
File "/home/anaconda3/envs/py38/lib/python3.8/site-packages/torch/_utils.py", line 428, in reraise
raise self.exc_type(msg)
FileNotFoundError: Caught FileNotFoundError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/home/anaconda3/envs/py38/lib/python3.8/site-packages/scipy/io/matlab/mio.py", line 39, in _open_file
return open(file_like, mode), True
FileNotFoundError: [Errno 2] No such file or directory: '/home/cctrans/part_A_final/train_data/ground-truth/GT_IMG_232.mat'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/anaconda3/envs/py38/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 198, in _worker_loop
data = fetcher.fetch(index)
File "/home/anaconda3/envs/py38/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/anaconda3/envs/py38/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/cctrans/datasets/crowd.py", line 186, in getitem
keypoints = sio.loadmat(gd_path)['image_info'][0][0][0][0][0]
File "/home/anaconda3/envs/py38/lib/python3.8/site-packages/scipy/io/matlab/mio.py", line 222, in loadmat
with _open_file_context(file_name, appendmat) as f:
File "/home/anaconda3/envs/py38/lib/python3.8/contextlib.py", line 113, in enter
return next(self.gen)
File "/home/anaconda3/envs/py38/lib/python3.8/site-packages/scipy/io/matlab/mio.py", line 17, in _open_file_context
f, opened = _open_file(file_like, appendmat, mode)
File "/home/anaconda3/envs/py38/lib/python3.8/site-packages/scipy/io/matlab/mio.py", line 45, in _open_file
return open(file_like, mode), True
FileNotFoundError: [Errno 2] No such file or directory: '/home/cctrans/part_A_final/train_data/ground-truth/GT_IMG_232.mat'

我按照网上的方式把线程改成了0以后依旧会有找不到mat文件的错误,我能够确保ground-truth下我的mat文件都在,所以不知道如何解决这个问题。

cjl09 commented

谢谢作者的确是路径问题。因为网上下载的数据集中默认ground_truth文件夹中的是下横杠,把crowd代码中 gd_path = os.path.join(self.root_path, 'ground-truth', 'GT_{}.mat'.format(name))的'ground-truth'改为ground_truth即可。找了半天终于找到是这里的问题。