open-mmlab / mmdetection

OpenMMLab Detection Toolbox and Benchmark
https://mmdetection.readthedocs.io
Apache License 2.0
29.59k stars 9.46k forks source link

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

Open JNaranjo-Alcazar opened 8 months ago

JNaranjo-Alcazar commented 8 months ago

Dear community, I have two jsons (one for training and one for validation). Here is the format of an annotation (all annotations are in this format)

        {
            "id": 836,
            "image_id": 120,
            "category_id": 1,
            "segmentation": [
                [
                    783,
                    1997,
                    780,
                    2000,
                    779,
                    2000,
                    776,
                    2003,
                    776,
                    2004,
                    772,
                    2008,
                    772,
                    2009,
                    769,
                    2012,
                    769,
                    2013,
                    767,
                    2015,
                    767,
                    2016,
                    766,
                    2017,
                    766,
                    2018,
                    765
                ]
            ],
            "area": 3285.0,
            "bbox": [
                760.0,
                1997.0,
                55.0,
                83.0
            ],
            "iscrowd": 0,
            "extra": {}
        }

The training process performs correctly. However, when it comes to validate the following error appears: TypeError: Argument 'bb' has incorrect type (expected numpy.ndarray, got list)

I get the following warning before evaluation process:

mmdet - INFO - Evaluating segm...
/opt/conda/lib/python3.7/site-packages/mmdet/datasets/coco.py:474: UserWarning: The key "bbox" is deleted for more accurate mask AP of small/medium/large instances since v2.12.0. This does not change the overall mAP calculation.

I don't understand why the script is waiting for a numpy array. I've trained MaskRCNN several times and I don't understand why this time it expects a numpy array... Any suggestions why this is happening?

MORE INFO

I have obtained the points of the polygon by a conversion from RLE to Poly with the following function:

rle = mask_utils.frPyObjects(annotation['segmentation'], annotation['segmentation']['size'][0],
                                     annotation['segmentation']['size'][1])
mask = mask_utils.decode(rle)
mask = (mask > 0).astype(bool)
contours, _ = cv2.findContours(mask.astype(np.uint8), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
segmentation = [contour.ravel().tolist() for contour in contours]

Could this process be the problem? Can MaskRCNN be trained directly with the RLE format?

JNaranjo-Alcazar commented 8 months ago

I found that I had segmentation lists that were composed of lists as it seems that the conversion to polygon was not correct. Is there a way to train directly with RLE?