category.py 24 KB

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