1. 安裝paddlehub
pip3 install paddlehub --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple
2.安裝服務(wù)模塊
PaddleOCR提供3種服務(wù)模塊个唧,根據(jù)需要安裝所需模塊钥顽。如:
安裝檢測(cè)服務(wù)模塊:
hub install deploy/ocr_hubserving/ocr_det
或坟冲,安裝識(shí)別服務(wù)模塊:
hub install deploy/ocr_hubserving/ocr_rec
或睛挚,安裝檢測(cè)+識(shí)別串聯(lián)服務(wù)模塊:
hub install deploy/ocr_hubserving/ocr_system
注意
deploy/hubserving/ocr_det 是根據(jù)自己具體路徑而定邪蛔,例如我的是這樣的
image.png
還有最后的斜杠一定不要加上,要不它就是提示下面的錯(cuò)誤
TypeError: the 'package' argument is required to perform a relative import for '.module'
3.啟動(dòng)服務(wù)
hub serving start -m ocr_system --config deploy/ocr_hubserving/ocr_system/config.json
提示沒有ocr_system模塊扎狱,然后根據(jù)錯(cuò)誤提示侧到,順著各個(gè)py文件查找,找了半天找到了原因淤击,原因是安裝模塊時(shí)匠抗,hub會(huì)把ocr_det等文件移動(dòng)到C:\Users\Administrator\.paddlehub\modules目錄下,而這時(shí)每個(gè)模塊下的module.py中import的tools會(huì)因?yàn)槁窂轿募也坏轿厶В灾苯影裻ools所在的路徑添加到sys.path中就可以了汞贸。
config.json中模型路徑直接改為完整路徑