YOLOv3 とか darknet - らんだむな記憶 を踏まえつつ漢字とかの検出を試してみたかったので、GitHub - chineseocr/darknet-ocr: darknet text detect and darknet cnn ocr を使ってみた。
CPU ビルドの darknet だったから心配だったけど、普通に水平に書かれた漢字のテキストを読み取れた!*1
$ pip list | grep -e numpy -e opencv -e pillow -e h5py -e requests -e web.py h5py 3.4.0 numpy 1.20.3 opencv-contrib-python 4.5.5.62 requests 2.25.1 requests-oauthlib 1.3.0 web.py 0.62
という感じでバージョンは適当なんだけど。と言うか、指定通りだと実行時エラーになることもあったので、これで。
他、コードも怒られる箇所があったので、
--- a/app.py +++ b/app.py @@ -69,7 +69,7 @@ class TEXT: billModel = data.get('billModel',"") iscut = data.get('iscut',False)##是否多票据识别 isclass = data.get('isclass',False)##是否自动进行票据分类 - if 'uuid' is not None and (url is not None or imgString is not None): + if uuid is not None and (url is not None or imgString is not None): res = job(uuid,url,imgString,iscut,isclass,billModel,ip) post.update(res) else: --- a/helper/image.py +++ b/helper/image.py @@ -76,7 +76,7 @@ def resize_img(image,scale,maxScale=None): """ image = np.copy(image) vggMeans = [122.7717,102.9801, 115.9465 ] - imageList = cv2.split(image.astype(np.float32)) + imageList = list(cv2.split(image.astype(np.float32))) imageList[0] = imageList[0]-vggMeans[0] imageList[1] = imageList[1]-vggMeans[1] imageList[2] = imageList[2]-vggMeans[2]
しといた。適当なんだけど。たぶん依存モジュールのバージョンにもよるとは思う・・・。