cnocr安装

cnocr安装

CnOCR 是 Python 3 下的文字识别(Optical Character Recognition,简称OCR)工具包,支持简体中文、繁体中文(部分模型)、英文和数字的常见字符识别,支持竖排文字的识别。

官方文档:https://cnocr.readthedocs.io/zh-cn/stable/install/

为了避免一下包的冲突,可以使用python的虚拟环境安装执行。虚拟环境使用请参考往期文章:https://www.madbull.site/?p=1558 python虚拟环境

在文章 https://www.madbull.site/?p=1558 的第四步,我们就可以进行一些安装和运行了。

需要安装的包有:cnocr[ort-cpu]、uvicorn、pydantic、fastapi、python-multipart

pip install -i https://pypi.doubanio.com/simple --cache-dir /data/tmp cnocr[ort-cpu]
pip install -i https://pypi.doubanio.com/simple --cache-dir /data/tmp uvicorn
pip install -i https://pypi.doubanio.com/simple --cache-dir /data/tmp pydantic
pip install -i https://pypi.doubanio.com/simple --cache-dir /data/tmp/ fastapi
pip install -i https://pypi.doubanio.com/simple --cache-dir /data/tmp/ python-multipart

运行:

指令:cnocr serve -p 3333

systemd监控脚本

[Unit]
Description=CnOcr
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=root
Group=root

WorkingDirectory=/data/pyve/py3.12
ExecStart=/bin/bash -c ". /data/pyve/py3.12/bin/activate && exec cnocr serve -p 2233 -H 127.0.0.1"

RestartSec=5
Restart=always
MemoryLimit=3G

# Turn-off memory accounting by systemd, which is buggy.
MemoryAccounting=no

[Install]
WantedBy=multi-user.target

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注