Hello, I keep getting ValueError. My setup is following: Ubuntu 16.04, python 3.6, tensorflow 1.5. Please help me with this error. Thanks!
Running COCO evaluation on 500 images.
Traceback (most recent call last):
File "coco.py", line 524, in <module>
evaluate_coco(model, dataset_val, coco, "bbox", limit=int(args.limit))
File "coco.py", line 372, in evaluate_coco
r["scores"], r["masks"])
File "coco.py", line 334, in build_coco_results
"segmentation": maskUtils.encode(np.asfortranarray(mask))
File "/home/kiho/anaconda3/lib/python3.6/site-packages/pycocotools/mask.py", line 85, in encode
return _mask.encode(bimask.reshape((h, w, 1), order='F'))[0]
File "pycocotools/_mask.pyx", line 137, in pycocotools._mask.encode
ValueError: Does not understand character buffer dtype format string ('?')
Same error, Windows 10.
Happens when running this command:
python3 coco.py evaluate --dataset=/path/to/coco/ --model=last
I believe this is fixed already in this commit: https://github.com/matterport/Mask_RCNN/commit/40bca1eb260fe3d81a0930e60a6055f8aa2a9887
I also same error:
Epoch: [0] [ 0/60] eta: 0:00:49 lr: 0.000090 loss: 4.0678 (4.0678) loss_classifier: 0.7700 (0.7700) loss_box_reg: 0.2747 (0.2747) loss_mask: 2.9924 (2.9924) loss_objectness: 0.0151 (0.0151) loss_rpn_box_reg: 0.0156 (0.0156) time: 0.8251 data: 0.1585 max mem: 2531
Epoch: [0] [10/60] eta: 0:00:18 lr: 0.000936 loss: 1.4376 (2.3119) loss_classifier: 0.5386 (0.5114) loss_box_reg: 0.1624 (0.1837) loss_mask: 0.8224 (1.5892) loss_objectness: 0.0151 (0.0172) loss_rpn_box_reg: 0.0116 (0.0103) time: 0.3652 data: 0.0198 max mem: 2897
Epoch: [0] [20/60] eta: 0:00:13 lr: 0.001783 loss: 0.8359 (1.5028) loss_classifier: 0.2377 (0.3581) loss_box_reg: 0.1604 (0.1637) loss_mask: 0.3927 (0.9560) loss_objectness: 0.0099 (0.0128) loss_rpn_box_reg: 0.0116 (0.0123) time: 0.3155 data: 0.0054 max mem: 2903
Epoch: [0] [30/60] eta: 0:00:10 lr: 0.002629 loss: 0.5557 (1.1743) loss_classifier: 0.1234 (0.2724) loss_box_reg: 0.1479 (0.1598) loss_mask: 0.2388 (0.7192) loss_objectness: 0.0055 (0.0105) loss_rpn_box_reg: 0.0119 (0.0124) time: 0.3325 data: 0.0049 max mem: 3856
Epoch: [0] [40/60] eta: 0:00:06 lr: 0.003476 loss: 0.4407 (0.9824) loss_classifier: 0.0696 (0.2220) loss_box_reg: 0.1111 (0.1480) loss_mask: 0.2049 (0.5910) loss_objectness: 0.0025 (0.0088) loss_rpn_box_reg: 0.0099 (0.0126) time: 0.3335 data: 0.0050 max mem: 3856
Epoch: [0] [50/60] eta: 0:00:03 lr: 0.004323 loss: 0.3357 (0.8501) loss_classifier: 0.0438 (0.1866) loss_box_reg: 0.0681 (0.1316) loss_mask: 0.1946 (0.5120) loss_objectness: 0.0012 (0.0077) loss_rpn_box_reg: 0.0093 (0.0122) time: 0.3193 data: 0.0048 max mem: 3856
Epoch: [0] [59/60] eta: 0:00:00 lr: 0.005000 loss: 0.2688 (0.7637) loss_classifier: 0.0401 (0.1646) loss_box_reg: 0.0575 (0.1191) loss_mask: 0.1680 (0.4604) loss_objectness: 0.0015 (0.0069) loss_rpn_box_reg: 0.0093 (0.0126) time: 0.3131 data: 0.0049 max mem: 3856
Epoch: [0] Total time: 0:00:19 (0.3309 s / it)
creating index...
index created!
ValueError Traceback (most recent call last)
1 if __name__== "__main__":
----> 2 main()
53 lr_scheduler.step()
54 # evaluate on the test dataset
---> 55 evaluate(model, data_loader_test, device=device)
56
57 print("That's it!")
/usr/local/lib/python3.7/dist-packages/torch/autograd/grad_mode.py in decorate_no_grad(args, *kwargs)
47 def decorate_no_grad(args, *kwargs):
48 with self:
---> 49 return func(args, *kwargs)
50 return decorate_no_grad
51
~/deepZ/odFineTuning/engine.py in evaluate(model, data_loader, device)
93 res = {target["image_id"].item(): output for target, output in zip(targets, outputs)}
94 evaluator_time = time.time()
---> 95 coco_evaluator.update(res)
96 evaluator_time = time.time() - evaluator_time
97 metric_logger.update(model_time=model_time, evaluator_time=evaluator_time)
~/deepZ/odFineTuning/coco_eval.py in update(self, predictions)
36
37 for iou_type in self.iou_types:
---> 38 results = self.prepare(predictions, iou_type)
39 coco_dt = loadRes(self.coco_gt, results) if results else COCO()
40 coco_eval = self.coco_eval[iou_type]
~/deepZ/odFineTuning/coco_eval.py in prepare(self, predictions, iou_type)
64 return self.prepare_for_coco_detection(predictions)
65 elif iou_type == "segm":
---> 66 return self.prepare_for_coco_segmentation(predictions)
67 elif iou_type == "keypoints":
68 return self.prepare_for_coco_keypoint(predictions)
~/deepZ/odFineTuning/coco_eval.py in prepare_for_coco_segmentation(self, predictions)
111 rles = [
112 mask_util.encode(np.array(mask[0, :, :, np.newaxis], order="F"))[0]
--> 113 for mask in masks
114 ]
115 for rle in rles:
~/deepZ/odFineTuning/coco_eval.py in
111 rles = [
112 mask_util.encode(np.array(mask[0, :, :, np.newaxis], order="F"))[0]
--> 113 for mask in masks
114 ]
115 for rle in rles:
/usr/local/lib/python3.7/dist-packages/pycocotools-2.0-py3.7-linux-x86_64.egg/pycocotools/mask.py in encode(bimask)
80 def encode(bimask):
81 if len(bimask.shape) == 3:
---> 82 return _mask.encode(bimask)
83 elif len(bimask.shape) == 2:
84 h, w = bimask.shape
pycocotools/_mask.pyx in pycocotools._mask.encode()
ValueError: Does not understand character buffer dtype format string ('?')
@waleedka , But there is no "r[ "masks"] ..." in my coco.py.
Whats wrong to me?
@bemoregt this solution worked for me.
In coco_eval.py:
rles = [
mask_util.encode(np.array(mask[0, :, :, np.newaxis], dtype=np.uint8, order="F"))[0]
for mask in masks
]
@bemoregt Good job!
Most helpful comment
@bemoregt this solution worked for me.
In coco_eval.py:
rles = [
mask_util.encode(np.array(mask[0, :, :, np.newaxis], dtype=np.uint8, order="F"))[0]
for mask in masks
]