windows下安装cocoApi和CrowdPoseApi
2021/6/17 7:27:58
本文主要是介绍windows下安装cocoApi和CrowdPoseApi,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1. 安装COCOAPI
1.首先git clone下载:
使用国内镜像会更快些:
git clone https://github.com.cnpmjs.org/cocodataset/cocoapi.git
2.然后cd cocoapi/PythonAPI/
3.修改setup.py
文件,将extra_compile_args=['-Wno-cpp', '-Wno-unused-function', '-std=c99']
替换为extra_compile_args=[]
如下:
from distutils.core import setup from Cython.Build import cythonize from distutils.extension import Extension import numpy as np # To install and compile to your anaconda/python site-packages, simply run: # $ pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI # Note that the original compile flags below are GCC flags unsupported by the Visual C++ 2015 build tools. # They can safely be removed. ext_modules = [ Extension( 'pycocotools._mask', sources=['../common/maskApi.c', 'pycocotools/_mask.pyx'], include_dirs = [np.get_include(), '../common'], extra_compile_args=[] # originally was ['-Wno-cpp', '-Wno-unused-function', '-std=c99'], ) ] setup(name='pycocotools', packages=['pycocotools'], package_dir = {'pycocotools': 'pycocotools'}, version='2.0', ext_modules= cythonize(ext_modules) )
4.运行文件
python setup.py build_ext --inplace python setup.py build_ext install
5.若出现报错:
TypeError: 'numpy.float64' object cannot be interpreted as an integer
解决方案:
修改文件:cocoapi/PythonAPI/pycocotools/cocoeval.py
,如下:
class Params: ''' Params for coco evaluation api ''' def setDetParams(self): self.imgIds = [] self.catIds = [] # np.arange causes trouble. the data point on arange is slightly larger than the true value # @Author pei @Data:2020.12.18 @Content: TypeError: object of type <class 'numpy.float64'> cannot be safely interpreted as an integer. self.iouThrs = np.linspace(.5, 0.95, int(np.round((0.95 - .5) / .05)) + 1, endpoint=True) #self.iouThrs = np.linspace(.5, 0.95, np.round((0.95 - .5) / .05) + 1, endpoint=True) self.recThrs = np.linspace(.0, 1.00, np.round((1.00 - .0) / .01) + 1, endpoint=True) self.maxDets = [1, 10, 100] self.areaRng = [[0 ** 2, 1e5 ** 2], [0 ** 2, 32 ** 2], [32 ** 2, 96 ** 2], [96 ** 2, 1e5 ** 2]] self.areaRngLbl = ['all', 'small', 'medium', 'large'] self.useCats = 1 def setKpParams(self): self.imgIds = [] self.catIds = [] # @Author pei @Data:2020.12.18 @Content: TypeError: 'numpy.float64' object cannot be interpreted as an integer self.iouThrs = np.linspace(.5, 0.95, int(np.round((0.95 - .5) / .05)) + 1, endpoint=True) self.recThrs = np.linspace(.0, 1.00, np.round((1.00 - .0) / .01) + 1, endpoint=True) self.maxDets = [20] self.areaRng = [[0 ** 2, 1e5 ** 2], [32 ** 2, 96 ** 2], [96 ** 2, 1e5 ** 2]] self.areaRngLbl = ['all', 'medium', 'large'] self.useCats = 1 def __init__(self, iouType='segm'): if iouType == 'segm' or iouType == 'bbox': self.setDetParams() elif iouType == 'keypoints': self.setKpParams() else: raise Exception('iouType not supported') self.iouType = iouType # useSegm is deprecated self.useSegm = None
然后重新安装cocoApi
2. 安装CrowdposeAPI
1.首先git clone下载:
使用国内镜像会更快些:
git clone https://github.com.cnpmjs.org/Jeff-sjtu/CrowdPose.git
2.然后cd CrowdPose/crowdpose-api/PythonAPI/
3.修改setup.py
文件,将extra_compile_args=['-Wno-cpp', '-Wno-unused-function', '-std=c99']
替换为extra_compile_args=['-std=c99']
,如下:
from distutils.core import setup from Cython.Build import cythonize from distutils.extension import Extension import numpy as np # To compile and install locally run "python setup.py build_ext --inplace" # To install library to Python site-packages run "python setup.py build_ext install" ext_modules = [ Extension( 'crowdposetools._mask', sources=['../common/maskApi.c', 'crowdposetools/_mask.pyx'], include_dirs=[np.get_include(), '../common'], # @Pei Hongwei # @2020.11.16 # originally was extra_compile_args=['-Wno-cpp', '-Wno-unused-function', '-std=c99'], extra_compile_args=['-std=c99'] ) ] setup(name='crowdposetools', packages=['crowdposetools'], package_dir={'crowdposetools': 'crowdposetools'}, version='2.0', ext_modules=cythonize(ext_modules) )
4.运行文件
python setup.py build_ext --inplace python setup.py build_ext install
这篇关于windows下安装cocoApi和CrowdPoseApi的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-24怎么切换 Git 项目的远程仓库地址?-icode9专业技术文章分享
- 2024-12-24怎么更改 Git 远程仓库的名称?-icode9专业技术文章分享
- 2024-12-24更改 Git 本地分支关联的远程分支是什么命令?-icode9专业技术文章分享
- 2024-12-24uniapp 连接之后会被立马断开是什么原因?-icode9专业技术文章分享
- 2024-12-24cdn 路径可以指定规则映射吗?-icode9专业技术文章分享
- 2024-12-24CAP:Serverless?+AI?让应用开发更简单
- 2024-12-23新能源车企如何通过CRM工具优化客户关系管理,增强客户忠诚度与品牌影响力
- 2024-12-23原创tauri2.1+vite6.0+rust+arco客户端os平台系统|tauri2+rust桌面os管理
- 2024-12-23DevExpress 怎么实现右键菜单(Context Menu)显示中文?-icode9专业技术文章分享
- 2024-12-22怎么通过控制台去看我的页面渲染的内容在哪个文件中呢-icode9专业技术文章分享