0

我有一个名为newDataset并运行以下代码的文件夹:

valid_dataset = Dataset_Creator('NewDataset', 'val')

test_dataset = Dataset_Creator('NewDataset', 'test')

train_dataset = Dataset_Creator('NewDataset', 'train')

from chainercv.visualizations import vis_bbox

img, bbox, label = train_dataset[0]

ax = vis_bbox(img, bbox, label, label_names=bball_labels)
ax.set_axis_off()
ax.figure.tight_layout() 

但是,我收到此错误:

AttributeError: 'NoneType' object has no attribute 'ndim'
Traceback (most recent call last)
<ipython-input-8-e066149fb0bf> in <module>
     10 from chainercv.visualizations import vis_bbox
     11 
---> 12 img, bbox, label = train_dataset[0]
     13 ax = vis_bbox(img, bbox, label, label_names=bball_labels)
     14 ax.set_axis_off()

/home/malini/anaconda3/envs/chainer/lib/python3.7/site-packages/chainer/dataset/dataset_mixin.py in __getitem__(self, index)
     65             return [self.get_example(i) for i in index]
     66         else:
---> 67             return self.get_example(index)
     68 
     69     def __len__(self):

/home/malini/anaconda3/envs/chainer/lib/python3.7/site-packages/chainercv/chainer_experimental/datasets/sliceable/sliceable_dataset.py in get_example(self, index)
     96         if isinstance(self.keys, tuple):
     97             return self.get_example_by_keys(
---> 98                 index, tuple(range(len(self.keys))))
     99         else:
    100             return self.get_example_by_keys(index, (0,))[0]

/home/malini/anaconda3/envs/chainer/lib/python3.7/site-packages/chainercv/chainer_experimental/datasets/sliceable/getter_dataset.py in get_example_by_keys(self, index, key_indices)
     87             _, getter_index, key_index = self._keys[key_index]
     88             if getter_index not in cache:
---> 89                 cache[getter_index] = self._getters[getter_index](index)
     90             if key_index is None:
     91                 example.append(cache[getter_index])

/home/malini/anaconda3/envs/chainer/lib/python3.7/site-packages/chainercv/datasets/voc/voc_bbox_dataset.py in _get_image(self, i)

85         id_ = self.ids[i]
     86         img_path = os.path.join(self.data_dir, 'JPEGImages', id_ + '.jpg')
---> 87         img = read_image(img_path, color=True)
     88         return img
     89 

/home/malini/anaconda3/envs/chainer/lib/python3.7/site-packages/chainercv/utils/image/read_image.py in read_image(file, dtype, color, alpha)
    124     if chainer.config.cv_read_image_backend is None:
    125         if _cv2_available:
--> 126             return _read_image_cv2(file, dtype, color, alpha)
    127         else:
    128             return _read_image_pil(file, dtype, color, alpha)

/home/malini/anaconda3/envs/chainer/lib/python3.7/site-packages/chainercv/utils/image/read_image.py in _read_image_cv2(file, dtype, color, alpha)
     50         img = cv2.imread(file, color_option)
     51 
---> 52     if img.ndim == 2:
     53         # reshape (H, W) -> (1, H, W)
     54         return img[np.newaxis].astype(dtype)

AttributeError: 'NoneType' object has no attribute 'ndim'

我的图像分辨率在 500 到 1000 之间。

我尝试了绝对路径和相对路径,但仍然出现错误。

4

0 回答 0