当前位置:网站首页>使用EAST ocr遇到的坑解决方法(编译lanms)
使用EAST ocr遇到的坑解决方法(编译lanms)
2022-06-25 21:50:00 【雪回】
在这里使用的是pytorch版本的EAST,下载地址 :
https://github.com/SakuraRiven/EAST
一、在用不了cuda的情况下运行
将model.load_state_dict(torch.load(model_path))换成
model.load_state_dict(torch.load(model_path, map_location='cpu'))
二、lanms包无法使用
1.方法一:使用locality_aware_nms
里面需要用到lanms包,我直接用pip install有各种各样的问题下不下来,寻找别人的解决方法,说把detect.py中的import lanms注释掉,改成
import locality_aware_nms as nms_clslocality
boxes = lanms.merge_quadrangle_n9(boxes.astype(‘float32’), nms_thresh)改成
boxes = nms_locality.nms_locality(boxes.astype('float32'), nms_thresh)
同样会报错,于是舍弃了这个办法
2方法二:编译lanms
原pytorch的版本的EAST中没有lanms,我在TensorFlow版本的EAST中找到了lanms源码
https://github.com/argman/EAST
首先需要将mingw配入环境变量,不然无法make编译lanms中的makefile
原版makefile
CXXFLAGS = -I include -std=c++11 -O3 $(shell python3-config --cflags)
LDFLAGS = $(shell python3-config --ldflags)
DEPS = lanms.h $(shell find include -xtype f)
CXX_SOURCES = adaptor.cpp include/clipper/clipper.cpp
LIB_SO = adaptor.so
$(LIB_SO): $(CXX_SOURCES) $(DEPS)
$(CXX) -o [email protected] $(CXXFLAGS) $(LDFLAGS) $(CXX_SOURCES) --shared -fPIC
clean:
rm -rf $(LIB_SO)
然后运行detect.py它会自动开始编译lanms,过程中会报很多错,令人头疼

这个错误是找不到头文件,观察这个cpython大概是python拥有的基础头文件。于是在第一行加上头文件地址
CXXFLAGS = -I include -std=c++11 -O3 -I 'C:/ProgramData/Anaconda3/include'
再重新make,又出现了新的错误

undefined reference to `__imp_PyErr_SetString
出现这种错误一般是找不到头文件相对应的库
将LDFLAGS改成以下形式
LDFLAGS = -L 'C:/ProgramData/Anaconda3/libs'
然后将第九十行的内容改成以下
$(LIB_SO): $(CXX_SOURCES) $(DEPS)
$(CXX) -o [email protected] $(CXXFLAGS) $(LDFLAGS) $(CXX_SOURCES) -lpython3 -lpython38 --shared -fPIC
再看就发现成功编译出了一个叫adapter.so的库,说明编译成功了。
需要注意的地方:Anaconda下的include和libs文件分别是python原始头文件和库文件。
Anaconda下的Library下的include 和lib应该是anaconda安装的包的头文件和库文件,类似opencv
这个问题对编译库没有影响,但是将第四行改写成为
DEPS = lanms.h
就没有相关报错了
全部更改后的makefile文件
CXXFLAGS = -I include -std=c++11 -O3 -I 'C:/ProgramData/Anaconda3/include'
LDFLAGS = -L 'C:/ProgramData/Anaconda3/libs'
DEPS = lanms.h
CXX_SOURCES = adaptor.cpp include/clipper/clipper.cpp
LIB_SO = adaptor.so
$(LIB_SO): $(CXX_SOURCES) $(DEPS)
$(CXX) -o [email protected] $(CXXFLAGS) $(LDFLAGS) $(CXX_SOURCES) -lpython3 -lpython38 --shared -fPIC
clean:
rm -rf $(LIB_SO)
三、无法import adapter库
我是用windows测试EAST,上一步编译出来的so调用的时候会显示No module named ‘adaptor’,
后来我突然想到so是linux上的动态库,windows上应该不能调用,然后我改了makefile中的第七行改成
LIB_SO = adaptor.dll
结果发现仍然不能调用
首先测试是否是库的问题
使用这个方法:https://blog.csdn.net/zhanglifu3601881/article/details/106563907
如果库没问题就需要考虑是别的问题通过这个博客找到了问题的关键点
https://blog.csdn.net/XCCCCZ/article/details/111089151
确认你当前使用的python版本支持哪些后缀的库能被import
import importlib.machinery
print(importlib.machinery.all_suffixes())

打印出来so库和dll库都不能被import调用
于是直接将dll后缀改成pyd,结果调用成功,detect.py能正常运行起来了!
边栏推荐
- oracle -- 表操作
- 华为云短信测了很多手机都提示发送频繁
- Analysis report on market business model and development direction of China mobile operation industry from 2022 to 2028
- Online crudhasone Association query reports an error unabletouseinternalvariable:list
- What are the channels for Internet advertising to gain customers?
- 不荒唐的茶小程序-规则改动
- Report on development status and prospects of global and Chinese coating industry strategic planning proposal 2022-2028
- What do l and R of earphone mean?
- Global and Chinese flame retardant ABS industry development trend and market demand analysis report 2022 ~ 2028
- MATLAB Programming Notes
猜你喜欢

Yyds dry goods inventory CEPH installation visual dashboard

Record the learning record of the exists keyword once

腾讯《和平精英》新版本将至:新增账号安全保护系统,游戏内违规行为检测升级

27 Chinese scholars including Yaoban and chendanqi from Tsinghua won the awards, and the list of winners of Sloan award in 2022 was issued

2022-2028 global co extrusion production line industry research and trend analysis report

Obsidian基础教程

How to design a complex business system? From the understanding of domain design, cloud native, micro service, and middle platform

Nacos source code analysis 01 code structure

Chapter 3 use of requests Library
![[WPF] XAML code skills that can be directly used for converting CAD engineering drawings to WPF](/img/a1/09d2dc0ec47c54530da4d42d218d1c.jpg)
[WPF] XAML code skills that can be directly used for converting CAD engineering drawings to WPF
随机推荐
Tlog helps Pangu framework realize microservice link log tracking
2022-2028 global industrial touch screen industry research and trend analysis report
To ensure the Beijing Winter Olympic Games, digital data gives a power without code!
Beyond natural motion: exploring the discontinuity of video interpolation
Programmer weekly (issue 4): the wealth view of programmers
Unity技术手册 - GetKey和GetAxis和GetButton
Unity技术手册 - 粒子发射和生命周期内速度子模块
2022-2028 global industrial TFT LCD industry survey and trend analysis report
Why is BeanUtils not recommended?
不荒唐的茶小程序-规则改动
Nacos 源码分析01 代码结构
What are the debugging methods for nodejs
目前期货怎么开户安全些?哪些期货公司靠谱些?
2022-2028 global web and browser isolation platform industry research and trend analysis report
Huasheng lithium battery IPO meeting: 9-month revenue of 690million; shenjinliang's family relationship is complex
Research Report on China's new energy technology and equipment market competition analysis and marketing strategy suggestions 2022-2028
Initialization process of gstlibav
Relinearization in homomorphic encryption (ckks)
荣耀推出积分商城,支持兑换各种荣耀产品
How to guarantee idempotency of message queue