Skip to main content

Generates text from image

Project description

shiftlab_ocr

SHIFT OCR is a library fo handwriting text segmentation and character recognition.

Get Started

Doc2Text

it transcribes an image into text

pip install shiftlab_ocr


from shiftlab_ocr import Scanner

PATH_TO_IMAGE = 'test.jpg'
scanner = Scanner(ocr_model='hw-cyr')
result = scanner.doc2text(PATH_TO_IMAGE)

('Директору Заявление 10 январе 2019г. Ирл Иванов А.П. ',
 [<shift_ocr.crop.Crop at 0x7f158cffd1d0>,
  <shift_ocr.crop.Crop at 0x7f158cffd610>,
  <shift_ocr.crop.Crop at 0x7f158cffd790>,
  <shift_ocr.crop.Crop at 0x7f158cffd8d0>,
  <shift_ocr.crop.Crop at 0x7f158cffdd50>,
  <shift_ocr.crop.Crop at 0x7f158cffd910>])

Generator of handwriting

It generates handwriting script with random backgrounds and handwriting fonts with given list of strings


from shiftlab_ocr import Generator

g = Generator(lang='ru')
g.upload_source('/content/source.txt')

s = g.generate_from_string('Москва',min_length=4,max_length=24) # get from a string
s


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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

shiftlab_ocr-0.3.1-py3-none-any.whl (30.7 MB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page