YOLOv6
YOLOv6 copied to clipboard
ValueError: not enough values to unpack (expected 2, got 0)
I am facing this error and I am using customize dataset.I followed the same instructions mentioned by the author.
YOLOv6/yolov6/data/datasets.py", line 337, in get_imgs_labels for img_path, info in img_info.items() ValueError: not enough values to unpack (expected 2, got 0)
I don't know what is the matter but I am facing this error.I already trained my dataset with yolov5.For yolov6 it very difficult for me to train.
I have also encountered this problem. You just need to replace your data set and tag name with numbers.
I didn't get your point.what do you mean replace dataset and tags? n with what numbers??
I face the same problem and the followings are my cases. For me, this happens with previously generated .json files (especially .train.json with borken information) Now due to the Linux system, we cannot see the file start with "." but os.path.exists found it. Therefore, I remove the old .train.json and also changed the following code. From yolov6/data/datasets.py:203 osp.dirname(img_dir), "." + osp.basename(img_dir) + ".json" -> osp.dirname(img_dir), osp.basename(img_dir) + ".json"
I changed as you mentioned and I got this error
YOLOv6/yolov6/data/datasets.py", line 308, in get_imgs_labels f"WARNING: No labels found in {osp.dirname(self.img_paths[0])}. " AttributeError: 'TrainValDataset' object has no attribute 'img_paths'
I was getting the same problem. Fortunately it got resolved. Here is what I did
Step 1: I tried deleting the previous ".train.json" file generated with hashes in it
Step 2: The problem is with images being detected as corrupted, So I have commented the command im.verify() in datasets.py
def check_image(im_file):
# verify an image.
nc, msg = 0, ""
try:
im = Image.open(im_file)
#im.verify() # PIL verify
Step 3: I have modified the image directory folder structure as below data --images -----train (contains training images) -----val (contains validation images) -----labels ---------train (contains training annotations) ---------val (contains validation annotations)
If I follow your steps I got this error. YOLOv6/yolov6/data/datasets.py", line 422 nc, msg = 0, "" ^ IndentationError: unexpected indent.
plus in lables file your putting json? not txt files?
Labels are in .txt files
yes But I don't know why I am not able to train my dataset.I have tried everything
是的,但我不知道为什么我无法训练我的数据集。我已经尝试了一切
I suggest you start from scratch, place the train.py file and data set in the root directory, and create a yaml file as follows
YOLO formatted datasets do not require the Test folder
I got this error again.I have followed your instruction.I think it is not for cityscape dataset.
File "/home/travail/noanw/YOLOv6/yolov6/data/datasets.py", line 256, in get_imgs_labels assert osp.exists(label_dir), f"{label_dir} is an invalid directory path!" AssertionError: labels/train is an invalid directory path!
These error are same I faced earlier.
f"WARNING: No labels found in {osp.dirname(self.img_paths[0])}. " AttributeError: 'TrainValDataset' object has no attribute 'img_paths'
这些错误与我之前遇到的错误相同。
f“WARNING: 在 {osp.dirname(self.img_paths[0])} 中找不到任何标签。“ 属性错误: 'TrainValDataset' 对象没有属性 'img_paths'
I have encountered these errors before, but they are all related to the format or path of the dataset. You can test them with other YOLO smaller datasets,Whether it's because of the data set
What is the directory of your labels file?
I'm sorry that my English is not very good. The TXT label file is in the labels folder, and the labels file path is not entered in the YAML file

I believe you need to make "images" folder for train/val image, as https://github.com/meituan/YOLOv6/issues/181#issuecomment-1173024487 shows in step 3.
我相信您需要为火车/val图像创建“图像”文件夹,如步骤3中的#181(注释)所示。
No, I didn't create the images folder. If I did, I would get an error that I couldn't find the images
是的,但我不知道为什么我无法训练我的数据集。我已经尝试了一切
I suggest you start from scratch, place the train.py file and data set in the root directory, and create a yaml file as follows YOLO formatted datasets do not require the Test folder
![]()
![]()
Placing my dataset into YOLOv6 directory solved my problem. Don't place your dataset outside of main directory (this should be fixed in the future). However, I got another problem, " Unable to find a valid cuDNN algorithm to run convolution" :) I trained my dataset well in YOLOv5 before several times, but, now I get this error.
I'm getting this error as well, while trying to use the eval.py with the COCO-Val2017 dataset:
f"WARNING: No labels found in {osp.dirname(self.img_paths[0])}. "
AttributeError: 'TrainValDataset' object has no attribute 'img_paths'
I'm unclear how to get the labels/*.txt files? Are they produced from the instances_val2017.json? or some other way? The *.txt files don't exist in the coco dataset
Fixed: it was solved by commenting out the logger:
if nf == 0:
LOGGER.warning(
f"WARNING: No labels found in {osp.dirname(self.img_paths[0])}. "
)
At that point in the code, self.img_paths isn't yet defined. Commenting it out solves it
Labels are in .txt files
@saiteja-kuchipudi I apologize if this is a basic question - but how should I get/create the labels *.txt files? I'm working with the coco2017 dataset and the txt labels aren't a part of the dataset as far as I've seen
@DShaience I always worked with custom images. But, I hope this link helps you. Give it a try.