File size: 13,481 Bytes
2c67080 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
<div align="center">
<img src="./docs/figs/p2t-logo.png" width="220px"/>
<div> </div>
[](https://discord.gg/GgD87WM8Tf)
[](https://pepy.tech/project/pix2text)
[](https://visitorbadge.io/status?path=https%3A%2F%2Fgithub.com%2Fbreezedeus%2FPix2Text)
[](./LICENSE)
[](https://badge.fury.io/py/pix2text)
[](https://github.com/breezedeus/pix2text)
[](https://github.com/breezedeus/pix2text)


[](https://twitter.com/breezedeus)
[📖 在线文档](https://pix2text.readthedocs.io) |
[👩🏻💻 网页版](https://p2t.breezedeus.com) |
[👨🏻💻 在线 Demo](https://huggingface.co/spaces/breezedeus/Pix2Text-Demo) |
[💬 交流群](https://www.breezedeus.com/article/join-group)
</div>
<div align="center">
[English](./README.md) | 中文
</div>
# Pix2Text (P2T)
## Update 2025.07.25:发布 **V1.1.4**
主要变更:
- 数学公式检测(MFD)和数学公式识别(MFR)模型升级到 1.5 版本,所有默认配置、文档和示例均以 `mfd-1.5` 和 `mfr-1.5` 为标准模型。
## Update 2025.04.15:分布 **V1.1.3**
主要变更:
- 支持基于 VLM 接口(具体参考 [LiteLLM 文档](https://docs.litellm.ai/docs/))的 `VlmTableOCR` 和 `VlmTextFormulaOCR` 模型,可使用闭源 VLM 模型。安装命令:`pip install pix2text[vlm]`。
- 使用方式见 [tests/test_vlm.py](tests/test_vlm.py) 和 [tests/test_pix2text.py](tests/test_pix2text.py)。
## Update 2024.11.17:发布 **V1.1.2**
主要变更:
* 版面分析模型加入 [DocLayout-YOLO](https://github.com/opendatalab/DocLayout-YOLO),提升版面分析的准确性。
## Update 2024.06.18:发布 **V1.1.1**
主要变更:
* 支持新的数学公式检测模型(MFD):[breezedeus/pix2text-mfd](https://huggingface.co/breezedeus/pix2text-mfd) ([国内镜像](https://hf-mirror.com/breezedeus/pix2text-mfd)),公式检测精度获得较大提升。
具体说明请见:[Pix2Text V1.1.1 发布,带来更好的数学公式检测模型 | Breezedeus.com](https://www.breezedeus.com/article/p2t-mfd-v1.1.1)。
## Update 2024.04.28:发布 **V1.1**
主要变更:
* 加入了版面分析和表格识别模型,支持把复杂排版的图片转换为 Markdown 格式,示例见:[Pix2Text 在线文档/Examples](https://pix2text.readthedocs.io/zh-cn/stable/examples/)。
* 支持把整个 PDF 文件转换为 Markdown 格式,示例见:[Pix2Text 在线文档/Examples](https://pix2text.readthedocs.io/zh-cn/stable/examples/)。
* 加入了更丰富的接口,已有接口的参数也有所调整。
* 上线了 [Pix2Text 在线文档](https://pix2text.readthedocs.io)。
## Update 2024.02.26:发布 **V1.0**
主要变更:
* 数学公式识别(MFR)模型使用新架构,在新的数据集上训练,获得了 SOTA 的精度。具体说明请见:[Pix2Text V1.0 新版发布:最好的开源公式识别模型 | Breezedeus.com](https://www.breezedeus.com/article/p2t-v1.0)。
了解更多:[RELEASE.md](docs/RELEASE.md) 。
<br/>
**Pix2Text (P2T)** 期望成为 **[Mathpix](https://mathpix.com/)** 的**免费开源 Python** 替代工具,目前已经可以完成 **Mathpix** 的核心功能。
**Pix2Text (P2T) 可以识别图片中的版面、表格、图片、文字、数学公式等内容,并整合所有内容后以 Markdown 格式输出。P2T 也可以把一整个 PDF 文件(PDF 的内容可以是扫描图片或者其他任何格式)转换为 Markdown 格式。**
**Pix2Text (P2T)** 整合了以下模型:
- **版面分析模型**:[breezedeus/pix2text-layout](https://huggingface.co/breezedeus/pix2text-layout) ([国内镜像](https://hf-mirror.com/breezedeus/pix2text-layout))。
- **表格识别模型**:[breezedeus/pix2text-table-rec](https://huggingface.co/breezedeus/pix2text-table-rec) ([国内镜像](https://hf-mirror.com/breezedeus/pix2text-table-rec))。
- **文字识别引擎**:支持 **`80+` 种语言**,如**英文、简体中文、繁体中文、越南语**等。其中,**英文**和**简体中文**识别使用的是开源 OCR 工具 [CnOCR](https://github.com/breezedeus/cnocr) ,其他语言的识别使用的是开源 OCR 工具 [EasyOCR](https://github.com/JaidedAI/EasyOCR) 。
- **数学公式检测模型(MFD)**:[breezedeus/pix2text-mfd-1.5](https://huggingface.co/breezedeus/pix2text-mfd-1.5) ([国内镜像](https://hf-mirror.com/breezedeus/pix2text-mfd-1.5))。基于 [CnSTD](https://github.com/breezedeus/cnstd) 实现。
- **数学公式识别模型(MFR)**:[breezedeus/pix2text-mfr-1.5](https://huggingface.co/breezedeus/pix2text-mfr-1.5) ([国内镜像](https://hf-mirror.com/breezedeus/pix2text-mfr-1.5))。
其中多个模型来自其他开源作者, 非常感谢他们的贡献。
<div align="center">
<img src="docs/figs/arch-flow.jpg" alt="Pix2Text Arch Flow"/>
</div>
具体说明请参考:[Pix2Text在线文档/模型](https://pix2text.readthedocs.io/zh-cn/stable/models/)。
<br/>
P2T 作为Python3工具包,对于不熟悉Python的朋友不太友好,所以我们也发布了**可免费使用**的 **[P2T网页版](https://p2t.breezedeus.com)**,直接把图片丢进网页就能输出P2T的解析结果。**网页版会使用最新的模型,效果会比开源模型更好。**
感兴趣的朋友欢迎扫码加小助手为好友,备注 `p2t`,小助手会定期统一邀请大家入群。群内会发布P2T相关工具的最新进展:
<div align="center">
<img src="./docs/figs/wx-qr-code.JPG" alt="微信群二维码" width="300px"/>
</div>
作者也维护 **知识星球** [**P2T/CnOCR/CnSTD私享群**](https://t.zsxq.com/FEYZRJQ) ,这里面的提问会较快得到作者的回复,欢迎加入。**知识星球私享群**也会陆续发布一些P2T/CnOCR/CnSTD相关的私有资料,包括**部分未公开的模型**,**购买付费模型享优惠**,**不同应用场景的调用代码**,使用过程中遇到的难题解答等。星球也会发布P2T/OCR/STD相关的最新研究资料。
## 支持的语言列表
Pix2Text 的文字识别引擎支持 **`80+` 种语言**,如**英文、简体中文、繁体中文、越南语**等。其中,**英文**和**简体中文**识别使用的是开源 OCR 工具 **[CnOCR](https://github.com/breezedeus/cnocr)** ,其他语言的识别使用的是开源 OCR 工具 **[EasyOCR](https://github.com/JaidedAI/EasyOCR)** ,感谢相关的作者们。
支持的**语言列表**和**语言代码**如下:
<details>
<summary>↓↓↓ Click to show details ↓↓↓</summary>
| Language | Code Name |
| ------------------- | ----------- |
| Abaza | abq |
| Adyghe | ady |
| Afrikaans | af |
| Angika | ang |
| Arabic | ar |
| Assamese | as |
| Avar | ava |
| Azerbaijani | az |
| Belarusian | be |
| Bulgarian | bg |
| Bihari | bh |
| Bhojpuri | bho |
| Bengali | bn |
| Bosnian | bs |
| Simplified Chinese | ch_sim |
| Traditional Chinese | ch_tra |
| Chechen | che |
| Czech | cs |
| Welsh | cy |
| Danish | da |
| Dargwa | dar |
| German | de |
| English | en |
| Spanish | es |
| Estonian | et |
| Persian (Farsi) | fa |
| French | fr |
| Irish | ga |
| Goan Konkani | gom |
| Hindi | hi |
| Croatian | hr |
| Hungarian | hu |
| Indonesian | id |
| Ingush | inh |
| Icelandic | is |
| Italian | it |
| Japanese | ja |
| Kabardian | kbd |
| Kannada | kn |
| Korean | ko |
| Kurdish | ku |
| Latin | la |
| Lak | lbe |
| Lezghian | lez |
| Lithuanian | lt |
| Latvian | lv |
| Magahi | mah |
| Maithili | mai |
| Maori | mi |
| Mongolian | mn |
| Marathi | mr |
| Malay | ms |
| Maltese | mt |
| Nepali | ne |
| Newari | new |
| Dutch | nl |
| Norwegian | no |
| Occitan | oc |
| Pali | pi |
| Polish | pl |
| Portuguese | pt |
| Romanian | ro |
| Russian | ru |
| Serbian (cyrillic) | rs_cyrillic |
| Serbian (latin) | rs_latin |
| Nagpuri | sck |
| Slovak | sk |
| Slovenian | sl |
| Albanian | sq |
| Swedish | sv |
| Swahili | sw |
| Tamil | ta |
| Tabassaran | tab |
| Telugu | te |
| Thai | th |
| Tajik | tjk |
| Tagalog | tl |
| Turkish | tr |
| Uyghur | ug |
| Ukranian | uk |
| Urdu | ur |
| Uzbek | uz |
| Vietnamese | vi |
> Ref: [Supported Languages](https://www.jaided.ai/easyocr/) .
</details>
## P2T 网页版
所有人都可以免费使用 **[P2T网页版](https://p2t.breezedeus.com)**,每人每天可以免费识别 10000 个字符,正常使用应该够用了。*请不要批量调用接口,机器资源有限,批量调用会导致其他人无法使用服务。*
受限于机器资源,网页版当前只支持**简体中文和英文**,要尝试其他语言上的效果,请使用以下的**在线 Demo**。
## 在线 Demo 🤗
也可以使用 **[在线 Demo](https://huggingface.co/spaces/breezedeus/Pix2Text-Demo)**(无法科学上网可以使用 [国内镜像](https://hf.qhduan.com/spaces/breezedeus/Pix2Text-Demo)) 尝试 **P2T** 在不同语言上的效果。但在线 Demo 使用的硬件配置较低,速度会较慢。如果是简体中文或者英文图片,建议使用 **[P2T网页版](https://p2t.breezedeus.com)**。
## 示例
参见:[Pix2Text在线文档/示例](https://pix2text.readthedocs.io/zh-cn/stable/examples/)。
## 使用说明
参见:[Pix2Text在线文档/使用说明](https://pix2text.readthedocs.io/zh-cn/stable/usage/)。
## 模型下载
参见:[Pix2Text在线文档/模型](https://pix2text.readthedocs.io/zh-cn/stable/models/)。
## 安装
嗯,顺利的话一行命令即可。
```bash
pip install pix2text
```
如果需要识别**英文**与**简体中文**之外的文字,请使用以下命令安装额外的包:
```bash
pip install pix2text[multilingual]
```
安装速度慢的话,可以指定国内的安装源,如使用阿里云的安装源:
```bash
pip install pix2text -i https://mirrors.aliyun.com/pypi/simple
```
<br/>
更多说明参见:[Pix2Text在线文档/安装](https://pix2text.readthedocs.io/zh-cn/stable/install/)。
## 命令行工具
参见:[Pix2Text在线文档/命令行工具](https://pix2text.readthedocs.io/zh-cn/stable/command/)。
## HTTP 服务
参见:[Pix2Text在线文档/命令行工具/开启服务](https://pix2text.readthedocs.io/zh-cn/stable/command/)。
## Mac 桌面客户端
请参考 [Pix2Text-Mac](https://github.com/breezedeus/Pix2Text-Mac) 安装 Pix2Text 的 MacOS 桌面客户端。
<div align="center">
<img src="https://github.com/breezedeus/Pix2Text-Mac/raw/main/assets/on_menu_bar.jpg" alt="Pix2Text Mac 客户端" width="400px"/>
</div>
## 给作者来杯咖啡
开源不易,如果此项目对您有帮助,可以考虑 [给作者加点油🥤,鼓鼓气💪🏻](https://www.breezedeus.com/article/buy-me-coffee) 。
---
官方代码库:[https://github.com/breezedeus/pix2text](https://github.com/breezedeus/pix2text) 。
Pix2Text (P2T) 更多信息:[https://www.breezedeus.com/article/pix2text_cn](https://www.breezedeus.com/article/pix2text_cn) 。
|