Torchless EasyOCR
This package is EasyOCR-based optical character recognition. Unlike EasyOCR, the package uses a pre-saved with onnx language models, so it doesn't need a 1-2 Gb pytorch dependency. This is particularly useful for developing and packaging light-weight applications that utilize text recognition.
Comparison for virtual env size
- 272 MB
torchfree_ocrwith dependencies - 1.52 GB
easyocrwith dependencies - 4.79 GB
easyocrwith dependencies + GPU enabled
More importantly, packed python .exe loads and runs much faster with torchfree_ocr
requirements.txt
opencv-python-headless
numpy
onnxruntime
Pillow
python-bidi
Limitations
There is no GPU CUDA support.
Performance of torchfree_ocr vs easyocr
In terms of recognition, there is no visible recognition quality difference between torchfree_ocr and easyocr.
In terms of speed torchfree_ocr works a bit faster than easyocr in CPU mode (~30% faster).
Obviously, easyocr generally runs much faster in GPU mode, which torchfree_ocr doesn't support.
Examples
Installation
Install using pip
For the latest release:
pip install torchfree_ocr
or
pip install torchfree-ocr
Usage
import torchfree_ocr
reader = torchfree_ocr.Reader(["en"]) # Supports all EasyOCR languages
result = reader.readtext('english.png')
The output will be in a list format, each item represents a bounding box, the text detected and confident level, respectively.
[([[231, 32], [672, 32], [672, 64], [231, 64]], 'Reduce your risk of coronavirus infection:', 0.8413621448628567),
([[326, 98], [598, 98], [598, 124], [326, 124]], 'Clean hands with soap and water', 0.9633979603853523),
([[328, 124], [540, 124], [540, 148], [328, 148]], 'or alcohol-based hand rub', 0.802668636048309),
([[248, 170], [595, 170], [595, 196], [248, 196]], 'Cover nose and mouth when coughing and', 0.9529594602295661),
([[248, 196], [546, 196], [546, 222], [248, 222]], 'sneezing with tissue or flexed elbow', 0.8406205896147358),
([[320, 240], [624, 240], [624, 266], [320, 266]], 'Avoid close contact with anyone with', 0.8602271367787114),
([[318, 265], [528, 265], [528, 293], [318, 293]], 'cold or flu-like symptoms', 0.9378307488433589),
([[248, 322], [510, 322], [510, 348], [248, 348]], 'Thoroughly cook meat and eggs', 0.7159722535422908),
([[332, 370], [640, 370], [640, 396], [332, 396]], 'No unprotected contact with live wild', 0.8346977728209518),
([[334, 396], [464, 396], [464, 420], [334, 420]], 'or farm animals', 0.7179850171130348),
([[595, 427], [683, 427], [683, 447], [595, 447]], 'World Health', 0.9979501800152029),
([[597, 445], [685, 445], [685, 463], [597, 463]], 'Organization', 0.9977550970521537)]
Note 1: Instead of the filepath english.png, you can also pass an OpenCV image object (numpy array) or an image file as bytes. A URL to a raw image is also acceptable.
Note 2: The line reader = easyocr.Reader(["en"]) is for loading a model into memory. It takes some time but it needs to be run only once.
You can also set detail=0 for simpler output.
reader.readtext('english.png', detail = 0)
Result:
['Reduce your risk of coronavirus infection:', 'Clean hands with soap and water', 'or alcohol-based hand rub', 'Cover nose and mouth when coughing and', 'sneezing with tissue or flexed elbow', 'Avoid close contact with anyone with', 'cold or flu-like symptoms', 'Thoroughly cook meat and eggs', 'No unprotected contact with live wild', 'or farm animals', 'World Health', 'Organization']
Averall, usage is the same as with EasyOCR, except Reader in this package only has lang_list and recognizer=True parameters.
Usage for EasyOCR can be found in their tutorial and API Documentation.
Run on command line
$ torchfree_ocr -l en -f english.png --detail=1
Metadata
Release files for torchfree-ocr 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| torchfree_ocr-1.1.0.tar.gz | 67.3 kB | Without provenance | Details for torchfree_ocr-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| torchfree_ocr-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for torchfree_ocr-1.1.0-py3-none-any.whl |
Total release size: 132.5 kB
Release files / torchfree_ocr-1.1.0.tar.gz
| Download URL | torchfree_ocr-1.1.0.tar.gz |
|---|---|
| Size | 67.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
35a9d0244352f54e192a584a6a6300a814fab1f6f4a1c6f1bd0cc8e84cd1f31d
|
|
BLAKE2b-256 checksum How to use checksums |
3427fd7cb269e96179f3a4186d5af728426274a3592b66372c94a803bef8c018
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.11
|
Release files / torchfree_ocr-1.1.0-py3-none-any.whl
| Download URL | torchfree_ocr-1.1.0-py3-none-any.whl |
|---|---|
| Size | 65.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a58c0f54c7a5c8e69d46221524366ed04c102b955b68763b6a0e188c66bbd730
|
|
BLAKE2b-256 checksum How to use checksums |
5f208c55fde870cd3a02e05e7ed74ac163581da46496ed984019797746484ca4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.11
|
Security for torchfree-ocr 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.