category.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940
  1. # Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from __future__ import absolute_import
  15. from __future__ import division
  16. from __future__ import print_function
  17. import os
  18. from ppdet.data.source.voc import pascalvoc_label
  19. from ppdet.data.source.widerface import widerface_label
  20. from ppdet.utils.logger import setup_logger
  21. logger = setup_logger(__name__)
  22. __all__ = ['get_categories']
  23. def get_categories(metric_type, anno_file=None, arch=None):
  24. """
  25. Get class id to category id map and category id
  26. to category name map from annotation file.
  27. Args:
  28. metric_type (str): metric type, currently support 'coco', 'voc', 'oid'
  29. and 'widerface'.
  30. anno_file (str): annotation file path
  31. """
  32. if arch == 'keypoint_arch':
  33. return (None, {'id': 'keypoint'})
  34. if anno_file == None or (not os.path.isfile(anno_file)):
  35. logger.warning(
  36. "anno_file '{}' is None or not set or not exist, "
  37. "please recheck TrainDataset/EvalDataset/TestDataset.anno_path, "
  38. "otherwise the default categories will be used by metric_type.".
  39. format(anno_file))
  40. if metric_type.lower() == 'coco' or metric_type.lower(
  41. ) == 'rbox' or metric_type.lower() == 'snipercoco':
  42. if anno_file and os.path.isfile(anno_file):
  43. if anno_file.endswith('json'):
  44. # lazy import pycocotools here
  45. from pycocotools.coco import COCO
  46. coco = COCO(anno_file)
  47. cats = coco.loadCats(coco.getCatIds())
  48. clsid2catid = {i: cat['id'] for i, cat in enumerate(cats)}
  49. catid2name = {cat['id']: cat['name'] for cat in cats}
  50. elif anno_file.endswith('txt'):
  51. cats = []
  52. with open(anno_file) as f:
  53. for line in f.readlines():
  54. cats.append(line.strip())
  55. if cats[0] == 'background': cats = cats[1:]
  56. clsid2catid = {i: i for i in range(len(cats))}
  57. catid2name = {i: name for i, name in enumerate(cats)}
  58. else:
  59. raise ValueError("anno_file {} should be json or txt.".format(
  60. anno_file))
  61. return clsid2catid, catid2name
  62. # anno file not exist, load default categories of COCO17
  63. else:
  64. if metric_type.lower() == 'rbox':
  65. logger.warning(
  66. "metric_type: {}, load default categories of DOTA.".format(
  67. metric_type))
  68. return _dota_category()
  69. logger.warning("metric_type: {}, load default categories of COCO.".
  70. format(metric_type))
  71. return _coco17_category()
  72. elif metric_type.lower() == 'voc':
  73. if anno_file and os.path.isfile(anno_file):
  74. cats = []
  75. with open(anno_file) as f:
  76. for line in f.readlines():
  77. cats.append(line.strip())
  78. if cats[0] == 'background':
  79. cats = cats[1:]
  80. clsid2catid = {i: i for i in range(len(cats))}
  81. catid2name = {i: name for i, name in enumerate(cats)}
  82. return clsid2catid, catid2name
  83. # anno file not exist, load default categories of
  84. # VOC all 20 categories
  85. else:
  86. logger.warning("metric_type: {}, load default categories of VOC.".
  87. format(metric_type))
  88. return _vocall_category()
  89. elif metric_type.lower() == 'oid':
  90. if anno_file and os.path.isfile(anno_file):
  91. logger.warning("only default categories support for OID19")
  92. return _oid19_category()
  93. elif metric_type.lower() == 'widerface':
  94. return _widerface_category()
  95. elif metric_type.lower() == 'keypointtopdowncocoeval' or metric_type.lower(
  96. ) == 'keypointtopdownmpiieval':
  97. return (None, {'id': 'keypoint'})
  98. elif metric_type.lower() == 'pose3deval':
  99. return (None, {'id': 'pose3d'})
  100. elif metric_type.lower() in ['mot', 'motdet', 'reid']:
  101. if anno_file and os.path.isfile(anno_file):
  102. cats = []
  103. with open(anno_file) as f:
  104. for line in f.readlines():
  105. cats.append(line.strip())
  106. if cats[0] == 'background':
  107. cats = cats[1:]
  108. clsid2catid = {i: i for i in range(len(cats))}
  109. catid2name = {i: name for i, name in enumerate(cats)}
  110. return clsid2catid, catid2name
  111. # anno file not exist, load default category 'pedestrian'.
  112. else:
  113. logger.warning(
  114. "metric_type: {}, load default categories of pedestrian MOT.".
  115. format(metric_type))
  116. return _mot_category(category='pedestrian')
  117. elif metric_type.lower() in ['kitti', 'bdd100kmot']:
  118. return _mot_category(category='vehicle')
  119. elif metric_type.lower() in ['mcmot']:
  120. if anno_file and os.path.isfile(anno_file):
  121. cats = []
  122. with open(anno_file) as f:
  123. for line in f.readlines():
  124. cats.append(line.strip())
  125. if cats[0] == 'background':
  126. cats = cats[1:]
  127. clsid2catid = {i: i for i in range(len(cats))}
  128. catid2name = {i: name for i, name in enumerate(cats)}
  129. return clsid2catid, catid2name
  130. # anno file not exist, load default categories of visdrone all 10 categories
  131. else:
  132. logger.warning(
  133. "metric_type: {}, load default categories of VisDrone.".format(
  134. metric_type))
  135. return _visdrone_category()
  136. else:
  137. raise ValueError("unknown metric type {}".format(metric_type))
  138. def _mot_category(category='pedestrian'):
  139. """
  140. Get class id to category id map and category id
  141. to category name map of mot dataset
  142. """
  143. label_map = {category: 0}
  144. label_map = sorted(label_map.items(), key=lambda x: x[1])
  145. cats = [l[0] for l in label_map]
  146. clsid2catid = {i: i for i in range(len(cats))}
  147. catid2name = {i: name for i, name in enumerate(cats)}
  148. return clsid2catid, catid2name
  149. def _coco17_category():
  150. """
  151. Get class id to category id map and category id
  152. to category name map of COCO2017 dataset
  153. """
  154. clsid2catid = {
  155. 1: 1,
  156. 2: 2,
  157. 3: 3,
  158. 4: 4,
  159. 5: 5,
  160. 6: 6,
  161. 7: 7,
  162. 8: 8,
  163. 9: 9,
  164. 10: 10,
  165. 11: 11,
  166. 12: 13,
  167. 13: 14,
  168. 14: 15,
  169. 15: 16,
  170. 16: 17,
  171. 17: 18,
  172. 18: 19,
  173. 19: 20,
  174. 20: 21,
  175. 21: 22,
  176. 22: 23,
  177. 23: 24,
  178. 24: 25,
  179. 25: 27,
  180. 26: 28,
  181. 27: 31,
  182. 28: 32,
  183. 29: 33,
  184. 30: 34,
  185. 31: 35,
  186. 32: 36,
  187. 33: 37,
  188. 34: 38,
  189. 35: 39,
  190. 36: 40,
  191. 37: 41,
  192. 38: 42,
  193. 39: 43,
  194. 40: 44,
  195. 41: 46,
  196. 42: 47,
  197. 43: 48,
  198. 44: 49,
  199. 45: 50,
  200. 46: 51,
  201. 47: 52,
  202. 48: 53,
  203. 49: 54,
  204. 50: 55,
  205. 51: 56,
  206. 52: 57,
  207. 53: 58,
  208. 54: 59,
  209. 55: 60,
  210. 56: 61,
  211. 57: 62,
  212. 58: 63,
  213. 59: 64,
  214. 60: 65,
  215. 61: 67,
  216. 62: 70,
  217. 63: 72,
  218. 64: 73,
  219. 65: 74,
  220. 66: 75,
  221. 67: 76,
  222. 68: 77,
  223. 69: 78,
  224. 70: 79,
  225. 71: 80,
  226. 72: 81,
  227. 73: 82,
  228. 74: 84,
  229. 75: 85,
  230. 76: 86,
  231. 77: 87,
  232. 78: 88,
  233. 79: 89,
  234. 80: 90
  235. }
  236. catid2name = {
  237. 0: 'background',
  238. 1: 'person',
  239. 2: 'bicycle',
  240. 3: 'car',
  241. 4: 'motorcycle',
  242. 5: 'airplane',
  243. 6: 'bus',
  244. 7: 'train',
  245. 8: 'truck',
  246. 9: 'boat',
  247. 10: 'traffic light',
  248. 11: 'fire hydrant',
  249. 13: 'stop sign',
  250. 14: 'parking meter',
  251. 15: 'bench',
  252. 16: 'bird',
  253. 17: 'cat',
  254. 18: 'dog',
  255. 19: 'horse',
  256. 20: 'sheep',
  257. 21: 'cow',
  258. 22: 'elephant',
  259. 23: 'bear',
  260. 24: 'zebra',
  261. 25: 'giraffe',
  262. 27: 'backpack',
  263. 28: 'umbrella',
  264. 31: 'handbag',
  265. 32: 'tie',
  266. 33: 'suitcase',
  267. 34: 'frisbee',
  268. 35: 'skis',
  269. 36: 'snowboard',
  270. 37: 'sports ball',
  271. 38: 'kite',
  272. 39: 'baseball bat',
  273. 40: 'baseball glove',
  274. 41: 'skateboard',
  275. 42: 'surfboard',
  276. 43: 'tennis racket',
  277. 44: 'bottle',
  278. 46: 'wine glass',
  279. 47: 'cup',
  280. 48: 'fork',
  281. 49: 'knife',
  282. 50: 'spoon',
  283. 51: 'bowl',
  284. 52: 'banana',
  285. 53: 'apple',
  286. 54: 'sandwich',
  287. 55: 'orange',
  288. 56: 'broccoli',
  289. 57: 'carrot',
  290. 58: 'hot dog',
  291. 59: 'pizza',
  292. 60: 'donut',
  293. 61: 'cake',
  294. 62: 'chair',
  295. 63: 'couch',
  296. 64: 'potted plant',
  297. 65: 'bed',
  298. 67: 'dining table',
  299. 70: 'toilet',
  300. 72: 'tv',
  301. 73: 'laptop',
  302. 74: 'mouse',
  303. 75: 'remote',
  304. 76: 'keyboard',
  305. 77: 'cell phone',
  306. 78: 'microwave',
  307. 79: 'oven',
  308. 80: 'toaster',
  309. 81: 'sink',
  310. 82: 'refrigerator',
  311. 84: 'book',
  312. 85: 'clock',
  313. 86: 'vase',
  314. 87: 'scissors',
  315. 88: 'teddy bear',
  316. 89: 'hair drier',
  317. 90: 'toothbrush'
  318. }
  319. clsid2catid = {k - 1: v for k, v in clsid2catid.items()}
  320. catid2name.pop(0)
  321. return clsid2catid, catid2name
  322. def _dota_category():
  323. """
  324. Get class id to category id map and category id
  325. to category name map of dota dataset
  326. """
  327. catid2name = {
  328. 0: 'background',
  329. 1: 'plane',
  330. 2: 'baseball-diamond',
  331. 3: 'bridge',
  332. 4: 'ground-track-field',
  333. 5: 'small-vehicle',
  334. 6: 'large-vehicle',
  335. 7: 'ship',
  336. 8: 'tennis-court',
  337. 9: 'basketball-court',
  338. 10: 'storage-tank',
  339. 11: 'soccer-ball-field',
  340. 12: 'roundabout',
  341. 13: 'harbor',
  342. 14: 'swimming-pool',
  343. 15: 'helicopter'
  344. }
  345. catid2name.pop(0)
  346. clsid2catid = {i: i + 1 for i in range(len(catid2name))}
  347. return clsid2catid, catid2name
  348. def _vocall_category():
  349. """
  350. Get class id to category id map and category id
  351. to category name map of mixup voc dataset
  352. """
  353. label_map = pascalvoc_label()
  354. label_map = sorted(label_map.items(), key=lambda x: x[1])
  355. cats = [l[0] for l in label_map]
  356. clsid2catid = {i: i for i in range(len(cats))}
  357. catid2name = {i: name for i, name in enumerate(cats)}
  358. return clsid2catid, catid2name
  359. def _widerface_category():
  360. label_map = widerface_label()
  361. label_map = sorted(label_map.items(), key=lambda x: x[1])
  362. cats = [l[0] for l in label_map]
  363. clsid2catid = {i: i for i in range(len(cats))}
  364. catid2name = {i: name for i, name in enumerate(cats)}
  365. return clsid2catid, catid2name
  366. def _oid19_category():
  367. clsid2catid = {k: k + 1 for k in range(500)}
  368. catid2name = {
  369. 0: "background",
  370. 1: "Infant bed",
  371. 2: "Rose",
  372. 3: "Flag",
  373. 4: "Flashlight",
  374. 5: "Sea turtle",
  375. 6: "Camera",
  376. 7: "Animal",
  377. 8: "Glove",
  378. 9: "Crocodile",
  379. 10: "Cattle",
  380. 11: "House",
  381. 12: "Guacamole",
  382. 13: "Penguin",
  383. 14: "Vehicle registration plate",
  384. 15: "Bench",
  385. 16: "Ladybug",
  386. 17: "Human nose",
  387. 18: "Watermelon",
  388. 19: "Flute",
  389. 20: "Butterfly",
  390. 21: "Washing machine",
  391. 22: "Raccoon",
  392. 23: "Segway",
  393. 24: "Taco",
  394. 25: "Jellyfish",
  395. 26: "Cake",
  396. 27: "Pen",
  397. 28: "Cannon",
  398. 29: "Bread",
  399. 30: "Tree",
  400. 31: "Shellfish",
  401. 32: "Bed",
  402. 33: "Hamster",
  403. 34: "Hat",
  404. 35: "Toaster",
  405. 36: "Sombrero",
  406. 37: "Tiara",
  407. 38: "Bowl",
  408. 39: "Dragonfly",
  409. 40: "Moths and butterflies",
  410. 41: "Antelope",
  411. 42: "Vegetable",
  412. 43: "Torch",
  413. 44: "Building",
  414. 45: "Power plugs and sockets",
  415. 46: "Blender",
  416. 47: "Billiard table",
  417. 48: "Cutting board",
  418. 49: "Bronze sculpture",
  419. 50: "Turtle",
  420. 51: "Broccoli",
  421. 52: "Tiger",
  422. 53: "Mirror",
  423. 54: "Bear",
  424. 55: "Zucchini",
  425. 56: "Dress",
  426. 57: "Volleyball",
  427. 58: "Guitar",
  428. 59: "Reptile",
  429. 60: "Golf cart",
  430. 61: "Tart",
  431. 62: "Fedora",
  432. 63: "Carnivore",
  433. 64: "Car",
  434. 65: "Lighthouse",
  435. 66: "Coffeemaker",
  436. 67: "Food processor",
  437. 68: "Truck",
  438. 69: "Bookcase",
  439. 70: "Surfboard",
  440. 71: "Footwear",
  441. 72: "Bench",
  442. 73: "Necklace",
  443. 74: "Flower",
  444. 75: "Radish",
  445. 76: "Marine mammal",
  446. 77: "Frying pan",
  447. 78: "Tap",
  448. 79: "Peach",
  449. 80: "Knife",
  450. 81: "Handbag",
  451. 82: "Laptop",
  452. 83: "Tent",
  453. 84: "Ambulance",
  454. 85: "Christmas tree",
  455. 86: "Eagle",
  456. 87: "Limousine",
  457. 88: "Kitchen & dining room table",
  458. 89: "Polar bear",
  459. 90: "Tower",
  460. 91: "Football",
  461. 92: "Willow",
  462. 93: "Human head",
  463. 94: "Stop sign",
  464. 95: "Banana",
  465. 96: "Mixer",
  466. 97: "Binoculars",
  467. 98: "Dessert",
  468. 99: "Bee",
  469. 100: "Chair",
  470. 101: "Wood-burning stove",
  471. 102: "Flowerpot",
  472. 103: "Beaker",
  473. 104: "Oyster",
  474. 105: "Woodpecker",
  475. 106: "Harp",
  476. 107: "Bathtub",
  477. 108: "Wall clock",
  478. 109: "Sports uniform",
  479. 110: "Rhinoceros",
  480. 111: "Beehive",
  481. 112: "Cupboard",
  482. 113: "Chicken",
  483. 114: "Man",
  484. 115: "Blue jay",
  485. 116: "Cucumber",
  486. 117: "Balloon",
  487. 118: "Kite",
  488. 119: "Fireplace",
  489. 120: "Lantern",
  490. 121: "Missile",
  491. 122: "Book",
  492. 123: "Spoon",
  493. 124: "Grapefruit",
  494. 125: "Squirrel",
  495. 126: "Orange",
  496. 127: "Coat",
  497. 128: "Punching bag",
  498. 129: "Zebra",
  499. 130: "Billboard",
  500. 131: "Bicycle",
  501. 132: "Door handle",
  502. 133: "Mechanical fan",
  503. 134: "Ring binder",
  504. 135: "Table",
  505. 136: "Parrot",
  506. 137: "Sock",
  507. 138: "Vase",
  508. 139: "Weapon",
  509. 140: "Shotgun",
  510. 141: "Glasses",
  511. 142: "Seahorse",
  512. 143: "Belt",
  513. 144: "Watercraft",
  514. 145: "Window",
  515. 146: "Giraffe",
  516. 147: "Lion",
  517. 148: "Tire",
  518. 149: "Vehicle",
  519. 150: "Canoe",
  520. 151: "Tie",
  521. 152: "Shelf",
  522. 153: "Picture frame",
  523. 154: "Printer",
  524. 155: "Human leg",
  525. 156: "Boat",
  526. 157: "Slow cooker",
  527. 158: "Croissant",
  528. 159: "Candle",
  529. 160: "Pancake",
  530. 161: "Pillow",
  531. 162: "Coin",
  532. 163: "Stretcher",
  533. 164: "Sandal",
  534. 165: "Woman",
  535. 166: "Stairs",
  536. 167: "Harpsichord",
  537. 168: "Stool",
  538. 169: "Bus",
  539. 170: "Suitcase",
  540. 171: "Human mouth",
  541. 172: "Juice",
  542. 173: "Skull",
  543. 174: "Door",
  544. 175: "Violin",
  545. 176: "Chopsticks",
  546. 177: "Digital clock",
  547. 178: "Sunflower",
  548. 179: "Leopard",
  549. 180: "Bell pepper",
  550. 181: "Harbor seal",
  551. 182: "Snake",
  552. 183: "Sewing machine",
  553. 184: "Goose",
  554. 185: "Helicopter",
  555. 186: "Seat belt",
  556. 187: "Coffee cup",
  557. 188: "Microwave oven",
  558. 189: "Hot dog",
  559. 190: "Countertop",
  560. 191: "Serving tray",
  561. 192: "Dog bed",
  562. 193: "Beer",
  563. 194: "Sunglasses",
  564. 195: "Golf ball",
  565. 196: "Waffle",
  566. 197: "Palm tree",
  567. 198: "Trumpet",
  568. 199: "Ruler",
  569. 200: "Helmet",
  570. 201: "Ladder",
  571. 202: "Office building",
  572. 203: "Tablet computer",
  573. 204: "Toilet paper",
  574. 205: "Pomegranate",
  575. 206: "Skirt",
  576. 207: "Gas stove",
  577. 208: "Cookie",
  578. 209: "Cart",
  579. 210: "Raven",
  580. 211: "Egg",
  581. 212: "Burrito",
  582. 213: "Goat",
  583. 214: "Kitchen knife",
  584. 215: "Skateboard",
  585. 216: "Salt and pepper shakers",
  586. 217: "Lynx",
  587. 218: "Boot",
  588. 219: "Platter",
  589. 220: "Ski",
  590. 221: "Swimwear",
  591. 222: "Swimming pool",
  592. 223: "Drinking straw",
  593. 224: "Wrench",
  594. 225: "Drum",
  595. 226: "Ant",
  596. 227: "Human ear",
  597. 228: "Headphones",
  598. 229: "Fountain",
  599. 230: "Bird",
  600. 231: "Jeans",
  601. 232: "Television",
  602. 233: "Crab",
  603. 234: "Microphone",
  604. 235: "Home appliance",
  605. 236: "Snowplow",
  606. 237: "Beetle",
  607. 238: "Artichoke",
  608. 239: "Jet ski",
  609. 240: "Stationary bicycle",
  610. 241: "Human hair",
  611. 242: "Brown bear",
  612. 243: "Starfish",
  613. 244: "Fork",
  614. 245: "Lobster",
  615. 246: "Corded phone",
  616. 247: "Drink",
  617. 248: "Saucer",
  618. 249: "Carrot",
  619. 250: "Insect",
  620. 251: "Clock",
  621. 252: "Castle",
  622. 253: "Tennis racket",
  623. 254: "Ceiling fan",
  624. 255: "Asparagus",
  625. 256: "Jaguar",
  626. 257: "Musical instrument",
  627. 258: "Train",
  628. 259: "Cat",
  629. 260: "Rifle",
  630. 261: "Dumbbell",
  631. 262: "Mobile phone",
  632. 263: "Taxi",
  633. 264: "Shower",
  634. 265: "Pitcher",
  635. 266: "Lemon",
  636. 267: "Invertebrate",
  637. 268: "Turkey",
  638. 269: "High heels",
  639. 270: "Bust",
  640. 271: "Elephant",
  641. 272: "Scarf",
  642. 273: "Barrel",
  643. 274: "Trombone",
  644. 275: "Pumpkin",
  645. 276: "Box",
  646. 277: "Tomato",
  647. 278: "Frog",
  648. 279: "Bidet",
  649. 280: "Human face",
  650. 281: "Houseplant",
  651. 282: "Van",
  652. 283: "Shark",
  653. 284: "Ice cream",
  654. 285: "Swim cap",
  655. 286: "Falcon",
  656. 287: "Ostrich",
  657. 288: "Handgun",
  658. 289: "Whiteboard",
  659. 290: "Lizard",
  660. 291: "Pasta",
  661. 292: "Snowmobile",
  662. 293: "Light bulb",
  663. 294: "Window blind",
  664. 295: "Muffin",
  665. 296: "Pretzel",
  666. 297: "Computer monitor",
  667. 298: "Horn",
  668. 299: "Furniture",
  669. 300: "Sandwich",
  670. 301: "Fox",
  671. 302: "Convenience store",
  672. 303: "Fish",
  673. 304: "Fruit",
  674. 305: "Earrings",
  675. 306: "Curtain",
  676. 307: "Grape",
  677. 308: "Sofa bed",
  678. 309: "Horse",
  679. 310: "Luggage and bags",
  680. 311: "Desk",
  681. 312: "Crutch",
  682. 313: "Bicycle helmet",
  683. 314: "Tick",
  684. 315: "Airplane",
  685. 316: "Canary",
  686. 317: "Spatula",
  687. 318: "Watch",
  688. 319: "Lily",
  689. 320: "Kitchen appliance",
  690. 321: "Filing cabinet",
  691. 322: "Aircraft",
  692. 323: "Cake stand",
  693. 324: "Candy",
  694. 325: "Sink",
  695. 326: "Mouse",
  696. 327: "Wine",
  697. 328: "Wheelchair",
  698. 329: "Goldfish",
  699. 330: "Refrigerator",
  700. 331: "French fries",
  701. 332: "Drawer",
  702. 333: "Treadmill",
  703. 334: "Picnic basket",
  704. 335: "Dice",
  705. 336: "Cabbage",
  706. 337: "Football helmet",
  707. 338: "Pig",
  708. 339: "Person",
  709. 340: "Shorts",
  710. 341: "Gondola",
  711. 342: "Honeycomb",
  712. 343: "Doughnut",
  713. 344: "Chest of drawers",
  714. 345: "Land vehicle",
  715. 346: "Bat",
  716. 347: "Monkey",
  717. 348: "Dagger",
  718. 349: "Tableware",
  719. 350: "Human foot",
  720. 351: "Mug",
  721. 352: "Alarm clock",
  722. 353: "Pressure cooker",
  723. 354: "Human hand",
  724. 355: "Tortoise",
  725. 356: "Baseball glove",
  726. 357: "Sword",
  727. 358: "Pear",
  728. 359: "Miniskirt",
  729. 360: "Traffic sign",
  730. 361: "Girl",
  731. 362: "Roller skates",
  732. 363: "Dinosaur",
  733. 364: "Porch",
  734. 365: "Human beard",
  735. 366: "Submarine sandwich",
  736. 367: "Screwdriver",
  737. 368: "Strawberry",
  738. 369: "Wine glass",
  739. 370: "Seafood",
  740. 371: "Racket",
  741. 372: "Wheel",
  742. 373: "Sea lion",
  743. 374: "Toy",
  744. 375: "Tea",
  745. 376: "Tennis ball",
  746. 377: "Waste container",
  747. 378: "Mule",
  748. 379: "Cricket ball",
  749. 380: "Pineapple",
  750. 381: "Coconut",
  751. 382: "Doll",
  752. 383: "Coffee table",
  753. 384: "Snowman",
  754. 385: "Lavender",
  755. 386: "Shrimp",
  756. 387: "Maple",
  757. 388: "Cowboy hat",
  758. 389: "Goggles",
  759. 390: "Rugby ball",
  760. 391: "Caterpillar",
  761. 392: "Poster",
  762. 393: "Rocket",
  763. 394: "Organ",
  764. 395: "Saxophone",
  765. 396: "Traffic light",
  766. 397: "Cocktail",
  767. 398: "Plastic bag",
  768. 399: "Squash",
  769. 400: "Mushroom",
  770. 401: "Hamburger",
  771. 402: "Light switch",
  772. 403: "Parachute",
  773. 404: "Teddy bear",
  774. 405: "Winter melon",
  775. 406: "Deer",
  776. 407: "Musical keyboard",
  777. 408: "Plumbing fixture",
  778. 409: "Scoreboard",
  779. 410: "Baseball bat",
  780. 411: "Envelope",
  781. 412: "Adhesive tape",
  782. 413: "Briefcase",
  783. 414: "Paddle",
  784. 415: "Bow and arrow",
  785. 416: "Telephone",
  786. 417: "Sheep",
  787. 418: "Jacket",
  788. 419: "Boy",
  789. 420: "Pizza",
  790. 421: "Otter",
  791. 422: "Office supplies",
  792. 423: "Couch",
  793. 424: "Cello",
  794. 425: "Bull",
  795. 426: "Camel",
  796. 427: "Ball",
  797. 428: "Duck",
  798. 429: "Whale",
  799. 430: "Shirt",
  800. 431: "Tank",
  801. 432: "Motorcycle",
  802. 433: "Accordion",
  803. 434: "Owl",
  804. 435: "Porcupine",
  805. 436: "Sun hat",
  806. 437: "Nail",
  807. 438: "Scissors",
  808. 439: "Swan",
  809. 440: "Lamp",
  810. 441: "Crown",
  811. 442: "Piano",
  812. 443: "Sculpture",
  813. 444: "Cheetah",
  814. 445: "Oboe",
  815. 446: "Tin can",
  816. 447: "Mango",
  817. 448: "Tripod",
  818. 449: "Oven",
  819. 450: "Mouse",
  820. 451: "Barge",
  821. 452: "Coffee",
  822. 453: "Snowboard",
  823. 454: "Common fig",
  824. 455: "Salad",
  825. 456: "Marine invertebrates",
  826. 457: "Umbrella",
  827. 458: "Kangaroo",
  828. 459: "Human arm",
  829. 460: "Measuring cup",
  830. 461: "Snail",
  831. 462: "Loveseat",
  832. 463: "Suit",
  833. 464: "Teapot",
  834. 465: "Bottle",
  835. 466: "Alpaca",
  836. 467: "Kettle",
  837. 468: "Trousers",
  838. 469: "Popcorn",
  839. 470: "Centipede",
  840. 471: "Spider",
  841. 472: "Sparrow",
  842. 473: "Plate",
  843. 474: "Bagel",
  844. 475: "Personal care",
  845. 476: "Apple",
  846. 477: "Brassiere",
  847. 478: "Bathroom cabinet",
  848. 479: "studio couch",
  849. 480: "Computer keyboard",
  850. 481: "Table tennis racket",
  851. 482: "Sushi",
  852. 483: "Cabinetry",
  853. 484: "Street light",
  854. 485: "Towel",
  855. 486: "Nightstand",
  856. 487: "Rabbit",
  857. 488: "Dolphin",
  858. 489: "Dog",
  859. 490: "Jug",
  860. 491: "Wok",
  861. 492: "Fire hydrant",
  862. 493: "Human eye",
  863. 494: "Skyscraper",
  864. 495: "Backpack",
  865. 496: "Potato",
  866. 497: "Paper towel",
  867. 498: "Lifejacket",
  868. 499: "Bicycle wheel",
  869. 500: "Toilet",
  870. }
  871. return clsid2catid, catid2name
  872. def _visdrone_category():
  873. clsid2catid = {i: i for i in range(10)}
  874. catid2name = {
  875. 0: 'pedestrian',
  876. 1: 'people',
  877. 2: 'bicycle',
  878. 3: 'car',
  879. 4: 'van',
  880. 5: 'truck',
  881. 6: 'tricycle',
  882. 7: 'awning-tricycle',
  883. 8: 'bus',
  884. 9: 'motor'
  885. }
  886. return clsid2catid, catid2name