如何解决“ AttributeError:模块'pycocotools'没有属性'mask'”在Python中的错误

时间:2019-08-17 15:10:53

标签: python-3.x machine-learning dataset pycocotools

即使我正确安装了pycocotools,我仍然遇到一些问题。另外,请在已经安装了pycocotools的colab上进行尝试。

安装方法:

!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'

抛出此错误的行: pycocotools.mask.frPyObjects(segmentation, mask.shape[0], mask.shape[1])

0 个答案:

没有答案