Can help, I am new with pytorch. What's wrong here

Traceback (most recent call last):
File “train.py”, line 51, in
for i, data in enumerate(train_dataset):
File “/content/gdrive/My Drive/SNE-RoadSeg/data/init.py”, line 71, in iter
for i, data in enumerate(self.dataloader):
File “/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py”, line 521, in next
data = self._next_data()
File “/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py”, line 1203, in _next_data
return self._process_data(data)
File “/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py”, line 1229, in _process_data
data.reraise()
File “/usr/local/lib/python3.7/dist-packages/torch/_utils.py”, line 425, in reraise
raise self.exc_type(msg)
cv2.error: Caught error in DataLoader worker process 0.
Original Traceback (most recent call last):
File “/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/worker.py”, line 287, in _worker_loop
data = fetcher.fetch(index)
File “/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py”, line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File “/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py”, line 44, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File “/content/gdrive/My Drive/SNE-RoadSeg/data/R2D_dataset.py”, line 38, in getitem
rgb_image = cv2.cvtColor(cv2.imread(os.path.join(useDir, ‘rgb’, name)), cv2.COLOR_BGR2RGB)
cv2.error: OpenCV(4.1.2) /io/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function ‘cvtColor’

The error is raised by OpenCV and based on the error message it seems the imread is failing and might be returning an empty array so you should check the path and make sure cv2 can properly read the image.

1 Like