ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
48.29k stars 15.85k forks source link

A request about the coco test2017 dataset labels. #940

Closed smiles724 closed 3 years ago

smiles724 commented 3 years ago

Hi, YOLOv5 team,

It's such a wonderful work you've done. I tried to modify the YOLO based on your architecture. However, it seems that you only provide processed labels of the val2017 dataset but no test2017 labels. Though your tutorials said we can download the labels by calling "gdrive_download('1cXZR_ckHki6nddOmcysCuuJFM--T-Q6L','coco2017labels.zip') # annotations", no test2017 labels were found.

Can you please give us a link to download the test2017 labels so that we can test the performance on our own. Great Thanks.

QQ截图20200910135435

glenn-jocher commented 3 years ago

See https://github.com/ultralytics/yolov5/blob/master/data/scripts/get_coco.sh

You simply uncomment the test line to also download the test set.

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

trived76 commented 3 years ago

See https://github.com/ultralytics/yolov5/blob/master/data/scripts/get_coco.sh

You simply uncomment the test line to also download the test set.

To the best of my knowledge, COCO does not release the testset label on their end.

glenn-jocher commented 3 years ago

@trived76 that is correct. Test set is only available as images, no labels.

ohjunee commented 1 year ago

@glenn-jocher COCO test-dev2017 is provided only as an image without a test set label, so I used the codalab evaluation server, and the test performance was close to zero. the compressed file I uploaded are as follows: {file name}_predictions.json. It works well on val.py. May I know what the problem is?

yuping3252 commented 9 months ago

Hi, YOLOv5 team,

I am so glad that you have this venue for answering yolo related questions. I downloaded coco2017 (on 2023-09-10), using command "yolo train data=coco.yaml" on Windows, and I did some checking in just downloaded coco2017 dataset, under coco/images/train2017, image file 000000000034.jpg contains a giraffe, and under coco/labels/train2017, text file 000000000034.txt contains the following numbers: 23 0.00746875 0.0539294 0.117891 0.0921412 0.231297 0.110118 0.2895 0.0674118 0.331281 0.0472 0.3865 0.0696706 0.423813 0.0943765 0.446188 0.105624 0.467078 0.1528 0.517813 0.182024 0.577516 0.253929 0.658094 0.379765 0.690922 0.532588 0.687937 0.6 0.650625 0.555059 0.658094 0.644941 0.668547 0.755059 0.676 0.838212 0.658094 0.894376 0.613328 0.925835 0.589453 0.914612 0.590938 0.856188 0.552141 0.791012 0.523781 0.725835 0.528266 0.633718 0.498422 0.577529 0.444703 0.505624 0.407391 0.505624 0.395453 0.541576 0.417844 0.591012 0.450672 0.642706 0.456641 0.642706 0.461109 0.725835 0.458125 0.786518 0.450672 0.853929 0.444703 0.898871 0.401422 0.869671 0.411875 0.815741 0.423813 0.734824 0.425297 0.694376 0.361125 0.608988 0.316359 0.588753 0.280547 0.703365 0.271594 0.757294 0.261141 0.829224 0.268609 0.869671 0.277562 0.901129 0.250703 0.937082 0.222344 0.939318 0.231297 0.901129 0.222344 0.844941 0.238766 0.7236 0.246219 0.642706 0.271594 0.510118 0.182062 0.507859 0.0999844 0.525835 0.0208906 0.494376 0.0015 0.0516941 question: I know integer 23 is a label representing giraffe, but what are the remaining real numbers? It also appears that, at different image files, and for different labels, the length of real number following the label are different. What are they and how to interpret them?

OK, I just figured it out: its the points on the segmentation (contour) line of the detected object, identified by the label number, with coordinates in both directions from 0 to 1.

But then, a natural question is: ultralytics provides the command "yolo train data=coco.yaml" to do a training on coco2017 dataset, what flexibility do I have? If I want to prepare my own training dataset, mimic to that of coco2017 dataset, I will need to first detect each object in each image file, find out the segment line points, then make the label file.

Any simpler way to prepare label set? For example, just provide a bounding box, like label xmin, ymin, xmax, ymax on a row, like that coco128 datsaet? In order to use a simpler label file format, what do I need to do in yolo code or command?

glenn-jocher commented 9 months ago

@yuping3252 the YOLOv5 training process supports various label formats, including bounding box coordinates and segmentation masks. The coco2017 dataset uses segmentation masks, which include the label number followed by the contour coordinates ranging from 0 to 1.

If you prefer using bounding box labels instead of segmentation masks, you can modify the label format. YOLOv5 supports multiple label formats, such as YOLO, COCO, Pascal VOC, and more. To use a simpler label file format with bounding box coordinates, you can convert your dataset annotations to YOLO or COCO format, which specify the bounding box coordinates (xmin, ymin, xmax, ymax) for each object.

You can refer to the data.yaml file in the YOLOv5 repository to specify the dataset's YAML configuration file and corresponding label format. Adjust the box_format parameter to yolo or coco to match your label format. Make sure to update the label files accordingly.

Please let me know if you need further assistance or clarification.

yuping3252 commented 9 months ago

I am very happy to see your answer. I tried to find data.yaml, or something similar to that. But failed.

I downloaded yolov5 folder using git clone https://github.com/ultralytics/yolov5.git In yolov5 folder, I find no data.yaml I find many similarly named files, like yolov5l.yaml, yolo5m.yaml, yolov5n.yaml, yolov5s.yaml, yolov5x.yaml, yolov5m6.yaml These files have similar format, like the following (yolov5m6.yaml):

YOLOv5 🚀 by Ultralytics, AGPL-3.0 license

Parameters

nc: 80 # number of classes depth_multiple: 0.67 # model depth multiple width_multiple: 0.75 # layer channel multiple anchors:

YOLOv5 v6.0 backbone

backbone:

[from, number, module, args]

[[-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2 [-1, 1, Conv, [128, 3, 2]], # 1-P2/4 [-1, 3, C3, [128]], [-1, 1, Conv, [256, 3, 2]], # 3-P3/8 [-1, 6, C3, [256]], [-1, 1, Conv, [512, 3, 2]], # 5-P4/16 [-1, 9, C3, [512]], [-1, 1, Conv, [768, 3, 2]], # 7-P5/32 [-1, 3, C3, [768]], [-1, 1, Conv, [1024, 3, 2]], # 9-P6/64 [-1, 3, C3, [1024]], [-1, 1, SPPF, [1024, 5]], # 11 ]

YOLOv5 v6.0 head

head: [[-1, 1, Conv, [768, 1, 1]], [-1, 1, nn.Upsample, [None, 2, 'nearest']], [[-1, 8], 1, Concat, [1]], # cat backbone P5 [-1, 3, C3, [768, False]], # 15

[-1, 1, Conv, [512, 1, 1]], [-1, 1, nn.Upsample, [None, 2, 'nearest']], [[-1, 6], 1, Concat, [1]], # cat backbone P4 [-1, 3, C3, [512, False]], # 19

[-1, 1, Conv, [256, 1, 1]], [-1, 1, nn.Upsample, [None, 2, 'nearest']], [[-1, 4], 1, Concat, [1]], # cat backbone P3 [-1, 3, C3, [256, False]], # 23 (P3/8-small)

[-1, 1, Conv, [256, 3, 2]], [[-1, 20], 1, Concat, [1]], # cat head P4 [-1, 3, C3, [512, False]], # 26 (P4/16-medium)

[-1, 1, Conv, [512, 3, 2]], [[-1, 16], 1, Concat, [1]], # cat head P5 [-1, 3, C3, [768, False]], # 29 (P5/32-large)

[-1, 1, Conv, [768, 3, 2]], [[-1, 12], 1, Concat, [1]], # cat head P6 [-1, 3, C3, [1024, False]], # 32 (P6/64-xlarge)

[[23, 26, 29, 32], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5, P6) ]

Suppose I took one of these yaml files as an example of the yaml file, there is no "box_format" string to be found in the file. Also, it is not obvious how to specify bounding box since most numbers here are grouped in triples, except the last line. Also, not sure how to interpret these numbers and let alone make one of my own to make custom training using custom label file set.

The ultimate goal is still to get a reliable way to specify label file format for training. Since yolov5 able to accept different label formats for training, there must be way to specify this choice and the actual file format for use by yolov5 to do training.

Under yolov5/data folder, there are two files coco.yaml and coco128.yaml , among others. both specify a list of label numbers and their corresponding names. coco.yaml is slight biggger than coco128.yaml, with some (looks like) 10 lines of python code at the bottoms of the file to specify how to download labels and files. Nowhere does it specify how the label file is actually formatted. So, coco.yaml and coco128.yaml cannot serve the purpose of informing yolov5 software what data format is used in label files for training.

To my understanding, if there are flexibility of using different file formats in yolov5 to make label files, there must be a way to inform yolov5, what exactly the format is, either by specifying name (then the actual format is specified some other place) or by literayy list out the data format (since these label files are text files). In most software, this is achieved by configuration file (at least coco.yaml and coco128.yaml don't seem able to achieve this goal), or by command line arguments.

Really appreciate if a direction can be given where to find such information. Thanks a lot!

I am glad that I found it!

the web page, at https://roboflow.com/formats/yolov5-pytorch-txt?ref=ultralytics It says to use roboflow to convert other label file formats to "yolov5 pytorch txt" format.

Thanks.

glenn-jocher commented 9 months ago

@yuping3252 hi,

Thank you for reaching out. I apologize for any confusion you experienced. The data.yaml file you are looking for should be present in the yolov5/data directory of the YOLOv5 repository.

The data.yaml file is typically used to specify the dataset configuration and label format for training. It contains information such as the number of classes (nc), the path to the train and validation directories, and the label format (box_format).

If you intend to use a bounding box format for your custom dataset, you can specify it in the data.yaml file by setting box_format: 'xyxy'. This format represents the bounding box coordinates as (xmin, ymin, xmax, ymax).

To specify your custom label format and its structure, you would need to modify the code inside the YOLOv5 repository accordingly. Specifically, you can make changes to the datasets module where the dataset loading and label parsing functions are defined. You would also need to update the corresponding code in the train.py script to ensure the labels are read and interpreted correctly during training.

If you prefer to use a different tool, such as Roboflow, to convert your label files to the YOLOv5 PyTorch text format, you can follow the instructions provided in their documentation.

I hope this clarifies the necessary steps. Please let me know if you have any further questions or need additional guidance.