Skip to main content

Pix2Text

# 目前最高只支持 Python 3.12
# CnSTD>=1.2.1, CnOCR>=2.2.2.1, transformers>=4.37.0
# pip install pix2text[multilingual] # 多语言 - 除了 简体中文和英文以外
pip install pix2text -i https://mirrors.aliyun.com/pypi/simple

# for GPU
pip uninstall onnxruntime
pip install onnxruntime-gpu

# --file-type [pdf|page|text_formula|formula|text]
# -i, --img-file-or-dir TEXT
p2t predict \
-l en,ch_sim --disable-formula --enable-table \
--resized-shape 768 \
--file-type pdf \
-i docs/examples/test-doc.pdf \
-o output-md \
--save-debug-res output-debug

# 启动 HTTP 服务
p2t serve -l en,ch_sim -H 0.0.0.0 -p 8503

curl -X POST \
-F "file_type=page" \
-F "resized_shape=768" \
-F "embed_sep= $,$ " \
-F "isolated_sep=$$\n, \n$$" \
-F "image=@docs/examples/page2.png;type=image/jpeg" \
http://0.0.0.0:8503/pix2text

CN OCR

# pip install cnocr[ort-gpu]
pip install cnocr[ort-cpu] -i https://mirrors.aliyun.com/pypi/simple