openocr-python 0.0.9__py3-none-any.whl → 0.1.0.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openocr/__init__.py +35 -1
- openocr/configs/dataset/rec/evaluation.yaml +41 -0
- openocr/configs/dataset/rec/ltb.yaml +9 -0
- openocr/configs/dataset/rec/mjsynth.yaml +11 -0
- openocr/configs/dataset/rec/openvino.yaml +25 -0
- openocr/configs/dataset/rec/ost.yaml +17 -0
- openocr/configs/dataset/rec/synthtext.yaml +7 -0
- openocr/configs/dataset/rec/test.yaml +77 -0
- openocr/configs/dataset/rec/textocr.yaml +13 -0
- openocr/configs/dataset/rec/textocr_horizontal.yaml +13 -0
- openocr/configs/dataset/rec/union14m_b.yaml +47 -0
- openocr/configs/dataset/rec/union14m_l_filtered.yaml +35 -0
- openocr/configs/rec/cmer/cmer.yml +127 -0
- openocr/configs/rec/mdiff4str/svtrv2_mdiffdecoder_base.yml +152 -0
- openocr/configs/rec/mdiff4str/svtrv2_mdiffdecoder_small.yml +152 -0
- openocr/configs/rec/unirec/focalsvtr_ardecoder_unirec.yml +114 -0
- openocr/configs/rec/unirec/opendoc_pipeline.yml +105 -0
- openocr/demo_gradio.py +28 -8
- openocr/demo_opendoc.py +572 -0
- openocr/demo_unirec.py +392 -0
- openocr/opendet/losses/__init__.py +5 -7
- openocr/opendet/preprocess/crop_resize.py +2 -1
- openocr/openocr.py +685 -0
- openocr/openrec/losses/__init__.py +8 -3
- openocr/openrec/losses/cmer_loss.py +12 -0
- openocr/openrec/losses/mdiff_loss.py +11 -0
- openocr/openrec/losses/unirec_loss.py +12 -0
- openocr/openrec/metrics/__init__.py +4 -1
- openocr/openrec/metrics/rec_metric_cmer.py +328 -0
- openocr/openrec/modeling/cmer_modeling/modeling_cmer.py +643 -0
- openocr/openrec/modeling/decoders/__init__.py +1 -0
- openocr/openrec/modeling/decoders/ctc_decoder.py +1 -1
- openocr/openrec/modeling/decoders/dan_decoder.py +4 -4
- openocr/openrec/modeling/decoders/dptr_parseq_clip_b_decoder.py +1563 -1398
- openocr/openrec/modeling/decoders/mdiff_decoder.py +587 -0
- openocr/openrec/modeling/decoders/smtr_decoder.py +99 -48
- openocr/openrec/modeling/unirec_modeling/configuration_unirec.py +166 -0
- openocr/openrec/modeling/unirec_modeling/modeling_unirec.py +433 -0
- openocr/openrec/optimizer/__init__.py +4 -3
- openocr/openrec/optimizer/lr.py +49 -0
- openocr/openrec/postprocess/__init__.py +2 -0
- openocr/openrec/postprocess/abinet_postprocess.py +1 -1
- openocr/openrec/postprocess/ar_postprocess.py +1 -1
- openocr/openrec/postprocess/cmer_postprocess.py +86 -0
- openocr/openrec/postprocess/cppd_postprocess.py +1 -1
- openocr/openrec/postprocess/igtr_postprocess.py +1 -1
- openocr/openrec/postprocess/lister_postprocess.py +1 -1
- openocr/openrec/postprocess/mgp_postprocess.py +1 -1
- openocr/openrec/postprocess/nrtr_postprocess.py +2 -2
- openocr/openrec/postprocess/smtr_postprocess.py +1 -1
- openocr/openrec/postprocess/srn_postprocess.py +1 -1
- openocr/openrec/postprocess/unirec_postprocess.py +58 -0
- openocr/openrec/postprocess/visionlan_postprocess.py +1 -1
- openocr/openrec/preprocess/__init__.py +5 -0
- openocr/openrec/preprocess/ce_label_encode.py +1 -1
- openocr/openrec/preprocess/cmer_label_encode.py +1025 -0
- openocr/openrec/preprocess/ctc_label_encode.py +1 -1
- openocr/openrec/preprocess/dptr_label_encode.py +177 -157
- openocr/openrec/preprocess/igtr_label_encode.py +4 -2
- openocr/openrec/preprocess/mdiff_label_encode.py +312 -0
- openocr/openrec/preprocess/rec_aug.py +128 -2
- openocr/openrec/preprocess/resize.py +57 -0
- openocr/openrec/preprocess/unirec_label_encode.py +62 -0
- openocr/tools/data/__init__.py +78 -55
- openocr/tools/data/cmer_web_dataset.py +310 -0
- openocr/tools/data/native_size_dataset.py +753 -0
- openocr/tools/data/native_size_sampler.py +158 -0
- openocr/tools/data/ratio_dataset_tvresize.py +2 -0
- openocr/tools/data/ratio_sampler.py +2 -1
- openocr/tools/download/download_dataset.py +38 -0
- openocr/tools/download/utils.py +28 -0
- openocr/tools/download_example_images.py +236 -0
- openocr/tools/engine/trainer.py +155 -39
- openocr/tools/eval_rec_all_ch.py +2 -2
- openocr/tools/infer_det.py +20 -2
- openocr/tools/infer_doc.py +898 -0
- openocr/tools/infer_doc_onnx.py +1172 -0
- openocr/tools/infer_e2e.py +27 -10
- openocr/tools/infer_rec.py +64 -15
- openocr/tools/infer_unirec_onnx.py +730 -0
- openocr/tools/to_markdown.py +468 -0
- openocr/tools/utils/ckpt.py +17 -5
- openocr/tools/utils/opendoc_onnx_utils/utils.py +1052 -0
- openocr_python-0.1.0.dev0.dist-info/METADATA +324 -0
- {openocr_python-0.0.9.dist-info → openocr_python-0.1.0.dev0.dist-info}/RECORD +89 -45
- {openocr_python-0.0.9.dist-info → openocr_python-0.1.0.dev0.dist-info}/WHEEL +1 -1
- openocr_python-0.1.0.dev0.dist-info/entry_points.txt +2 -0
- openocr_python-0.0.9.dist-info/METADATA +0 -149
- /openocr_python-0.0.9.dist-info/LICENCE → /openocr_python-0.1.0.dev0.dist-info/licenses/LICENSE +0 -0
- {openocr_python-0.0.9.dist-info → openocr_python-0.1.0.dev0.dist-info}/top_level.txt +0 -0
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: openocr-python
|
|
3
|
-
Version: 0.0.9
|
|
4
|
-
Summary: a python package for openocr, which is used to help developers quickly deploy OCR algorithms implemented in the openocr framework.
|
|
5
|
-
Home-page: https://github.com/Topdu/OpenOCR
|
|
6
|
-
Author: OpenOCR
|
|
7
|
-
Author-email: 784990967@qq.com
|
|
8
|
-
Project-URL: Source Code, https://github.com/Topdu/OpenOCR
|
|
9
|
-
Keywords: python,OCR,STR,OpenOCR,openocr
|
|
10
|
-
Classifier: Development Status :: 1 - Planning
|
|
11
|
-
Classifier: Intended Audience :: Developers
|
|
12
|
-
Classifier: Programming Language :: Python :: 3
|
|
13
|
-
Classifier: Operating System :: Unix
|
|
14
|
-
Classifier: Operating System :: Microsoft :: Windows
|
|
15
|
-
Description-Content-Type: text/markdown
|
|
16
|
-
License-File: LICENCE
|
|
17
|
-
Requires-Dist: opencv-python<=4.6.0.66
|
|
18
|
-
Requires-Dist: tqdm
|
|
19
|
-
Requires-Dist: rapidfuzz
|
|
20
|
-
Requires-Dist: lmdb
|
|
21
|
-
Requires-Dist: imgaug
|
|
22
|
-
Requires-Dist: pyyaml
|
|
23
|
-
Requires-Dist: pyclipper
|
|
24
|
-
|
|
25
|
-
# OpenOCR: a general OCR system with accuracy and efficiency
|
|
26
|
-
|
|
27
|
-
## Recent Updates
|
|
28
|
-
|
|
29
|
-
- **0.0.9**: Fixing torch inference bug.
|
|
30
|
-
- **0.0.8**: Automatic Downloading ONNX model.
|
|
31
|
-
- **0.0.7**: Releasing the feature of [ONNX model export for wider compatibility](#export-onnx-model).
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
## Quick Start
|
|
35
|
-
|
|
36
|
-
**Note**: OpenOCR supports inference using both the ONNX and Torch frameworks, with the dependency environments for the two frameworks being isolated. When using ONNX for inference, there is no need to install Torch, and vice versa.
|
|
37
|
-
|
|
38
|
-
### 1. ONNX Inference
|
|
39
|
-
|
|
40
|
-
#### Install OpenOCR and Dependencies:
|
|
41
|
-
|
|
42
|
-
```shell
|
|
43
|
-
pip install openocr-python
|
|
44
|
-
pip install onnxruntime
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
#### Usage:
|
|
48
|
-
|
|
49
|
-
```python
|
|
50
|
-
from openocr import OpenOCR
|
|
51
|
-
onnx_engine = OpenOCR(backend='onnx', device='cpu')
|
|
52
|
-
img_path = '/path/img_path or /path/img_file'
|
|
53
|
-
result, elapse = onnx_engine(img_path)
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### 2. Pytorch inference
|
|
57
|
-
|
|
58
|
-
#### Dependencies:
|
|
59
|
-
|
|
60
|
-
- [PyTorch](http://pytorch.org/) version >= 1.13.0
|
|
61
|
-
- Python version >= 3.7
|
|
62
|
-
|
|
63
|
-
```shell
|
|
64
|
-
conda create -n openocr python==3.8
|
|
65
|
-
conda activate openocr
|
|
66
|
-
# install gpu version torch
|
|
67
|
-
conda install pytorch==2.2.0 torchvision==0.17.0 torchaudio==2.2.0 pytorch-cuda=11.8 -c pytorch -c nvidia
|
|
68
|
-
# or cpu version
|
|
69
|
-
conda install pytorch torchvision torchaudio cpuonly -c pytorch
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
After installing dependencies, the following two installation methods are available. Either one can be chosen.
|
|
73
|
-
|
|
74
|
-
#### 2.1. Python Modules
|
|
75
|
-
|
|
76
|
-
**Install OpenOCR**:
|
|
77
|
-
|
|
78
|
-
```shell
|
|
79
|
-
pip install openocr-python
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
**Usage**:
|
|
83
|
-
|
|
84
|
-
```python
|
|
85
|
-
from openocr import OpenOCR
|
|
86
|
-
engine = OpenOCR()
|
|
87
|
-
img_path = '/path/img_path or /path/img_file'
|
|
88
|
-
result, elapse = engine(img_path)
|
|
89
|
-
|
|
90
|
-
# Server mode
|
|
91
|
-
# engine = OpenOCR(mode='server')
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
#### 2.2. Clone this repository:
|
|
95
|
-
|
|
96
|
-
```shell
|
|
97
|
-
git clone https://github.com/Topdu/OpenOCR.git
|
|
98
|
-
cd OpenOCR
|
|
99
|
-
pip install -r requirements.txt
|
|
100
|
-
wget https://github.com/Topdu/OpenOCR/releases/download/develop0.0.1/openocr_det_repvit_ch.pth
|
|
101
|
-
wget https://github.com/Topdu/OpenOCR/releases/download/develop0.0.1/openocr_repsvtr_ch.pth
|
|
102
|
-
# Rec Server model
|
|
103
|
-
# wget https://github.com/Topdu/OpenOCR/releases/download/develop0.0.1/openocr_svtrv2_ch.pth
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
**Usage**:
|
|
107
|
-
|
|
108
|
-
```shell
|
|
109
|
-
# OpenOCR system: Det + Rec model
|
|
110
|
-
python tools/infer_e2e.py --img_path=/path/img_fold or /path/img_file
|
|
111
|
-
# Det model
|
|
112
|
-
python tools/infer_det.py --c ./configs/det/dbnet/repvit_db.yml --o Global.infer_img=/path/img_fold or /path/img_file
|
|
113
|
-
# Rec model
|
|
114
|
-
python tools/infer_rec.py --c ./configs/rec/svtrv2/repsvtr_ch.yml --o Global.infer_img=/path/img_fold or /path/img_file
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
##### Export ONNX model
|
|
118
|
-
|
|
119
|
-
```shell
|
|
120
|
-
pip install onnx
|
|
121
|
-
python tools/toonnx.py --c configs/rec/svtrv2/repsvtr_ch.yml --o Global.device=cpu
|
|
122
|
-
python tools/toonnx.py --c configs/det/dbnet/repvit_db.yml --o Global.device=cpu
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
##### Inference with ONNXRuntime
|
|
126
|
-
|
|
127
|
-
```shell
|
|
128
|
-
pip install onnxruntime
|
|
129
|
-
# OpenOCR system: Det + Rec model
|
|
130
|
-
python tools/infer_e2e.py --img_path=/path/img_fold or /path/img_file --backend=onnx --device=cpu
|
|
131
|
-
# Det model
|
|
132
|
-
python tools/infer_det.py --c ./configs/det/dbnet/repvit_db.yml --o Global.backend=onnx Global.device=cpu Global.infer_img=/path/img_fold or /path/img_file
|
|
133
|
-
# Rec model
|
|
134
|
-
python tools/infer_rec.py --c ./configs/rec/svtrv2/repsvtr_ch.yml --o Global.backend=onnx Global.device=cpu Global.infer_img=/path/img_fold or /path/img_file
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
#### Local Demo
|
|
138
|
-
|
|
139
|
-
```shell
|
|
140
|
-
pip install gradio==4.20.0
|
|
141
|
-
wget https://github.com/Topdu/OpenOCR/releases/download/develop0.0.1/OCR_e2e_img.tar
|
|
142
|
-
tar xf OCR_e2e_img.tar
|
|
143
|
-
# start demo
|
|
144
|
-
python demo_gradio.py
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
## More detail in [OpenOCR Documentation](https://github.com/Topdu/OpenOCR)
|
/openocr_python-0.0.9.dist-info/LICENCE → /openocr_python-0.1.0.dev0.dist-info/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|