GOT-OCR本地部署:
一:项目介绍:这是一款对纯文本,公式等进行识别的工具
项目地址:https://github.com/Ucas-HaoranWei/GOT-OCR2.0
二:准备环境与工具:python3.10、CUDA12.2
三:部署步骤:
- 将项目文件下载到本地
- 创建虚拟环境:conda create -n got python=3.10 -y
- 激活虚拟环境:conda activate got
- 进入项目所在文件夹,如:
D:
cd D:\liu\Project\GOT-OCR2.0-main\GOT-OCR-2.0-master
- 使用项目安装文件安装依赖:pip install -e .
- 重装与本机对应版本的pytorch(因为项目文件安装的pytorch文件可能与本机cuda版本不对应,此处也可修改其项目文件中下载pytorch字段):pip install torch==2.2.0 torchvision==0.17.0 torchaudio==2.2.0 --index-url https://download.pytorch.org/whl/cu121
- 输入命令单独安装Flash-Attention:
pip install ninja
pip install flash-attn --no-build-isolation(此条命令耗时较久,本次安装大约耗时三小时)
- 下载模型(前两个需要科学上网):
Huggingface:https://huggingface.co/ucaslcl/GOT-OCR2_0
Google Drive:drive.google.com
BaiduYun:百度网盘 请输入提取码 (baidu.com) 提取码:OCR2
- 本地运行
纯文本识别:python GOT/demo/run_ocr_2.0.py --model-name GOT_weights/ --image-file file.png --type ocr
格式化文本识别: python GOT/demo/run_ocr_2.0.py --model-name GOT_weights/ --image-file file.png --type format
更多功能见官网:
可能出现的问题:本人在安装过程中出现报错RuntimeError: Numpy is not available,大概原因是版本不兼容,使用命令pip install numpy==1.24.4重新安装其他版本numpy