Cython——Windows环境下配置faster-rcnn、yolo、ctpn等目标检测框架中Cython文件[cython_nms、bbox、gpu_nms]编译问题解决方案
問題描述
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中可能大小并不相同(issues:https://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 install2.針對【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 npsetup(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‘]解決方案
?
總結
以上是生活随笔為你收集整理的Cython——Windows环境下配置faster-rcnn、yolo、ctpn等目标检测框架中Cython文件[cython_nms、bbox、gpu_nms]编译问题解决方案的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Cython——[AttributeEr
- 下一篇: Tesseract OCR——Windo