Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Ureisen opened this issue Oct 25, 2022 · 8 comments
Open

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

Ureisen opened this issue Oct 25, 2022 · 8 comments

Comments

@Ureisen
Copy link

Ureisen commented Oct 25, 2022

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'

@AndrewTKent
Copy link

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

@RizwanMunawar
Copy link
Owner

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

@AndrewTKent
Copy link

AndrewTKent commented Nov 3, 2022

@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

@goeunnykim
Copy link

@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.

@RizwanMunawar
Copy link
Owner

@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
Copy link
Owner

RizwanMunawar commented Dec 1, 2022

@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

@stephansturges
Copy link

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

@5JM
Copy link

5JM commented Jul 15, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants