pytorch-YOLOv4
pytorch-YOLOv4 copied to clipboard
cannot find the images when training my personal dataset
Epoch 1/300: 0%| | 0/40 [00:00<?, ?img/s]
Traceback (most recent call last):
File "train.py", line 623, in
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.