提交 c1b1543e 编写于 作者: K Kentaro Wada

Fix labelme2coco.py to parse with pycocotools

Keys: id, segmentation
上级 3bec9f61
{"info": {"description": null, "url": null, "version": null, "year": 2019, "contributor": null, "date_created": "2019-01-31 23:37:23.484326"}, "licenses": [{"url": null, "id": 0, "name": null}], "images": [{"license": 0, "url": null, "file_name": "JPEGImages/2011_000003.jpg", "height": 338, "width": 500, "date_captured": null, "id": 0}, {"license": 0, "url": null, "file_name": "JPEGImages/2011_000025.jpg", "height": 375, "width": 500, "date_captured": null, "id": 1}, {"license": 0, "url": null, "file_name": "JPEGImages/2011_000006.jpg", "height": 375, "width": 500, "date_captured": null, "id": 2}], "type": "instances", "annotations": [{"segmentation": {"size": [338, 500], "counts": "Zco13\\94_G2Y8<[GJ]8?\\GG[8>dGGT8=jGIn7;PHIj7;THHg7e1J6K5L4N2M3N2M3N2M3N2N2M3N2M>C=B2O1M3M3M3M3\\OgJkK\\5R4lJfKU5Y4c0N2N2N2N2N2N200O100O1O10UNTLPMk3Q3ZLlKL4k3o3^LeK07a3U4dL[K4:Y3[4bM_K^2a4hMZKW2g4j1O010O010O01O10O011N2O0O2O1O0OaJ^KQ5a4nJcKP5]4nJgKo4Z4oJiKP5V4nJlKS5T4kJmKV5d0hJX20UMX5?lJ]2JVMZ58QKU3P5hLSKW3m4iLSKW3n4gLTKY3l4fLUKY3k4fLVKZ3k4dLWK[3j4dLVK\\3k4bLWK^3i4aLXK^3i4`LXK`3j4\\LYKc3h4[LZKe3f4YL[Kg3f4VL]Ki3g5O010O0]OXI\\Mi6`2ZI`Mg6]2[IdMd6\\2\\IcMf6\\2ZIcMh6[2YIeMg6[2YIdMi6[2XIcMj6[2XIcMi6]2XIaMj6^2WIaMj6]2XIaMi6]2YIbMi6\\2YIbMi6[2ZIdMf6Z2]IdMe6Z2k0M3N1N3N2M2O2M3M2O2M5K6POlF6\\9DhF6`9DdF6P:J^kl1"}, "area": 15689.0, "iscrowd": null, "image_id": 0, "category_id": 15}, {"segmentation": {"size": [338, 500], "counts": "ldh35X:6N2O1NM3IT<1SD2N2N2N2N2N2N2N2N2N2M3M3N2dN@SHFMl0P8\\OTHT1j7lNVHV1h7jNXHX1;\\Nb6;TI[18ZNe6:TI]15ZNf69UI_13XNh69UIa11WNi68VIc1OVNj67WIe1LUNm67WIe1JUNn66XIg1HSNP76XIi1FRNP77YIi1EPNR77YIT2f6lM[IT2d6lM\\IT2c6nM\\IS2b6nM^IR2b6nM^IR2a6PN_Io1`6RN`In1`6RN`In1_6SNaIm1^6UNaIk1^6WNbIh1]6[NaIe1^6]NaIc1^6_NaIa1]6`NeI_1Z6bNfI^1Y6cNgI]1X6dNhI\\1W6eNiI[1W6eNjIZ1U6gNkIY1T6hNlIX1T6gNmIY1R6hNnIX1Q6iNPJV1P6jNPJV1o5kNQJU1n5lNRJNEKY67RJOEIX68UJNDIW69UJNDIV6:VJNDGU6<WJMEFT6=UJOHCR6?QJ4M\\OQ6a0mI83VOP6\\2QJcMn5_2RJ`Mm5a2TJ^Ml5b2TJ^Mk5d2UJ[Mj5f2WJYMi5g2XJXMg5j2eJjLZ5V3P11O2O0O1O2O0O101N1O101N1O101\\Oc0N2M4M3L4M4K4M3M3O1O1N3jKiJm2X5nLWKg2j4UM[Kh2h4TM\\Kj2g4QM]Kl2h4nL\\KP3U6N2M3N1O0O11O00010O0000010O00001O01OSOYMnIh2P6_MiId2T6dMeI]2Y6jM`IX2^6UN"}, "area": 17254.0, "iscrowd": null, "image_id": 0, "category_id": 15}, {"segmentation": {"size": [338, 500], "counts": "kni3Z1V92N2N3M2N201OO1000000O10002N2M3Nk0UO<DdhT1"}, "area": 873.0, "iscrowd": null, "image_id": 0, "category_id": 5}, {"segmentation": {"size": [375, 500], "counts": "jim04];5K6J6J6J6J5K6bHMT37gLV1o1lNlM[1P2gNkM`1Q2bNjMd1T2\\NhMk1T2WNgMP2U2RNfMT2W2nMdMY2X2iMcM^2Z2bMcMc2Z2_MaMh2[2ZM`Mm2\\2UM_MQ3_2PM\\MW3`2kL[M\\3a2eL[Ma3b2aLYMf3d2[LWMl3e2VLVMP4g2c2L4L3N3L4L3M4M3L3M2N2N2O1N2N2N2O10000O1000000O10000O1000000O10000O1000000O10000O1000000O10000O1000001NN3L4K4M4L4K4M4M3000O10000O1000000O10000O1000000O10000O1000000O10000O11O0000000000000000000000000000000000000000001O000000000000000000000000000000000000000000001O00000000000000000000000000000000000O1000001O000000000000000000000000000000000000000000000000001O000000000000000000000000000000000000000000000000001O000000000000000000000000000000000000000000000000001O001O00001O001O08I`0_O9HO00001O001O001O000010O01O001O001O00001O010O001O001O00001O001O010O00001O001O001O0010ON2M4L3L6K6J6J6J6J6I8I6J6K5M3M3M3M2N0WJTNg1l1YNUNe1l1[NUNd1l1ZNUNf1k1ZNVNe1j1[NWNd1i1[NYNd1h1[NYNd1g1\\NZNc1f1\\N\\Nb1f1]NZNc1f1]N[Nb1e1]N]NLdMMo37^NGTNE_3c0^NCcN^Oo2n0`N_OROVO^2[1`N[Of3e0[LVOj3h0XLSOl3m0_300J;Ab0^O[Rh0"}, "area": 102701.0, "iscrowd": null, "image_id": 1, "category_id": 6}, {"segmentation": {"size": [375, 500], "counts": "P3Z5^6O000000001O0000001O000000001O000000001O0000001O000004L9H4KO10001O000000001O000000001O0000001N100000001O000000001O0000001O00000O1O2N1O1N2O2N1O1O1O1O2N1O1N2O1O2N1O1_LoH[2R7`MSI_2o6[MVId2k6VM[Ii2f6RM^Im2d6nLaIQ3`6jLeIU3_7O0M4J6J6J6I6K6J6I7J5K6J6J6K5L3L5K5K5L3LeQ_4"}, "area": 15781.0, "iscrowd": null, "image_id": 1, "category_id": 6}, {"segmentation": {"size": [375, 500], "counts": "nce45X;;E;E:F;I7O1O1O001O1O1O1O1O001O1O1O1O001O1O;E<DO10000000000000000000000000000000000000000000000000000000000000000O1000000000000000000000000000000000000000000000000000000000000000Vb0"}, "area": 7256.0, "iscrowd": null, "image_id": 1, "category_id": 7}, {"segmentation": {"size": [375, 500], "counts": "XmQ13b;7J7H5K2O1N2O1N2bGXOl5i0jIAT6a0bII]68YI2e60PI;n6GhHc0W7]O`Hm0^7SOZHW1e7hNVH_1i7`NWHc1g7\\NYHf1f7YNYHj1f7UNZHm1e7RN[HP2e7Q1O1O1O1O2N1O1OeLcH^2\\7bMeH^2Z7cMeH^2Z7bMgH^2Y7aMhH_2W7aMiHa2U7_MlHa2S7`MmH`2R7`MnHa2Q7_MPIa2o6_MRIa2m6`MRIa2m6_MTIa2k6_MVIa2i6_MWIc2g6^MYIa2h6^MYIa2g6_MYIb2f6^M[Ia2e6_M\\I`2d6aM[I_2e6aM\\I^2d6bM]I^2b6bM^I^2b6cM^I\\2b6dM_I[2a6eM_I\\2`6dM_I]2b6cM]IW2i6iMVIm1U7SNjHi1[7WNeHi1[7XNcHh1^7XNbHh1^7XNaHi1_7WNaHi1_7WN`Hj1`7WN_Hh1b7XN]Hi1d7VN[Hk1e7UN[Hk1e7S10O1000001O0O2O0K6D;K60O00100O010OO2N1N3M2O0O2N100011N2O1N2O0O2N2O1N101N2O1N2N101N2O11O0O101O000O2O00001O0N2N3M3M3M3L4M3M4L3L4M3M3M3Mh0WO4M2N3M3M3L4M2N3M3L4M3M2N3Mlnm2"}, "area": 15203.0, "iscrowd": null, "image_id": 2, "category_id": 15}, {"segmentation": {"size": [375, 500], "counts": "l_n1n0h:1O1O1O1O1O1O1O1N2O1O1O1O1O1O1O1O2N1000000O10000O1000000O1000000O101O000O10000O1000000O1N2N2N2M3N2M3N3M1N101O0O101N101O0O101N101O2M2O2N1N3N1N3N2N1L2gGiLP8_3PHbLg7i3J6J8K501O0000001O0000001O0000001OO1O100O1O100O1O002O2M2N3N2M2N3M2O2M2N3N1N3M3M2O2M2N3N1N3M2N3N2M2N3N1N3lNmF_OU9=RG^OP9>WG^Ok8<]G_Oe8=bG^O`8>gG^O[8=lG^OV8>d1K6K4LXiU2"}, "area": 11735.0, "iscrowd": null, "image_id": 2, "category_id": 15}, {"segmentation": {"size": [375, 500], "counts": "oal22c;2M3M4M2M3N3L3M3N3M2O2O0O1O2O0O1O2O0O1O2NN3L3L4M4K4L4M4K4M3N30O1O00100O00100O00100O001O1mNGhF8b7GPI8YO2d7KnH9ZOMe7OmH:ZOFg75jH;[OAh79hH=[O[Oj7=fH>]OTOk7c0cH`0]OnNm7g0aHn0\\7WO`Hj0^7[O]Hh0a7\\OZHg0f7d110000O10000O10000O10000O10000O1000000000000001O00000002N4L3N3L3M4L3M4L3N2M2N3M3M3M3N1M4L3M2M3N2N2N2N2N2N2M4M2N2N2K5I7I7I7I7I[f^1"}, "area": 7597.0, "iscrowd": null, "image_id": 2, "category_id": 15}, {"segmentation": {"size": [375, 500], "counts": "d_f16`;=C7J1N2N2N2N2O1N2N2N6J;F9F:F;E5K100O1O1O1O100O1O1O11O000000000000001O000000000000001O000000000000001O000000000000001O000000000000001O000000000000001O000000000000001O000000000000001O000000000000001O000000000000001O000000000000001O000000000000O1M3L4M3M3M3L4M3M3L4M3N20000O10000O10000O10000O10000O10000O10000O10000O10000O1000000000000000000000000000000000O100000000000000000000000000000000000000000000000O1O1O1O1O1O1O1O1O1O1O1O1O1O1O1O1O1O10000000000O100000000O10000000000O100000000O10000000000O10000000000O100000000O10000000000O100000000O10000000000O100000000O10000000000O1O1O1O1O1O1O1O1O1O1O1O1O1O1O1O1O1O1O1O11O000000001O000000001O000000001O000000001O0000001O000000001O00000N2M4L3M3M3M3L5L3M3M3M3MWa0"}, "area": 44532.0, "iscrowd": null, "image_id": 2, "category_id": 9}, {"segmentation": {"size": [375, 500], "counts": "Rcb41e;1N2O1O1O1N2O1O1N2O1O1O1N2O1O1N2O1O1O1N2O1O1N2O1O11O001O00001O001O001O00001N1O2N1O2N1N2O2N1O4L7Ibbb0"}, "area": 996.0, "iscrowd": null, "image_id": 2, "category_id": 15}, {"segmentation": {"size": [375, 500], "counts": "fi64^;9H8G9I6M00000000000O100000000000001N1000000000000O1000000000001N100000000000000eGgNW6Z1iIfNW6Z1iIfNW6Z1hIgNX6Y1hIgNX6Y1hIhNW6X1iIhNW6Y1gIhNX6Y1hIgNX6Y1hIgNX6Y1gIiNX6W1hIiNX6W1hIiNX6W1hIiNX6W1gIjNX6W1hIjNW6V1iIjNW6V1hIkNX6U1hIkNX6U1hIkNX6U1hIlNW6U1gIlNY6T1gIlNX6U1hIkNX6U1gImNX6S1hImNX6S1hImNX6S1hImNX6S1gInNY6R1gIoNW6R1iInNW6R1hIoNX6Q1hIoNX6Q1hIoNX6g0THPOd1:W6d0\\HnN[1?Y6b0UJ^Oj5b0WJ^Oi5`0XJAh5>YJCf5<[JBg5<[J@i5?WJ_Ol5?VJ]On5b0SJ[Oo5e0QJXOS6f0`2O1O1N2O1OO0O2N2N2M3N3M2N2N2N2N2M3N3M2N2O11O1O1O100O1O1O1O1O1O1O100O1O1O1O1O1O100O1O1O1O1O1O100O1O1O1O1O1O100O1O1O1O1O1O1O100O1O1O1O1O1O100O1O1O1O1O1O100O1O1O_n<0aQC1O1O1O2N1O101N1O1O1O2N1O1O2N1O1O1O2N100O2N1O1O1O2N1O110O0000010O00010OM3L4K6K4L4K5L`\\o0OfcPO3L3M4L4L2N1O1O1O1O1O1O1O1O1O1O2N1O1O1O1eFQOl7P1mGUOT8l0fGYOZ8h0_G^Oa8c0XGCh8>RGGn8:kFKV9[10000000O100000000O100000000O2O0000000O100000000O10000000000O100000000O100000000O100000000O100000000O100000000O101O00000O1O1O1O1O1N2O1O1O1O1O1O1O1O1N2O1O1O1O1000000001O0000001O000000001O0000001OM5H8H9H8G8Hol7"}, "area": 14001.0, "iscrowd": null, "image_id": 2, "category_id": 18}], "categories": [{"supercategory": null, "id": 0, "name": "_background_"}, {"supercategory": null, "id": 1, "name": "aeroplane"}, {"supercategory": null, "id": 2, "name": "bicycle"}, {"supercategory": null, "id": 3, "name": "bird"}, {"supercategory": null, "id": 4, "name": "boat"}, {"supercategory": null, "id": 5, "name": "bottle"}, {"supercategory": null, "id": 6, "name": "bus"}, {"supercategory": null, "id": 7, "name": "car"}, {"supercategory": null, "id": 8, "name": "cat"}, {"supercategory": null, "id": 9, "name": "chair"}, {"supercategory": null, "id": 10, "name": "cow"}, {"supercategory": null, "id": 11, "name": "diningtable"}, {"supercategory": null, "id": 12, "name": "dog"}, {"supercategory": null, "id": 13, "name": "horse"}, {"supercategory": null, "id": 14, "name": "motorbike"}, {"supercategory": null, "id": 15, "name": "person"}, {"supercategory": null, "id": 16, "name": "potted plant"}, {"supercategory": null, "id": 17, "name": "sheep"}, {"supercategory": null, "id": 18, "name": "sofa"}, {"supercategory": null, "id": 19, "name": "train"}, {"supercategory": null, "id": 20, "name": "tv/monitor"}]}
\ No newline at end of file
{"info": {"description": null, "url": null, "version": null, "year": 2019, "contributor": null, "date_created": "2019-03-09 01:48:36.742451"}, "licenses": [{"url": null, "id": 0, "name": null}], "images": [{"license": 0, "url": null, "file_name": "JPEGImages/2011_000003.jpg", "height": 338, "width": 500, "date_captured": null, "id": 0}, {"license": 0, "url": null, "file_name": "JPEGImages/2011_000025.jpg", "height": 375, "width": 500, "date_captured": null, "id": 1}, {"license": 0, "url": null, "file_name": "JPEGImages/2011_000006.jpg", "height": 375, "width": 500, "date_captured": null, "id": 2}], "type": "instances", "annotations": [{"id": 0, "segmentation": [[251.8142292490119, 107.33596837944665, 230.8142292490119, 119.33596837944665, 222.8142292490119, 135.33596837944665, 224.8142292490119, 148.33596837944665, 218.8142292490119, 161.33596837944665, 203.8142292490119, 168.33596837944665, 193.8142292490119, 200.33596837944665, 195.8142292490119, 222.33596837944665, 200.8142292490119, 227.33596837944665, 192.8142292490119, 234.33596837944665, 198.8142292490119, 264.3359683794467, 214.8142292490119, 295.3359683794467, 215.8142292490119, 320.3359683794467, 222.8142292490119, 327.3359683794467, 236.8142292490119, 326.3359683794467, 241.8142292490119, 323.3359683794467, 236.8142292490119, 298.3359683794467, 239.8142292490119, 287.3359683794467, 235.8142292490119, 268.3359683794467, 258.81422924901193, 258.3359683794467, 265.81422924901193, 264.3359683794467, 257.81422924901193, 273.3359683794467, 260.81422924901193, 282.3359683794467, 285.81422924901193, 288.3359683794467, 298.81422924901193, 278.3359683794467, 289.81422924901193, 270.3359683794467, 282.81422924901193, 270.3359683794467, 284.81422924901193, 264.3359683794467, 293.81422924901193, 261.3359683794467, 309.81422924901193, 236.33596837944665, 314.81422924901193, 217.33596837944665, 310.81422924901193, 208.33596837944665, 313.81422924901193, 202.33596837944665, 309.81422924901193, 185.33596837944665, 292.81422924901193, 173.33596837944665, 270.81422924901193, 159.33596837944665, 262.81422924901193, 154.33596837944665, 265.81422924901193, 142.33596837944665, 274.81422924901193, 137.33596837944665, 279.81422924901193, 130.33596837944665, 271.81422924901193, 121.33596837944665]], "area": 15689.0, "iscrowd": null, "image_id": 0, "category_id": 15}, {"id": 1, "segmentation": [[482.81422924901193, 85.33596837944665, 468.81422924901193, 90.33596837944665, 460.81422924901193, 110.33596837944665, 460.81422924901193, 127.33596837944665, 444.81422924901193, 137.33596837944665, 419.81422924901193, 153.33596837944665, 410.81422924901193, 163.33596837944665, 403.81422924901193, 168.33596837944665, 394.81422924901193, 170.33596837944665, 386.81422924901193, 168.33596837944665, 386.81422924901193, 184.33596837944665, 392.81422924901193, 182.33596837944665, 410.81422924901193, 187.33596837944665, 414.81422924901193, 192.33596837944665, 437.81422924901193, 189.33596837944665, 434.81422924901193, 204.33596837944665, 390.81422924901193, 195.33596837944665, 386.81422924901193, 195.33596837944665, 387.81422924901193, 208.33596837944665, 381.81422924901193, 212.33596837944665, 372.81422924901193, 212.33596837944665, 372.81422924901193, 216.33596837944665, 400.81422924901193, 270.3359683794467, 389.81422924901193, 272.3359683794467, 389.81422924901193, 274.3359683794467, 403.81422924901193, 282.3359683794467, 444.81422924901193, 283.3359683794467, 443.81422924901193, 259.3359683794467, 426.81422924901193, 244.33596837944665, 462.81422924901193, 256.3359683794467, 474.81422924901193, 270.3359683794467, 477.81422924901193, 280.3359683794467, 473.81422924901193, 289.3359683794467, 471.81422924901193, 296.3359683794467, 472.81422924901193, 317.3359683794467, 480.81422924901193, 332.3359683794467, 494.81422924901193, 335.3359683794467, 498.81422924901193, 329.3359683794467, 494.81422924901193, 308.3359683794467, 499.81422924901193, 297.3359683794467, 499.81422924901193, 90.33596837944665], [370.81422924901193, 170.33596837944665, 366.81422924901193, 173.33596837944665, 365.81422924901193, 182.33596837944665, 368.81422924901193, 185.33596837944665]], "area": 17254.0, "iscrowd": null, "image_id": 0, "category_id": 15}, {"id": 2, "segmentation": [[374.81422924901193, 159.33596837944665, 369.81422924901193, 170.33596837944665, 369.81422924901193, 210.33596837944665, 375.81422924901193, 212.33596837944665, 387.81422924901193, 209.33596837944665, 385.81422924901193, 185.33596837944665, 385.81422924901193, 168.33596837944665, 385.81422924901193, 165.33596837944665, 382.81422924901193, 159.33596837944665]], "area": 873.0, "iscrowd": null, "image_id": 0, "category_id": 5}, {"id": 3, "segmentation": [[260.936170212766, 22.563829787234056, 193.936170212766, 19.563829787234056, 124.93617021276599, 39.563829787234056, 89.93617021276599, 101.56382978723406, 81.93617021276599, 150.56382978723406, 108.93617021276599, 145.56382978723406, 88.93617021276599, 244.56382978723406, 89.93617021276599, 322.56382978723406, 116.93617021276599, 367.56382978723406, 158.936170212766, 368.56382978723406, 165.936170212766, 337.56382978723406, 347.936170212766, 335.56382978723406, 349.936170212766, 369.56382978723406, 391.936170212766, 373.56382978723406, 403.936170212766, 335.56382978723406, 425.936170212766, 332.56382978723406, 421.936170212766, 281.56382978723406, 428.936170212766, 252.56382978723406, 428.936170212766, 236.56382978723406, 409.936170212766, 220.56382978723406, 409.936170212766, 150.56382978723406, 430.936170212766, 143.56382978723406, 433.936170212766, 112.56382978723406, 431.936170212766, 96.56382978723406, 408.936170212766, 90.56382978723406, 395.936170212766, 50.563829787234056, 338.936170212766, 25.563829787234056]], "area": 102701.0, "iscrowd": null, "image_id": 1, "category_id": 6}, {"id": 4, "segmentation": [[88.93617021276599, 115.56382978723406, 0.9361702127659877, 96.56382978723406, 0.0, 251.968085106388, 0.9361702127659877, 265.56382978723406, 27.936170212765987, 265.56382978723406, 29.936170212765987, 283.56382978723406, 63.93617021276599, 281.56382978723406, 89.93617021276599, 252.56382978723406, 100.93617021276599, 183.56382978723406, 108.93617021276599, 145.56382978723406, 81.93617021276599, 151.56382978723406]], "area": 15781.0, "iscrowd": null, "image_id": 1, "category_id": 6}, {"id": 5, "segmentation": [[413.936170212766, 168.56382978723406, 497.936170212766, 168.56382978723406, 497.936170212766, 256.56382978723406, 431.936170212766, 258.56382978723406, 430.936170212766, 236.56382978723406, 408.936170212766, 218.56382978723406]], "area": 7256.0, "iscrowd": null, "image_id": 1, "category_id": 7}, {"id": 6, "segmentation": [[204.936170212766, 108.56382978723406, 183.936170212766, 141.56382978723406, 166.936170212766, 150.56382978723406, 108.93617021276599, 203.56382978723406, 92.93617021276599, 228.56382978723406, 95.93617021276599, 244.56382978723406, 105.93617021276599, 244.56382978723406, 116.93617021276599, 223.56382978723406, 163.936170212766, 187.56382978723406, 147.936170212766, 212.56382978723406, 117.93617021276599, 222.56382978723406, 108.93617021276599, 243.56382978723406, 100.93617021276599, 325.56382978723406, 135.936170212766, 329.56382978723406, 148.936170212766, 319.56382978723406, 150.936170212766, 295.56382978723406, 169.936170212766, 272.56382978723406, 171.936170212766, 249.56382978723406, 178.936170212766, 246.56382978723406, 186.936170212766, 225.56382978723406, 214.936170212766, 219.56382978723406, 242.936170212766, 157.56382978723406, 228.936170212766, 146.56382978723406, 228.936170212766, 125.56382978723406, 216.936170212766, 112.56382978723406]], "area": 15203.0, "iscrowd": null, "image_id": 2, "category_id": 15}, {"id": 7, "segmentation": [[271.936170212766, 109.56382978723406, 249.936170212766, 110.56382978723406, 244.936170212766, 150.56382978723406, 215.936170212766, 219.56382978723406, 208.936170212766, 245.56382978723406, 214.936170212766, 220.56382978723406, 188.936170212766, 227.56382978723406, 170.936170212766, 246.56382978723406, 170.936170212766, 275.56382978723406, 221.936170212766, 278.56382978723406, 233.936170212766, 259.56382978723406, 246.936170212766, 253.56382978723406, 245.936170212766, 256.56382978723406, 242.936170212766, 251.56382978723406, 262.936170212766, 256.56382978723406, 304.936170212766, 226.56382978723406, 297.936170212766, 199.56382978723406, 308.936170212766, 164.56382978723406, 296.936170212766, 148.56382978723406]], "area": 11735.0, "iscrowd": null, "image_id": 2, "category_id": 15}, {"id": 8, "segmentation": [[308.936170212766, 115.56382978723406, 298.936170212766, 145.56382978723406, 309.936170212766, 166.56382978723406, 297.936170212766, 200.56382978723406, 305.936170212766, 228.56382978723406, 262.936170212766, 258.56382978723406, 252.936170212766, 284.56382978723406, 272.936170212766, 291.56382978723406, 281.936170212766, 250.56382978723406, 326.936170212766, 235.56382978723406, 351.936170212766, 239.56382978723406, 365.936170212766, 223.56382978723406, 371.936170212766, 187.56382978723406, 353.936170212766, 168.56382978723406, 344.936170212766, 143.56382978723406, 336.936170212766, 115.56382978723406]], "area": 7597.0, "iscrowd": null, "image_id": 2, "category_id": 15}, {"id": 9, "segmentation": [[308.936170212766, 242.56382978723406, 281.936170212766, 251.56382978723406, 270.936170212766, 287.56382978723406, 174.936170212766, 275.56382978723406, 148.936170212766, 296.56382978723406, 150.936170212766, 319.56382978723406, 159.936170212766, 328.56382978723406, 164.77327127659578, 375.0, 485.936170212766, 373.56382978723406, 497.936170212766, 336.56382978723406, 497.936170212766, 202.56382978723406, 453.936170212766, 193.56382978723406, 434.936170212766, 212.56382978723406, 367.936170212766, 224.56382978723406, 350.936170212766, 241.56382978723406]], "area": 44532.0, "iscrowd": null, "image_id": 2, "category_id": 9}, {"id": 10, "segmentation": [[425.936170212766, 82.56382978723406, 404.936170212766, 109.56382978723406, 400.936170212766, 114.56382978723406, 437.936170212766, 114.56382978723406, 448.936170212766, 102.56382978723406, 446.936170212766, 91.56382978723406]], "area": 996.0, "iscrowd": null, "image_id": 2, "category_id": 15}, {"id": 11, "segmentation": [[183.936170212766, 140.56382978723406, 125.93617021276599, 140.56382978723406, 110.93617021276599, 187.56382978723406, 22.936170212765987, 199.56382978723406, 18.936170212765987, 218.56382978723406, 22.936170212765987, 234.56382978723406, 93.93617021276599, 239.56382978723406, 91.93617021276599, 229.56382978723406, 110.93617021276599, 203.56382978723406], [103.93617021276599, 290.56382978723406, 58.93617021276599, 303.56382978723406, 97.93617021276599, 311.56382978723406], [348.936170212766, 146.56382978723406, 472.936170212766, 149.56382978723406, 477.936170212766, 162.56382978723406, 471.936170212766, 196.56382978723406, 453.936170212766, 192.56382978723406, 434.936170212766, 213.56382978723406, 368.936170212766, 226.56382978723406, 375.936170212766, 187.56382978723406, 353.936170212766, 164.56382978723406], [246.936170212766, 252.56382978723406, 219.936170212766, 277.56382978723406, 254.936170212766, 287.56382978723406, 261.936170212766, 256.56382978723406]], "area": 14001.0, "iscrowd": null, "image_id": 2, "category_id": 18}], "categories": [{"supercategory": null, "id": 0, "name": "_background_"}, {"supercategory": null, "id": 1, "name": "aeroplane"}, {"supercategory": null, "id": 2, "name": "bicycle"}, {"supercategory": null, "id": 3, "name": "bird"}, {"supercategory": null, "id": 4, "name": "boat"}, {"supercategory": null, "id": 5, "name": "bottle"}, {"supercategory": null, "id": 6, "name": "bus"}, {"supercategory": null, "id": 7, "name": "car"}, {"supercategory": null, "id": 8, "name": "cat"}, {"supercategory": null, "id": 9, "name": "chair"}, {"supercategory": null, "id": 10, "name": "cow"}, {"supercategory": null, "id": 11, "name": "diningtable"}, {"supercategory": null, "id": 12, "name": "dog"}, {"supercategory": null, "id": 13, "name": "horse"}, {"supercategory": null, "id": 14, "name": "motorbike"}, {"supercategory": null, "id": 15, "name": "person"}, {"supercategory": null, "id": 16, "name": "potted plant"}, {"supercategory": null, "id": 17, "name": "sheep"}, {"supercategory": null, "id": 18, "name": "sofa"}, {"supercategory": null, "id": 19, "name": "train"}, {"supercategory": null, "id": 20, "name": "tv/monitor"}]}
\ No newline at end of file
#!/usr/bin/env python
import argparse
import collections
import datetime
import glob
import json
......@@ -107,7 +108,8 @@ def main():
id=image_id,
))
masks = {}
masks = {} # for area
segmentations = collections.defaultdict(list) # for segmentation
for shape in label_data['shapes']:
points = shape['points']
label = shape['label']
......@@ -116,22 +118,27 @@ def main():
img.shape[:2], points, shape_type
)
mask = np.asfortranarray(mask.astype(np.uint8))
if label in masks:
masks[label] = masks[label] | mask
else:
masks[label] = mask
points = np.asarray(points).flatten().tolist()
segmentations[label].append(points)
for label, mask in masks.items():
cls_name = label.split('-')[0]
if cls_name not in class_name_to_id:
continue
cls_id = class_name_to_id[cls_name]
segmentation = pycocotools.mask.encode(mask)
segmentation['counts'] = segmentation['counts'].decode()
area = float(pycocotools.mask.area(segmentation))
mask = np.asfortranarray(mask.astype(np.uint8))
mask = pycocotools.mask.encode(mask)
area = float(pycocotools.mask.area(mask))
data['annotations'].append(dict(
segmentation=segmentation,
id=len(data['annotations']),
segmentation=segmentations[label],
area=area,
iscrowd=None,
image_id=image_id,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册