Skip to main content

A packaged and flexible version of the CRAFT text detector and Keras OCR example.

Reason this release was yanked:

The URLs for weights have changed. Please upgrade.

Project description

keras-ocr

This is a slightly polished and packaged version of the Keras CRNN implementation and the published CRAFT text detection model. It provides a high level API for training a text detection and OCR pipeline.

Getting Started

Installation

# To install from master
pip install git+https://github.com/faustomorales/keras-ocr.git#egg=keras-ocr

# To install from PyPi
pip install keras-ocr

Using

Using pretrained text detection and recognition models

The package ships with an easy-to-use implementation of the CRAFT text detection model from this repository and the CRNN recognition model from this repository.

import matplotlib.pyplot as plt

import keras_ocr

# keras-ocr will automatically download pretrained
# weights for the detector and recognizer.
detector = keras_ocr.detection.Detector()
recognizer = keras_ocr.recognition.Recognizer()

image = keras_ocr.tools.read('tests/test_image.jpg')

# Boxes will be an Nx4x2 array of box quadrangles
# where N is the number of detected text boxes.
# Predictions is a list of (string, box) tuples.
boxes = detector.detect(images=[image])[0]
predictions = recognizer.recognize_from_boxes(image=image, boxes=boxes)

# Plot the results.
fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(10, 10))
canvas = keras_ocr.detection.drawBoxes(image, boxes)
ax1.imshow(image)
ax2.imshow(canvas)

for text, box in predictions:
    ax2.annotate(s=text, xy=box[0], xytext=box[0] - 50, arrowprops={'arrowstyle': '->'})

example of labeled image

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

keras-ocr-0.3.1.tar.gz (145.5 kB view details)

Uploaded Source

File details

Details for the file keras-ocr-0.3.1.tar.gz.

File metadata

  • Download URL: keras-ocr-0.3.1.tar.gz
  • Upload date:
  • Size: 145.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.4

File hashes

Hashes for keras-ocr-0.3.1.tar.gz
Algorithm Hash digest
SHA256 4fa33a561b3a6b509e0362078877199d225b1e7238a6edc9b3f43a6c5d6e49c9
MD5 53c87a54a38ee03d972fbd2dfcbd9fe4
BLAKE2b-256 a2605602747fd17b836b56f23ee01e45afc22e811c5e84e845e8a42029fc6e9a

See more details on using hashes here.

Supported by

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