Closed tiltgod closed 4 years ago
Hi, did you solved this problem?
Hi, did you solved this problem?
nope ;w;
I print segms without indexing and get these. It's not bytes @hellock @ZwwWayne
[array([[False, False, False, ..., False, False, False], [False, False, False, ..., False, False, False], [False, False, False, ..., False, False, False], ..., [False, False, False, ..., False, False, False], [False, False, False, ..., False, False, False], [False, False, False, ..., False, False, False]])]
Trained the Mask RCNN model on COCO style dataset and got the same segmentation values, so I can't inference with them, only output bboxes. Will try to look for any workarounds, but @hellock should look into this hopefully.
I solved this @mangdian @virusapex try this
for i in range(bboxes.shape[0]):
data = dict()
data['image_id'] = img_id
data['bbox'] = self.xyxy2xywh(bboxes[i])
data['score'] = float(mask_score[i])
data['category_id'] = self.cat_ids[label]
# if isinstance(segms[i]['counts'], bytes):
# segms[i]['counts'] = segms[i]['counts'].decode()
# data['segmentation'] = segms[i]
segm_json_results.append(data)
return bbox_json_results, segm_json_results
in mmdet/datasets/coco.py def _segm2json
I solved this @mangdian @virusapex try this
for i in range(bboxes.shape[0]): data = dict() data['image_id'] = img_id data['bbox'] = self.xyxy2xywh(bboxes[i]) data['score'] = float(mask_score[i]) data['category_id'] = self.cat_ids[label] # if isinstance(segms[i]['counts'], bytes): # segms[i]['counts'] = segms[i]['counts'].decode() # data['segmentation'] = segms[i] segm_json_results.append(data) return bbox_json_results, segm_json_results
in mmdet/datasets/coco.py def _segm2json
It probably worked for you, since it's for converting segmentation values to json, but I'm still looking for solution while trying to get inference from the model. The point of failure for me is this:
~/mmdetection/mmdet/models/detectors/base.py in show_result(self, img, result, score_thr, bbox_color, text_color, thickness, font_scale, win_name, show, wait_time, out_file)
210 i = int(i)
211 color_mask = color_masks[labels[i]]
--> 212 mask = maskUtils.decode(segms[i]).astype(np.bool)
213 img[mask] = img[mask] * 0.5 + color_mask * 0.5
214 # if out_file specified, do not show image in window
/usr/local/lib/python3.6/dist-packages/pycocotools/mask.py in decode(rleObjs)
89 return _mask.decode(rleObjs)
90 else:
---> 91 return _mask.decode([rleObjs])[:,:,0]
92
93 def area(rleObjs):
pycocotools/_mask.pyx in pycocotools._mask.decode()
pycocotools/_mask.pyx in pycocotools._mask._frString()
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
I solved this @mangdian @virusapex try this
for i in range(bboxes.shape[0]): data = dict() data['image_id'] = img_id data['bbox'] = self.xyxy2xywh(bboxes[i]) data['score'] = float(mask_score[i]) data['category_id'] = self.cat_ids[label] # if isinstance(segms[i]['counts'], bytes): # segms[i]['counts'] = segms[i]['counts'].decode() # data['segmentation'] = segms[i] segm_json_results.append(data) return bbox_json_results, segm_json_results
in mmdet/datasets/coco.py def _segm2json
It probably worked for you, since it's for converting segmentation values to json, but I'm still looking for solution while trying to get inference from the model. The point of failure for me is this:
~/mmdetection/mmdet/models/detectors/base.py in show_result(self, img, result, score_thr, bbox_color, text_color, thickness, font_scale, win_name, show, wait_time, out_file) 210 i = int(i) 211 color_mask = color_masks[labels[i]] --> 212 mask = maskUtils.decode(segms[i]).astype(np.bool) 213 img[mask] = img[mask] * 0.5 + color_mask * 0.5 214 # if out_file specified, do not show image in window /usr/local/lib/python3.6/dist-packages/pycocotools/mask.py in decode(rleObjs) 89 return _mask.decode(rleObjs) 90 else: ---> 91 return _mask.decode([rleObjs])[:,:,0] 92 93 def area(rleObjs): pycocotools/_mask.pyx in pycocotools._mask.decode() pycocotools/_mask.pyx in pycocotools._mask._frString() IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
sorry then #2734 should help
I solved this @mangdian @virusapex try this
for i in range(bboxes.shape[0]): data = dict() data['image_id'] = img_id data['bbox'] = self.xyxy2xywh(bboxes[i]) data['score'] = float(mask_score[i]) data['category_id'] = self.cat_ids[label] # if isinstance(segms[i]['counts'], bytes): # segms[i]['counts'] = segms[i]['counts'].decode() # data['segmentation'] = segms[i] segm_json_results.append(data) return bbox_json_results, segm_json_results
in mmdet/datasets/coco.py def _segm2json
It probably worked for you, since it's for converting segmentation values to json, but I'm still looking for solution while trying to get inference from the model. The point of failure for me is this:
~/mmdetection/mmdet/models/detectors/base.py in show_result(self, img, result, score_thr, bbox_color, text_color, thickness, font_scale, win_name, show, wait_time, out_file) 210 i = int(i) 211 color_mask = color_masks[labels[i]] --> 212 mask = maskUtils.decode(segms[i]).astype(np.bool) 213 img[mask] = img[mask] * 0.5 + color_mask * 0.5 214 # if out_file specified, do not show image in window /usr/local/lib/python3.6/dist-packages/pycocotools/mask.py in decode(rleObjs) 89 return _mask.decode(rleObjs) 90 else: ---> 91 return _mask.decode([rleObjs])[:,:,0] 92 93 def area(rleObjs): pycocotools/_mask.pyx in pycocotools._mask.decode() pycocotools/_mask.pyx in pycocotools._mask._frString() IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
sorry then #2734 should help
No, there is nothing to be sorry about. I just mentioned it, since it seems to be a similar problem in a way. Thank you for linking it to me.
Checklist
Describe the bug I want to test robustness with my model and my custom dataset in the COCO format. It's working in the previous version of mmdetection and normal testing on /tools/test.py but In mmdetection 2.0 It appears 'IndexError: only integers, slices (
:
), ellipsis (...
), numpy.newaxis (None
) and integer or boolean arrays are valid indices' after loading annotations and creating index process.Reproduction
What command or script did you run? I run
!python3 /content/mmdetection/tools/test_robustness.py /content/gdrive/'My Drive'/panet.py /content/gdrive/'My Drive'/panet101/fold1/epoch_200.pth --eval segm bbox --out /content/gdrive/'My Drive'/panet101/panet_robust.pkl --corruptions snow --severities 1
in Google ColabDid you make any modifications on the code or config? Did you understand what you have modified? my config
modification in /mmdet/coco.py
sys.platform: linux Python: 3.6.9 (default, Apr 18 2020, 01:56:04) [GCC 8.4.0] CUDA available: True CUDA_HOME: /usr/local/cuda NVCC: Cuda compilation tools, release 10.1, V10.1.243 GPU 0: Tesla P100-PCIE-16GB GCC: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 PyTorch: 1.5.0+cu101 PyTorch compiling details: PyTorch built with:
Error traceback If applicable, paste the error trackback here.