ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

windows下安装cocoApi和CrowdPoseApi

2021-06-16 21:04:10  阅读:577  来源: 互联网

标签:cocoApi CrowdPoseApi windows self py compile ext np setup


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

标签:cocoApi,CrowdPoseApi,windows,self,py,compile,ext,np,setup
来源: https://blog.csdn.net/sazass/article/details/117966478

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有