chainer / chainercv

ChainerCV: a Library for Deep Learning in Computer Vision
MIT License
1.48k stars 304 forks source link

training SSD terminated due to the error `AttributeError: 'NoneType' object has no attribute 'ndim'` #828

Closed d-li14 closed 5 years ago

d-li14 commented 5 years ago

When I was running python train.py --model ssd300 --batchsize 32 --gpu 0 as suggested, I met the following error at the epoch 154

Premature end of JPEG file###################.................] 66.66%
Exception in main training loop: 'NoneType' object has no attribute 'ndim'
Traceback (most recent call last):0 iterations
  File "/home/ayao/anaconda3/lib/python3.6/site-packages/chainer-6.0.0b3-py3.6.egg/chainer/training/trainer.py", line 319, in r
un
    entry.extension(self)
  File "/home/ayao/anaconda3/lib/python3.6/site-packages/chainer-6.0.0b3-py3.6.egg/chainer/training/extensions/evaluator.py", l
ine 163, in __call__
    result = self.evaluate()
  File "/home/ayao/lid/chainercv/chainercv/extensions/evaluator/detection_voc_evaluator.py", line 91, in evaluate
    use_07_metric=self.use_07_metric)
  File "/home/ayao/lid/chainercv/chainercv/evaluations/eval_detection_voc.py", line 76, in eval_detection_voc
    iou_thresh=iou_thresh)
  File "/home/ayao/lid/chainercv/chainercv/evaluations/eval_detection_voc.py", line 161, in calc_detection_voc_prec_rec
    gt_bboxes, gt_labels, gt_difficults):
  File "/home/ayao/lid/chainercv/chainercv/utils/iterator/apply_to_iterator.py", line 252, in <genexpr>
    return (sample for batch in iterator for sample in batch)
  File "/home/ayao/lid/chainercv/chainercv/utils/iterator/unzip.py", line 47, in __next__
    values = next(self.iterator)
  File "/home/ayao/lid/chainercv/chainercv/utils/iterator/unzip.py", line 47, in __next__
    values = next(self.iterator)
  File "/home/ayao/lid/chainercv/chainercv/utils/iterator/apply_to_iterator.py", line 160, in _apply
    batch = next(iterator)
  File "/home/ayao/anaconda3/lib/python3.6/site-packages/chainer-6.0.0b3-py3.6.egg/chainer/iterators/serial_iterator.py", line
77, in __next__
    batch = [self.dataset[index] for index in indices]
  File "/home/ayao/anaconda3/lib/python3.6/site-packages/chainer-6.0.0b3-py3.6.egg/chainer/iterators/serial_iterator.py", line
77, in <listcomp>
    batch = [self.dataset[index] for index in indices]
  File "/home/ayao/anaconda3/lib/python3.6/site-packages/chainer-6.0.0b3-py3.6.egg/chainer/dataset/dataset_mixin.py", line 67,
in __getitem__
    return self.get_example(index)
  File "/home/ayao/lid/chainercv/chainercv/chainer_experimental/datasets/sliceable/sliceable_dataset.py", line 98, in get_examp
le
    index, tuple(range(len(self.keys))))
  File "/home/ayao/lid/chainercv/chainercv/chainer_experimental/datasets/sliceable/getter_dataset.py", line 94, in get_example_
by_keys
    cache[getter_index] = self._getters[getter_index](index)
  File "/home/ayao/lid/chainercv/chainercv/datasets/voc/voc_bbox_dataset.py", line 87, in _get_image
    img = read_image(img_path, color=True)
  File "/home/ayao/lid/chainercv/chainercv/utils/image/read_image.py", line 120, in read_image
    return _read_image_cv2(path, dtype, color, alpha)
  File "/home/ayao/lid/chainercv/chainercv/utils/image/read_image.py", line 49, in _read_image_cv2
    if img.ndim == 2:
Will finalize trainer extensions and updater before reraising the exception.
Traceback (most recent call last):
  File "/home/ayao/lid/chainercv/chainercv/utils/iterator/unzip.py", line 45, in __next__
    return self.buffers[self.index].popleft()
IndexError: pop from an empty deque

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ayao/lid/chainercv/chainercv/utils/iterator/unzip.py", line 45, in __next__
    return self.buffers[self.index].popleft()
IndexError: pop from an empty deque

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "train.py", line 200, in <module>
    main()
  File "train.py", line 196, in main
    trainer.run()
  File "/home/ayao/anaconda3/lib/python3.6/site-packages/chainer-6.0.0b3-py3.6.egg/chainer/training/trainer.py", line 349, in r
un
    six.reraise(*exc_info)
  File "/home/ayao/anaconda3/lib/python3.6/site-packages/six.py", line 693, in reraise
    raise value
  File "/home/ayao/anaconda3/lib/python3.6/site-packages/chainer-6.0.0b3-py3.6.egg/chainer/training/trainer.py", line 319, in r
un
    entry.extension(self)
  File "/home/ayao/anaconda3/lib/python3.6/site-packages/chainer-6.0.0b3-py3.6.egg/chainer/training/extensions/evaluator.py", l
ine 163, in __call__
    result = self.evaluate()
  File "/home/ayao/lid/chainercv/chainercv/extensions/evaluator/detection_voc_evaluator.py", line 91, in evaluate
    use_07_metric=self.use_07_metric)
  File "/home/ayao/lid/chainercv/chainercv/evaluations/eval_detection_voc.py", line 76, in eval_detection_voc
    iou_thresh=iou_thresh)
  File "/home/ayao/lid/chainercv/chainercv/evaluations/eval_detection_voc.py", line 161, in calc_detection_voc_prec_rec
    gt_bboxes, gt_labels, gt_difficults):
  File "/home/ayao/lid/chainercv/chainercv/utils/iterator/apply_to_iterator.py", line 252, in <genexpr>
    return (sample for batch in iterator for sample in batch)
  File "/home/ayao/lid/chainercv/chainercv/utils/iterator/unzip.py", line 47, in __next__
    values = next(self.iterator)
  File "/home/ayao/lid/chainercv/chainercv/utils/iterator/unzip.py", line 47, in __next__
    values = next(self.iterator)
  File "/home/ayao/lid/chainercv/chainercv/utils/iterator/apply_to_iterator.py", line 160, in _apply
    batch = next(iterator)
  File "/home/ayao/anaconda3/lib/python3.6/site-packages/chainer-6.0.0b3-py3.6.egg/chainer/iterators/serial_iterator.py", line
77, in __next__
    batch = [self.dataset[index] for index in indices]
  File "/home/ayao/anaconda3/lib/python3.6/site-packages/chainer-6.0.0b3-py3.6.egg/chainer/iterators/serial_iterator.py", line
77, in <listcomp>
    batch = [self.dataset[index] for index in indices]
  File "/home/ayao/anaconda3/lib/python3.6/site-packages/chainer-6.0.0b3-py3.6.egg/chainer/dataset/dataset_mixin.py", line 67,
in __getitem__
    return self.get_example(index)
  File "/home/ayao/lid/chainercv/chainercv/chainer_experimental/datasets/sliceable/sliceable_dataset.py", line 98, in get_examp
le
    index, tuple(range(len(self.keys))))
  File "/home/ayao/lid/chainercv/chainercv/chainer_experimental/datasets/sliceable/getter_dataset.py", line 94, in get_example_
by_keys
    cache[getter_index] = self._getters[getter_index](index)
  File "/home/ayao/lid/chainercv/chainercv/datasets/voc/voc_bbox_dataset.py", line 87, in _get_image
    img = read_image(img_path, color=True)
  File "/home/ayao/lid/chainercv/chainercv/utils/image/read_image.py", line 120, in read_image
    return _read_image_cv2(path, dtype, color, alpha)
  File "/home/ayao/lid/chainercv/chainercv/utils/image/read_image.py", line 49, in _read_image_cv2
    if img.ndim == 2:
AttributeError: 'NoneType' object has no attribute 'ndim'
yuyu2172 commented 5 years ago

The image is missing in the filesystem.

d-li14 commented 5 years ago

Yes, something unexpected occurs when downloading the dataset. Thanks @yuyu2172