解决Win系统下安装pycococreatortools工具包(亲测!不踩坑)

一、首先创建虚拟环境
二、安装
采用pip 安装:  
pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
三、下载源码
然后采用下面的网址:https://github.com/philferriere/cocoapi下载源码进行解压。
然后切换到cocoapi\PythonAPI目录下运行以下指令:
# install pycocotools locally
python setup.py build_ext --inplace
# install pycocotools to the Python site-packages
python setup.py build_ext install

以上便实现pycocotools的安装。
接下来进行pycococreator的安装:
直接运行:pip install git+https://github.com/waspinator/pycococreator.git
最终实现pycococreator的安装。
安装完成后,大概率会出现下面的问题:
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.
解决方案如下:
cd到虚拟环境中的pycococreatortools文件夹下,找到pycococreatortools.py代码

一般是在46行:改成下面这三行代码。
contours = measure.find_contours(padded_binary_mask, 0.5)
contours=sorted(contours,key=lambda x: len(x),reverse=True)[0:1]#可能返回多个mask
contours = np.subtract(contours, 1)

最终实现json格式的转换!!

  • 6
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值