YOLOv6 icon indicating copy to clipboard operation
YOLOv6 copied to clipboard

ValueError: not enough values to unpack (expected 2, got 0)

Open noreenanwar opened this issue 2 years ago • 23 comments

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)

noreenanwar avatar Jun 30 '22 21:06 noreenanwar

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.

noreenanwar avatar Jul 02 '22 00:07 noreenanwar

I have also encountered this problem. You just need to replace your data set and tag name with numbers.

Sunzhanxin avatar Jul 02 '22 08:07 Sunzhanxin

I didn't get your point.what do you mean replace dataset and tags? n with what numbers??

noreenanwar avatar Jul 02 '22 13:07 noreenanwar

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"

cominger avatar Jul 02 '22 22:07 cominger

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'

noreenanwar avatar Jul 03 '22 00:07 noreenanwar

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)

saiteja-kuchipudi avatar Jul 03 '22 06:07 saiteja-kuchipudi

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?

noreenanwar avatar Jul 03 '22 12:07 noreenanwar

Labels are in .txt files

saiteja-kuchipudi avatar Jul 03 '22 13:07 saiteja-kuchipudi

yes But I don't know why I am not able to train my dataset.I have tried everything

noreenanwar avatar Jul 03 '22 13:07 noreenanwar

是的,但我不知道为什么我无法训练我的数据集。我已经尝试了一切

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 image image image

M15-3080 avatar Jul 04 '22 00:07 M15-3080

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!

noreenanwar avatar Jul 04 '22 01:07 noreenanwar

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'

noreenanwar avatar Jul 04 '22 01:07 noreenanwar

这些错误与我之前遇到的错误相同。

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

M15-3080 avatar Jul 04 '22 01:07 M15-3080

What is the directory of your labels file?

noreenanwar avatar Jul 04 '22 02:07 noreenanwar

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 image

M15-3080 avatar Jul 04 '22 02:07 M15-3080

Screen Shot 2022-07-03 at 10 27 38 PM I have the same directories but still facing issues.I am using cityscape dataset and I also trained it with yolov5 .but for yolov6 I am facing issues.

noreenanwar avatar Jul 04 '22 02:07 noreenanwar

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.

cominger avatar Jul 04 '22 03:07 cominger

我相信您需要为火车/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

M15-3080 avatar Jul 04 '22 03:07 M15-3080

是的,但我不知道为什么我无法训练我的数据集。我已经尝试了一切

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 image image image

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.

ilkin94 avatar Jul 09 '22 01:07 ilkin94

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

DShaience avatar Jul 10 '22 08:07 DShaience

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

DShaience avatar Jul 10 '22 09:07 DShaience

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 avatar Jul 10 '22 09:07 DShaience

@DShaience I always worked with custom images. But, I hope this link helps you. Give it a try.

saiteja-kuchipudi avatar Jul 10 '22 10:07 saiteja-kuchipudi