oid_eval.py 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. # Copyright (c) 2019 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. from __future__ import unicode_literals
  18. from .coco_eval import bbox2out
  19. import logging
  20. logger = logging.getLogger(__name__)
  21. __all__ = ['bbox2out', 'get_category_info']
  22. def get_category_info(anno_file=None,
  23. with_background=True,
  24. use_default_label=False):
  25. clsid2catid = {k: k for k in range(1, 501)}
  26. catid2name = {
  27. 0: "background",
  28. 1: "Infant bed",
  29. 2: "Rose",
  30. 3: "Flag",
  31. 4: "Flashlight",
  32. 5: "Sea turtle",
  33. 6: "Camera",
  34. 7: "Animal",
  35. 8: "Glove",
  36. 9: "Crocodile",
  37. 10: "Cattle",
  38. 11: "House",
  39. 12: "Guacamole",
  40. 13: "Penguin",
  41. 14: "Vehicle registration plate",
  42. 15: "Bench",
  43. 16: "Ladybug",
  44. 17: "Human nose",
  45. 18: "Watermelon",
  46. 19: "Flute",
  47. 20: "Butterfly",
  48. 21: "Washing machine",
  49. 22: "Raccoon",
  50. 23: "Segway",
  51. 24: "Taco",
  52. 25: "Jellyfish",
  53. 26: "Cake",
  54. 27: "Pen",
  55. 28: "Cannon",
  56. 29: "Bread",
  57. 30: "Tree",
  58. 31: "Shellfish",
  59. 32: "Bed",
  60. 33: "Hamster",
  61. 34: "Hat",
  62. 35: "Toaster",
  63. 36: "Sombrero",
  64. 37: "Tiara",
  65. 38: "Bowl",
  66. 39: "Dragonfly",
  67. 40: "Moths and butterflies",
  68. 41: "Antelope",
  69. 42: "Vegetable",
  70. 43: "Torch",
  71. 44: "Building",
  72. 45: "Power plugs and sockets",
  73. 46: "Blender",
  74. 47: "Billiard table",
  75. 48: "Cutting board",
  76. 49: "Bronze sculpture",
  77. 50: "Turtle",
  78. 51: "Broccoli",
  79. 52: "Tiger",
  80. 53: "Mirror",
  81. 54: "Bear",
  82. 55: "Zucchini",
  83. 56: "Dress",
  84. 57: "Volleyball",
  85. 58: "Guitar",
  86. 59: "Reptile",
  87. 60: "Golf cart",
  88. 61: "Tart",
  89. 62: "Fedora",
  90. 63: "Carnivore",
  91. 64: "Car",
  92. 65: "Lighthouse",
  93. 66: "Coffeemaker",
  94. 67: "Food processor",
  95. 68: "Truck",
  96. 69: "Bookcase",
  97. 70: "Surfboard",
  98. 71: "Footwear",
  99. 72: "Bench",
  100. 73: "Necklace",
  101. 74: "Flower",
  102. 75: "Radish",
  103. 76: "Marine mammal",
  104. 77: "Frying pan",
  105. 78: "Tap",
  106. 79: "Peach",
  107. 80: "Knife",
  108. 81: "Handbag",
  109. 82: "Laptop",
  110. 83: "Tent",
  111. 84: "Ambulance",
  112. 85: "Christmas tree",
  113. 86: "Eagle",
  114. 87: "Limousine",
  115. 88: "Kitchen & dining room table",
  116. 89: "Polar bear",
  117. 90: "Tower",
  118. 91: "Football",
  119. 92: "Willow",
  120. 93: "Human head",
  121. 94: "Stop sign",
  122. 95: "Banana",
  123. 96: "Mixer",
  124. 97: "Binoculars",
  125. 98: "Dessert",
  126. 99: "Bee",
  127. 100: "Chair",
  128. 101: "Wood-burning stove",
  129. 102: "Flowerpot",
  130. 103: "Beaker",
  131. 104: "Oyster",
  132. 105: "Woodpecker",
  133. 106: "Harp",
  134. 107: "Bathtub",
  135. 108: "Wall clock",
  136. 109: "Sports uniform",
  137. 110: "Rhinoceros",
  138. 111: "Beehive",
  139. 112: "Cupboard",
  140. 113: "Chicken",
  141. 114: "Man",
  142. 115: "Blue jay",
  143. 116: "Cucumber",
  144. 117: "Balloon",
  145. 118: "Kite",
  146. 119: "Fireplace",
  147. 120: "Lantern",
  148. 121: "Missile",
  149. 122: "Book",
  150. 123: "Spoon",
  151. 124: "Grapefruit",
  152. 125: "Squirrel",
  153. 126: "Orange",
  154. 127: "Coat",
  155. 128: "Punching bag",
  156. 129: "Zebra",
  157. 130: "Billboard",
  158. 131: "Bicycle",
  159. 132: "Door handle",
  160. 133: "Mechanical fan",
  161. 134: "Ring binder",
  162. 135: "Table",
  163. 136: "Parrot",
  164. 137: "Sock",
  165. 138: "Vase",
  166. 139: "Weapon",
  167. 140: "Shotgun",
  168. 141: "Glasses",
  169. 142: "Seahorse",
  170. 143: "Belt",
  171. 144: "Watercraft",
  172. 145: "Window",
  173. 146: "Giraffe",
  174. 147: "Lion",
  175. 148: "Tire",
  176. 149: "Vehicle",
  177. 150: "Canoe",
  178. 151: "Tie",
  179. 152: "Shelf",
  180. 153: "Picture frame",
  181. 154: "Printer",
  182. 155: "Human leg",
  183. 156: "Boat",
  184. 157: "Slow cooker",
  185. 158: "Croissant",
  186. 159: "Candle",
  187. 160: "Pancake",
  188. 161: "Pillow",
  189. 162: "Coin",
  190. 163: "Stretcher",
  191. 164: "Sandal",
  192. 165: "Woman",
  193. 166: "Stairs",
  194. 167: "Harpsichord",
  195. 168: "Stool",
  196. 169: "Bus",
  197. 170: "Suitcase",
  198. 171: "Human mouth",
  199. 172: "Juice",
  200. 173: "Skull",
  201. 174: "Door",
  202. 175: "Violin",
  203. 176: "Chopsticks",
  204. 177: "Digital clock",
  205. 178: "Sunflower",
  206. 179: "Leopard",
  207. 180: "Bell pepper",
  208. 181: "Harbor seal",
  209. 182: "Snake",
  210. 183: "Sewing machine",
  211. 184: "Goose",
  212. 185: "Helicopter",
  213. 186: "Seat belt",
  214. 187: "Coffee cup",
  215. 188: "Microwave oven",
  216. 189: "Hot dog",
  217. 190: "Countertop",
  218. 191: "Serving tray",
  219. 192: "Dog bed",
  220. 193: "Beer",
  221. 194: "Sunglasses",
  222. 195: "Golf ball",
  223. 196: "Waffle",
  224. 197: "Palm tree",
  225. 198: "Trumpet",
  226. 199: "Ruler",
  227. 200: "Helmet",
  228. 201: "Ladder",
  229. 202: "Office building",
  230. 203: "Tablet computer",
  231. 204: "Toilet paper",
  232. 205: "Pomegranate",
  233. 206: "Skirt",
  234. 207: "Gas stove",
  235. 208: "Cookie",
  236. 209: "Cart",
  237. 210: "Raven",
  238. 211: "Egg",
  239. 212: "Burrito",
  240. 213: "Goat",
  241. 214: "Kitchen knife",
  242. 215: "Skateboard",
  243. 216: "Salt and pepper shakers",
  244. 217: "Lynx",
  245. 218: "Boot",
  246. 219: "Platter",
  247. 220: "Ski",
  248. 221: "Swimwear",
  249. 222: "Swimming pool",
  250. 223: "Drinking straw",
  251. 224: "Wrench",
  252. 225: "Drum",
  253. 226: "Ant",
  254. 227: "Human ear",
  255. 228: "Headphones",
  256. 229: "Fountain",
  257. 230: "Bird",
  258. 231: "Jeans",
  259. 232: "Television",
  260. 233: "Crab",
  261. 234: "Microphone",
  262. 235: "Home appliance",
  263. 236: "Snowplow",
  264. 237: "Beetle",
  265. 238: "Artichoke",
  266. 239: "Jet ski",
  267. 240: "Stationary bicycle",
  268. 241: "Human hair",
  269. 242: "Brown bear",
  270. 243: "Starfish",
  271. 244: "Fork",
  272. 245: "Lobster",
  273. 246: "Corded phone",
  274. 247: "Drink",
  275. 248: "Saucer",
  276. 249: "Carrot",
  277. 250: "Insect",
  278. 251: "Clock",
  279. 252: "Castle",
  280. 253: "Tennis racket",
  281. 254: "Ceiling fan",
  282. 255: "Asparagus",
  283. 256: "Jaguar",
  284. 257: "Musical instrument",
  285. 258: "Train",
  286. 259: "Cat",
  287. 260: "Rifle",
  288. 261: "Dumbbell",
  289. 262: "Mobile phone",
  290. 263: "Taxi",
  291. 264: "Shower",
  292. 265: "Pitcher",
  293. 266: "Lemon",
  294. 267: "Invertebrate",
  295. 268: "Turkey",
  296. 269: "High heels",
  297. 270: "Bust",
  298. 271: "Elephant",
  299. 272: "Scarf",
  300. 273: "Barrel",
  301. 274: "Trombone",
  302. 275: "Pumpkin",
  303. 276: "Box",
  304. 277: "Tomato",
  305. 278: "Frog",
  306. 279: "Bidet",
  307. 280: "Human face",
  308. 281: "Houseplant",
  309. 282: "Van",
  310. 283: "Shark",
  311. 284: "Ice cream",
  312. 285: "Swim cap",
  313. 286: "Falcon",
  314. 287: "Ostrich",
  315. 288: "Handgun",
  316. 289: "Whiteboard",
  317. 290: "Lizard",
  318. 291: "Pasta",
  319. 292: "Snowmobile",
  320. 293: "Light bulb",
  321. 294: "Window blind",
  322. 295: "Muffin",
  323. 296: "Pretzel",
  324. 297: "Computer monitor",
  325. 298: "Horn",
  326. 299: "Furniture",
  327. 300: "Sandwich",
  328. 301: "Fox",
  329. 302: "Convenience store",
  330. 303: "Fish",
  331. 304: "Fruit",
  332. 305: "Earrings",
  333. 306: "Curtain",
  334. 307: "Grape",
  335. 308: "Sofa bed",
  336. 309: "Horse",
  337. 310: "Luggage and bags",
  338. 311: "Desk",
  339. 312: "Crutch",
  340. 313: "Bicycle helmet",
  341. 314: "Tick",
  342. 315: "Airplane",
  343. 316: "Canary",
  344. 317: "Spatula",
  345. 318: "Watch",
  346. 319: "Lily",
  347. 320: "Kitchen appliance",
  348. 321: "Filing cabinet",
  349. 322: "Aircraft",
  350. 323: "Cake stand",
  351. 324: "Candy",
  352. 325: "Sink",
  353. 326: "Mouse",
  354. 327: "Wine",
  355. 328: "Wheelchair",
  356. 329: "Goldfish",
  357. 330: "Refrigerator",
  358. 331: "French fries",
  359. 332: "Drawer",
  360. 333: "Treadmill",
  361. 334: "Picnic basket",
  362. 335: "Dice",
  363. 336: "Cabbage",
  364. 337: "Football helmet",
  365. 338: "Pig",
  366. 339: "Person",
  367. 340: "Shorts",
  368. 341: "Gondola",
  369. 342: "Honeycomb",
  370. 343: "Doughnut",
  371. 344: "Chest of drawers",
  372. 345: "Land vehicle",
  373. 346: "Bat",
  374. 347: "Monkey",
  375. 348: "Dagger",
  376. 349: "Tableware",
  377. 350: "Human foot",
  378. 351: "Mug",
  379. 352: "Alarm clock",
  380. 353: "Pressure cooker",
  381. 354: "Human hand",
  382. 355: "Tortoise",
  383. 356: "Baseball glove",
  384. 357: "Sword",
  385. 358: "Pear",
  386. 359: "Miniskirt",
  387. 360: "Traffic sign",
  388. 361: "Girl",
  389. 362: "Roller skates",
  390. 363: "Dinosaur",
  391. 364: "Porch",
  392. 365: "Human beard",
  393. 366: "Submarine sandwich",
  394. 367: "Screwdriver",
  395. 368: "Strawberry",
  396. 369: "Wine glass",
  397. 370: "Seafood",
  398. 371: "Racket",
  399. 372: "Wheel",
  400. 373: "Sea lion",
  401. 374: "Toy",
  402. 375: "Tea",
  403. 376: "Tennis ball",
  404. 377: "Waste container",
  405. 378: "Mule",
  406. 379: "Cricket ball",
  407. 380: "Pineapple",
  408. 381: "Coconut",
  409. 382: "Doll",
  410. 383: "Coffee table",
  411. 384: "Snowman",
  412. 385: "Lavender",
  413. 386: "Shrimp",
  414. 387: "Maple",
  415. 388: "Cowboy hat",
  416. 389: "Goggles",
  417. 390: "Rugby ball",
  418. 391: "Caterpillar",
  419. 392: "Poster",
  420. 393: "Rocket",
  421. 394: "Organ",
  422. 395: "Saxophone",
  423. 396: "Traffic light",
  424. 397: "Cocktail",
  425. 398: "Plastic bag",
  426. 399: "Squash",
  427. 400: "Mushroom",
  428. 401: "Hamburger",
  429. 402: "Light switch",
  430. 403: "Parachute",
  431. 404: "Teddy bear",
  432. 405: "Winter melon",
  433. 406: "Deer",
  434. 407: "Musical keyboard",
  435. 408: "Plumbing fixture",
  436. 409: "Scoreboard",
  437. 410: "Baseball bat",
  438. 411: "Envelope",
  439. 412: "Adhesive tape",
  440. 413: "Briefcase",
  441. 414: "Paddle",
  442. 415: "Bow and arrow",
  443. 416: "Telephone",
  444. 417: "Sheep",
  445. 418: "Jacket",
  446. 419: "Boy",
  447. 420: "Pizza",
  448. 421: "Otter",
  449. 422: "Office supplies",
  450. 423: "Couch",
  451. 424: "Cello",
  452. 425: "Bull",
  453. 426: "Camel",
  454. 427: "Ball",
  455. 428: "Duck",
  456. 429: "Whale",
  457. 430: "Shirt",
  458. 431: "Tank",
  459. 432: "Motorcycle",
  460. 433: "Accordion",
  461. 434: "Owl",
  462. 435: "Porcupine",
  463. 436: "Sun hat",
  464. 437: "Nail",
  465. 438: "Scissors",
  466. 439: "Swan",
  467. 440: "Lamp",
  468. 441: "Crown",
  469. 442: "Piano",
  470. 443: "Sculpture",
  471. 444: "Cheetah",
  472. 445: "Oboe",
  473. 446: "Tin can",
  474. 447: "Mango",
  475. 448: "Tripod",
  476. 449: "Oven",
  477. 450: "Mouse",
  478. 451: "Barge",
  479. 452: "Coffee",
  480. 453: "Snowboard",
  481. 454: "Common fig",
  482. 455: "Salad",
  483. 456: "Marine invertebrates",
  484. 457: "Umbrella",
  485. 458: "Kangaroo",
  486. 459: "Human arm",
  487. 460: "Measuring cup",
  488. 461: "Snail",
  489. 462: "Loveseat",
  490. 463: "Suit",
  491. 464: "Teapot",
  492. 465: "Bottle",
  493. 466: "Alpaca",
  494. 467: "Kettle",
  495. 468: "Trousers",
  496. 469: "Popcorn",
  497. 470: "Centipede",
  498. 471: "Spider",
  499. 472: "Sparrow",
  500. 473: "Plate",
  501. 474: "Bagel",
  502. 475: "Personal care",
  503. 476: "Apple",
  504. 477: "Brassiere",
  505. 478: "Bathroom cabinet",
  506. 479: "studio couch",
  507. 480: "Computer keyboard",
  508. 481: "Table tennis racket",
  509. 482: "Sushi",
  510. 483: "Cabinetry",
  511. 484: "Street light",
  512. 485: "Towel",
  513. 486: "Nightstand",
  514. 487: "Rabbit",
  515. 488: "Dolphin",
  516. 489: "Dog",
  517. 490: "Jug",
  518. 491: "Wok",
  519. 492: "Fire hydrant",
  520. 493: "Human eye",
  521. 494: "Skyscraper",
  522. 495: "Backpack",
  523. 496: "Potato",
  524. 497: "Paper towel",
  525. 498: "Lifejacket",
  526. 499: "Bicycle wheel",
  527. 500: "Toilet",
  528. }
  529. if not with_background:
  530. clsid2catid = {k - 1: v for k, v in clsid2catid.items()}
  531. return clsid2catid, catid2name