Skip to content

Commit 3df0dfa

Browse files
committed
Optim yolov5 to coco
1 parent fe5b5f0 commit 3df0dfa

File tree

11 files changed

+59
-249
lines changed

11 files changed

+59
-249
lines changed

README.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,34 @@
1818

1919
#### YOLOV5格式数据→COCO
2020
- YOLOV5训练格式目录结构(详情参见`dataset/YOLOV5`):
21-
```text
22-
YOLOV5
23-
├── classes.txt
24-
├── xxxx
25-
│ ├── images
26-
│ └── labels
27-
├── train.txt
28-
└── val.txt
29-
```
21+
```text
22+
YOLOV5
23+
├── classes.txt
24+
├── images
25+
│ ├── images(13).jpg
26+
│ └── images(3).jpg
27+
├── labels
28+
│ ├── images(13).txt
29+
│ └── images(3).txt
30+
├── train.txt
31+
└── val.txt
32+
```
3033
3134
- 转换
3235
```shell
3336
python yolov5_2_coco.py --dir_path dataset/YOLOV5
3437
```
38+
- 转换后目录结构(详情参见`dataset/YOLOV5_COCO_format`):
39+
```text
40+
YOLOV5_COCO_format
41+
├── annotations
42+
│ ├── instances_train2017.json
43+
│ └── instances_val2017.json
44+
├── train2017
45+
│ └── 000000000001.jpg
46+
└── val2017
47+
└── 000000000001.jpg
48+
```
3549
3650
#### 可视化COCO格式标注格式
3751
```shell
File renamed without changes.
File renamed without changes.

dataset/YOLOV5/train.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
dataset/YOLOV5/stamp/images/images(3).jpg
1+
dataset/YOLOV5/images/images(3).jpg

dataset/YOLOV5/val.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
dataset/YOLOV5/stamp/images/images(13).jpg
1+
dataset/YOLOV5/images/images(13).jpg
Lines changed: 1 addition & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -1,159 +1 @@
1-
{
2-
"info": {
3-
"year": 2021,
4-
"version": "1.0",
5-
"description": "For object detection",
6-
"date_created": "2021"
7-
},
8-
"images": [
9-
{
10-
"date_captured": "2021",
11-
"file_name": "000000000001.jpg",
12-
"id": 1,
13-
"height": 224,
14-
"width": 224
15-
}
16-
],
17-
"licenses": [
18-
{
19-
"id": 1,
20-
"name": "GNU General Public License v3.0",
21-
"url": "https://github.com/zhiqwang/yolov5-rt-stack/blob/master/LICENSE"
22-
}
23-
],
24-
"type": "instances",
25-
"annotations": [
26-
{
27-
"segmentation": [
28-
[
29-
18.000080000000004,
30-
2.999920000000003,
31-
105.000112,
32-
2.999920000000003,
33-
105.000112,
34-
89.000016,
35-
18.000080000000004,
36-
89.000016
37-
]
38-
],
39-
"area": 7482.011104003072,
40-
"iscrowd": 0,
41-
"image_id": 1,
42-
"bbox": [
43-
18.000080000000004,
44-
2.999920000000003,
45-
87.000032,
46-
86.000096
47-
],
48-
"category_id": 1,
49-
"id": 1
50-
},
51-
{
52-
"segmentation": [
53-
[
54-
126.99993599999999,
55-
3.9999679999999955,
56-
210.999936,
57-
3.9999679999999955,
58-
210.999936,
59-
88.999904,
60-
126.99993599999999,
61-
88.999904
62-
]
63-
],
64-
"area": 7139.994624000001,
65-
"iscrowd": 0,
66-
"image_id": 1,
67-
"bbox": [
68-
126.99993599999999,
69-
3.9999679999999955,
70-
84,
71-
84.999936
72-
],
73-
"category_id": 1,
74-
"id": 2
75-
},
76-
{
77-
"segmentation": [
78-
[
79-
74.99990400000002,
80-
76.000064,
81-
150.99996800000002,
82-
76.000064,
83-
150.99996800000002,
84-
153.000064,
85-
74.99990400000002,
86-
153.000064
87-
]
88-
],
89-
"area": 5852.004927999999,
90-
"iscrowd": 0,
91-
"image_id": 1,
92-
"bbox": [
93-
74.99990400000002,
94-
76.000064,
95-
76.000064,
96-
77
97-
],
98-
"category_id": 1,
99-
"id": 3
100-
},
101-
{
102-
"segmentation": [
103-
[
104-
12.000127999999997,
105-
135.000096,
106-
97.00006400000001,
107-
135.000096,
108-
97.00006400000001,
109-
220.00003200000003,
110-
12.000127999999997,
111-
220.00003200000003
112-
]
113-
],
114-
"area": 7224.989120004097,
115-
"iscrowd": 0,
116-
"image_id": 1,
117-
"bbox": [
118-
12.000127999999997,
119-
135.000096,
120-
84.999936,
121-
84.999936
122-
],
123-
"category_id": 1,
124-
"id": 4
125-
},
126-
{
127-
"segmentation": [
128-
[
129-
132.00006399999998,
130-
136.999968,
131-
215.00012799999996,
132-
136.999968,
133-
215.00012799999996,
134-
220.00003199999998,
135-
132.00006399999998,
136-
220.00003199999998
137-
]
138-
],
139-
"area": 6889.010624004095,
140-
"iscrowd": 0,
141-
"image_id": 1,
142-
"bbox": [
143-
132.00006399999998,
144-
136.999968,
145-
83.000064,
146-
83.000064
147-
],
148-
"category_id": 1,
149-
"id": 5
150-
}
151-
],
152-
"categories": [
153-
{
154-
"supercategory": "stamp",
155-
"id": 1,
156-
"name": "stamp"
157-
}
158-
]
159-
}
1+
{"info": {"year": 2021, "version": "1.0", "description": "For object detection", "date_created": "2021"}, "images": [{"date_captured": "2021", "file_name": "000000000001.jpg", "id": 1, "height": 224, "width": 224}], "licenses": [{"id": 1, "name": "Apache License v2.0", "url": "https://github.com/RapidAI/YOLO2COCO/LICENSE"}], "type": "instances", "annotations": [{"segmentation": [[18.000080000000004, 2.999920000000003, 105.000112, 2.999920000000003, 105.000112, 89.000016, 18.000080000000004, 89.000016]], "area": 7482.011104003072, "iscrowd": 0, "image_id": 1, "bbox": [18.000080000000004, 2.999920000000003, 87.000032, 86.000096], "category_id": 1, "id": 1}, {"segmentation": [[126.99993599999999, 3.9999679999999955, 210.999936, 3.9999679999999955, 210.999936, 88.999904, 126.99993599999999, 88.999904]], "area": 7139.994624000001, "iscrowd": 0, "image_id": 1, "bbox": [126.99993599999999, 3.9999679999999955, 84.0, 84.999936], "category_id": 1, "id": 2}, {"segmentation": [[74.99990400000002, 76.000064, 150.99996800000002, 76.000064, 150.99996800000002, 153.000064, 74.99990400000002, 153.000064]], "area": 5852.004927999999, "iscrowd": 0, "image_id": 1, "bbox": [74.99990400000002, 76.000064, 76.000064, 77.0], "category_id": 1, "id": 3}, {"segmentation": [[12.000127999999997, 135.000096, 97.00006400000001, 135.000096, 97.00006400000001, 220.00003200000003, 12.000127999999997, 220.00003200000003]], "area": 7224.989120004097, "iscrowd": 0, "image_id": 1, "bbox": [12.000127999999997, 135.000096, 84.999936, 84.999936], "category_id": 1, "id": 4}, {"segmentation": [[132.00006399999998, 136.999968, 215.00012799999996, 136.999968, 215.00012799999996, 220.00003199999998, 132.00006399999998, 220.00003199999998]], "area": 6889.010624004095, "iscrowd": 0, "image_id": 1, "bbox": [132.00006399999998, 136.999968, 83.000064, 83.000064], "category_id": 1, "id": 5}], "categories": [{"supercategory": "stamp", "id": 1, "name": "stamp"}]}
Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1 @@
1-
{
2-
"info": {
3-
"year": 2021,
4-
"version": "1.0",
5-
"description": "For object detection",
6-
"date_created": "2021"
7-
},
8-
"images": [
9-
{
10-
"date_captured": "2021",
11-
"file_name": "000000000001.jpg",
12-
"id": 1,
13-
"height": 248,
14-
"width": 203
15-
}
16-
],
17-
"licenses": [
18-
{
19-
"id": 1,
20-
"name": "GNU General Public License v3.0",
21-
"url": "https://github.com/zhiqwang/yolov5-rt-stack/blob/master/LICENSE"
22-
}
23-
],
24-
"type": "instances",
25-
"annotations": [
26-
{
27-
"segmentation": [
28-
[
29-
18.999988000000002,
30-
16.999904,
31-
183.000034,
32-
16.999904,
33-
183.000034,
34-
178.999952,
35-
18.999988000000002,
36-
178.999952
37-
]
38-
],
39-
"area": 26568.015324002205,
40-
"iscrowd": 0,
41-
"image_id": 1,
42-
"bbox": [
43-
18.999988000000002,
44-
16.999904,
45-
164.000046,
46-
162.000048
47-
],
48-
"category_id": 1,
49-
"id": 6
50-
}
51-
],
52-
"categories": [
53-
{
54-
"supercategory": "stamp",
55-
"id": 1,
56-
"name": "stamp"
57-
}
58-
]
59-
}
1+
{"info": {"year": 2021, "version": "1.0", "description": "For object detection", "date_created": "2021"}, "images": [{"date_captured": "2021", "file_name": "000000000001.jpg", "id": 1, "height": 248, "width": 203}], "licenses": [{"id": 1, "name": "Apache License v2.0", "url": "https://github.com/RapidAI/YOLO2COCO/LICENSE"}], "type": "instances", "annotations": [{"segmentation": [[18.999988000000002, 16.999904, 183.000034, 16.999904, 183.000034, 178.999952, 18.999988000000002, 178.999952]], "area": 26568.015324002205, "iscrowd": 0, "image_id": 1, "bbox": [18.999988000000002, 16.999904, 164.000046, 162.000048], "category_id": 1, "id": 6}], "categories": [{"supercategory": "stamp", "id": 1, "name": "stamp"}]}

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
opencv_python==4.2.0.32
1+
opencv_python
2+
tqdm

0 commit comments

Comments
 (0)