|
a |
|
b/data/Objects365.yaml |
|
|
1 |
# YOLOv5 🚀 by Ultralytics, AGPL-3.0 license |
|
|
2 |
# Objects365 dataset https://www.objects365.org/ by Megvii |
|
|
3 |
# Example usage: python train.py --data Objects365.yaml |
|
|
4 |
# parent |
|
|
5 |
# ├── yolov5 |
|
|
6 |
# └── datasets |
|
|
7 |
# └── Objects365 ← downloads here (712 GB = 367G data + 345G zips) |
|
|
8 |
|
|
|
9 |
|
|
|
10 |
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..] |
|
|
11 |
path: ../datasets/Objects365 # dataset root dir |
|
|
12 |
train: images/train # train images (relative to 'path') 1742289 images |
|
|
13 |
val: images/val # val images (relative to 'path') 80000 images |
|
|
14 |
test: # test images (optional) |
|
|
15 |
|
|
|
16 |
# Classes |
|
|
17 |
names: |
|
|
18 |
0: Person |
|
|
19 |
1: Sneakers |
|
|
20 |
2: Chair |
|
|
21 |
3: Other Shoes |
|
|
22 |
4: Hat |
|
|
23 |
5: Car |
|
|
24 |
6: Lamp |
|
|
25 |
7: Glasses |
|
|
26 |
8: Bottle |
|
|
27 |
9: Desk |
|
|
28 |
10: Cup |
|
|
29 |
11: Street Lights |
|
|
30 |
12: Cabinet/shelf |
|
|
31 |
13: Handbag/Satchel |
|
|
32 |
14: Bracelet |
|
|
33 |
15: Plate |
|
|
34 |
16: Picture/Frame |
|
|
35 |
17: Helmet |
|
|
36 |
18: Book |
|
|
37 |
19: Gloves |
|
|
38 |
20: Storage box |
|
|
39 |
21: Boat |
|
|
40 |
22: Leather Shoes |
|
|
41 |
23: Flower |
|
|
42 |
24: Bench |
|
|
43 |
25: Potted Plant |
|
|
44 |
26: Bowl/Basin |
|
|
45 |
27: Flag |
|
|
46 |
28: Pillow |
|
|
47 |
29: Boots |
|
|
48 |
30: Vase |
|
|
49 |
31: Microphone |
|
|
50 |
32: Necklace |
|
|
51 |
33: Ring |
|
|
52 |
34: SUV |
|
|
53 |
35: Wine Glass |
|
|
54 |
36: Belt |
|
|
55 |
37: Monitor/TV |
|
|
56 |
38: Backpack |
|
|
57 |
39: Umbrella |
|
|
58 |
40: Traffic Light |
|
|
59 |
41: Speaker |
|
|
60 |
42: Watch |
|
|
61 |
43: Tie |
|
|
62 |
44: Trash bin Can |
|
|
63 |
45: Slippers |
|
|
64 |
46: Bicycle |
|
|
65 |
47: Stool |
|
|
66 |
48: Barrel/bucket |
|
|
67 |
49: Van |
|
|
68 |
50: Couch |
|
|
69 |
51: Sandals |
|
|
70 |
52: Basket |
|
|
71 |
53: Drum |
|
|
72 |
54: Pen/Pencil |
|
|
73 |
55: Bus |
|
|
74 |
56: Wild Bird |
|
|
75 |
57: High Heels |
|
|
76 |
58: Motorcycle |
|
|
77 |
59: Guitar |
|
|
78 |
60: Carpet |
|
|
79 |
61: Cell Phone |
|
|
80 |
62: Bread |
|
|
81 |
63: Camera |
|
|
82 |
64: Canned |
|
|
83 |
65: Truck |
|
|
84 |
66: Traffic cone |
|
|
85 |
67: Cymbal |
|
|
86 |
68: Lifesaver |
|
|
87 |
69: Towel |
|
|
88 |
70: Stuffed Toy |
|
|
89 |
71: Candle |
|
|
90 |
72: Sailboat |
|
|
91 |
73: Laptop |
|
|
92 |
74: Awning |
|
|
93 |
75: Bed |
|
|
94 |
76: Faucet |
|
|
95 |
77: Tent |
|
|
96 |
78: Horse |
|
|
97 |
79: Mirror |
|
|
98 |
80: Power outlet |
|
|
99 |
81: Sink |
|
|
100 |
82: Apple |
|
|
101 |
83: Air Conditioner |
|
|
102 |
84: Knife |
|
|
103 |
85: Hockey Stick |
|
|
104 |
86: Paddle |
|
|
105 |
87: Pickup Truck |
|
|
106 |
88: Fork |
|
|
107 |
89: Traffic Sign |
|
|
108 |
90: Balloon |
|
|
109 |
91: Tripod |
|
|
110 |
92: Dog |
|
|
111 |
93: Spoon |
|
|
112 |
94: Clock |
|
|
113 |
95: Pot |
|
|
114 |
96: Cow |
|
|
115 |
97: Cake |
|
|
116 |
98: Dinning Table |
|
|
117 |
99: Sheep |
|
|
118 |
100: Hanger |
|
|
119 |
101: Blackboard/Whiteboard |
|
|
120 |
102: Napkin |
|
|
121 |
103: Other Fish |
|
|
122 |
104: Orange/Tangerine |
|
|
123 |
105: Toiletry |
|
|
124 |
106: Keyboard |
|
|
125 |
107: Tomato |
|
|
126 |
108: Lantern |
|
|
127 |
109: Machinery Vehicle |
|
|
128 |
110: Fan |
|
|
129 |
111: Green Vegetables |
|
|
130 |
112: Banana |
|
|
131 |
113: Baseball Glove |
|
|
132 |
114: Airplane |
|
|
133 |
115: Mouse |
|
|
134 |
116: Train |
|
|
135 |
117: Pumpkin |
|
|
136 |
118: Soccer |
|
|
137 |
119: Skiboard |
|
|
138 |
120: Luggage |
|
|
139 |
121: Nightstand |
|
|
140 |
122: Tea pot |
|
|
141 |
123: Telephone |
|
|
142 |
124: Trolley |
|
|
143 |
125: Head Phone |
|
|
144 |
126: Sports Car |
|
|
145 |
127: Stop Sign |
|
|
146 |
128: Dessert |
|
|
147 |
129: Scooter |
|
|
148 |
130: Stroller |
|
|
149 |
131: Crane |
|
|
150 |
132: Remote |
|
|
151 |
133: Refrigerator |
|
|
152 |
134: Oven |
|
|
153 |
135: Lemon |
|
|
154 |
136: Duck |
|
|
155 |
137: Baseball Bat |
|
|
156 |
138: Surveillance Camera |
|
|
157 |
139: Cat |
|
|
158 |
140: Jug |
|
|
159 |
141: Broccoli |
|
|
160 |
142: Piano |
|
|
161 |
143: Pizza |
|
|
162 |
144: Elephant |
|
|
163 |
145: Skateboard |
|
|
164 |
146: Surfboard |
|
|
165 |
147: Gun |
|
|
166 |
148: Skating and Skiing shoes |
|
|
167 |
149: Gas stove |
|
|
168 |
150: Donut |
|
|
169 |
151: Bow Tie |
|
|
170 |
152: Carrot |
|
|
171 |
153: Toilet |
|
|
172 |
154: Kite |
|
|
173 |
155: Strawberry |
|
|
174 |
156: Other Balls |
|
|
175 |
157: Shovel |
|
|
176 |
158: Pepper |
|
|
177 |
159: Computer Box |
|
|
178 |
160: Toilet Paper |
|
|
179 |
161: Cleaning Products |
|
|
180 |
162: Chopsticks |
|
|
181 |
163: Microwave |
|
|
182 |
164: Pigeon |
|
|
183 |
165: Baseball |
|
|
184 |
166: Cutting/chopping Board |
|
|
185 |
167: Coffee Table |
|
|
186 |
168: Side Table |
|
|
187 |
169: Scissors |
|
|
188 |
170: Marker |
|
|
189 |
171: Pie |
|
|
190 |
172: Ladder |
|
|
191 |
173: Snowboard |
|
|
192 |
174: Cookies |
|
|
193 |
175: Radiator |
|
|
194 |
176: Fire Hydrant |
|
|
195 |
177: Basketball |
|
|
196 |
178: Zebra |
|
|
197 |
179: Grape |
|
|
198 |
180: Giraffe |
|
|
199 |
181: Potato |
|
|
200 |
182: Sausage |
|
|
201 |
183: Tricycle |
|
|
202 |
184: Violin |
|
|
203 |
185: Egg |
|
|
204 |
186: Fire Extinguisher |
|
|
205 |
187: Candy |
|
|
206 |
188: Fire Truck |
|
|
207 |
189: Billiards |
|
|
208 |
190: Converter |
|
|
209 |
191: Bathtub |
|
|
210 |
192: Wheelchair |
|
|
211 |
193: Golf Club |
|
|
212 |
194: Briefcase |
|
|
213 |
195: Cucumber |
|
|
214 |
196: Cigar/Cigarette |
|
|
215 |
197: Paint Brush |
|
|
216 |
198: Pear |
|
|
217 |
199: Heavy Truck |
|
|
218 |
200: Hamburger |
|
|
219 |
201: Extractor |
|
|
220 |
202: Extension Cord |
|
|
221 |
203: Tong |
|
|
222 |
204: Tennis Racket |
|
|
223 |
205: Folder |
|
|
224 |
206: American Football |
|
|
225 |
207: earphone |
|
|
226 |
208: Mask |
|
|
227 |
209: Kettle |
|
|
228 |
210: Tennis |
|
|
229 |
211: Ship |
|
|
230 |
212: Swing |
|
|
231 |
213: Coffee Machine |
|
|
232 |
214: Slide |
|
|
233 |
215: Carriage |
|
|
234 |
216: Onion |
|
|
235 |
217: Green beans |
|
|
236 |
218: Projector |
|
|
237 |
219: Frisbee |
|
|
238 |
220: Washing Machine/Drying Machine |
|
|
239 |
221: Chicken |
|
|
240 |
222: Printer |
|
|
241 |
223: Watermelon |
|
|
242 |
224: Saxophone |
|
|
243 |
225: Tissue |
|
|
244 |
226: Toothbrush |
|
|
245 |
227: Ice cream |
|
|
246 |
228: Hot-air balloon |
|
|
247 |
229: Cello |
|
|
248 |
230: French Fries |
|
|
249 |
231: Scale |
|
|
250 |
232: Trophy |
|
|
251 |
233: Cabbage |
|
|
252 |
234: Hot dog |
|
|
253 |
235: Blender |
|
|
254 |
236: Peach |
|
|
255 |
237: Rice |
|
|
256 |
238: Wallet/Purse |
|
|
257 |
239: Volleyball |
|
|
258 |
240: Deer |
|
|
259 |
241: Goose |
|
|
260 |
242: Tape |
|
|
261 |
243: Tablet |
|
|
262 |
244: Cosmetics |
|
|
263 |
245: Trumpet |
|
|
264 |
246: Pineapple |
|
|
265 |
247: Golf Ball |
|
|
266 |
248: Ambulance |
|
|
267 |
249: Parking meter |
|
|
268 |
250: Mango |
|
|
269 |
251: Key |
|
|
270 |
252: Hurdle |
|
|
271 |
253: Fishing Rod |
|
|
272 |
254: Medal |
|
|
273 |
255: Flute |
|
|
274 |
256: Brush |
|
|
275 |
257: Penguin |
|
|
276 |
258: Megaphone |
|
|
277 |
259: Corn |
|
|
278 |
260: Lettuce |
|
|
279 |
261: Garlic |
|
|
280 |
262: Swan |
|
|
281 |
263: Helicopter |
|
|
282 |
264: Green Onion |
|
|
283 |
265: Sandwich |
|
|
284 |
266: Nuts |
|
|
285 |
267: Speed Limit Sign |
|
|
286 |
268: Induction Cooker |
|
|
287 |
269: Broom |
|
|
288 |
270: Trombone |
|
|
289 |
271: Plum |
|
|
290 |
272: Rickshaw |
|
|
291 |
273: Goldfish |
|
|
292 |
274: Kiwi fruit |
|
|
293 |
275: Router/modem |
|
|
294 |
276: Poker Card |
|
|
295 |
277: Toaster |
|
|
296 |
278: Shrimp |
|
|
297 |
279: Sushi |
|
|
298 |
280: Cheese |
|
|
299 |
281: Notepaper |
|
|
300 |
282: Cherry |
|
|
301 |
283: Pliers |
|
|
302 |
284: CD |
|
|
303 |
285: Pasta |
|
|
304 |
286: Hammer |
|
|
305 |
287: Cue |
|
|
306 |
288: Avocado |
|
|
307 |
289: Hamimelon |
|
|
308 |
290: Flask |
|
|
309 |
291: Mushroom |
|
|
310 |
292: Screwdriver |
|
|
311 |
293: Soap |
|
|
312 |
294: Recorder |
|
|
313 |
295: Bear |
|
|
314 |
296: Eggplant |
|
|
315 |
297: Board Eraser |
|
|
316 |
298: Coconut |
|
|
317 |
299: Tape Measure/Ruler |
|
|
318 |
300: Pig |
|
|
319 |
301: Showerhead |
|
|
320 |
302: Globe |
|
|
321 |
303: Chips |
|
|
322 |
304: Steak |
|
|
323 |
305: Crosswalk Sign |
|
|
324 |
306: Stapler |
|
|
325 |
307: Camel |
|
|
326 |
308: Formula 1 |
|
|
327 |
309: Pomegranate |
|
|
328 |
310: Dishwasher |
|
|
329 |
311: Crab |
|
|
330 |
312: Hoverboard |
|
|
331 |
313: Meat ball |
|
|
332 |
314: Rice Cooker |
|
|
333 |
315: Tuba |
|
|
334 |
316: Calculator |
|
|
335 |
317: Papaya |
|
|
336 |
318: Antelope |
|
|
337 |
319: Parrot |
|
|
338 |
320: Seal |
|
|
339 |
321: Butterfly |
|
|
340 |
322: Dumbbell |
|
|
341 |
323: Donkey |
|
|
342 |
324: Lion |
|
|
343 |
325: Urinal |
|
|
344 |
326: Dolphin |
|
|
345 |
327: Electric Drill |
|
|
346 |
328: Hair Dryer |
|
|
347 |
329: Egg tart |
|
|
348 |
330: Jellyfish |
|
|
349 |
331: Treadmill |
|
|
350 |
332: Lighter |
|
|
351 |
333: Grapefruit |
|
|
352 |
334: Game board |
|
|
353 |
335: Mop |
|
|
354 |
336: Radish |
|
|
355 |
337: Baozi |
|
|
356 |
338: Target |
|
|
357 |
339: French |
|
|
358 |
340: Spring Rolls |
|
|
359 |
341: Monkey |
|
|
360 |
342: Rabbit |
|
|
361 |
343: Pencil Case |
|
|
362 |
344: Yak |
|
|
363 |
345: Red Cabbage |
|
|
364 |
346: Binoculars |
|
|
365 |
347: Asparagus |
|
|
366 |
348: Barbell |
|
|
367 |
349: Scallop |
|
|
368 |
350: Noddles |
|
|
369 |
351: Comb |
|
|
370 |
352: Dumpling |
|
|
371 |
353: Oyster |
|
|
372 |
354: Table Tennis paddle |
|
|
373 |
355: Cosmetics Brush/Eyeliner Pencil |
|
|
374 |
356: Chainsaw |
|
|
375 |
357: Eraser |
|
|
376 |
358: Lobster |
|
|
377 |
359: Durian |
|
|
378 |
360: Okra |
|
|
379 |
361: Lipstick |
|
|
380 |
362: Cosmetics Mirror |
|
|
381 |
363: Curling |
|
|
382 |
364: Table Tennis |
|
|
383 |
|
|
|
384 |
|
|
|
385 |
# Download script/URL (optional) --------------------------------------------------------------------------------------- |
|
|
386 |
download: | |
|
|
387 |
from tqdm import tqdm |
|
|
388 |
|
|
|
389 |
from utils.general import Path, check_requirements, download, np, xyxy2xywhn |
|
|
390 |
|
|
|
391 |
check_requirements('pycocotools>=2.0') |
|
|
392 |
from pycocotools.coco import COCO |
|
|
393 |
|
|
|
394 |
# Make Directories |
|
|
395 |
dir = Path(yaml['path']) # dataset root dir |
|
|
396 |
for p in 'images', 'labels': |
|
|
397 |
(dir / p).mkdir(parents=True, exist_ok=True) |
|
|
398 |
for q in 'train', 'val': |
|
|
399 |
(dir / p / q).mkdir(parents=True, exist_ok=True) |
|
|
400 |
|
|
|
401 |
# Train, Val Splits |
|
|
402 |
for split, patches in [('train', 50 + 1), ('val', 43 + 1)]: |
|
|
403 |
print(f"Processing {split} in {patches} patches ...") |
|
|
404 |
images, labels = dir / 'images' / split, dir / 'labels' / split |
|
|
405 |
|
|
|
406 |
# Download |
|
|
407 |
url = f"https://dorc.ks3-cn-beijing.ksyun.com/data-set/2020Objects365%E6%95%B0%E6%8D%AE%E9%9B%86/{split}/" |
|
|
408 |
if split == 'train': |
|
|
409 |
download([f'{url}zhiyuan_objv2_{split}.tar.gz'], dir=dir, delete=False) # annotations json |
|
|
410 |
download([f'{url}patch{i}.tar.gz' for i in range(patches)], dir=images, curl=True, delete=False, threads=8) |
|
|
411 |
elif split == 'val': |
|
|
412 |
download([f'{url}zhiyuan_objv2_{split}.json'], dir=dir, delete=False) # annotations json |
|
|
413 |
download([f'{url}images/v1/patch{i}.tar.gz' for i in range(15 + 1)], dir=images, curl=True, delete=False, threads=8) |
|
|
414 |
download([f'{url}images/v2/patch{i}.tar.gz' for i in range(16, patches)], dir=images, curl=True, delete=False, threads=8) |
|
|
415 |
|
|
|
416 |
# Move |
|
|
417 |
for f in tqdm(images.rglob('*.jpg'), desc=f'Moving {split} images'): |
|
|
418 |
f.rename(images / f.name) # move to /images/{split} |
|
|
419 |
|
|
|
420 |
# Labels |
|
|
421 |
coco = COCO(dir / f'zhiyuan_objv2_{split}.json') |
|
|
422 |
names = [x["name"] for x in coco.loadCats(coco.getCatIds())] |
|
|
423 |
for cid, cat in enumerate(names): |
|
|
424 |
catIds = coco.getCatIds(catNms=[cat]) |
|
|
425 |
imgIds = coco.getImgIds(catIds=catIds) |
|
|
426 |
for im in tqdm(coco.loadImgs(imgIds), desc=f'Class {cid + 1}/{len(names)} {cat}'): |
|
|
427 |
width, height = im["width"], im["height"] |
|
|
428 |
path = Path(im["file_name"]) # image filename |
|
|
429 |
try: |
|
|
430 |
with open(labels / path.with_suffix('.txt').name, 'a') as file: |
|
|
431 |
annIds = coco.getAnnIds(imgIds=im["id"], catIds=catIds, iscrowd=False) |
|
|
432 |
for a in coco.loadAnns(annIds): |
|
|
433 |
x, y, w, h = a['bbox'] # bounding box in xywh (xy top-left corner) |
|
|
434 |
xyxy = np.array([x, y, x + w, y + h])[None] # pixels(1,4) |
|
|
435 |
x, y, w, h = xyxy2xywhn(xyxy, w=width, h=height, clip=True)[0] # normalized and clipped |
|
|
436 |
file.write(f"{cid} {x:.5f} {y:.5f} {w:.5f} {h:.5f}\n") |
|
|
437 |
except Exception as e: |
|
|
438 |
print(e) |