yolov7-segmentation icon indicating copy to clipboard operation
yolov7-segmentation copied to clipboard

AttributeError: 'list' object has no attribute 'shape'

Open Ureisen opened this issue 3 years ago • 8 comments

Hi! I encountered such an error in the training process of using my own dataset (exported by RoboFlow). Is it because I have only one segmentation object? It will be appreciated if you could give me some suggestions!

Traceback (most recent call last): File "train.py", line 613, in main(opt) File "train.py", line 509, in main train(opt.hyp, opt, device, callbacks) File "train.py", line 291, in train loss, loss_items = compute_loss(pred, targets.to(device)) # loss scaled by batch_size File "/home/yolov7-segmentation-main/utils/loss.py", line 127, in call tcls, tbox, indices, anchors = self.build_targets(p, targets) # targets File "/home/yolov7-segmentation-main/utils/loss.py", line 200, in build_targets anchors, shape = self.anchors[i], p[i].shape AttributeError: 'list' object has no attribute 'shape'

Ureisen avatar Oct 25 '22 06:10 Ureisen

@Ureisen I have the same issue, did you figure out the solution?

AndrewTKent avatar Nov 02 '22 15:11 AndrewTKent

@AndrewTKent! What is the format of your labels, its in coco format or YOLO format?

RizwanMunawar avatar Nov 03 '22 06:11 RizwanMunawar

@RizwanMunawar Hi! Yes I have it in coco format (JSON) and I'm working out of a folder called coco_custom, and I have a coco_custom.yaml pointing to this folder

coco_custom │--annotations | |--instances_default.json │--images | |--train | | |--.jpg | |--val | | |--.jpg │--train.txt │--val.txt

AndrewTKent avatar Nov 03 '22 14:11 AndrewTKent

@AndrewTKent! What is the format of your labels, its in coco format or YOLO format?

Hi! Is it fixed? I have the same issue. My dataset is in yolo format.

goeunnykim avatar Dec 01 '22 05:12 goeunnykim

@RizwanMunawar Hi! Yes I have it in coco format (JSON) and I'm working out of a folder called coco_custom, and I have a coco_custom.yaml pointing to this folder

coco_custom │--annotations | |--instances_default.json │--images | |--train | | |--.jpg | |--val | | |--.jpg │--train.txt │--val.txt

@AndrewTKent The format is wrong, you will need to convert the labels to yolo (Polygon box) format. Also I will recommend to follow the tutorial for data labeling, that I already recommended for proper training. https://medium.com/augmented-startups/train-yolov7-segmentation-on-custom-data-b91237bd2a29

RizwanMunawar avatar Dec 01 '22 07:12 RizwanMunawar

@AndrewTKent! What is the format of your labels, its in coco format or YOLO format?

Hi! Is it fixed? I have the same issue. My dataset is in yolo format.

The required labeling format is Polygon box (with YOLO format). You can follow the tutorial for data labeling, that I already recommended for proper training. https://medium.com/augmented-startups/train-yolov7-segmentation-on-custom-data-b91237bd2a29

RizwanMunawar avatar Dec 01 '22 07:12 RizwanMunawar

I have this with the existing code base as well, with labels in YOLO format... digging into it to propose a fix.

stephansturges avatar Sep 13 '23 12:09 stephansturges

It's late, but I'll leave it here in case anyone gets lost. If an error occurs even in YOLO format

Check you are running ./segment/train.py. (Not ./train.py)

5JM avatar Jul 15 '24 07:07 5JM