windows下安装cocoApi和CrowdPoseApi

2023-11-01 10: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 --inplacepython 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 = 1def setKpParams(self):self.imgIds = []self.catIds = []# @Author pei @Data:2020.12.18 @Content: TypeError: 'numpy.float64' object cannot be interpreted as an integerself.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 = 1def __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 deprecatedself.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 --inplacepython setup.py build_ext install

这篇关于windows下安装cocoApi和CrowdPoseApi的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/322468

相关文章

Python中Request的安装以及简单的使用方法图文教程

《Python中Request的安装以及简单的使用方法图文教程》python里的request库经常被用于进行网络爬虫,想要学习网络爬虫的同学必须得安装request这个第三方库,:本文主要介绍P... 目录1.Requests 安装cmd 窗口安装为pycharm安装在pycharm设置中为项目安装req

windows下安装Nginx全过程

《windows下安装Nginx全过程》文章介绍了HTTP和反向代理服务器的概念,包括正向代理和反向代理的区别,并详细描述了如何安装和配置Nginx作为反向代理服务器... 目录概念代理正向代理反向代理安装基本属性nginx.conf查询结构属性使用运行重启停止总结概念是一个高性能的HTTP和反向代理we

2025最新版Android Studio安装及组件配置教程(SDK、JDK、Gradle)

《2025最新版AndroidStudio安装及组件配置教程(SDK、JDK、Gradle)》:本文主要介绍2025最新版AndroidStudio安装及组件配置(SDK、JDK、Gradle... 目录原生 android 简介Android Studio必备组件一、Android Studio安装二、A

在C#中调用Windows防火墙界面的常见方式

《在C#中调用Windows防火墙界面的常见方式》在C#中调用Windows防火墙界面(基础设置或高级安全设置),可以使用进程启动(Process.Start)或Win32API来实现,所以本文给大家... 目录引言1. 直接启动防火墙界面(1) 打开基本防火墙设置(firewall.cpl)(2) 打开高

基于Python实现局域网内Windows桌面文件传输

《基于Python实现局域网内Windows桌面文件传输》这篇文章介绍了如何使用Python实现一个局域网文件传输系统,包括发送端和接收端的代码示例,发送端和接收端都需要在同一局域网内运行,并且确保防... 目录发送端代码 (sender.py)接收端代码 (receiver.py)图形界面版本 (可选)使

前端Visual Studio Code安装配置教程之下载、汉化、常用组件及基本操作

《前端VisualStudioCode安装配置教程之下载、汉化、常用组件及基本操作》VisualStudioCode是微软推出的一个强大的代码编辑器,功能强大,操作简单便捷,还有着良好的用户界面,... 目录一、Visual Studio Code下载二、汉化三、常用组件1、Auto Rename Tag2

win10安装及配置Gradle全过程

《win10安装及配置Gradle全过程》本文详细介绍了Gradle的下载、安装、环境变量配置以及如何修改本地仓库位置,通过这些步骤,用户可以成功安装并配置Gradle,以便进行项目构建... 目录一、Gradle下载1.1、Gradle下载地址1.2、Gradle下载步骤二、Gradle安装步骤2.1、安

Linux挂载linux/Windows共享目录实现方式

《Linux挂载linux/Windows共享目录实现方式》:本文主要介绍Linux挂载linux/Windows共享目录实现方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地... 目录文件共享协议linux环境作为服务端(NFS)在服务器端安装 NFS创建要共享的目录修改 NFS 配

基于Python开发Windows自动更新控制工具

《基于Python开发Windows自动更新控制工具》在当今数字化时代,操作系统更新已成为计算机维护的重要组成部分,本文介绍一款基于Python和PyQt5的Windows自动更新控制工具,有需要的可... 目录设计原理与技术实现系统架构概述数学建模工具界面完整代码实现技术深度分析多层级控制理论服务层控制注

python依赖管理工具UV的安装和使用教程

《python依赖管理工具UV的安装和使用教程》UV是一个用Rust编写的Python包安装和依赖管理工具,比传统工具(如pip)有着更快、更高效的体验,:本文主要介绍python依赖管理工具UV... 目录前言一、命令安装uv二、手动编译安装2.1在archlinux安装uv的依赖工具2.2从github