Skip to content

Commit

Permalink
Fix documentation builder.
Browse files Browse the repository at this point in the history
  • Loading branch information
faustomorales committed Jun 18, 2021
1 parent f8cc4f7 commit bd5dd5e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ shell: ## Jump into poetry shell.
poetry shell

docs: ## Make a local HTML doc server that updates on changes to from Sphinx source
pip install docs/requirements.txt
@$(EXEC) sphinx-autobuild -b html docs/source docs/build/html $(SPHINX_AUTO_EXTRA)
@$(EXEC) pip install -r docs/requirements.txt
@$(EXEC) sphinx-autobuild -b html docs docs/build/html $(SPHINX_AUTO_EXTRA)
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# keras-ocr [![CircleCI](https://circleci.com/gh/faustomorales/keras-ocr.svg?style=shield)](https://circleci.com/gh/faustomorales/keras-ocr) [![Documentation Status](https://readthedocs.org/projects/keras-ocr/badge/?version=latest)](https://keras-ocr.readthedocs.io/en/latest/?badge=latest)
# keras-ocr [![Documentation Status](https://readthedocs.org/projects/keras-ocr/badge/?version=latest)](https://keras-ocr.readthedocs.io/en/latest/?badge=latest)

This is a slightly polished and packaged version of the [Keras CRNN implementation](https://github.com/kurapan/CRNN) and the published [CRAFT text detection model](https://github.com/clovaai/CRAFT-pytorch). It provides a high level API for training a text detection and OCR pipeline.

Please see [the documentation](https://keras-ocr.readthedocs.io/) for more examples, including for training a custom model.

## Getting Started

### Installation

`keras-ocr` supports Python >= 3.6 and TensorFlow >= 2.0.0.

```bash
Expand Down Expand Up @@ -50,30 +52,31 @@ for ax, image, predictions in zip(axs, images, prediction_groups):

![example of labeled image](https://raw.githubusercontent.com/faustomorales/keras-ocr/master/docs/_static/readme_labeled.jpg)


## Comparing keras-ocr and other OCR approaches

You may be wondering how the models in this package compare to existing cloud OCR APIs. We provide some metrics below and [the notebook](https://drive.google.com/file/d/1FMS3aUZnBU4Tc6bosBPnrjdMoSrjZXRp/view?usp=sharing) used to compute them using the first 1,000 images in the COCO-Text validation set. We limited it to 1,000 because the Google Cloud free tier is for 1,000 calls a month at the time of this writing. As always, caveats apply:

- No guarantees apply to these numbers -- please beware and compute your own metrics independently to verify them. As of this writing, they should be considered a very rough first draft. Please open an issue if you find a mistake. In particular, the cloud APIs have a variety of options that one can use to improve their performance and the responses can be parsed in different ways. It is possible that I made some error in configuration or parsing. Again, please open an issue if you find a mistake!
- We ignore punctuation and letter case because the out-of-the-box recognizer in keras-ocr (provided by [this independent repository](https://github.com/kurapan/CRNN)) does not support either. Note that both AWS Rekognition and Google Cloud Vision support punctuation as well as upper and lowercase characters.
- We ignore non-English text.
- We ignore illegible text.

| model | latency | precision | recall |
|-----------------------|---------|-----------|--------|
| [AWS](https://github.com/faustomorales/keras-ocr/releases/download/v0.8.4/aws_annotations.json) | 719ms | 0.45 | 0.48 |
| [GCP](https://github.com/faustomorales/keras-ocr/releases/download/v0.8.4/google_annotations.json) | 388ms | 0.53 | 0.58 |
| [keras-ocr](https://github.com/faustomorales/keras-ocr/releases/download/v0.8.4/keras_ocr_annotations_scale_2.json) (scale=2) | 417ms | 0.53 | 0.54 |
| [keras-ocr](https://github.com/faustomorales/keras-ocr/releases/download/v0.8.4/keras_ocr_annotations_scale_3.json) (scale=3) | 699ms | 0.5 | 0.59 |
| model | latency | precision | recall |
| ----------------------------------------------------------------------------------------------------------------------------- | ------- | --------- | ------ |
| [AWS](https://github.com/faustomorales/keras-ocr/releases/download/v0.8.4/aws_annotations.json) | 719ms | 0.45 | 0.48 |
| [GCP](https://github.com/faustomorales/keras-ocr/releases/download/v0.8.4/google_annotations.json) | 388ms | 0.53 | 0.58 |
| [keras-ocr](https://github.com/faustomorales/keras-ocr/releases/download/v0.8.4/keras_ocr_annotations_scale_2.json) (scale=2) | 417ms | 0.53 | 0.54 |
| [keras-ocr](https://github.com/faustomorales/keras-ocr/releases/download/v0.8.4/keras_ocr_annotations_scale_3.json) (scale=3) | 699ms | 0.5 | 0.59 |

- Precision and recall were computed based on an intersection over union of 50% or higher and a text similarity to ground truth of 50% or higher.
- `keras-ocr` latency values were computed using a Tesla P4 GPU on Google Colab. `scale` refers to the argument provided to `keras_ocr.pipelines.Pipeline()` which determines the upscaling applied to the image prior to inference.
- Latency for the cloud providers was measured with sequential requests, so you can obtain significant speed improvements by making multiple simultaneous API requests.
- Each of the entries provides a link to the JSON file containing the annotations made on each pass. You can use this with the notebook to compute metrics without having to make the API calls yourself (though you are encoraged to replicate it independently)!

*Why not compare to Tesseract?* In every configuration I tried, Tesseract did very poorly on this test. Tesseract performs best on scans of books, not on incidental scene text like that in this dataset.
_Why not compare to Tesseract?_ In every configuration I tried, Tesseract did very poorly on this test. Tesseract performs best on scans of books, not on incidental scene text like that in this dataset.

## Contributing

To work on the project, start by doing the following. These instructions probably do not yet work for Windows but if a Windows user has some ideas for how to fix that it would be greatly appreciated (I don't have a Windows machine to test on at the moment).

```bash
Expand All @@ -86,13 +89,14 @@ make init
make build
```

- You can get a JupyterLab server running to experiment with using make `lab-server`.
- To run checks before committing code, you can use `make precommit`.
- To view the documentation, use `make documentation-server`.
- You can get a JupyterLab server running to experiment with using `make lab`.
- To run checks before committing code, you can use `make format-check type-check lint-check test`.
- To view the documentation, use `make docs`.

To implement new features, please first file an issue proposing your change for discussion.

To report problems, please file an issue with sample code, expected results, actual results, and a complete traceback.

## Troubleshooting
- *This package is installing `opencv-python-headless` but I would prefer a different `opencv` flavor.* This is due to [aleju/imgaug#473](https://github.com/aleju/imgaug/issues/473). You can uninstall the unwanted OpenCV flavor after installing `keras-ocr`. We apologize for the inconvenience.

- _This package is installing `opencv-python-headless` but I would prefer a different `opencv` flavor._ This is due to [aleju/imgaug#473](https://github.com/aleju/imgaug/issues/473). You can uninstall the unwanted OpenCV flavor after installing `keras-ocr`. We apologize for the inconvenience.
7 changes: 0 additions & 7 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,3 @@ and :doc:`fine-tuning recognizer <examples/fine_tuning_recognizer>` examples.
.. automodule:: keras_ocr.datasets
:members:

Custom Objects
**************

These are experimental objects to be used for custom operations with Keras.

.. automodule:: keras_ocr.custom_objects
:members:
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
copyright = "2019, Fausto Morales"
author = "Fausto Morales"

import keras_ocr._version
import keras_ocr

# The short X.Y version
version = keras_ocr._version.get_versions()["version"]
version = keras_ocr.__version__
# The full version, including alpha/beta/rc tags
# release = ''

Expand Down

0 comments on commit bd5dd5e

Please sign in to comment.