Cython——Windows环境下配置faster-rcnn、yolo、ctpn等目标检测框架中Cython文件[cython_nms、bbox、gpu_nms]编译问题解决方案

问题描述

  1. AttributeError: ‘MSVCCompiler’ object has no attribute ‘compiler_so’
  2. ValueError: Buffer dtype mismatch, expected ‘int_t’ but got 'long long
  3. ImportError: cannot import name ‘bbox’
  4. mv: 无法获取’utils/*’ 的文件状态(stat): No such file or directory
  5. Cython fatal error C1083: 无法打开包括文件: “numpy/arrayobject.h”: No such file or directory

问题分析

这些文件在 Fast-RCNN 项目(https://github.com/rbgirshick/fast-rcnn/tree/master/lib/utils)已经被使用,而yolo、ctpn等目标检测框架继承或者使用了 Fast-RCNN 项目,导致出现都出现编译问题。

faster-rcnn、yolo、ctpn等目标检测框架均在Linux环境下开发,似乎没有考虑Windows的兼容性问题。

1.这个问题在win7上无解,无论怎么安装vs2015还是.net什么都没用,Windows10上是可以的,亲测有效;

2.np.int_t在Windows和Linux中可能大小并不相同(issueshttps://github.com/eragonruan/text-detection-ctpn/issues/380)(针对第二个问题)

3.这个是纯编译问题,Windows7上貌似没办法编译。

4.编译完成会生成一个.so文件(Linux下的.so文件是基于Linux下的动态链接库),但是这个文件没法复制,在Windows上也无法使用,这也是为什么需要手动编译的原因。(针对第三个问题)

5.mv是Linux系统移动文件的指令(可参阅:https://www.runoob.com/linux/linux-comm-mv.html),所以这个问题Linux不会发生。(这个问题出现在make.sh文件中)(针对第四个问题)

6..compiler_so字段仅存在于distutils.unixcompiler.UnixCCompiler和派生中。因此,此程序包不支持标准的Windows构建环境。根据Windows上的“从源构建” | TensorFlow,应该使用MSYS2构建。(针对第一个问题)

Cython——[AttributeError: ‘MSVCCompiler‘ object has no attribute ‘compiler_so‘]解决方案

7.在Cython编译成c时,如果使用python库,需要包含相应的python库(针对第五个问题)

解决方案

一般方案

1. 针对make.sh文件的问题

可以修改成make.bat文件以支持Windows10

cython bbox.pyx
cython cython_nms.pyx
cython gpu_nms.pyx
python setup.py  install
copy utils/* ./
del /s build
del /s utils
python setup.py build
python setup.py install

2.针对【AttributeError: ‘MSVCCompiler’ object has no attribute ‘compiler_so’】问题

Cython——[AttributeError: ‘MSVCCompiler‘ object has no attribute ‘compiler_so‘]解决方案

3.针对.so或者.pyd文件模型里import的代码名称不同问题

事实上,这并不需要重命名,只要将文件移动到对应位置(即/lib/utils/)即可。

4.针对【Cython fatal error C1083: 无法打开包括文件: “numpy/arrayobject.h”: No such file or directory】问题

添加 include_dirs=[np.get_include()]

from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import numpy as np
 
setup(
    cmdclass={'build_ext': build_ext},
    ext_modules=[Extension('calculate', ['cythonfnS.pyx'])],
    include_dirs=[np.get_include()])

5.针对【ValueError: Buffer dtype mismatch, expected 'int_t' but got 'long long'】问题 

issues​​​​​​​https://github.com/eragonruan/text-detection-ctpn/issues/380

将第25行或者第27行cython_nms.pyx中的np.int_t Replace >> np.int64_t 

NOTICE: After makeing this change. You need to compile setup.py again

懒人方案 

已经编译完成的文件(搬运)(缺少bbox.pyd)

https://github.com/liuxufenfeiya/win-cython_nms-bbox-

参考文章

win配置faster-rcnn、yolo、ctpn等目标检测的几个大坑

Cython——[AttributeError: ‘MSVCCompiler‘ object has no attribute ‘compiler_so‘]解决方案

 

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Starzkg

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值