Skip to content

Commit 9d59957

Browse files
committed
Optim code.
1 parent bb763b5 commit 9d59957

File tree

5 files changed

+180
-6
lines changed

5 files changed

+180
-6
lines changed

darknet2coco.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import cv2 as cv
1212

1313

14-
class DARKNET2COCO:
14+
class DARKNET2COCO():
1515
def __init__(self, genconfig_data):
1616
self.src_data = genconfig_data
1717
self.src = Path(self.src_data).parent
Lines changed: 175 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,175 @@
1-
{"info": {"year": 2022, "version": "1.0", "description": "For object detection", "date_created": "2022"}, "images": [{"date_captured": "2022", "file_name": "000000000001.jpg", "id": 1, "height": 224, "width": 224}, {"date_captured": "2022", "file_name": "000000000002.jpg", "id": 2, "height": 424, "width": 550}], "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}, {"segmentation": [], "area": 0, "iscrowd": 0, "image_id": 2, "bbox": [], "category_id": -1, "id": 6}], "categories": [{"supercategory": "stamp", "id": 1, "name": "stamp"}]}
1+
{
2+
"info": {
3+
"year": 2022,
4+
"version": "1.0",
5+
"description": "For object detection",
6+
"date_created": "2022"
7+
},
8+
"images": [
9+
{
10+
"date_captured": "2022",
11+
"file_name": "000000000001.jpg",
12+
"id": 1,
13+
"height": 224,
14+
"width": 224
15+
},
16+
{
17+
"date_captured": "2022",
18+
"file_name": "000000000002.jpg",
19+
"id": 2,
20+
"height": 424,
21+
"width": 550
22+
}
23+
],
24+
"licenses": [
25+
{
26+
"id": 1,
27+
"name": "Apache License v2.0",
28+
"url": "https://github.com/RapidAI/YOLO2COCO/LICENSE"
29+
}
30+
],
31+
"type": "instances",
32+
"annotations": [
33+
{
34+
"segmentation": [
35+
[
36+
18.000080000000004,
37+
2.999920000000003,
38+
105.000112,
39+
2.999920000000003,
40+
105.000112,
41+
89.000016,
42+
18.000080000000004,
43+
89.000016
44+
]
45+
],
46+
"area": 7482.011104003072,
47+
"iscrowd": 0,
48+
"image_id": 1,
49+
"bbox": [
50+
18.000080000000004,
51+
2.999920000000003,
52+
87.000032,
53+
86.000096
54+
],
55+
"category_id": 1,
56+
"id": 1
57+
},
58+
{
59+
"segmentation": [
60+
[
61+
126.99993599999999,
62+
3.9999679999999955,
63+
210.999936,
64+
3.9999679999999955,
65+
210.999936,
66+
88.999904,
67+
126.99993599999999,
68+
88.999904
69+
]
70+
],
71+
"area": 7139.994624000001,
72+
"iscrowd": 0,
73+
"image_id": 1,
74+
"bbox": [
75+
126.99993599999999,
76+
3.9999679999999955,
77+
84.0,
78+
84.999936
79+
],
80+
"category_id": 1,
81+
"id": 2
82+
},
83+
{
84+
"segmentation": [
85+
[
86+
74.99990400000002,
87+
76.000064,
88+
150.99996800000002,
89+
76.000064,
90+
150.99996800000002,
91+
153.000064,
92+
74.99990400000002,
93+
153.000064
94+
]
95+
],
96+
"area": 5852.004927999999,
97+
"iscrowd": 0,
98+
"image_id": 1,
99+
"bbox": [
100+
74.99990400000002,
101+
76.000064,
102+
76.000064,
103+
77.0
104+
],
105+
"category_id": 1,
106+
"id": 3
107+
},
108+
{
109+
"segmentation": [
110+
[
111+
12.000127999999997,
112+
135.000096,
113+
97.00006400000001,
114+
135.000096,
115+
97.00006400000001,
116+
220.00003200000003,
117+
12.000127999999997,
118+
220.00003200000003
119+
]
120+
],
121+
"area": 7224.989120004097,
122+
"iscrowd": 0,
123+
"image_id": 1,
124+
"bbox": [
125+
12.000127999999997,
126+
135.000096,
127+
84.999936,
128+
84.999936
129+
],
130+
"category_id": 1,
131+
"id": 4
132+
},
133+
{
134+
"segmentation": [
135+
[
136+
132.00006399999998,
137+
136.999968,
138+
215.00012799999996,
139+
136.999968,
140+
215.00012799999996,
141+
220.00003199999998,
142+
132.00006399999998,
143+
220.00003199999998
144+
]
145+
],
146+
"area": 6889.010624004095,
147+
"iscrowd": 0,
148+
"image_id": 1,
149+
"bbox": [
150+
132.00006399999998,
151+
136.999968,
152+
83.000064,
153+
83.000064
154+
],
155+
"category_id": 1,
156+
"id": 5
157+
},
158+
{
159+
"segmentation": [],
160+
"area": 0,
161+
"iscrowd": 0,
162+
"image_id": 2,
163+
"bbox": [],
164+
"category_id": -1,
165+
"id": 6
166+
}
167+
],
168+
"categories": [
169+
{
170+
"supercategory": "stamp",
171+
"id": 1,
172+
"name": "stamp"
173+
}
174+
]
175+
}

labelImg_2_yolov5.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from tqdm import tqdm
1111

1212

13-
class LabelImgToYOLOV5(object):
13+
class LabelImgToYOLOV5():
1414
def __init__(self, root_dir, out_dir, val_ratio, have_test, test_ratio):
1515
self.root_dir = Path(root_dir)
1616
self.verify_exists(self.root_dir)

yolov5_2_coco.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
import argparse
66
import json
77
import shutil
8-
from pathlib import Path
98
import time
109
import warnings
10+
from pathlib import Path
1111

1212
import cv2
1313
from tqdm import tqdm
1414

1515

16-
class YOLOV5ToCOCO(object):
16+
class YOLOV5ToCOCO():
1717
def __init__(self, data_dir):
1818
self.raw_data_dir = Path(data_dir)
1919

yolov5_yaml_2_coco.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def verify_exists(file_path):
2929
raise FileNotFoundError(f'The {file_path} is not exists!!!')
3030

3131

32-
class YOLOV5CFG2COCO(object):
32+
class YOLOV5CFG2COCO():
3333
def __init__(self, yaml_path):
3434
verify_exists(yaml_path)
3535
with open(yaml_path, 'r', encoding="UTF-8") as f:

0 commit comments

Comments
 (0)