3

即使我正确安装了 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])

4

0 回答 0