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

Why do you use segmentation labels instead of bounding boxes in the COCO dataset? #28

Open
gongyan1 opened this issue Mar 24, 2024 · 3 comments

Comments

@gongyan1
Copy link

Hello,
This is indeed a fascinating piece of work, and I appreciate the outstanding contribution you have made to the community. However, I have a question. I noticed that the labels in this repository use segmentation instead of bounding boxes. Could you explain the reason behind this choice? If my dataset is labeled with bounding boxes, would it still be compatible? Moreover, were the performances of other methods compared in the article also trained with segmentation labels? To my knowledge, both v7 and v5 have used bounding box labels.

@LZHgrla
Copy link
Collaborator

LZHgrla commented Mar 24, 2024

Hi! @gongyan1
We use the same loss from yolov7, and do not involve seg labels.

Could you show the related code about the seg labels?

@gongyan1
Copy link
Author

@LZHgrla
Dear Lin,

Thank you for reaching out. However, when I downloaded the COCO labels mentioned in your readme, I found that they are not stored as four values of x, y, w, h as expected but rather as many values, and the number of values per line is inconsistent. Therefore, my question is, given that one txt file corresponds to one image and each line corresponds to one object, if these are bounding boxes, they should all be in the common format of class_id x y w h.

5001b5b8-9470-48a6-8325-2e9d4e6b4cd2

@LZHgrla
Copy link
Collaborator

LZHgrla commented Mar 25, 2024

@gongyan1
The COCO labels mentioned in our README are for downloading segmentation labels. However, during the training process, the segmentation labels will be processed into bounding box labels.

with open(lb_file, 'r') as f:
l = [x.split() for x in f.read().strip().splitlines()]
if any([len(x) > 8 for x in l]): # is segment
classes = np.array([x[0] for x in l], dtype=np.float32)
segments = [np.array(x[1:], dtype=np.float32).reshape(-1, 2) for x in l] # (cls, xy1...)
l = np.concatenate((classes.reshape(-1, 1), segments2boxes(segments)), 1) # (cls, xywh)
l = np.array(l, dtype=np.float32)
if len(l):
assert l.shape[1] == 5, 'labels require 5 columns each'

You can also directly download bounding box labels here, https://github.com/ultralytics/yolov5/releases/download/v1.0/coco2017labels.zip

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

2 participants