bgshih/crnn
bgshih/crnn has 2,104 GitHub stars and 545 forks. GitHot measured 0 stars in 24 hours and -1 in 7 days. Last checked 2026-11-07 02:52 UTC. Last push 2019-03-04.
Convolutional Recurrent Neural Network (CRNN) for image-based sequence recognition.
Measured star growth
- in 24h
- 0
- in 7 days
- -1
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalConvolutional Recurrent Neural Network
This software implements the Convolutional Recurrent Neural Network (CRNN), a combination of CNN, RNN and CTC loss for image-based sequence recognition tasks, such as scene text recognition and OCR. For details, please refer to our paper http://arxiv.org/abs/1507.05717.
UPDATE Mar 14, 2017 A Docker file has been added to the project. Thanks to @varun-suresh.
UPDATE May 1, 2017 A PyTorch port has been made by @meijieru.
UPDATE Jun 19, 2017 For an end-to-end text detector+recognizer, check out the CTPN+CRNN implementation by @AKSHAYUBHAT.
Build
The software has only been tested on Ubuntu 14.04 (x64). CUDA-enabled GPUs are required. To build the project, first install the latest versions of Torch7, fblualib and LMDB. Please follow their installation instructions respectively. On Ubuntu, lmdb can be installed by apt-get install liblmdb-dev.
To build the project, go to src/ and execute sh build_cpp.sh to build the C++ code. If successful, a file named libcrnn.so should be produced in the src/ directory.
Run demo
A demo program can be found in src/demo.lua. Before running the demo, download a pretrained model from here. Put the downloaded model file crnn_demo_model.t7 into directory model/crnn_demo/. Then launch the demo by:
th demo.lua
The demo reads an example image and recognizes its text content.
Example image:

Expected output:
Loading model...
Model loaded from ../model/crnn_demo/model.t7
Recognized text: available (raw: a-----v--a-i-l-a-bb-l-e---)
Another example:

Recognized text: shakeshack (raw: ss-h-a--k-e-ssh--aa-c--k--)
Use pretrained model
The pretrained model can be used for lexicon-free and lexicon-based recognition tasks. Refer to the functions recognizeImageLexiconFree and recognizeImageWithLexicion in file utilities.lua for details.
Train a new model
Follow the following steps to train a new model on your own dataset.
- Create a new LMDB dataset. A python program is provided in
tool/create_dataset.py. Refer to the functioncreateDatasetfor details (need topip install lmdbfirst). - Create model directory under
model/. For example,model/foo_model. Then create configuraton fileconfig.luaunder the model directory. You can copymodel/crnn_demo/config.luaand do modifications. - Go to
src/and executeth main_train.lua ../models/foo_model/. Model snapshots and logging file will be saved into the model directory.
Build using docker
- Install docker. Follow the instructions here
- Install nvidia-docker - Follow the instructions here
- Clone this repo, from this directory run
docker build -t crnn_docker . - Once the image is built, the docker can be run using
nvidia-docker run -it crnn_docker.
Citation
Please cite the following paper if you are using the code/model in your research paper.
@article{ShiBY17,
author = {Baoguang Shi and
Xiang Bai and
Cong Yao},
title = {An End-to-End Trainable Neural Network for Image-Based Sequence Recognition
and Its Application to Scene Text Recognition},
journal = {{IEEE} Trans. Pattern Anal. Mach. Intell.},
volume = {39},
number = {11},
pages = {2298--2304},
year = {2017}
}
Acknowledgements
The authors would like to thank the developers of Torch7, TH++, lmdb-lua-ffi and char-rnn.
Please let me know if you encounter any issues.
Explore related projects
tensorflow/tensorflow
An Open Source Machine Learning Framework for Everyone
201,311 starshuggingface/transformers
🤗 Transformers: the model-definition framework for state-of-the-art machine learning models in text, vision, audio, and multimodal models, for both inference and training.
168,576 starsAUTOMATIC1111/stable-diffusion-webui
Stable Diffusion web UI
165,264 starsComfy-Org/ComfyUI
The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
145,310 stars