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

相关文章

SQL server数据库如何下载和安装

《SQLserver数据库如何下载和安装》本文指导如何下载安装SQLServer2022评估版及SSMS工具,涵盖安装配置、连接字符串设置、C#连接数据库方法和安全注意事项,如混合验证、参数化查... 目录第一步:打开官网下载对应文件第二步:程序安装配置第三部:安装工具SQL Server Manageme

Python中win32包的安装及常见用途介绍

《Python中win32包的安装及常见用途介绍》在Windows环境下,PythonWin32模块通常随Python安装包一起安装,:本文主要介绍Python中win32包的安装及常见用途的相关... 目录前言主要组件安装方法常见用途1. 操作Windows注册表2. 操作Windows服务3. 窗口操作

基于Python开发Windows屏幕控制工具

《基于Python开发Windows屏幕控制工具》在数字化办公时代,屏幕管理已成为提升工作效率和保护眼睛健康的重要环节,本文将分享一个基于Python和PySide6开发的Windows屏幕控制工具,... 目录概述功能亮点界面展示实现步骤详解1. 环境准备2. 亮度控制模块3. 息屏功能实现4. 息屏时间

gitlab安装及邮箱配置和常用使用方式

《gitlab安装及邮箱配置和常用使用方式》:本文主要介绍gitlab安装及邮箱配置和常用使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1.安装GitLab2.配置GitLab邮件服务3.GitLab的账号注册邮箱验证及其分组4.gitlab分支和标签的

MySQL MCP 服务器安装配置最佳实践

《MySQLMCP服务器安装配置最佳实践》本文介绍MySQLMCP服务器的安装配置方法,本文结合实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下... 目录mysql MCP 服务器安装配置指南简介功能特点安装方法数据库配置使用MCP Inspector进行调试开发指

在Windows上使用qemu安装ubuntu24.04服务器的详细指南

《在Windows上使用qemu安装ubuntu24.04服务器的详细指南》本文介绍了在Windows上使用QEMU安装Ubuntu24.04的全流程:安装QEMU、准备ISO镜像、创建虚拟磁盘、配置... 目录1. 安装QEMU环境2. 准备Ubuntu 24.04镜像3. 启动QEMU安装Ubuntu4

Windows下C++使用SQLitede的操作过程

《Windows下C++使用SQLitede的操作过程》本文介绍了Windows下C++使用SQLite的安装配置、CppSQLite库封装优势、核心功能(如数据库连接、事务管理)、跨平台支持及性能优... 目录Windows下C++使用SQLite1、安装2、代码示例CppSQLite:C++轻松操作SQ

Python UV安装、升级、卸载详细步骤记录

《PythonUV安装、升级、卸载详细步骤记录》:本文主要介绍PythonUV安装、升级、卸载的详细步骤,uv是Astral推出的下一代Python包与项目管理器,主打单一可执行文件、极致性能... 目录安装检查升级设置自动补全卸载UV 命令总结 官方文档详见:https://docs.astral.sh/

基于Python实现一个Windows Tree命令工具

《基于Python实现一个WindowsTree命令工具》今天想要在Windows平台的CMD命令终端窗口中使用像Linux下的tree命令,打印一下目录结构层级树,然而还真有tree命令,但是发现... 目录引言实现代码使用说明可用选项示例用法功能特点添加到环境变量方法一:创建批处理文件并添加到PATH1

Nexus安装和启动的实现教程

《Nexus安装和启动的实现教程》:本文主要介绍Nexus安装和启动的实现教程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、Nexus下载二、Nexus安装和启动三、关闭Nexus总结一、Nexus下载官方下载链接:DownloadWindows系统根