openocr-python


Nameopenocr-python JSON
Version 0.0.10 PyPI version JSON
download
home_pagehttps://github.com/Topdu/OpenOCR
Summarya python package for openocr, which is used to help developers quickly deploy OCR algorithms implemented in the openocr framework.
upload_time2025-07-10 11:23:59
maintainerNone
docs_urlNone
authorOpenOCR
requires_pythonNone
licenseNone
keywords python ocr str openocr openocr
VCS
bugtrack_url
requirements imgaug lmdb numpy opencv-python pyclipper pyyaml rapidfuzz tqdm
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # OpenOCR: a general OCR system with accuracy and efficiency

## Recent Updates
- **0.0.10**: Remove OpenCV version restrictions.
- **0.0.9**: Fixing torch inference bug.
- **0.0.8**: Automatic Downloading ONNX model.
- **0.0.7**: Releasing the feature of [ONNX model export for wider compatibility](#export-onnx-model).


## Quick Start

**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.

### 1. ONNX Inference

#### Install OpenOCR and Dependencies:

```shell
pip install openocr-python
pip install onnxruntime
```

#### Usage:

```python
from openocr import OpenOCR
onnx_engine = OpenOCR(backend='onnx', device='cpu')
img_path = '/path/img_path or /path/img_file'
result, elapse = onnx_engine(img_path)
```

### 2. Pytorch inference

#### Dependencies:

- [PyTorch](http://pytorch.org/) version >= 1.13.0
- Python version >= 3.7

```shell
conda create -n openocr python==3.8
conda activate openocr
# install gpu version torch
conda install pytorch==2.2.0 torchvision==0.17.0 torchaudio==2.2.0 pytorch-cuda=11.8 -c pytorch -c nvidia
# or cpu version
conda install pytorch torchvision torchaudio cpuonly -c pytorch
```

After installing dependencies, the following two installation methods are available. Either one can be chosen.

#### 2.1. Python Modules

**Install OpenOCR**:

```shell
pip install openocr-python
```

**Usage**:

```python
from openocr import OpenOCR
engine = OpenOCR()
img_path = '/path/img_path or /path/img_file'
result, elapse = engine(img_path)

# Server mode
# engine = OpenOCR(mode='server')
```

#### 2.2. Clone this repository:

```shell
git clone https://github.com/Topdu/OpenOCR.git
cd OpenOCR
pip install -r requirements.txt
wget https://github.com/Topdu/OpenOCR/releases/download/develop0.0.1/openocr_det_repvit_ch.pth
wget https://github.com/Topdu/OpenOCR/releases/download/develop0.0.1/openocr_repsvtr_ch.pth
# Rec Server model
# wget https://github.com/Topdu/OpenOCR/releases/download/develop0.0.1/openocr_svtrv2_ch.pth
```

**Usage**:

```shell
# OpenOCR system: Det + Rec model
python tools/infer_e2e.py --img_path=/path/img_fold or /path/img_file
# Det model
python tools/infer_det.py --c ./configs/det/dbnet/repvit_db.yml --o Global.infer_img=/path/img_fold or /path/img_file
# Rec model
python tools/infer_rec.py --c ./configs/rec/svtrv2/repsvtr_ch.yml --o Global.infer_img=/path/img_fold or /path/img_file
```

##### Export ONNX model

```shell
pip install onnx
python tools/toonnx.py --c configs/rec/svtrv2/repsvtr_ch.yml --o Global.device=cpu
python tools/toonnx.py --c configs/det/dbnet/repvit_db.yml --o Global.device=cpu
```

##### Inference with ONNXRuntime

```shell
pip install onnxruntime
# OpenOCR system: Det + Rec model
python tools/infer_e2e.py --img_path=/path/img_fold or /path/img_file --backend=onnx --device=cpu
# Det model
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
# Rec model
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
```

#### Local Demo

```shell
pip install gradio==4.20.0
wget https://github.com/Topdu/OpenOCR/releases/download/develop0.0.1/OCR_e2e_img.tar
tar xf OCR_e2e_img.tar
# start demo
python demo_gradio.py
```



## More detail in [OpenOCR Documentation](https://github.com/Topdu/OpenOCR)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Topdu/OpenOCR",
    "name": "openocr-python",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "python, OCR, STR, OpenOCR, openocr",
    "author": "OpenOCR",
    "author_email": "784990967@qq.com",
    "download_url": null,
    "platform": null,
    "description": "# OpenOCR: a general OCR system with accuracy and efficiency\n\n## Recent Updates\n- **0.0.10**: Remove OpenCV version restrictions.\n- **0.0.9**: Fixing torch inference bug.\n- **0.0.8**: Automatic Downloading ONNX model.\n- **0.0.7**: Releasing the feature of [ONNX model export for wider compatibility](#export-onnx-model).\n\n\n## Quick Start\n\n**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.\n\n### 1. ONNX Inference\n\n#### Install OpenOCR and Dependencies:\n\n```shell\npip install openocr-python\npip install onnxruntime\n```\n\n#### Usage:\n\n```python\nfrom openocr import OpenOCR\nonnx_engine = OpenOCR(backend='onnx', device='cpu')\nimg_path = '/path/img_path or /path/img_file'\nresult, elapse = onnx_engine(img_path)\n```\n\n### 2. Pytorch inference\n\n#### Dependencies:\n\n- [PyTorch](http://pytorch.org/) version >= 1.13.0\n- Python version >= 3.7\n\n```shell\nconda create -n openocr python==3.8\nconda activate openocr\n# install gpu version torch\nconda install pytorch==2.2.0 torchvision==0.17.0 torchaudio==2.2.0 pytorch-cuda=11.8 -c pytorch -c nvidia\n# or cpu version\nconda install pytorch torchvision torchaudio cpuonly -c pytorch\n```\n\nAfter installing dependencies, the following two installation methods are available. Either one can be chosen.\n\n#### 2.1. Python Modules\n\n**Install OpenOCR**:\n\n```shell\npip install openocr-python\n```\n\n**Usage**:\n\n```python\nfrom openocr import OpenOCR\nengine = OpenOCR()\nimg_path = '/path/img_path or /path/img_file'\nresult, elapse = engine(img_path)\n\n# Server mode\n# engine = OpenOCR(mode='server')\n```\n\n#### 2.2. Clone this repository:\n\n```shell\ngit clone https://github.com/Topdu/OpenOCR.git\ncd OpenOCR\npip install -r requirements.txt\nwget https://github.com/Topdu/OpenOCR/releases/download/develop0.0.1/openocr_det_repvit_ch.pth\nwget https://github.com/Topdu/OpenOCR/releases/download/develop0.0.1/openocr_repsvtr_ch.pth\n# Rec Server model\n# wget https://github.com/Topdu/OpenOCR/releases/download/develop0.0.1/openocr_svtrv2_ch.pth\n```\n\n**Usage**:\n\n```shell\n# OpenOCR system: Det + Rec model\npython tools/infer_e2e.py --img_path=/path/img_fold or /path/img_file\n# Det model\npython tools/infer_det.py --c ./configs/det/dbnet/repvit_db.yml --o Global.infer_img=/path/img_fold or /path/img_file\n# Rec model\npython tools/infer_rec.py --c ./configs/rec/svtrv2/repsvtr_ch.yml --o Global.infer_img=/path/img_fold or /path/img_file\n```\n\n##### Export ONNX model\n\n```shell\npip install onnx\npython tools/toonnx.py --c configs/rec/svtrv2/repsvtr_ch.yml --o Global.device=cpu\npython tools/toonnx.py --c configs/det/dbnet/repvit_db.yml --o Global.device=cpu\n```\n\n##### Inference with ONNXRuntime\n\n```shell\npip install onnxruntime\n# OpenOCR system: Det + Rec model\npython tools/infer_e2e.py --img_path=/path/img_fold or /path/img_file --backend=onnx --device=cpu\n# Det model\npython 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\n# Rec model\npython 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\n```\n\n#### Local Demo\n\n```shell\npip install gradio==4.20.0\nwget https://github.com/Topdu/OpenOCR/releases/download/develop0.0.1/OCR_e2e_img.tar\ntar xf OCR_e2e_img.tar\n# start demo\npython demo_gradio.py\n```\n\n\n\n## More detail in [OpenOCR Documentation](https://github.com/Topdu/OpenOCR)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "a python package for openocr, which is used to help developers quickly deploy OCR algorithms implemented in the openocr framework.",
    "version": "0.0.10",
    "project_urls": {
        "Homepage": "https://github.com/Topdu/OpenOCR",
        "Source Code": "https://github.com/Topdu/OpenOCR"
    },
    "split_keywords": [
        "python",
        " ocr",
        " str",
        " openocr",
        " openocr"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3557b0940a4d34c66418b78904b5bb740ca0325e6d76b1b600dcad1b6ff89781",
                "md5": "a48d61e3239d4ae1e18882d360930292",
                "sha256": "7e3e836f72c4d43b8e3a6e545558af5e674f261540b88fd7e1012012f7c5706e"
            },
            "downloads": -1,
            "filename": "openocr_python-0.0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a48d61e3239d4ae1e18882d360930292",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 573158,
            "upload_time": "2025-07-10T11:23:59",
            "upload_time_iso_8601": "2025-07-10T11:23:59.978501Z",
            "url": "https://files.pythonhosted.org/packages/35/57/b0940a4d34c66418b78904b5bb740ca0325e6d76b1b600dcad1b6ff89781/openocr_python-0.0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-10 11:23:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Topdu",
    "github_project": "OpenOCR",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "imgaug",
            "specs": []
        },
        {
            "name": "lmdb",
            "specs": []
        },
        {
            "name": "numpy",
            "specs": []
        },
        {
            "name": "opencv-python",
            "specs": []
        },
        {
            "name": "pyclipper",
            "specs": []
        },
        {
            "name": "pyyaml",
            "specs": []
        },
        {
            "name": "rapidfuzz",
            "specs": []
        },
        {
            "name": "tqdm",
            "specs": []
        }
    ],
    "lcname": "openocr-python"
}
        
Elapsed time: 1.46044s