Open Rich2333 opened 3 years ago
Are you giving it the correct dataset_dir
to find your images and annotations?
Note that argparse may overwrite the dataset_dir
from cfg.py
using its default val :
https://github.com/Tianxiaomo/pytorch-YOLOv4/blob/master/train.py#L540-L541
Do you solve this problem?My dataset_dir is correct but i still get the"cv2.error: OpenCV(4.4.0) /tmp/pip-req-build-99ib2vsi/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'"
Try printing out the 'img_path
on this line:
https://github.com/Tianxiaomo/pytorch-YOLOv4/blob/master/dataset.py#L274
Check to see if the relative path to the image is correct.
Are you giving it the correct
dataset_dir
to find your images and annotations? Note that argparse may overwrite thedataset_dir
fromcfg.py
using its default val : https://github.com/Tianxiaomo/pytorch-YOLOv4/blob/master/train.py#L540-L541
Thanks for the advice! I've checked it again and uses the absolute path, but still not work...
Try printing out the
'img_path
on this line: https://github.com/Tianxiaomo/pytorch-YOLOv4/blob/master/dataset.py#L274Check to see if the relative path to the image is correct.
Thank you! I'll try it again
Do you solve this problem?My dataset_dir is correct but i still get the"cv2.error: OpenCV(4.4.0) /tmp/pip-req-build-99ib2vsi/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'"
No... I'm wondering if there's something wrong with my train images(e.g.: size or other properties). Actually I've tried both relative path and absolute path, but it still shows the same error. "cv2.error: OpenCV(4.4.0) /tmp/pip-req-build-99ib2vsi/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'"
Try printing out the
'img_path
on this line: https://github.com/Tianxiaomo/pytorch-YOLOv4/blob/master/dataset.py#L274Check to see if the relative path to the image is correct.
I put the images in this path "D:\yolov4_torch\pytorch-YOLOv4-master\trainImage", then I use the command "python train.py -l 0.001 -g 0 -pretrained ./data/yolov4.conv.137.pth -classes 10 -dir D:/yolov4_torch/pytorch-YOLOv4-master/trainImage" and "python train.py -l 0.001 -g 0 -pretrained ./data/yolov4.conv.137.pth -classes 10 -dir ./trainImage". But both didn't work and shows the same error as I wrote in this issue :(
Thanks a lot for all these advice! I cannot solve, and find that yolov5 works well. lol
Do you solve this problem?My dataset_dir is correct but i still get the"cv2.error: OpenCV(4.4.0) /tmp/pip-req-build-99ib2vsi/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'"
Do you solve this problem?I have the same problem. I have checked my dataset_dir. dataset_dir is correct.But i still get this error.
Do you solve this problem?My dataset_dir is correct but i still get the"cv2.error: OpenCV(4.4.0) /tmp/pip-req-build-99ib2vsi/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'"
Do you solve this problem?I have the same problem. I have checked my dataset_dir. dataset_dir is correct.But i still get this error.
I have the same problem then I modify the line code : img_path = os.path.join(self.cfg.dataset_dir, img_path) then it work
I solved this problem。 My dataset format is img_path x1,y1,x2,y2,1 Then I modified one place in dataset.py. previous: data = line.strip('\n').split(" ") modified: data = line.strip('\n').split(" ") Because when image is background, the img_path would be xxx.jpg\n,witch is wrong,and cv2 can't cvt it。
I solved this problem。 My dataset format is img_path x1,y1,x2,y2,1 Then I modified one place in dataset.py. previous: data = line.strip('\n').split(" ") modified: data = line.strip('\n').split(" ") Because when image is background, the img_path would be xxx.jpg\n,witch is wrong,and cv2 can't cvt it。
It's the same before and after you changed it,and I changed it like you said,it didn't work too
Do you solve this problem?My dataset_dir is correct but i still get the"cv2.error: OpenCV(4.4.0) /tmp/pip-req-build-99ib2vsi/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'"
Do you solve this problem?I have the same problem. I have checked my dataset_dir. dataset_dir is correct.But i still get this error.
I have the same problem then I modify the line code : img_path = os.path.join(self.cfg.dataset_dir, img_path) then it work
hi,repository source code in dataset.py is the code you changed, and i try it again, it doesn't work too.
Epoch 1/300: 0%| | 0/40 [00:00<?, ?img/s] Traceback (most recent call last): File "train.py", line 623, in
train(model=model,
File "train.py", line 370, in train
for i, batch in enumerate(train_loader):
File "/home/richlinux/anaconda3/envs/torch/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 435, in next
data = self._next_data()
File "/home/richlinux/anaconda3/envs/torch/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1085, in _next_data
return self._process_data(data)
File "/home/richlinux/anaconda3/envs/torch/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1111, in _process_data
data.reraise()
File "/home/richlinux/anaconda3/envs/torch/lib/python3.8/site-packages/torch/_utils.py", line 428, in reraise
raise self.exc_type(msg)
cv2.error: Caught error in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/home/richlinux/anaconda3/envs/torch/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 198, in _worker_loop
data = fetcher.fetch(index)
File "/home/richlinux/anaconda3/envs/torch/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/richlinux/anaconda3/envs/torch/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/richlinux/pytorch-YOLOv4-master/dataset.py", line 298, in getitem
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
cv2.error: OpenCV(4.4.0) /tmp/pip-req-build-99ib2vsi/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'