当前位置:网站首页>Pit resolution encountered using East OCR (compile LAMS)
Pit resolution encountered using East OCR (compile LAMS)
2022-06-25 23:02:00 【Xuehui】
What is used here is pytorch Version of EAST, Download address :
https://github.com/SakuraRiven/EAST
One 、 Not in use cuda Operation in case of
take model.load_state_dict(torch.load(model_path)) Switch to
model.load_state_dict(torch.load(model_path, map_location='cpu'))
Two 、lanms The bag cannot be used
1. Method 1 : Use locality_aware_nms
It needs to use lanms package , I use... Directly pip install There are all kinds of problems , Find someone else's solution , Said the detect.py Medium import lanms Comment out , Change to
import locality_aware_nms as nms_clslocality
boxes = lanms.merge_quadrangle_n9(boxes.astype(‘float32’), nms_thresh) Change to
boxes = nms_locality.nms_locality(boxes.astype('float32'), nms_thresh)
It will also report a mistake , So I abandoned this method
2 Method 2 : compile lanms
primary pytorch The version of the EAST There is no lanms, I am here TensorFlow Version of EAST Found in the lanms Source code
https://github.com/argman/EAST
First, you need to mingw Assign environment variables , Otherwise we can't make compile lanms Medium makefile
original edition 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)
And then run detect.py It will automatically start compiling lanms, Many errors will be reported in the process , It's a headache

The error is that the header file cannot be found , Look at this cpython Probably python Owned basic header file . So add the header address to the first line
CXXFLAGS = -I include -std=c++11 -O3 -I 'C:/ProgramData/Anaconda3/include'
Again make, There are new mistakes

undefined reference to `__imp_PyErr_SetString
This error usually occurs when the library corresponding to the header file cannot be found
take LDFLAGS Change to the following form
LDFLAGS = -L 'C:/ProgramData/Anaconda3/libs'
Then change line 90 to the following
$(LIB_SO): $(CXX_SOURCES) $(DEPS)
$(CXX) -o [email protected] $(CXXFLAGS) $(LDFLAGS) $(CXX_SOURCES) -lpython3 -lpython38 --shared -fPIC
Look again and you'll find that you have successfully compiled a file called adapter.so The library of , The compilation is successful .
What to pay attention to :Anaconda Under the include and libs The files are python Original header and library files .
Anaconda Under the Library Under the include and lib Should be anaconda The header and library files of the installed package , similar opencv
This problem has no effect on the compiler , But rewrite the fourth line as
DEPS = lanms.h
There is no relevant error report 
All changed makefile file
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)
3、 ... and 、 unable import adapter library
I use windows test EAST, Compiled in the previous step so When called, it will display No module named ‘adaptor’,
Then it occurred to me so yes linux Dynamic library on ,windows Should not be able to call , Then I changed makefile Change the seventh line in to
LIB_SO = adaptor.dll
It turns out that you still can't call
First, test whether it is a library problem
Using this method :https://blog.csdn.net/zhanglifu3601881/article/details/106563907
If the library is OK, you need to consider other issues. The key points of the problem are found through this blog
https://blog.csdn.net/XCCCCZ/article/details/111089151
Confirm that you are currently using python Which suffixes the version supports can be import
import importlib.machinery
print(importlib.machinery.all_suffixes())

Print out so Kuhe dll Libraries cannot be import call
So directly dll The suffix to pyd, Result the call succeeded ,detect.py It can work normally !
边栏推荐
- 你好,请问老师,在支付宝基金开户真的安全吗?
- 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年河南省第一届职业技能大赛网络安全项目试题
- Nacos 源码分析01 代码结构
- ES6-- 模板字符串、对象的简化写法、箭头函数
- Unity技术手册 - 粒子发射和生命周期内速度子模块
- 【EOSIO】EOS/WAX签名错误 is_canonical( c ): signature is not canonical 问题
- Talk about adapter mode
- 2022-2028 global industrial TFT LCD industry survey and trend analysis report
- Programmer weekly (issue 4): the wealth view of programmers
猜你喜欢

【EOSIO】EOS/WAX签名错误 is_canonical( c ): signature is not canonical 问题
This 110 year old "longevity" enterprise has been planning for the next century

Use of local stack in flask

简单好用的缓存库 gcache

2022-2028 global DC linear variable differential transformer (LVDT) industry survey and trend analysis report

Record the learning record of the exists keyword once

Openwrt (VIII) application layer development

Ribbon core ⼼ source code analysis

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

The Ping class of unity uses
随机推荐
Analysis report on demand and investment forecast of global and Chinese flame retardant hydraulic oil market from 2022 to 2028
在线CRUDhasone关联查询报错Unabletouseinternalvariable:List
2022年河南省第一届职业技能大赛网络安全项目试题
ES6学习-- LET
Simple and easy-to-use cache library gcache
Trillions of hot money smashed into the space economy. Is it really a good business?
Global and Chinese oleic acid operation mode and market supply and demand forecast report 2022 ~ 2028
App test points
How to use the find command
Cvpr2022 tutorial | machine learning remote sensing processing: agriculture and food security, University of Maryland
2022-2028 global open source cloud storage industry research and trend analysis report
QT learning setting executable exe attribute (solving the problem of Chinese attribute garbled)
Equivalence class, boundary value, application method and application scenario of scenario method
2022-2028 global web and browser isolation platform industry research and trend analysis report
Unity technical manual - particle foundation main module attributes - upper
ES6-- 模板字符串、对象的简化写法、箭头函数
[WPF] XAML code skills that can be directly used for converting CAD engineering drawings to WPF
Flutter 網絡請求封裝之Dio(Cookie管理、添加攔截器、下載文件、异常處理、取消請求等)
荣耀推出积分商城,支持兑换各种荣耀产品
adb常用命令