首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何修复python中的"AttributeError:模块‘pycocotools“没有属性”掩码“错误

如何修复python中的"AttributeError:模块‘pycocotools“没有属性”掩码“错误
EN

Stack Overflow用户
提问于 2019-08-17 15:10:53
回答 1查看 1.4K关注 0票数 3

尽管我正确地安装了化茧工具,但我仍然面临一些问题。此外,在colab上试用,那里已经安装了化茧工具。

安装方法:

代码语言:javascript
复制
!git clone https://github.com/cocodataset/cocoapi.git
%cd /content/cocoapi/PythonAPI
!make
!sudo make install
!sudo python setup.py install
%cd /content
代码语言:javascript
复制
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])

EN

回答 1

Stack Overflow用户

发布于 2022-05-25 14:55:27

如果您只是导入化茧工具,则不会导入掩码模块。

尝试显式导入掩码:

代码语言:javascript
复制
import pycocotools.mask
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57537480

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档