SHIFTLAB OCR
SHIFT OCR is a library for handwriting text segmentation and character recognition.
Get Started
pip install shiftlab_ocr
Doc2Text
Reader from doc2text performs text detection and the following recognition.
import urllib
from shiftlab_ocr.doc2text.reader import Reader
urllib.request.urlretrieve(
'https://raw.githubusercontent.com/konverner/shiftlab_ocr/main/demo_image.png',
'test.png')
reader = Reader()
result = reader.doc2text("test.png")
Display recognized text:
print(result[0])
Действительно ли добро сильнее зла?
Именно над этим вопросом аставля заставляет
читателей задуматься В. Тендряков.
Автор рассматривает данную пробле-
му на конкретном примере, рассказывая
историю 00 заблудившемся немце русских
солдатах, которые пожалели врала и
позволи ему остаться землянке.
Display segmented crops:
import matplotlib.pyplot as plt
def show_img_grid(images, N):
n = int(N**(0.5))
k = 0
f, axarr = plt.subplots(n,n,figsize=(10,10))
for i in range(n):
for j in range(n):
axarr[i,j].imshow(images[k].img)
k += 1
f.show()
show_img_grid(result[1], 48)
Generator of handwriting
It generates handwriting script with random backgrounds and handwriting fonts with a given string or a list of strings saved in source.txt.
Generating a random sample from a string:
from shiftlab_ocr.generator.generator import Generator
g = Generator(lang='ru')
s = g.generate_from_string('Москва',min_length=4,max_length=24) # get from a string
s
Generating batch of random samples from source.txt:
import numpy as np
# upload source.txt with one word per line
g.upload_source('source.txt')
b = g.generate_batch(12,4,13) # get batch of random samples from source.txt
fig=plt.figure(figsize=(10, 10))
rows = int(len(b)/4) + 2
columns = int(len(b)/8) + 2
for i in range(len(b)):
fig.add_subplot(rows, columns, i+1)
plt.imshow(np.asarray(b[i][0]))
Also, see Google Colab Demo
Metadata
Release files for shiftlab-ocr 0.3.2
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 |
|---|---|---|---|---|
| shiftlab-ocr-0.3.2.tar.gz | 1.6 MB | Without provenance | Details for shiftlab-ocr-0.3.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| shiftlab_ocr-0.3.2-py3-none-any.whl | Python 3 | none | any | Details for shiftlab_ocr-0.3.2-py3-none-any.whl |
Total release size: 3.3 MB
Release files / shiftlab-ocr-0.3.2.tar.gz
| Download URL | shiftlab-ocr-0.3.2.tar.gz |
|---|---|
| Size | 1.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
db95692c5af6c7a2a317ba36e6df5ce1fbbb15814a16743ade21098c5bdab162
|
|
BLAKE2b-256 checksum How to use checksums |
0272046035814cd471be9534bd7b0cb831b376cc9cac178edf58d7bca68cab00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.13
|
Release files / shiftlab_ocr-0.3.2-py3-none-any.whl
| Download URL | shiftlab_ocr-0.3.2-py3-none-any.whl |
|---|---|
| Size | 1.7 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4f04a0a2292fda20d6d95ec652f24342a5a85a64984af63bac0c25e8656bc565
|
|
BLAKE2b-256 checksum How to use checksums |
cd30b3be68e7b970c7b3140607367dede17227e11209aa19ab9069ec08cbee52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.13
|
Security for shiftlab-ocr 0.3.2
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.