Skip to content

AttributeError: 'NoneType' object has no attribute 'shape' #41

Description

@wolfwaytx

作者你好,训练时出现了这个报错:

File "/private/TX/anaconda3/envs/TCTrack/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1229, in _process_data
    data.reraise()
  File "/private/TX/anaconda3/envs/TCTrack/lib/python3.8/site-packages/torch/_utils.py", line 434, in reraise
    raise exception
AttributeError: Caught AttributeError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/private/TX/anaconda3/envs/TCTrack/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop
    data = fetcher.fetch(index)
  File "/private/TX/anaconda3/envs/TCTrack/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/private/TX/anaconda3/envs/TCTrack/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/private/TX/TCTrack-main/pysot/datasets/dataset.py", line 306, in __getitem__
    current_templatebox = self._get_bbox(current_templateimage, current[0][1])
  File "/private/TX/TCTrack-main/pysot/datasets/dataset.py", line 260, in _get_bbox
    imh, imw = image.shape[:2]
AttributeError: 'NoneType' object has no attribute 'shape'

经过debug后发现在pysot/datasets/dataset.py中

        current_templateimage=cv2.imread(current[0][0])
        current_searchimg=cv2.imread(current[1][0])

中current_templateimage和current_searchimg获取到的信息为None 但是我单独写了一个test 代入同样的image路径和以上的代码 发现是可以读取到数据的(非None) test代码如下:

import cv2
import numpy as np

current=(('./train_dataset/got10k/crop511/GOT-10k_Train/GOT-10k_Train_004614/000003.00.x.jpg', [864, 526, 911, 561]), ('./train_dataset/got10k/crop511/GOT-10k_Train/GOT-10k_Train_004614/000010.00.x.jpg', [855, 515, 910, 555]))
current_templateimage=cv2.imread(current[0][0])
current_searchimg=cv2.imread(current[1][0])
cv2.imshow("test", current_templateimage)
cv2.waitKey(0)

请问该如何解决呢

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions