3

I am facing some issues even though I installed pycocotools correctly. Also, tried on colab where they have pycocotools already installed..

Installation method:

!git clone https://github.com/cocodataset/cocoapi.git
%cd /content/cocoapi/PythonAPI
!make
!sudo make install
!sudo python setup.py install
%cd /content
AttributeError                            Traceback (most recent call last)

<ipython-input-11-6a1416ecd890> in <module>()
----> 1 new_mask = get_mask(label['segmentations'], mask)

/content/datasets/coco.py in get_mask(segmentations, mask)
     17 def get_mask(segmentations, mask):
     18     for segmentation in segmentations:
---> 19         rle = pycocotools.mask.frPyObjects(segmentation, mask.shape[0], mask.shape[1])
     20         mask[pycocotools.mask.decode(rle) > 0.5] = 0
     21     return mask

AttributeError: module 'pycocotools' has no attribute 'mask'

Line which throws this error: pycocotools.mask.frPyObjects(segmentation, mask.shape[0], mask.shape[1])

Kadam Parikh
  • 422
  • 4
  • 17

1 Answers1

1

If you just imported pycocotools, mask module is not imported.

Try to import mask explicitly:

import pycocotools.mask
user3537995
  • 11
  • 1
  • 2