Skip to content

Commit

Permalink
Merge pull request #280 from breezedeus/dev
Browse files Browse the repository at this point in the history
V2.2.4
  • Loading branch information
breezedeus authored Sep 26, 2023
2 parents 7c21696 + 3baa531 commit f036947
Show file tree
Hide file tree
Showing 29 changed files with 1,214 additions and 242 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ TRAIN_CONFIG_FP = docs/examples/train_config.json
train:
cnocr train -m $(MODEL_NAME) --index-dir $(INDEX_DIR) --train-config-fp $(TRAIN_CONFIG_FP)

# 训练模型
train-number-pure:
cnocr train -m number-$(MODEL_NAME) --index-dir data/number-pure-index --train-config-fp docs/examples/train_config_number.json

# 在测试集上评估模型,所有badcases的具体信息会存放到文件夹 `evaluate/$(MODEL_NAME)` 中
evaluate:
cnocr evaluate --model-name $(MODEL_NAME) -i data/test/dev.tsv \
Expand All @@ -34,7 +38,7 @@ package:
rm -rf build
python setup.py sdist bdist_wheel

VERSION = 2.2.3.2
VERSION = 2.2.4
upload:
python -m twine upload dist/cnocr-$(VERSION)* --verbose

Expand Down
63 changes: 44 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
[🛠️ 安装](https://cnocr.readthedocs.io/zh/latest/install/) |
[🧳 可用模型](https://cnocr.readthedocs.io/zh/latest/models/) |
[🕹 模型训练](https://cnocr.readthedocs.io/zh/latest/train/) |
[🛀🏻 在线Demo](https://huggingface.co/spaces/breezedeus/cnocr) |
[🛀🏻 在线Demo](https://huggingface.co/spaces/breezedeus/CnOCR-Demo) |
[💬 交流群](https://cnocr.readthedocs.io/zh/latest/contact/)

</div>
Expand All @@ -28,6 +28,7 @@
</div>

# CnOCR

<div align="center">
<strong>Tech should serve the people, not enslave them!</strong>
<br>
Expand All @@ -36,6 +37,17 @@
---
</div>

### [Update 2023.09.27]:发布 V2.2.4

主要变更:
* 加入了纯数字识别系列模型 `number-*`(见 [识别模型列表](#可使用的识别模型)),可用于纯数字识别场景,如银行卡识别、身份证识别、硬币年份识别等;
* 对各个包的新版做了接口适配,如 `pytorch_lightning``onnxruntime``pillow`等;
* 优化了训练过程使用的数据增强方式,并借鉴了**Nougat** 中的数据增强方法;
* 增加了对更大模型的支持,如 `densenet-lite-666``gru_large` 等;
* 以前的 `*-gru` 系列模型,现在也有 ONNX 版了;
* 修复了一堆的bugs,如 `val-complete_match-epoch` 训练过程一直为 `0` 等。


[**CnOCR**](https://github.com/breezedeus/cnocr)**Python 3** 下的**文字识别****Optical Character Recognition**,简称**OCR**)工具包,支持**简体中文****繁体中文**(部分模型)、**英文****数字**的常见字符识别,支持竖排文字的识别。自带了**20+个** [训练好的模型](https://cnocr.readthedocs.io/zh/latest/models/),适用于不同应用场景,安装后即可直接使用。同时,CnOCR也提供简单的[训练命令](https://cnocr.readthedocs.io/zh/latest/train/)供使用者训练自己的模型。欢迎扫码加小助手为好友,备注 `ocr`,小助手会定期统一邀请大家入群:

<div align="center">
Expand All @@ -55,9 +67,7 @@

以下是一些不同场景的调用示例。

## 在 Cloud IDE 中预览

[https://idegithub.com/breezedeus/CnOCR](https://idegithub.com/breezedeus/CnOCR)

## 不同场景的调用示例

Expand Down Expand Up @@ -227,18 +237,26 @@ print(out)
嗯,顺利的话一行命令即可。

```bash
pip install cnocr
$ pip install cnocr[ort-cpu]
```

如果是 **GPU** 环境使用 ONNX 模型,请使用以下命令进行安装:

```bash
$ pip install cnocr[ort-gpu]
```



安装速度慢的话,可以指定国内的安装源,如使用豆瓣源:

```bash
pip install cnocr -i https://pypi.doubanio.com/simple
$ pip install cnocr[ort-cpu] -i https://mirrors.aliyun.com/pypi/simple
```

> **Note**
>
> 请使用 **Python3**(3.6以及之后版本应该都行),没测过Python2下是否ok。
> 请使用 **Python3**(3.7.\*~3.10.\*之间的版本应该都行),没测过Python2下是否ok。
更多说明可见 [安装文档](https://cnocr.readthedocs.io/zh/latest/install/)

Expand Down Expand Up @@ -315,6 +333,8 @@ print(ocr_out)

### 可使用的检测模型

参考CnSTD的下载方式。

| `det_model_name` | PyTorch 版本 | ONNX 版本 | 模型原始来源 | 模型文件大小 | 支持语言 | 是否支持竖排文字识别 |
| ------------------------------------------------------------ | ------------ | --------- | ------------ | ------------ | ------------------------------ | -------------------- |
| db_shufflenet_v2 || X | cnocr | 18 M | 简体中文、繁体中文、英文、数字 ||
Expand All @@ -332,19 +352,24 @@ print(ocr_out)

### 可使用的识别模型

| `rec_model_name` | PyTorch 版本 | ONNX 版本 | 模型原始来源 | 模型文件大小 | 支持语言 | 是否支持竖排文字识别 |
| ------------------------- | ------------ | --------- | ------------ | ------------ | ------------------------ | -------------------- |
| densenet_lite_114-fc ||| cnocr | 4.9 M | 简体中文、英文、数字 | X |
| densenet_lite_124-fc ||| cnocr | 5.1 M | 简体中文、英文、数字 | X |
| densenet_lite_134-fc ||| cnocr | 5.4 M | 简体中文、英文、数字 | X |
| densenet_lite_136-fc ||| cnocr | 5.9 M | 简体中文、英文、数字 | X |
| densenet_lite_134-gru || X | cnocr | 11 M | 简体中文、英文、数字 | X |
| densenet_lite_136-gru || X | cnocr | 12 M | 简体中文、英文、数字 | X |
| ch_PP-OCRv3 | X || ppocr | 10 M | 简体中文、英文、数字 ||
| ch_ppocr_mobile_v2.0 | X || ppocr | 4.2 M | 简体中文、英文、数字 ||
| **en_PP-OCRv3** | X || ppocr | 8.5 M | **英文**、数字 ||
| **en_number_mobile_v2.0** | X || ppocr | 1.8 M | **英文**、数字 ||
| **chinese_cht_PP-OCRv3** | X || ppocr | 11 M | **繁体中文**、英文、数字 | X |
| `rec_model_name` | PyTorch 版本 | ONNX 版本 | 模型原始来源 | 模型文件大小 | 支持语言 | 是否支持竖排文字识别 |
| ------------------------------------------------------------ | ------------ | --------- | ------------ | ------------ | ----------------------------------- | -------------------- |
| **number-densenet_lite_136-fc** 🆕 ||| cnocr | 2.7 M | **纯数字**(仅包含 `0~9` 十个数字) | X |
| **number-densenet_lite_136-gru** 🆕 <br /> ([星球会员](https://t.zsxq.com/FEYZRJQ)专享) ||| cnocr | 5.5 M | **纯数字**(仅包含 `0~9` 十个数字) | X |
| **number-densenet_lite_666-gru_large** 🆕 <br />(Coming Soon) ||| cnocr | M | **纯数字**(仅包含 `0~9` 十个数字) | X |
| densenet_lite_114-fc ||| cnocr | 4.9 M | 简体中文、英文、数字 | X |
| densenet_lite_124-fc ||| cnocr | 5.1 M | 简体中文、英文、数字 | X |
| densenet_lite_134-fc ||| cnocr | 5.4 M | 简体中文、英文、数字 | X |
| densenet_lite_136-fc ||| cnocr | 5.9 M | 简体中文、英文、数字 | X |
| densenet_lite_134-gru ||| cnocr | 11 M | 简体中文、英文、数字 | X |
| densenet_lite_136-gru ||| cnocr | 12 M | 简体中文、英文、数字 | X |
| ch_PP-OCRv3 | X || ppocr | 10 M | 简体中文、英文、数字 ||
| ch_ppocr_mobile_v2.0 | X || ppocr | 4.2 M | 简体中文、英文、数字 ||
| en_PP-OCRv3 | X || ppocr | 8.5 M | **英文**、数字 ||
| en_number_mobile_v2.0 | X || ppocr | 1.8 M | **英文**、数字 ||
| chinese_cht_PP-OCRv3 | X || ppocr | 11 M | **繁体中文**、英文、数字 | X |



## 未来工作

Expand Down
27 changes: 22 additions & 5 deletions README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@
---
</div>

### [Update 2023.09.27]: Released V2.2.4

Main Changes:
* Added a series of pure numeric recognition models `number-*` (see [Pre-trained Recognition Models](#pre-trained-recognition-models)), suitable for pure numeric recognition scenarios such as bank card recognition, ID card recognition, coin year recognition, etc.
* Adapted with the new versions of various packages, such as `pytorch_lightning`, `onnxruntime`, `pillow`, etc.
* Optimized the data augmentation methods used in the training process and adopted the data augmentation methods from **Nougat**.
* Added support for larger models, such as `densenet-lite-666`, `gru_large`, etc.
* The previous `*-gru` series models are now also available in ONNX version.
* Fixed a bunch of bugs, such as `val-complete_match-epoch` always being `0` during the training process.


[**CnOCR**](https://github.com/breezedeus/cnocr) is an **Optical Character Recognition (OCR)** toolkit for **Python 3**. It supports recognition of common characters in **English and numbers**, **Simplified Chinese**, **Traditional Chinese** (some models), and **vertical text** recognition. It comes with [**20+ well-trained models**](https://cnocr.readthedocs.io/zh/latest/models/) for different application scenarios and can be used directly after installation. Also, CnOCR provides simple training [commands](https://cnocr.readthedocs.io/zh/latest/train/) for users to train their own models. Welcome to join the WeChat contact group.

<div align="center">
Expand All @@ -54,9 +65,6 @@ Starting from **V2.2**, **CnOCR** internally uses the text detection engine **[C

Here are some examples of usages for different scenarios.

## Start On Cloud IDE

[https://idegithub.com/breezedeus/CnOCR](https://idegithub.com/breezedeus/CnOCR)

## Usages for Different Scenarios

Expand Down Expand Up @@ -221,13 +229,19 @@ print(out)
Well, one line of command is enough if it goes well.

```bash
pip install cnocr
$ pip install cnocr[ort-cpu]
```

If you are using a **GPU** environment with an ONNX model, please install using the following command:

```bash
$ pip install cnocr[ort-gpu]
```

If the installation is slow, you can specify a domestic installation source, such as using the Douban source:

```bash
pip install cnocr -i https://pypi.doubanio.com/simple
$ pip install cnocr -i https://mirrors.aliyun.com/pypi/simple
```

> **Note**
Expand All @@ -247,6 +261,9 @@ More instructions can be found in the [installation documentation](https://cnocr

| `det_model_name` | PyTorch Version | ONNX Version | Model original source | Model File Size | Supported Language | Whether to support vertical text detection |
| ------------------------------------------------------------ | ------------ | --------- | ------------ | ------------ | ------------------------------ | -------------------- |
| **number-densenet_lite_136-fc** 🆕 ||| cnocr | 2.7 M | **Pure Numeric** (contains only the ten digits `0~9`) | X |
| **number-densenet_lite_136-gru** 🆕 <br /> ([Planet Members](https://t.zsxq.com/FEYZRJQ) Only) ||| cnocr | 5.5 M | **Pure Numeric** (contains only the ten digits `0~9`) | X |
| **number-densenet_lite_666-gru_large** 🆕 <br />(Coming Soon) ||| cnocr | 56 M | **Pure Numeric** (contains only the ten digits `0~9`) | X |
| **en_PP-OCRv3_det** | X || ppocr | 2.3 M | **English**、Numbers ||
| db_shufflenet_v2 || X | cnocr | 18 M | Simplified Chinese, Traditional Chinese, English, Numbers ||
| **db_shufflenet_v2_small** || X | cnocr | 12 M | Simplified Chinese, Traditional Chinese, English, Numbers ||
Expand Down
2 changes: 1 addition & 1 deletion cnocr/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
# specific language governing permissions and limitations
# under the License.

__version__ = '2.2.3.2'
__version__ = '2.2.4'
Loading

0 comments on commit f036947

Please sign in to comment.