cocodataset / cocoapi

COCO API - Dataset @ http://cocodataset.org/
Other
6.02k stars 3.75k forks source link

TypeError: Argument 'bb' has incorrect type (expected numpy.ndarray, got list) #139

Closed alwansm closed 6 years ago

alwansm commented 6 years ago

Hello i am trying to train my own dataset. the annotations are written as follow:

{"info": {"description": "Dtatset","url": "http://test.org","version": "1.0","year": 2017,"contributor": "test","date_created": "2017/09/01"},"images": [{"id": 1, "width": 512, "height": 512, "file_name": "3.jpg", "license": 1, "flickr_url": "www.test.com", "coco_url": "www.test.com", "date_captured": "2013-11-14 17:24:23"}, {"id": 2, "width": 512, "height": 512, "file_name": "114.jpg", "license": 1, "flickr_url": "www.test.com", "coco_url": "www.test.com", "date_captured": "2013-11-14 17:24:23"}, {"id": 3, "width": 512, "height": 512, "file_name": "13.jpg", "license": 1, "flickr_url": "www.test.com", "coco_url": "www.test.com", "date_captured": "2013-11-14 17:24:23"}],"annotations": [{"id": 1, "image_id": 1, "category_id": 2, "segmentation": [[74, 123, 72, 125, 72, 136, 73, 135, 74, 136, 77, 136, 78, 137, 78, 138, 77, 139, 72, 139, 72, 142, 73, 142, 74, 143, 81, 143, 82, 142, 107, 142, 108, 141, 117, 141, 118, 142, 121, 142, 121, 138, 101, 138, 100, 139, 94, 139, 92, 137, 92, 136, 91, 136, 85, 130, 84, 130, 83, 129, 83, 128, 79, 124, 78, 124, 77, 123]], "area": 1050, "bbox": [72, 123, 50, 21], "iscrowd": 0}, {"id": 2, "image_id": 1, "category_id": 2, "segmentation": [[245, 192, 245, 204, 243, 206, 242, 206, 241, 205, 233, 205, 233, 209, 234, 208, 236, 208, 237, 209, 241, 209, 242, 208, 244, 208, 245, 209, 245, 217, 249, 217, 249, 216, 248, 215, 248, 214, 249, 213, 248, 212, 248, 209, 249, 208, 270, 208, 271, 209, 272, 209, 272, 205, 271, 206, 270, 206, 269, 205, 261, 205, 260, 206, 259, 205, 250, 205, 249, 204, 249, 203, 248, 202, 248, 200, 249, 199, 249, 192]], "area": 1040, "bbox": [233, 192, 40, 26], "iscrowd": 0}, {"id": 3, "image_id": 1, "category_id": 1, "segmentation": [[244, 382, 244, 408, 243, 409, 237, 409, 236, 408, 232, 408, 231, 407, 227, 407, 226, 406, 225, 406, 225, 411, 229, 411, 230, 412, 235, 412, 236, 411, 237, 412, 242, 412, 244, 414, 244, 433, 243, 434, 243, 435, 244, 436, 244, 441, 243, 442, 244, 443, 248, 443, 248, 431, 247, 430, 247, 428, 248, 427, 248, 414, 250, 412, 251, 413, 258, 413, 259, 412, 266, 412, 267, 411, 268, 412, 268, 408, 263, 408, 262, 409, 258, 409, 257, 410, 256, 410, 255, 409, 250, 409, 249, 410, 247, 408, 247, 404, 248, 403, 248, 398, 247, 397, 248, 396, 248, 382]], "area": 2728, "bbox": [225, 382, 44, 62], "iscrowd": 0}, {"id": 4, "image_id": 1, "category_id": 2, "segmentation": [[244, 461, 244, 486, 243, 487, 238, 487, 237, 486, 228, 486, 228, 489, 230, 489, 231, 490, 243, 490, 244, 491, 244, 492, 243, 493, 243, 494, 244, 495, 249, 495, 249, 493, 248, 492, 250, 490, 251, 490, 252, 491, 253, 490, 265, 490, 265, 486, 261, 486, 260, 487, 249, 487, 248, 486, 248, 461]], "area": 1330, "bbox": [228, 461, 38, 35], "iscrowd": 0}, {"id": 5, "image_id": 1, "category_id": 2, "segmentation": [[420, 359, 420, 361, 438, 361, 439, 360, 439, 359, 437, 359, 436, 360, 435, 359], [430, 314, 430, 316, 432, 318, 432, 319, 433, 320, 433, 321, 434, 322, 434, 323, 435, 324, 435, 325, 436, 326, 436, 329, 438, 331, 438, 332, 439, 333, 439, 335, 440, 336, 440, 339, 441, 340, 441, 343, 442, 344, 442, 350, 443, 351, 443, 363, 444, 364, 443, 365, 443, 369, 442, 370, 442, 375, 441, 376, 441, 380, 440, 381, 440, 385, 445, 385, 446, 384, 447, 384, 447, 381, 448, 380, 448, 375, 449, 374, 449, 366, 450, 365, 450, 364, 449, 363, 449, 362, 450, 361, 502, 361, 502, 358, 492, 358, 491, 359, 490, 358, 489, 358, 488, 359, 486, 359, 485, 358, 482, 358, 481, 359, 475, 359, 474, 358, 473, 358, 472, 359, 453, 359, 452, 360, 451, 360, 449, 358, 449, 346, 448, 345, 449, 344, 448, 343, 448, 341, 447, 340, 447, 336, 445, 334, 445, 332, 444, 331, 444, 330, 443, 329, 443, 327, 442, 326, 442, 325, 441, 324, 441, 322, 439, 320, 439, 319, 438, 318, 438, 316, 437, 315, 437, 314]], "area": 60, "bbox": [420, 359, 20, 3], "iscrowd": 0}, {"id": 6, "image_id": 1, "category_id": 2, "segmentation": [[60, 322, 59, 323, 59, 325, 58, 326, 58, 329, 57, 330, 57, 331, 56, 332, 56, 334, 54, 336, 54, 338, 53, 339, 53, 345, 52, 346, 52, 358, 50, 360, 49, 360, 48, 359, 35, 359, 35, 361, 50, 361, 52, 363, 52, 374, 53, 375, 53, 379, 54, 380, 54, 384, 55, 384, 56, 385, 56, 387, 57, 388, 57, 391, 58, 392, 58, 393, 59, 394, 59, 395, 60, 396, 60, 398, 66, 398, 66, 394, 65, 393, 65, 392, 64, 392, 63, 391, 63, 390, 62, 389, 62, 386, 61, 385, 61, 381, 60, 380, 60, 378, 59, 377, 59, 370, 58, 369, 58, 362, 59, 361, 78, 361, 79, 362, 80, 361, 82, 361, 83, 362, 85, 362, 86, 361, 87, 361, 87, 359, 64, 359, 63, 360, 62, 360, 61, 359, 60, 359, 59, 360, 57, 358, 58, 357, 58, 351, 59, 350, 59, 343, 60, 342, 60, 338, 61, 337, 61, 336, 62, 335, 62, 331, 63, 330, 63, 329, 64, 328, 65, 328, 65, 326, 66, 325, 66, 323, 67, 322]], "area": 4081, "bbox": [35, 322, 53, 77], "iscrowd": 0}, {"id": 7, "image_id": 1, "category_id": 2, "segmentation": [[132, 205, 132, 209, 142, 209, 143, 210, 146, 210, 149, 213, 150, 212, 152, 214, 152, 215, 155, 218, 156, 218, 157, 219, 157, 220, 158, 221, 158, 231, 157, 232, 157, 235, 156, 236, 155, 236, 164, 236, 164, 235, 166, 233, 166, 222, 163, 219, 163, 218, 162, 217, 162, 216, 160, 214, 159, 214, 157, 212, 157, 211, 156, 210, 156, 209, 157, 208, 160, 208, 161, 209, 174, 209, 175, 208, 176, 208, 177, 209, 181, 209, 181, 205, 180, 206, 160, 206, 159, 205, 155, 205, 154, 206, 152, 206, 151, 205, 149, 205, 148, 206, 147, 206, 146, 205, 144, 205, 143, 206, 142, 205, 139, 205, 138, 206, 135, 206, 134, 205]], "area": 1600, "bbox": [132, 205, 50, 32], "iscrowd": 0}, {"id": 8, "image_id": 1, "category_id": 2, "segmentation": [[312, 205, 311, 206, 309, 206, 309, 208, 329, 208, 330, 209, 331, 209, 333, 211, 330, 214, 330, 215, 329, 216, 329, 218, 328, 219, 328, 226, 327, 227, 328, 228, 328, 231, 329, 232, 329, 233, 330, 234, 330, 235, 337, 235, 336, 234, 336, 233, 334, 231, 334, 226, 333, 225, 334, 224, 334, 222, 335, 221, 336, 221, 336, 217, 339, 214, 339, 212, 342, 209, 343, 209, 344, 208, 353, 208, 354, 209, 355, 208, 359, 208, 359, 205]], "area": 1581, "bbox": [309, 205, 51, 31], "iscrowd": 0}, {"id": 9, "image_id": 1, "category_id": 2, "segmentation": [[244, 292, 244, 294, 245, 295, 245, 299, 244, 300, 244, 302, 245, 303, 245, 306, 243, 308, 238, 308, 237, 309, 229, 309, 228, 310, 228, 314, 229, 313, 230, 313, 231, 314, 232, 313, 234, 313, 235, 312, 240, 312, 241, 311, 244, 311, 245, 312, 245, 322, 249, 322, 248, 321, 248, 318, 249, 317, 249, 315, 248, 314, 248, 312, 249, 311, 262, 311, 263, 312, 268, 312, 269, 313, 273, 313, 273, 309, 263, 309, 262, 308, 250, 308, 248, 306, 249, 305, 248, 304, 248, 301, 249, 300, 249, 298, 248, 297, 248, 295, 249, 294, 249, 293, 248, 292]], "area": 1426, "bbox": [228, 292, 46, 31], "iscrowd": 0}, {"id": 10, "image_id": 1, "category_id": 2, "segmentation": [[69, 266, 69, 269, 71, 271, 72, 271, 74, 273, 75, 273, 76, 274, 77, 274, 79, 276, 81, 276, 83, 278, 84, 278, 85, 279, 86, 279, 87, 280, 88, 280, 90, 282, 90, 284, 89, 285, 88, 285, 88, 286, 85, 289, 84, 289, 80, 293, 88, 293, 92, 289, 92, 288, 93, 287, 98, 287, 99, 288, 100, 288, 101, 289, 102, 289, 103, 290, 103, 291, 104, 292, 106, 292, 107, 293, 111, 293, 111, 292, 110, 291, 109, 291, 106, 288, 104, 288, 103, 287, 102, 287, 99, 284, 99, 283, 104, 278, 105, 278, 107, 276, 108, 276, 111, 273, 111, 267, 108, 270, 107, 270, 105, 272, 104, 272, 102, 274, 101, 274, 98, 277, 97, 277, 94, 280, 92, 280, 89, 277, 87, 277, 85, 275, 84, 275, 83, 274, 81, 274, 79, 272, 78, 272, 77, 271, 77, 270, 75, 270, 74, 269, 73, 269, 71, 267, 70, 267]], "area": 1204, "bbox": [69, 266, 43, 28], "iscrowd": 0}, {"id": 11, "image_id": 1, "category_id": 2, "segmentation": [[181, 333, 181, 334, 180, 335, 179, 335, 179, 336, 177, 338, 177, 339, 176, 340, 175, 340, 175, 341, 174, 342, 174, 343, 173, 344, 173, 345, 172, 346, 172, 348, 171, 349, 171, 351, 170, 352, 170, 359, 169, 360, 168, 360, 167, 359, 155, 359, 154, 360, 153, 359, 152, 359, 152, 361, 168, 361, 170, 363, 170, 367, 171, 368, 171, 372, 172, 373, 172, 374, 173, 375, 173, 377, 174, 378, 174, 379, 181, 379, 181, 378, 179, 376, 179, 375, 178, 374, 178, 371, 177, 370, 177, 367, 176, 366, 176, 362, 177, 361, 191, 361, 191, 359, 187, 359, 186, 360, 177, 360, 176, 359, 176, 356, 177, 355, 177, 352, 178, 351, 178, 349, 179, 348, 179, 346, 180, 345, 180, 344, 181, 343, 181, 342, 183, 340, 183, 339, 185, 337, 186, 337, 186, 336, 189, 333]], "area": 1880, "bbox": [152, 333, 40, 47], "iscrowd": 0}, {"id": 12, "image_id": 1, "category_id": 2, "segmentation": [[244, 339, 244, 355, 245, 356, 245, 358, 243, 360, 242, 359, 240, 359, 239, 360, 238, 360, 237, 359, 223, 359, 223, 361, 243, 361, 245, 363, 245, 368, 244, 369, 244, 378, 248, 378, 248, 362, 249, 361, 258, 361, 258, 359, 250, 359, 249, 360, 248, 359, 248, 352, 249, 351, 248, 350, 248, 341, 249, 340, 248, 339]], "area": 1440, "bbox": [223, 339, 36, 40], "iscrowd": 0}, {"id": 13, "image_id": 1, "category_id": 2, "segmentation": [[244, 291, 244, 294, 245, 295, 245, 299, 244, 300, 244, 302, 245, 303, 245, 306, 243, 308, 238, 308, 237, 309, 229, 309, 228, 310, 227, 310, 227, 314, 228, 314, 229, 313, 230, 313, 231, 314, 232, 313, 234, 313, 235, 312, 240, 312, 241, 311, 244, 311, 245, 312, 245, 322, 244, 323, 245, 324, 244, 325, 244, 332, 248, 332, 248, 328, 249, 327, 249, 322, 248, 321, 248, 318, 249, 317, 249, 315, 248, 314, 248, 312, 249, 311, 262, 311, 263, 312, 264, 312, 264, 309, 263, 309, 262, 308, 250, 308, 248, 306, 249, 305, 248, 304, 248, 301, 249, 300, 249, 298, 248, 297, 248, 295, 249, 294, 249, 293, 248, 292, 249, 291]], "area": 1596, "bbox": [227, 291, 38, 42], "iscrowd": 0}, {"id": 14, "image_id": 1, "category_id": 2, "segmentation": [[325, 351, 325, 355, 326, 356, 326, 357, 325, 358, 325, 359, 324, 360, 323, 359, 319, 359, 318, 360, 317, 359, 315, 359, 314, 360, 314, 361, 325, 361, 327, 363, 327, 365, 326, 366, 325, 366, 325, 368, 324, 369, 324, 370, 323, 371, 323, 374, 322, 375, 322, 376, 320, 378, 320, 379, 318, 381, 318, 382, 316, 384, 315, 384, 315, 385, 314, 386, 314, 388, 319, 388, 324, 383, 324, 382, 325, 381, 326, 381, 326, 380, 327, 379, 327, 378, 329, 376, 329, 373, 330, 372, 330, 370, 331, 369, 331, 366, 332, 365, 332, 362, 333, 361, 361, 361, 361, 359, 334, 359, 332, 357, 332, 354, 331, 353, 331, 351]], "area": 1824, "bbox": [314, 351, 48, 38], "iscrowd": 0}, {"id": 15, "image_id": 2, "category_id": 1, "segmentation": [[241, 48, 241, 49, 239, 51, 238, 51, 238, 53, 239, 53, 240, 54, 240, 58, 239, 59, 238, 59, 238, 61, 239, 61, 240, 62, 240, 78, 239, 79, 229, 79, 228, 78, 228, 77, 225, 77, 225, 78, 224, 79, 218, 79, 217, 80, 216, 80, 216, 86, 227, 86, 228, 85, 233, 85, 234, 84, 237, 84, 238, 85, 239, 85, 240, 86, 240, 106, 245, 106, 245, 102, 244, 101, 244, 99, 245, 98, 245, 96, 244, 95, 244, 88, 245, 87, 244, 86, 246, 84, 248, 84, 249, 85, 256, 85, 257, 86, 258, 85, 259, 85, 260, 86, 264, 86, 265, 87, 266, 87, 267, 86, 268, 86, 269, 87, 274, 87, 275, 88, 275, 89, 280, 89, 281, 90, 283, 90, 284, 91, 286, 91, 287, 92, 292, 92, 293, 93, 294, 93, 295, 94, 295, 95, 295, 86, 292, 86, 291, 85, 286, 85, 285, 84, 283, 84, 282, 83, 282, 82, 280, 82, 279, 81, 276, 81, 275, 80, 264, 80, 263, 79, 245, 79, 244, 78, 244, 77, 243, 77, 242, 76, 243, 75, 244, 75, 244, 63, 245, 62, 245, 61, 244, 60, 244, 58, 245, 57, 245, 52, 244, 51, 244, 50, 242, 50, 241, 49]], "area": 4720, "bbox": [216, 48, 80, 59], "iscrowd": 0}, {"id": 16, "image_id": 2, "category_id": 2, "segmentation": [[387, 154, 387, 158, 388, 158, 390, 160, 390, 161, 392, 163, 392, 165, 393, 166, 394, 166, 395, 167, 395, 168, 396, 169, 396, 170, 397, 171, 397, 172, 398, 173, 398, 175, 399, 176, 399, 177, 400, 177, 402, 179, 402, 182, 404, 184, 404, 187, 405, 188, 405, 189, 406, 189, 409, 192, 409, 194, 410, 195, 410, 198, 411, 198, 412, 199, 412, 201, 411, 202, 408, 202, 407, 203, 401, 203, 400, 202, 389, 202, 388, 203, 387, 203, 387, 210, 407, 210, 407, 209, 408, 208, 413, 208, 414, 209, 414, 210, 416, 212, 416, 214, 417, 214, 418, 215, 418, 219, 419, 220, 419, 224, 420, 225, 420, 228, 421, 229, 421, 230, 422, 231, 422, 239, 423, 239, 424, 240, 424, 245, 425, 246, 425, 248, 426, 249, 426, 250, 425, 251, 426, 252, 425, 253, 426, 254, 426, 259, 427, 260, 427, 261, 432, 261, 432, 253, 431, 252, 432, 251, 431, 250, 431, 240, 430, 239, 430, 234, 429, 233, 429, 230, 428, 230, 427, 229, 427, 225, 426, 224, 426, 220, 425, 219, 425, 218, 424, 217, 424, 213, 423, 212, 423, 211, 424, 210, 424, 209, 425, 208, 426, 208, 427, 209, 427, 210, 432, 210, 432, 203, 431, 203, 430, 202, 421, 202, 420, 201, 420, 200, 419, 199, 419, 196, 418, 195, 418, 194, 417, 193, 417, 189, 416, 189, 415, 188, 415, 185, 412, 182, 412, 180, 411, 179, 411, 178, 410, 178, 409, 177, 409, 176, 408, 175, 408, 173, 407, 172, 407, 171, 406, 170, 406, 169, 405, 169, 403, 167, 403, 166, 401, 164, 401, 162, 400, 161, 400, 160, 399, 160, 397, 158, 397, 156, 396, 156, 395, 155, 395, 154]], "area": 4968, "bbox": [387, 154, 46, 108], "iscrowd": 0}, {"id": 17, "image_id": 2, "category_id": 2, "segmentation": [[355, 205, 355, 208], [272, 203, 272, 211, 280, 211, 281, 210, 282, 210, 283, 211, 292, 211, 293, 210, 293, 209, 294, 208, 294, 207, 293, 206, 293, 205, 292, 204, 292, 203], [330, 202, 329, 203, 329, 204, 327, 206, 328, 207, 328, 208, 329, 209, 329, 210, 348, 210, 348, 209, 349, 208, 349, 206, 348, 205, 347, 205, 346, 204, 346, 203, 345, 203, 344, 202, 339, 202, 338, 203, 336, 203, 335, 202], [272, 178, 272, 188, 274, 188, 275, 189, 277, 189, 278, 190, 281, 190, 282, 191, 283, 191, 284, 192, 284, 193, 286, 193, 288, 195, 289, 195, 290, 196, 292, 196, 293, 197, 293, 198, 294, 199, 296, 199, 299, 202, 299, 208, 300, 209, 300, 210, 305, 210, 306, 211, 308, 211, 309, 212, 309, 213, 311, 215, 311, 216, 313, 218, 314, 218, 315, 219, 315, 221, 317, 223, 317, 224, 318, 225, 318, 227, 319, 227, 320, 228, 320, 229, 321, 230, 321, 231, 322, 232, 322, 234, 323, 235, 323, 237, 324, 238, 324, 240, 325, 240, 326, 241, 326, 245, 335, 245, 335, 243, 334, 242, 334, 241, 333, 240, 333, 237, 332, 236, 332, 235, 331, 234, 331, 232, 330, 232, 329, 231, 329, 230, 328, 229, 328, 226, 326, 224, 326, 223, 325, 222, 324, 222, 323, 221, 323, 219, 320, 216, 320, 214, 319, 213, 319, 211, 320, 210, 320, 209, 321, 208, 321, 205, 320, 204, 320, 203, 311, 203, 310, 202, 309, 202, 308, 201, 307, 201, 306, 200, 305, 200, 303, 198, 303, 197, 302, 196, 301, 196, 298, 193, 298, 192, 297, 192, 296, 191, 295, 191, 293, 189, 292, 189, 291, 188, 289, 188, 288, 187, 288, 186, 286, 186, 285, 185, 284, 185, 283, 184, 282, 184, 281, 183, 280, 183, 279, 182, 277, 182, 276, 181, 276, 180, 275, 179, 274, 179, 273, 178]], "area": 4, "bbox": [355, 205, 1, 4], "iscrowd": 0}, {"id": 18, "image_id": 2, "category_id": 2, "segmentation": [[241, 153, 240, 154, 240, 166, 241, 167, 241, 170, 240, 171, 241, 172, 239, 174, 231, 174, 231, 175, 230, 176, 226, 176, 226, 183, 229, 183, 230, 182, 236, 182, 237, 181, 238, 182, 239, 182, 240, 183, 240, 197, 245, 197, 245, 183, 247, 181, 248, 182, 252, 182, 253, 183, 262, 183, 263, 184, 264, 184, 265, 185, 266, 185, 266, 178, 264, 178, 263, 177, 260, 177, 259, 176, 254, 176, 253, 175, 253, 174, 246, 174, 245, 173, 245, 156, 244, 155, 244, 154, 242, 154]], "area": 1845, "bbox": [226, 153, 41, 45], "iscrowd": 0}, {"id": 19, "image_id": 2, "category_id": 2, "segmentation": [[240, 227, 240, 230, 241, 231, 241, 234, 240, 235, 240, 246, 241, 247, 241, 266, 240, 267, 240, 268, 239, 269, 235, 269, 234, 268, 234, 267, 229, 267, 229, 268, 228, 269, 218, 269, 217, 268, 217, 267, 217, 268, 216, 269, 212, 269, 212, 273, 230, 273, 230, 272, 231, 271, 236, 271, 237, 272, 237, 273, 238, 274, 238, 276, 241, 276, 242, 277, 242, 279, 241, 280, 241, 305, 245, 305, 246, 304, 245, 303, 245, 293, 246, 292, 246, 290, 245, 289, 245, 282, 246, 281, 246, 274, 247, 273, 247, 272, 248, 271, 250, 271, 251, 272, 251, 273, 256, 273, 256, 272, 257, 271, 258, 272, 258, 273, 283, 273, 283, 267, 282, 267, 282, 268, 281, 269, 251, 269, 250, 268, 250, 267, 248, 267, 248, 268, 247, 269, 246, 268, 246, 267, 245, 266, 245, 253, 246, 252, 245, 251, 246, 250, 246, 246, 245, 245, 245, 227]], "area": 5688, "bbox": [212, 227, 72, 79], "iscrowd": 0}, {"id": 20, "image_id": 2, "category_id": 2, "segmentation": [[149, 231, 149, 235, 148, 236, 148, 237, 147, 238, 146, 238, 146, 239, 145, 240, 145, 242, 144, 243, 144, 245, 142, 247, 142, 254, 141, 255, 140, 255, 140, 266, 139, 267, 138, 267, 138, 268, 137, 269, 130, 269, 129, 268, 129, 267, 122, 267, 122, 268, 121, 269, 114, 269, 114, 273, 132, 273, 132, 272, 133, 271, 136, 271, 137, 272, 137, 273, 138, 273, 139, 274, 139, 281, 140, 282, 140, 293, 141, 293, 142, 294, 142, 297, 143, 298, 143, 301, 152, 301, 151, 301, 150, 300, 150, 297, 149, 296, 149, 293, 148, 292, 148, 287, 147, 286, 147, 274, 148, 273, 175, 273, 175, 269, 148, 269, 147, 268, 147, 261, 148, 260, 148, 255, 149, 254, 149, 252, 150, 251, 150, 248, 151, 247, 152, 247, 152, 245, 153, 244, 153, 242, 154, 241, 154, 240, 155, 239, 155, 237, 156, 236, 156, 235, 157, 234, 158, 234, 158, 232, 159, 231]], "area": 4402, "bbox": [114, 231, 62, 71], "iscrowd": 0}, {"id": 21, "image_id": 2, "category_id": 2, "segmentation": [[189, 327, 187, 329, 186, 329, 186, 333, 187, 333, 188, 334, 188, 335, 190, 335, 191, 336, 191, 337, 208, 337, 208, 336, 209, 335, 210, 335, 210, 328, 205, 328, 204, 327], [133, 327, 133, 337, 143, 337, 143, 336, 144, 335, 144, 330, 142, 328, 139, 328, 138, 327], [145, 307, 145, 309, 146, 310, 146, 311, 147, 311, 148, 312, 148, 314, 150, 316, 150, 317, 151, 318, 151, 321, 152, 321, 154, 323, 154, 325, 155, 326, 154, 327, 154, 328, 152, 330, 151, 330, 151, 334, 153, 334, 154, 335, 161, 335, 162, 336, 162, 337, 163, 338, 164, 338, 167, 341, 167, 342, 169, 344, 170, 344, 173, 347, 173, 348, 174, 349, 175, 349, 178, 352, 179, 352, 180, 353, 180, 354, 181, 354, 182, 355, 183, 355, 186, 358, 188, 358, 189, 359, 189, 360, 191, 360, 192, 361, 193, 361, 194, 362, 196, 362, 197, 363, 199, 363, 200, 364, 200, 365, 201, 365, 202, 366, 206, 366, 207, 367, 210, 367, 210, 359, 206, 359, 205, 358, 203, 358, 202, 357, 200, 357, 199, 356, 197, 356, 196, 355, 195, 355, 194, 354, 194, 353, 192, 353, 190, 351, 189, 351, 187, 349, 185, 349, 184, 348, 184, 347, 183, 346, 182, 346, 181, 345, 180, 345, 177, 342, 177, 341, 175, 339, 174, 339, 173, 338, 173, 335, 174, 334, 175, 334, 176, 333, 176, 332, 175, 331, 175, 330, 174, 330, 172, 328, 171, 328, 170, 327, 165, 327, 164, 326, 163, 326, 162, 325, 162, 324, 160, 322, 160, 320, 159, 319, 159, 317, 158, 316, 158, 315, 157, 315, 156, 314, 156, 313, 154, 311, 154, 309, 153, 308, 153, 307]], "area": 275, "bbox": [186, 327, 25, 11], "iscrowd": 0}, {"id": 22, "image_id": 2, "category_id": 2, "segmentation": [[241, 344, 241, 363, 240, 364, 226, 364, 225, 363, 219, 363, 219, 369, 223, 369, 224, 370, 224, 371, 239, 371, 241, 373, 241, 395, 240, 396, 240, 398, 241, 399, 241, 400, 246, 400, 246, 398, 245, 397, 246, 396, 246, 395, 245, 394, 245, 393, 246, 392, 245, 391, 245, 373, 247, 371, 256, 371, 256, 370, 257, 369, 262, 369, 263, 368, 265, 368, 266, 367, 269, 367, 270, 366, 274, 366, 275, 365, 276, 365, 276, 364, 277, 363, 280, 363, 281, 362, 281, 353, 281, 354, 280, 355, 278, 355, 277, 356, 275, 356, 274, 357, 271, 357, 270, 358, 269, 358, 268, 359, 266, 359, 266, 360, 265, 361, 263, 361, 262, 362, 255, 362, 254, 363, 251, 363, 250, 364, 246, 364, 245, 363, 245, 349, 246, 348, 246, 347, 245, 346, 245, 344]], "area": 3591, "bbox": [219, 344, 63, 57], "iscrowd": 0}, {"id": 23, "image_id": 2, "category_id": 2, "segmentation": [[240, 421, 241, 422, 241, 424, 240, 425, 240, 429, 241, 430, 241, 431, 240, 432, 240, 434, 241, 435, 241, 437, 240, 438, 240, 440, 241, 441, 241, 442, 240, 443, 240, 446, 241, 447, 241, 449, 240, 450, 241, 451, 241, 458, 240, 459, 240, 460, 239, 461, 237, 461, 236, 460, 222, 460, 221, 459, 219, 459, 218, 460, 217, 459, 209, 459, 209, 465, 216, 465, 217, 466, 234, 466, 235, 467, 236, 466, 237, 466, 238, 467, 239, 467, 240, 468, 240, 469, 241, 470, 241, 472, 240, 473, 240, 489, 239, 490, 238, 490, 238, 491, 245, 491, 245, 468, 246, 467, 248, 467, 249, 466, 259, 466, 260, 465, 269, 465, 270, 464, 271, 464, 271, 458, 265, 458, 264, 459, 259, 459, 258, 460, 255, 460, 254, 461, 253, 461, 252, 460, 251, 461, 246, 461, 245, 460, 245, 459, 244, 458, 245, 457, 245, 456, 244, 455, 245, 454, 245, 421]], "area": 4473, "bbox": [209, 421, 63, 71], "iscrowd": 0}, {"id": 24, "image_id": 3, "category_id": 1, "segmentation": [[276, 322, 276, 337, 275, 338, 276, 339, 276, 344, 274, 346, 261, 346, 260, 345, 259, 346, 257, 346, 257, 351, 258, 351, 259, 350, 269, 350, 270, 351, 284, 351, 285, 350, 293, 350, 294, 351, 301, 351, 301, 346, 296, 346, 295, 345, 293, 345, 292, 346, 283, 346, 282, 345, 282, 337, 281, 336, 281, 332, 282, 331, 282, 327, 281, 326, 282, 325, 281, 324, 282, 323, 282, 322]], "area": 1350, "bbox": [257, 322, 45, 30], "iscrowd": 0}, {"id": 25, "image_id": 3, "category_id": 2, "segmentation": [[100, 314, 100, 346, 99, 347, 98, 347, 97, 348, 96, 347, 87, 347, 86, 346, 83, 346, 83, 352, 87, 352, 88, 351, 89, 352, 90, 352, 91, 351, 100, 351, 101, 352, 103, 352, 104, 351, 109, 351, 110, 352, 113, 352, 114, 351, 122, 351, 122, 346, 119, 346, 118, 347, 111, 347, 110, 348, 108, 348, 106, 346, 106, 331, 107, 330, 106, 329, 106, 321, 107, 320, 107, 319, 106, 318, 106, 314]], "area": 1560, "bbox": [83, 314, 40, 39], "iscrowd": 0}, {"id": 26, "image_id": 3, "category_id": 2, "segmentation": [[187, 321, 187, 326, 186, 327, 186, 329, 187, 330, 187, 331, 186, 332, 186, 337, 187, 338, 187, 345, 186, 346, 172, 346, 172, 351, 185, 351, 187, 353, 187, 355, 186, 356, 186, 357, 187, 358, 187, 359, 186, 360, 186, 361, 187, 362, 187, 363, 186, 364, 186, 365, 187, 366, 186, 367, 186, 370, 187, 371, 187, 373, 190, 373, 190, 352, 191, 351, 208, 351, 208, 346, 193, 346, 192, 347, 190, 345, 190, 321]], "area": 1961, "bbox": [172, 321, 37, 53], "iscrowd": 0}, {"id": 27, "image_id": 3, "category_id": 2, "segmentation": [[187, 476, 187, 489, 186, 490, 186, 494, 187, 495, 187, 496, 185, 498, 169, 498, 169, 504, 184, 504, 185, 505, 186, 505, 187, 506, 187, 507, 188, 508, 190, 508, 190, 506, 192, 504, 196, 504, 197, 505, 198, 505, 199, 504, 214, 504, 214, 497, 213, 498, 212, 497, 209, 497, 208, 498, 199, 498, 198, 497, 196, 497, 195, 498, 191, 498, 190, 497, 190, 476]], "area": 1518, "bbox": [169, 476, 46, 33], "iscrowd": 0}],"categories": [{"supercategory": "shape","id": 1,"name": "circle"},{"supercategory": "shape","id": 2,"name": "Junction"}]}

the error:

ERROR:root:Error processing image {'id': 2, 'source': 'coco', 'path': 'D:/Mask_RCNN-master/coco//val2017\\114.jpg', 'width': 512, 'height': 512, 'annotations': [{'id': 15, 'image_id': 2, 'category_id': 1, 'segmentation': [[241, 48, 241, 49, 239, 51, 238, 51, 238, 53, 239, 53, 240, 54, 240, 58, 239, 59, 238, 59, 238, 61, 239, 61, 240, 62, 240, 78, 239, 79, 229, 79, 228, 78, 228, 77, 225, 77, 225, 78, 224, 79, 218, 79, 217, 80, 216, 80, 216, 86, 227, 86, 228, 85, 233, 85, 234, 84, 237, 84, 238, 85, 239, 85, 240, 86, 240, 106, 245, 106, 245, 102, 244, 101, 244, 99, 245, 98, 245, 96, 244, 95, 244, 88, 245, 87, 244, 86, 246, 84, 248, 84, 249, 85, 256, 85, 257, 86, 258, 85, 259, 85, 260, 86, 264, 86, 265, 87, 266, 87, 267, 86, 268, 86, 269, 87, 274, 87, 275, 88, 275, 89, 280, 89, 281, 90, 283, 90, 284, 91, 286, 91, 287, 92, 292, 92, 293, 93, 294, 93, 295, 94, 295, 95, 295, 86, 292, 86, 291, 85, 286, 85, 285, 84, 283, 84, 282, 83, 282, 82, 280, 82, 279, 81, 276, 81, 275, 80, 264, 80, 263, 79, 245, 79, 244, 78, 244, 77, 243, 77, 242, 76, 243, 75, 244, 75, 244, 63, 245, 62, 245, 61, 244, 60, 244, 58, 245, 57, 245, 52, 244, 51, 244, 50, 242, 50, 241, 49]], 'area': 4720, 'bbox': [216, 48, 80, 59], 'iscrowd': 0}, {'id': 16, 'image_id': 2, 'category_id': 2, 'segmentation': [[387, 154, 387, 158, 388, 158, 390, 160, 390, 161, 392, 163, 392, 165, 393, 166, 394, 166, 395, 167, 395, 168, 396, 169, 396, 170, 397, 171, 397, 172, 398, 173, 398, 175, 399, 176, 399, 177, 400, 177, 402, 179, 402, 182, 404, 184, 404, 187, 405, 188, 405, 189, 406, 189, 409, 192, 409, 194, 410, 195, 410, 198, 411, 198, 412, 199, 412, 201, 411, 202, 408, 202, 407, 203, 401, 203, 400, 202, 389, 202, 388, 203, 387, 203, 387, 210, 407, 210, 407, 209, 408, 208, 413, 208, 414, 209, 414, 210, 416, 212, 416, 214, 417, 214, 418, 215, 418, 219, 419, 220, 419, 224, 420, 225, 420, 228, 421, 229, 421, 230, 422, 231, 422, 239, 423, 239, 424, 240, 424, 245, 425, 246, 425, 248, 426, 249, 426, 250, 425, 251, 426, 252, 425, 253, 426, 254, 426, 259, 427, 260, 427, 261, 432, 261, 432, 253, 431, 252, 432, 251, 431, 250, 431, 240, 430, 239, 430, 234, 429, 233, 429, 230, 428, 230, 427, 229, 427, 225, 426, 224, 426, 220, 425, 219, 425, 218, 424, 217, 424, 213, 423, 212, 423, 211, 424, 210, 424, 209, 425, 208, 426, 208, 427, 209, 427, 210, 432, 210, 432, 203, 431, 203, 430, 202, 421, 202, 420, 201, 420, 200, 419, 199, 419, 196, 418, 195, 418, 194, 417, 193, 417, 189, 416, 189, 415, 188, 415, 185, 412, 182, 412, 180, 411, 179, 411, 178, 410, 178, 409, 177, 409, 176, 408, 175, 408, 173, 407, 172, 407, 171, 406, 170, 406, 169, 405, 169, 403, 167, 403, 166, 401, 164, 401, 162, 400, 161, 400, 160, 399, 160, 397, 158, 397, 156, 396, 156, 395, 155, 395, 154]], 'area': 4968, 'bbox': [387, 154, 46, 108], 'iscrowd': 0}, {'id': 17, 'image_id': 2, 'category_id': 2, 'segmentation': [[355, 205, 355, 208], [272, 203, 272, 211, 280, 211, 281, 210, 282, 210, 283, 211, 292, 211, 293, 210, 293, 209, 294, 208, 294, 207, 293, 206, 293, 205, 292, 204, 292, 203], [330, 202, 329, 203, 329, 204, 327, 206, 328, 207, 328, 208, 329, 209, 329, 210, 348, 210, 348, 209, 349, 208, 349, 206, 348, 205, 347, 205, 346, 204, 346, 203, 345, 203, 344, 202, 339, 202, 338, 203, 336, 203, 335, 202], [272, 178, 272, 188, 274, 188, 275, 189, 277, 189, 278, 190, 281, 190, 282, 191, 283, 191, 284, 192, 284, 193, 286, 193, 288, 195, 289, 195, 290, 196, 292, 196, 293, 197, 293, 198, 294, 199, 296, 199, 299, 202, 299, 208, 300, 209, 300, 210, 305, 210, 306, 211, 308, 211, 309, 212, 309, 213, 311, 215, 311, 216, 313, 218, 314, 218, 315, 219, 315, 221, 317, 223, 317, 224, 318, 225, 318, 227, 319, 227, 320, 228, 320, 229, 321, 230, 321, 231, 322, 232, 322, 234, 323, 235, 323, 237, 324, 238, 324, 240, 325, 240, 326, 241, 326, 245, 335, 245, 335, 243, 334, 242, 334, 241, 333, 240, 333, 237, 332, 236, 332, 235, 331, 234, 331, 232, 330, 232, 329, 231, 329, 230, 328, 229, 328, 226, 326, 224, 326, 223, 325, 222, 324, 222, 323, 221, 323, 219, 320, 216, 320, 214, 319, 213, 319, 211, 320, 210, 320, 209, 321, 208, 321, 205, 320, 204, 320, 203, 311, 203, 310, 202, 309, 202, 308, 201, 307, 201, 306, 200, 305, 200, 303, 198, 303, 197, 302, 196, 301, 196, 298, 193, 298, 192, 297, 192, 296, 191, 295, 191, 293, 189, 292, 189, 291, 188, 289, 188, 288, 187, 288, 186, 286, 186, 285, 185, 284, 185, 283, 184, 282, 184, 281, 183, 280, 183, 279, 182, 277, 182, 276, 181, 276, 180, 275, 179, 274, 179, 273, 178]], 'area': 4, 'bbox': [355, 205, 1, 4], 'iscrowd': 0}, {'id': 18, 'image_id': 2, 'category_id': 2, 'segmentation': [[241, 153, 240, 154, 240, 166, 241, 167, 241, 170, 240, 171, 241, 172, 239, 174, 231, 174, 231, 175, 230, 176, 226, 176, 226, 183, 229, 183, 230, 182, 236, 182, 237, 181, 238, 182, 239, 182, 240, 183, 240, 197, 245, 197, 245, 183, 247, 181, 248, 182, 252, 182, 253, 183, 262, 183, 263, 184, 264, 184, 265, 185, 266, 185, 266, 178, 264, 178, 263, 177, 260, 177, 259, 176, 254, 176, 253, 175, 253, 174, 246, 174, 245, 173, 245, 156, 244, 155, 244, 154, 242, 154]], 'area': 1845, 'bbox': [226, 153, 41, 45], 'iscrowd': 0}, {'id': 19, 'image_id': 2, 'category_id': 2, 'segmentation': [[240, 227, 240, 230, 241, 231, 241, 234, 240, 235, 240, 246, 241, 247, 241, 266, 240, 267, 240, 268, 239, 269, 235, 269, 234, 268, 234, 267, 229, 267, 229, 268, 228, 269, 218, 269, 217, 268, 217, 267, 217, 268, 216, 269, 212, 269, 212, 273, 230, 273, 230, 272, 231, 271, 236, 271, 237, 272, 237, 273, 238, 274, 238, 276, 241, 276, 242, 277, 242, 279, 241, 280, 241, 305, 245, 305, 246, 304, 245, 303, 245, 293, 246, 292, 246, 290, 245, 289, 245, 282, 246, 281, 246, 274, 247, 273, 247, 272, 248, 271, 250, 271, 251, 272, 251, 273, 256, 273, 256, 272, 257, 271, 258, 272, 258, 273, 283, 273, 283, 267, 282, 267, 282, 268, 281, 269, 251, 269, 250, 268, 250, 267, 248, 267, 248, 268, 247, 269, 246, 268, 246, 267, 245, 266, 245, 253, 246, 252, 245, 251, 246, 250, 246, 246, 245, 245, 245, 227]], 'area': 5688, 'bbox': [212, 227, 72, 79], 'iscrowd': 0}, {'id': 20, 'image_id': 2, 'category_id': 2, 'segmentation': [[149, 231, 149, 235, 148, 236, 148, 237, 147, 238, 146, 238, 146, 239, 145, 240, 145, 242, 144, 243, 144, 245, 142, 247, 142, 254, 141, 255, 140, 255, 140, 266, 139, 267, 138, 267, 138, 268, 137, 269, 130, 269, 129, 268, 129, 267, 122, 267, 122, 268, 121, 269, 114, 269, 114, 273, 132, 273, 132, 272, 133, 271, 136, 271, 137, 272, 137, 273, 138, 273, 139, 274, 139, 281, 140, 282, 140, 293, 141, 293, 142, 294, 142, 297, 143, 298, 143, 301, 152, 301, 151, 301, 150, 300, 150, 297, 149, 296, 149, 293, 148, 292, 148, 287, 147, 286, 147, 274, 148, 273, 175, 273, 175, 269, 148, 269, 147, 268, 147, 261, 148, 260, 148, 255, 149, 254, 149, 252, 150, 251, 150, 248, 151, 247, 152, 247, 152, 245, 153, 244, 153, 242, 154, 241, 154, 240, 155, 239, 155, 237, 156, 236, 156, 235, 157, 234, 158, 234, 158, 232, 159, 231]], 'area': 4402, 'bbox': [114, 231, 62, 71], 'iscrowd': 0}, {'id': 21, 'image_id': 2, 'category_id': 2, 'segmentation': [[189, 327, 187, 329, 186, 329, 186, 333, 187, 333, 188, 334, 188, 335, 190, 335, 191, 336, 191, 337, 208, 337, 208, 336, 209, 335, 210, 335, 210, 328, 205, 328, 204, 327], [133, 327, 133, 337, 143, 337, 143, 336, 144, 335, 144, 330, 142, 328, 139, 328, 138, 327], [145, 307, 145, 309, 146, 310, 146, 311, 147, 311, 148, 312, 148, 314, 150, 316, 150, 317, 151, 318, 151, 321, 152, 321, 154, 323, 154, 325, 155, 326, 154, 327, 154, 328, 152, 330, 151, 330, 151, 334, 153, 334, 154, 335, 161, 335, 162, 336, 162, 337, 163, 338, 164, 338, 167, 341, 167, 342, 169, 344, 170, 344, 173, 347, 173, 348, 174, 349, 175, 349, 178, 352, 179, 352, 180, 353, 180, 354, 181, 354, 182, 355, 183, 355, 186, 358, 188, 358, 189, 359, 189, 360, 191, 360, 192, 361, 193, 361, 194, 362, 196, 362, 197, 363, 199, 363, 200, 364, 200, 365, 201, 365, 202, 366, 206, 366, 207, 367, 210, 367, 210, 359, 206, 359, 205, 358, 203, 358, 202, 357, 200, 357, 199, 356, 197, 356, 196, 355, 195, 355, 194, 354, 194, 353, 192, 353, 190, 351, 189, 351, 187, 349, 185, 349, 184, 348, 184, 347, 183, 346, 182, 346, 181, 345, 180, 345, 177, 342, 177, 341, 175, 339, 174, 339, 173, 338, 173, 335, 174, 334, 175, 334, 176, 333, 176, 332, 175, 331, 175, 330, 174, 330, 172, 328, 171, 328, 170, 327, 165, 327, 164, 326, 163, 326, 162, 325, 162, 324, 160, 322, 160, 320, 159, 319, 159, 317, 158, 316, 158, 315, 157, 315, 156, 314, 156, 313, 154, 311, 154, 309, 153, 308, 153, 307]], 'area': 275, 'bbox': [186, 327, 25, 11], 'iscrowd': 0}, {'id': 22, 'image_id': 2, 'category_id': 2, 'segmentation': [[241, 344, 241, 363, 240, 364, 226, 364, 225, 363, 219, 363, 219, 369, 223, 369, 224, 370, 224, 371, 239, 371, 241, 373, 241, 395, 240, 396, 240, 398, 241, 399, 241, 400, 246, 400, 246, 398, 245, 397, 246, 396, 246, 395, 245, 394, 245, 393, 246, 392, 245, 391, 245, 373, 247, 371, 256, 371, 256, 370, 257, 369, 262, 369, 263, 368, 265, 368, 266, 367, 269, 367, 270, 366, 274, 366, 275, 365, 276, 365, 276, 364, 277, 363, 280, 363, 281, 362, 281, 353, 281, 354, 280, 355, 278, 355, 277, 356, 275, 356, 274, 357, 271, 357, 270, 358, 269, 358, 268, 359, 266, 359, 266, 360, 265, 361, 263, 361, 262, 362, 255, 362, 254, 363, 251, 363, 250, 364, 246, 364, 245, 363, 245, 349, 246, 348, 246, 347, 245, 346, 245, 344]], 'area': 3591, 'bbox': [219, 344, 63, 57], 'iscrowd': 0}, {'id': 23, 'image_id': 2, 'category_id': 2, 'segmentation': [[240, 421, 241, 422, 241, 424, 240, 425, 240, 429, 241, 430, 241, 431, 240, 432, 240, 434, 241, 435, 241, 437, 240, 438, 240, 440, 241, 441, 241, 442, 240, 443, 240, 446, 241, 447, 241, 449, 240, 450, 241, 451, 241, 458, 240, 459, 240, 460, 239, 461, 237, 461, 236, 460, 222, 460, 221, 459, 219, 459, 218, 460, 217, 459, 209, 459, 209, 465, 216, 465, 217, 466, 234, 466, 235, 467, 236, 466, 237, 466, 238, 467, 239, 467, 240, 468, 240, 469, 241, 470, 241, 472, 240, 473, 240, 489, 239, 490, 238, 490, 238, 491, 245, 491, 245, 468, 246, 467, 248, 467, 249, 466, 259, 466, 260, 465, 269, 465, 270, 464, 271, 464, 271, 458, 265, 458, 264, 459, 259, 459, 258, 460, 255, 460, 254, 461, 253, 461, 252, 460, 251, 461, 246, 461, 245, 460, 245, 459, 244, 458, 245, 457, 245, 456, 244, 455, 245, 454, 245, 421]], 'area': 4473, 'bbox': [209, 421, 63, 71], 'iscrowd': 0}]} Traceback (most recent call last): File "D:\Mask_RCNN-master\model.py", line 1632, in data_generator use_mini_mask=config.USE_MINI_MASK) File "D:\Mask_RCNN-master\model.py", line 1191, in load_image_gt mask, class_ids = dataset.load_mask(image_id) File "coco.py", line 244, in load_mask image_info["width"]) File "coco.py", line 304, in annToMask rle = self.annToRLE(ann, height, width) File "coco.py", line 289, in annToRLE rles = maskUtils.frPyObjects(segm, height, width) File "pycocotools\_mask.pyx", line 293, in pycocotools._mask.frPyObjects TypeError: Argument 'bb' has incorrect type (expected numpy.ndarray, got list)

austinmw commented 6 years ago

Hey did you find the cause of this error? I'm getting it too.

Simonhong111 commented 5 years ago

have you solved this problem? I alse have met this problem and do know how to handle it

lkrishnan-argo commented 5 years ago

This happens if mask length for an annotation = 4, when it gets interpreted differently - as a bbox. See here: https://github.com/cocodataset/cocoapi/blob/master/PythonAPI/pycocotools/_mask.pyx#L292

In the example above - this segmentation annotation probably triggered this error [355, 205, 355, 208]

Mrutyunjay01 commented 4 years ago

have you solved this problem? I also have met this problem and do know how to handle it

Can you please help me fix it? I am getting a similar error.

rivered commented 3 years ago

This was a painstaking effort for me. Surely we are not going to change all rectangles to polygons in a few thousand annotated images as proposed by Zhang-O.

I loaded my erroneous file and searched for the segmentation which is pretending to be a bounding box:

#It happens to be so that the bounding boxes are lists and not ndarrays? Ndarrays are not JSON serialisable
#TypeError: Argument 'bb' has incorrect type (expected numpy.ndarray, got list)

#Find JSON that gives errors
JSON_LOC="/home/Desktop/annotation.json"

#Open JSON
val_json = open(JSON_LOC, "r")
json_object = json.load(val_json)
val_json.close()

for i, instance in enumerate(json_object["annotations"]):
    if len(instance["segmentation"][0]) == 4:
        print("instance number", i, "raises arror:", instance["segmentation"][0])
instance number 1030 raises arror: [461, 449, 461, 449]

Now we can simply adjust it or delete it or do whatever and write back the file

#Alter object generating the error with something random not causing the error
json_object["annotations"][1030]["segmentation"] = [[461, 449, 462, 449, 461, 449]]

#Write back altered JSON
val_json = open(JSON_LOC, "w")
json.dump(json_object, val_json)
val_json.close()

The error did not show up anymore after this change.

kevalrajpalknight commented 3 years ago

@rivered Hey, I am also facing the same issue and everywhere I am getting a reference to this thread only. I am unable to understand your solution & approach used in solving the stated problem. May I ask you for a little further explanation for your solution?

Like, Is it an extra python script that needs to be run to find the erroneous code segment or we need to tweak it to some already stated files?

Please help me with this issue. Thank You.

rivered commented 3 years ago

@rivered Hey, I am also facing the same issue and everywhere I am getting a reference to this thread only. I am unable to understand your solution & approach used in solving the stated problem. May I ask you for a little further explanation for your solution?

Like, Is it an extra python script that needs to be run to find the erroneous code segment or we need to tweak it to some already stated files?

Please help me with this issue. Thank You.

I think the entire solution is posted. The solution was taken from a Jupyter notebook, so indeed to run it you either need a notebook environment or you can convert it to a python script.

In my case I started receiving this error when I ran my own augmentation scripts and created a new .json file in which, unfortunately, a single segmentation of an instance pretended to be a bounding box.

As you are getting this error, it means you have a "corrupted" .json file, either in your validation or training .json file. The logic presented above could be used to rewrite an executable python script in which you need your .json files as input. Than you need to tweak the file a little bit to either remove or alter the erroneous .json or do nothing if it is an non corrupted file.

for i, instance in enumerate(json_object["annotations"]): if len(instance["segmentation"][0]) == 4: print("instance number", i, "raises error:", instance["segmentation"][0])

Basically the code above checks every annotation in the .json file which have the segmentations embedded in the annotation. If the segmentation within the annotation has a length of four coordinates it means it is corrupted and further downstream in the processing of this .json file, a parser will think that this segmentation is a bounding box because there are four coordinates. Therfore, if this is the case, it will raise the error and shows which index number belongs to the wrong annotation. This can be used to rewrite the wrong annotation:

json_object["annotations"][1030 (or basically i) ]["segmentation"] = [[461, 449, 462, 449, 461, 449]]

Logically it would be best to prevent this error from happening in the first place, for example when altering or making a new .json preventing the segmentations with 4 coordinates to be written or altered. Also in the reading of the .json file an alteration could be made to make sure bounding box is actually read as bounding box. I think that is where the actual root of the problem is located anyways..

I hope this helps.

kevalrajpalknight commented 3 years ago

Okay! Thank you so much. So you identified the rectangle and then populate the bounding box by just making them >4

rivered commented 3 years ago

Indeed. I identified the segmentation that is a rectangle, and than altered it to be >4. good luck!

TheWangYang commented 1 year ago

@rivered

Thank you for the solution you provided, why I increased the length of the corresponding segmentation list in my annotation.json file to greater than 4 according to your solution, this error "TypeError: Argument 'bb' has incorrect type (expected numpy.ndarray, got list)" no longer appears, but the following error still occurs: "File "pycocotools/_mask.pyx", line 307, in pycocotools._mask.frPyObjects Exception: input type is not supported.", how can I solve it? Thanks a lot.

TheWangYang commented 1 year ago

@rivered

Thank you for the solution you provided, why I increased the length of the corresponding segmentation list in my annotation.json file to greater than 4 according to your solution, this error "TypeError: Argument 'bb' has incorrect type (expected numpy.ndarray, got list)" no longer appears, but the following error still occurs: "File "pycocotools/_mask.pyx", line 307, in pycocotools._mask.frPyObjects Exception: input type is not supported.", how can I solve it? Thanks a lot.

I have already solved the problem. In my json file, there is still an error label corresponding to the segmentation whose list length is 2. You only need to add additional judgments to the above script, as follows:

for i, instance in enumerate(json_object["annotations"]):
if len(instance["segmentation"][0]) == 4:
print("instance number", i, "raises error:", instance["segmentation"][0])
# add new lines
elif len(instance["segmentation"][0]) == 2:
print("instance number", i, "raises error:", instance["segmentation"][0])

Then, modify the segmentation list under the corresponding i number (increase the length).