AstarLight / Lets_OCR

A repository for OCR, which inlcudes some classical OCR algorithms Pytorch implementation such as CTPN, EAST and CRNN.
MIT License
656 stars 327 forks source link

ModuleNotFoundError: No module named 'lib.nms' #18

Closed nicegdhj closed 5 years ago

nicegdhj commented 5 years ago

你好, 我想直接使用Inference,下载好pretrain model和数据以后 执行test.sh 但是报错ModuleNotFoundError: No module named 'lib.nms',然后我看了下lib目录下确实也没有nms这个文件,请问下怎么办的?

是因为我cd ctpn 后没有make吗? 我尝试了一下make但是报错信息如下: cython ../common/nms.pyx gcc -shared -pthread -fPIC -fwrapv -O2 -Wall -fno-strict-aliasing -I/usr/include/python2.7 -o ./lib/nms.so ../common/nms.c ../common/nms.c:4:20: fatal error: Python.h: No such file or directory compilation terminated. Makefile:3: recipe for target 'all' failed make: *** [all] Error 1

请问下是什么问题呢?我用的是anaconda python 3.6

leonzhu211 commented 5 years ago

把 Makefile 改一下 改成 -I/usr/include/python3.6 先查一下有没有这个目录 /usr/include/python3.6 如果没有,要走 apt-get 安装 python3 develop

nicegdhj commented 5 years ago

把 Makefile 改一下 改成 -I/usr/include/python3.6 先查一下有没有这个目录 /usr/include/python3.6 如果没有,要走 apt-get 安装 python3 develop

你好,我还是编译不成功,我对c和 cython或者make不熟,您可以直接把lib.nms 这个文件发给我看看吗,因为只是想用一下inference,它只是import而已,我不需要再去处理数据或者训练。 或者是说必须经过make步骤之后才能运行 438499123@qq.com 这是我的邮箱,万分感谢~

leonzhu211 commented 5 years ago

这个依赖你的机器,估计必须 make 才行。 编译后是在 lib 下生成了一个 nms.so

AstarLight commented 5 years ago

I provide a docker image to help you run this project quickly. Please refer README file.

fanruifeng commented 5 years ago

我make编译后在 lib 下生成了一个 nms.so, 但还是报以下错误 Traceback (most recent call last): File "/home/data/Lets_OCR-master/detector/ctpn/infer.py", line 357, in random_test(net) File "/home/data/Lets_OCR-master/detector/ctpn/infer.py", line 300, in random_test nms_result = lib.nms.cpu_nms(for_nms, NMS_THRESH) AttributeError: module 'lib' has no attribute 'nms'

lijiale0073 commented 5 years ago

你好 请问你这个问题如何解决的呢??

nicegdhj commented 5 years ago

这个问题 ,我最后没有解决,不过作者好像也进行了更新,请看他的readme

xiaoqg commented 5 years ago

把 Makefile 改一下 改成 -I/usr/include/python3.6 先查一下有没有这个目录 /usr/include/python3.6 如果没有,要走 apt-get 安装 python3 develop

你好,我还是编译不成功,我对c和 cython或者make不熟,您可以直接把lib.nms 这个文件发给我看看吗,因为只是想用一下inference,它只是import而已,我不需要再去处理数据或者训练。 或者是说必须经过make步骤之后才能运行 438499123@qq.com 这是我的邮箱,万分感谢~

您好,我跟您的是一样的情况,我是windows系统,自己下载了MinGW,然后make了一下,但是不知道怎么修改makefile, 也是报错没有python.h文件,请问您的问题解决了嘛?

Crescentz commented 5 years ago

cython ../common/nms.pyx gcc -shared -pthread -fPIC -fwrapv -O2 -Wall -fno-strict-aliasing -I/usr/include/python3.6 -o ./lib/nms.so ../common/nms.c In file included from /usr/include/numpy/ndarraytypes.h:1809:0, from /usr/include/numpy/ndarrayobject.h:18, from /usr/include/numpy/arrayobject.h:4, from ../common/nms.c:485: /usr/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]

warning "Using deprecated NumPy API, disable it by " \

^ rm -rf ../common/nms.c

同样的问题,生了个nms.so然后就没有然后了

maggie-c1523 commented 4 years ago

cython ../common/nms.pyx gcc -shared -pthread -fPIC -fwrapv -O2 -Wall -fno-strict-aliasing -I/usr/include/python3.6 -o ./lib/nms.so ../common/nms.c In file included from /usr/include/numpy/ndarraytypes.h:1809:0, from /usr/include/numpy/ndarrayobject.h:18, from /usr/include/numpy/arrayobject.h:4, from ../common/nms.c:485: /usr/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]

warning "Using deprecated NumPy API, disable it by "

^ rm -rf ../common/nms.c

同样的问题,生了个nms.so然后就没有然后了

我也和你遇到了差不多的情况不过我把makefile的代码只留了 gcc -shared -pthread -fPIC -fwrapv -O2 -Wall -fno-strict-aliasing -I/usr/include/python2.7 -o ./lib/nms.so ../common/nms.c 这一句然后在nms.c头一行加入

define NPY_NO_DEPRECATED_API NPY_API_VERSION

就解决这个问题 但是紧接着还有别的问题 ../common/nms.c: 在函数‘pyx_pf_6common_3nms_cpu_nms’中: ../common/nms.c:1864:2: 错误:提供给函数‘PyArray_DIMS’的实参太多 pyx_v_ndets = PyArray_DIMS(pyx_v_dets,0); ^ In file included from /usr/include/numpy/ndarrayobject.h:17:0, from /usr/include/numpy/arrayobject.h:15, from ../common/nms.c:266: /usr/include/numpy/ndarraytypes.h:1405:1: 附注:在此声明 PyArray_DIMS(PyArrayObject *arr) ^ ../common/nms.c:1864:16: 警告:赋值时将指针赋给整数,未作类型转换 [默认启用] __pyx_v_ndets = PyArray_DIMS(pyx_v_dets,0); ^ ../common/nms.c: 在函数‘pyx_pf_5numpy7ndarraygetbuffer’中: ../common/nms.c:2557:50: 错误:‘NPY_C_CONTIGUOUS’未声明(在此函数内第一次使用) pyx_t_2 = ((!(PyArray_CHKFLAGS(pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0); ^ ../common/nms.c:2557:50: 附注:每个未声明的标识符在其出现的函数内只报告一次 ../common/nms.c:2613:50: 错误:‘NPY_F_CONTIGUOUS’未声明(在此函数内第一次使用) pyx_t_2 = ((!(PyArray_CHKFLAGS(pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0); ^ ../common/nms.c:2798:40: 错误:‘PyArrayObject’没有名为‘descr’的成员 pyx_t_3 = ((PyObject *)pyx_v_self->descr); ^ In file included from /usr/include/python2.7/Python.h:80:0, from ../common/nms.c:4: ../common/nms.c: 在函数‘pyx_f_5numpy_set_array_base’中: ../common/nms.c:4435:25: 错误:‘PyArrayObject’没有名为‘base’的成员 Py_XDECREF(__pyx_v_arr->base); ^ /usr/include/python2.7/object.h:823:34: 附注:in definition of macro ‘Py_XDECREF’

define Py_XDECREF(op) do { if ((op) == NULL) ; else Py_DECREF(op); } while (0)

                              ^

../common/nms.c:4435:25: 错误:‘PyArrayObject’没有名为‘base’的成员 Py_XDECREF(pyx_v_arr->base); ^ /usr/include/python2.7/object.h:772:24: 附注:in definition of macro ‘Py_DECREF’ --((PyObject*)(op))->ob_refcnt != 0) \ ^ ../common/nms.c:4435:3: 附注:in expansion of macro ‘Py_XDECREF’ Py_XDECREF(pyx_v_arr->base); ^ ../common/nms.c:4435:25: 错误:‘PyArrayObject’没有名为‘base’的成员 Py_XDECREF(__pyx_v_arr->base); ^ /usr/include/python2.7/object.h:115:47: 附注:in definition of macro ‘Py_TYPE’

define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)

                                           ^

/usr/include/python2.7/object.h:775:9: 附注:in expansion of macro ‘_Py_Dealloc’ _Py_Dealloc((PyObject *)(op)); \ ^ /usr/include/python2.7/object.h:823:54: 附注:in expansion of macro ‘Py_DECREF’

define Py_XDECREF(op) do { if ((op) == NULL) ; else Py_DECREF(op); } while (0)

                                                  ^

../common/nms.c:4435:3: 附注:in expansion of macro ‘Py_XDECREF’ Py_XDECREF(__pyx_v_arr->base); ^ ../common/nms.c:4435:25: 错误:‘PyArrayObject’没有名为‘base’的成员 Py_XDECREF(__pyx_v_arr->base); ^ /usr/include/python2.7/object.h:762:45: 附注:in definition of macro ‘_Py_Dealloc’ (Py_TYPE(op)->tp_dealloc)((PyObject )(op))) ^ /usr/include/python2.7/object.h:823:54: 附注:in expansion of macro ‘Py_DECREF’

define Py_XDECREF(op) do { if ((op) == NULL) ; else Py_DECREF(op); } while (0)

                                                  ^

../common/nms.c:4435:3: 附注:in expansion of macro ‘Py_XDECREF’ Py_XDECREF(pyx_v_arr->base); ^ ../common/nms.c:4444:14: 错误:‘PyArrayObject’没有名为‘base’的成员 pyx_v_arr->base = pyx_v_baseptr; ^ ../common/nms.c: 在函数‘pyx_f_5numpy_get_array_base’中: ../common/nms.c:4479:28: 错误:‘PyArrayObject’没有名为‘base’的成员 pyx_t_1 = ((pyx_v_arr->base == NULL) != 0); ^ In file included from /usr/include/python2.7/Python.h:80:0, from ../common/nms.c:4: ../common/nms.c:4510:42: 错误:‘PyArrayObject’没有名为‘base’的成员