MMOCR使用指南
使用指南
2023-06-13 09:12:44 时间
MMOCR是通用视觉框架OpenMMLab的光学字符识别器。
安装配置环境
MMOCR github主页:GitHub - open-mmlab/mmocr: OpenMMLab Text Detection, Recognition and Understanding Toolbox
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.11.0/index.html
pip install mmdet -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install lmdb
pip install shapely
pip install rapidfuzz
pip install lanms
pip install pyclipper
pip install scikit-image
pip install imgaug
验证是否安装成功代码
import torch, torchvision
import mmcv
from mmcv.ops import get_compiling_cuda_version, get_compiler_version
import mmdet
import mmocr
from mmocr.utils.ocr import MMOCR
mmocr = MMOCR(det=None, recog='SAR', device='cpu')
print('mmocr载入成功')
文本检测与文本提取
import torch, torchvision
import mmcv
from mmcv.ops import get_compiling_cuda_version, get_compiler_version
import mmdet
import mmocr
from mmocr.utils.ocr import MMOCR
# mmocr = MMOCR(det=None, recog='SAR', device='cpu')
# print('mmocr载入成功')
if __name__ == '__main__':
detector = MMOCR(det='TextSnake', recog='SAR', device='cuda')
result = detector.readtext('demo/demo_densetext_det.jpg', output='output/demo_densetext_det.jpg')
中文检测与提取
在mmocr主目录下新建文件夹/data/chineseocr/labels
进入该文件夹执行
wget http://download.openmmlab.com/mmocr/textrecog/sar/dict_printed_chinese_english_digits.txt
wget http://download.openmmlab.com/mmocr/data/font.TTF
下载字体和字库
import torch, torchvision
import mmcv
from mmcv.ops import get_compiling_cuda_version, get_compiler_version
import mmdet
import mmocr
from mmocr.utils.ocr import MMOCR
# mmocr = MMOCR(det=None, recog='SAR', device='cpu')
# print('mmocr载入成功')
if __name__ == '__main__':
detector = MMOCR(det='TextSnake', recog='SAR_CN', device='cuda')
result = detector.readtext('demo/demo_densetext_det.jpg', output='output/demo_densetext_det.jpg')
相关文章
- 谷歌浏览器搜索使用指南[通俗易懂]
- Mysql存储过程使用指南(mysql存储过程教程)
- SQLserver 功能强大的使用指南(sqlserver使用)
- Linux下SNMP功能的使用指南(linuxsnmp使用)
- SQL Server测试环境使用指南(sqlserver测试库)
- Redis使用指南(redis 用户手册)
- MySQL命令CHM的使用指南(mysql 命令 chm)
- MySQL数据库简易使用指南:从周一到周日(mysql周几)
- 使用说明Redis使用指南简单易行的操作步骤(怎么写一个redis)
- Oracle数据库全备份脚本使用指南(oracle全备份脚本)
- 轻松入门MySQL个人使用指南(mysql个人使用)
- Oracle连接使用指南最佳实践(oracle中连接怎么用)