Vision: MaskRCNN: ValueError: Does not understand character buffer dtype format string ('?')

Created on 20 Sep 2019  路  4Comments  路  Source: pytorch/vision

I was trying to train MaskRCNN on my own dataset but I get this error every time during evaluation. Even if I try to train the model on PennFudanDataset from this link, the same error occurs. Though the code works on provided Colab

My docker container has Python 3.5, Pytorch 1.2.0, Torchvision 0.4.0

@fmassa
Can you help me figure out what could be the issue?

Traceback (most recent call last):
File "train.py", line 76, in
main()
File "train.py", line 69, in main
evaluate(model, val_data_loader, device=device)
File "/root/miniconda3/envs/pytorch/lib/python3.5/site-packages/torch/autograd/grad_mode.py", line 49, in decorate_no_grad
return func(args, *kwargs)
File "../../lib/engine.py", line 95, in evaluate
coco_evaluator.update(res)
File "../../lib/coco_eval.py", line 38, in update
results = self.prepare(predictions, iou_type)
File "../../lib/coco_eval.py", line 66, in prepare
return self.prepare_for_coco_segmentation(predictions)
File "../../lib/coco_eval.py", line 113, in prepare_for_coco_segmentation
for mask in masks
File "../../lib/coco_eval.py", line 113, in
for mask in masks
File "/root/miniconda3/envs/pytorch/lib/python3.5/site-packages/pycocotools/mask.py", line 82, in encode
return _mask.encode(bimask)
File "pycocotools/_mask.pyx", line 137, in pycocotools._mask.encode
ValueError: Does not understand character buffer dtype format string ('?')

reference scripts question object detection

Most helpful comment

in coco_eval
Use this

rles = [
mask_util.encode(np.array(mask[0, :, :, np.newaxis], dtype=np.uint8, order="F"))[0]
for mask in masks
]

instead of

        rles = [
            mask_util.encode(np.array(mask[0, :, :, np.newaxis], order="F"))[0]
            for mask in masks
        ]

All 4 comments

This is an error in pycocotools.

I suspect it's a problem with you environment locale.

Try checking the locale in colab and in your system, it might be relevant.

Given that this is not a problem with torchvision, I'm closing this issue, but let me know if you think otherwise

Did you resolve the problem, i also met this error.

in coco_eval
Use this

rles = [
mask_util.encode(np.array(mask[0, :, :, np.newaxis], dtype=np.uint8, order="F"))[0]
for mask in masks
]

instead of

        rles = [
            mask_util.encode(np.array(mask[0, :, :, np.newaxis], order="F"))[0]
            for mask in masks
        ]

@nicolasCruzW21 this fix is BTW present in torchvision since https://github.com/pytorch/vision/pull/1413 , and is available in a nightly release

Was this page helpful?
0 / 5 - 0 ratings

Related issues

300LiterPropofol picture 300LiterPropofol  路  3Comments

iacolippo picture iacolippo  路  4Comments

carlocab picture carlocab  路  3Comments

yxlabs picture yxlabs  路  4Comments

martinarjovsky picture martinarjovsky  路  4Comments