多模型开源OCR框架RapidOCR使用教程
信创级开源OCR - 为世界内容安全贡献力量
目前已知运行速度最快、支持最广,完全开源免费并支持离线快速部署的多平台多语言OCR。
支持的语言: 默认是中英文,其他语言识别需要自助转换。具体参考这里
缘起:PaddleOCR工程化不是太好,为了方便大家在各种端上进行OCR推理,我们将PaddleOCR中的模型转换为ONNX格式,使用Python/C++/Java/C# 将它移植到各个平台。
名称来源: 轻快好省并智能。基于深度学习的OCR技术,主打人工智能优势及小模型,以速度为使命,效果为主导。
使用:如果仓库下已有模型满足要求 → RapidOCR部署使用即可。
不满足要求 → 基于PaddleOCR在自己数据上微调 → RapidOCR部署
Python版(官方)
环境要求:Python>=3.6
支持系统: Linux、Win、Mac官网:点我跳转
使用预览:点我跳转
github:点我跳转
安装命令:
pip install rapidocr_onnxruntime使用demo代码如下
from PIL import Image
from rapidocr_onnxruntime import RapidOCR
if __name__ == "__main__":
# 创建RapidOCR实例
ocr_engine = RapidOCR()
img_path = Image.open('C:\\Users\\76110\\Desktop\\004.png')
result, elapse = ocr_engine(img_path)
for str in result:
print(str[1])
Java版
gitee:点我跳转
依赖引入:在maven的pom.xml中引入如下依赖
<!-- rapidocr这个必须要引入 -->
<!-- 可前往maven中央仓库https://repo1.maven.org/maven2/io/github/mymonstercat/rapidocr/,查看版本 -->
<dependency>
<groupId>io.github.mymonstercat</groupId>
<artifactId>rapidocr</artifactId>
<version>0.0.7</version>
</dependency>
<!-- 一般只需要引入一个,CPU端建议使用onnx,移动端建议使用ncnn -->
<!-- 可前往maven中央仓库https://repo1.maven.org/maven2/io/github/mymonstercat/,查看版本 -->
<dependency>
<groupId>io.github.mymonstercat</groupId>
<artifactId>rapidocr-onnx-platform</artifactId>
<version>0.0.7</version>
</dependency>
<dependency>
<groupId>io.github.mymonstercat</groupId>
<artifactId>rapidocr-ncnn-platform</artifactId>
<version>0.0.7</version>
</dependency>
使用Demo代码
/**
* @program: RapidOCR
* @description: OCR
* @author: gityyge
* @create: 2024-03-13 10:09
**/
import com.benjaminwan.ocrlibrary.OcrResult;
import io.github.mymonstercat.Model;
import io.github.mymonstercat.ocr.InferenceEngine;
public class demo {
public static void main(String[] args) {
InferenceEngine engine = InferenceEngine.getInstance(Model.ONNX_PPOCR_V4);
OcrResult ocrResult = engine.runOcr("C:\\Users\\76110\\Desktop\\004.png");
//输出识别后的内容
System.out.println(ocrResult.getStrRes().trim());
}
}
RobertroK
2024-03-17 22:07下午好! 我们给你一个促销代码 - ZBXM777
注册后,在您的个人帐户中激活它 www.cexasia.pro
您将收到高达1000usdt的存款。 交易愉快!
Manuelgreva
2024-03-14 21:41您是否需要google上的评论,投票网站上的评论,您是否需要有人创建gmail帐户,您是否希望增加youtube视频的浏览量,或者您是否需要人们在互联网上执行小任务, https://aviso.bz/?r=filosof20063