Skip to content

Commit 0648dcd

Browse files
committed
Releases 0.2.0
1 parent 8ece58a commit 0648dcd

File tree

4 files changed

+19
-24
lines changed

4 files changed

+19
-24
lines changed

Changelog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
### Add
99
- Use RaggedTensor for train and eval pipeline
1010

11+
## [0.2.0] - 2021-07-29
12+
### Changed
13+
- New export script
14+
- New model build way
15+
1116
## [0.1.1] - 2021-01-22
1217
### Changed
1318
- Reduce minimum TensorFlow version to 2.2

README.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Convolutional Recurrent Neural Network for End-to-End Text Recognition - TensorFlow 2
22

3-
![TensorFlow version](https://img.shields.io/badge/TensorFlow->=2.2-FF6F00?logo=tensorflow)
3+
![TensorFlow version](https://img.shields.io/badge/TensorFlow->=2.3-FF6F00?logo=tensorflow)
44
![Python version](https://img.shields.io/badge/Python->=3.6-3776AB?logo=python)
55
[![Paper](https://img.shields.io/badge/paper-arXiv:1507.05717-B3181B?logo=arXiv)](https://arxiv.org/abs/1507.05717)
66
[![Zhihu](https://img.shields.io/badge/知乎-文本识别网络CRNN—实现简述-blue?logo=zhihu)](https://zhuanlan.zhihu.com/p/122512498)
@@ -11,15 +11,20 @@ This is a re-implementation of the CRNN network, build by TensorFlow 2. This rep
1111

1212
This repo aims to build a simple, efficient text recognize network by using the various components of TensorFlow 2. The model build by the Keras API, the data pipeline build by `tf.data`, and training with `model.fit`, so we can use most of the functions provided by TensorFlow 2, such as `Tensorboard`, `Distribution strategy`, `TensorFlow Profiler` etc.
1313

14+
## Installation
15+
16+
```bash
17+
$ pip install -r requirements.txt
18+
```
19+
1420
## Demo
1521

1622
Here I provide an example model that trained on the Mjsynth dataset, this model can only predict 0-9 and a-z(ignore case).
1723

18-
- [百度, 密码: a4ki](https://pan.baidu.com/s/19__FzoQxbCArf1gDm_ptPQ)
19-
- [Google drive](https://drive.google.com/file/d/1iQZxBovoGT-KDksR5f3PD1Avyiq3QJa-/view?usp=sharing)
20-
2124
```bash
22-
$ python tools/demo.py --images example/images/ --config configs/mjsynth.yml --model PATH/TO/MODEL
25+
$ wget https://github.com/FLming/CRNN.tf2/releases/download/v0.2.0/SavedModel.tgz
26+
$ tar xzvf SavedModel.tgz
27+
$ python tools/demo.py --images example/images/ --config configs/mjsynth.yml --model SavedModel
2328
```
2429

2530
Then, You will see output like this:
@@ -38,12 +43,6 @@ About decode methods, sometimes the beam search method will be better than the g
3843

3944
Before you start training, maybe you should [prepare](#Data-prepare) data first. All predictable characters are defined by the [table.txt](example/table.txt) file. The configuration of the training process is defined by the [yml](configs/mjsynth.yml) file.
4045

41-
### Installation
42-
43-
```bash
44-
$ pip install -r requirements.txt
45-
```
46-
4746
This training script uses all GPUs by default, if you want to use a specific GPU, please set the `CUDA_VISIBLE_DEVICES` parameter.
4847

4948
```bash
@@ -89,15 +88,15 @@ We should write the image path and its corresponding label to a text file in a c
8988
## Eval
9089

9190
```bash
92-
$ python crnn/eval.py --config PATH/TO/CONFIG_FILE --model PATH/TO/MODEL
91+
$ python crnn/eval.py --config PATH/TO/CONFIG_FILE --weight PATH/TO/MODEL_WEIGHT
9392
```
9493

9594
## Converte & Ecosystem
9695

9796
There are many components here to help us do other things. For example, deploy by `Tensorflow serving`. Before you deploy, you can pick up a good weight, and convertes model to `SavedModel` format by this command, it will add the post processing layer in the last and cull the optimizer:
9897

9998
```bash
100-
$ python tools/export.py --model PATH/TO/MODEL --config PATH/TO/CONFIG_FILE --post greedy --output PATH/TO/OUTPUT
99+
$ python tools/export.py --config PATH/TO/CONFIG_FILE --weight PATH/TO/MODEL_WEIGHT --pre rescale --post greedy --output PATH/TO/OUTPUT
101100
```
102101

103102
And now `Tensorflow lite` also can convert this model, that means you can deploy it to Android, iOS etc.

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
pyyaml
2-
tensorflow >= 2.2
2+
tensorflow >= 2.3

tools/demo.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import tensorflow as tf
66
from tensorflow import keras
77

8-
import decoders
9-
108
parser = argparse.ArgumentParser()
119
parser.add_argument('--images', type=str, required=True,
1210
help='Image file or folder path.')
@@ -35,19 +33,12 @@ def read_img_and_resize(path, shape):
3533

3634

3735
model = keras.models.load_model(args.model, compile=False)
38-
decoder = decoders.CTCGreedyDecoder(config['table_path'])
3936

4037
p = Path(args.images)
41-
if p.is_dir():
42-
img_paths = p.iterdir()
43-
else:
44-
img_paths = [p]
45-
38+
img_paths = p.iterdir() if p.is_dir() else [p]
4639
for img_path in img_paths:
4740
img = read_img_and_resize(str(img_path), config['img_shape'])
4841
img = tf.expand_dims(img, 0)
4942
outputs = model(img)
50-
if not isinstance(outputs, tuple):
51-
outputs = decoder(outputs)
5243
print(f'Path: {img_path}, y_pred: {outputs[0].numpy()}, '
5344
f'probability: {outputs[1].numpy()}')

0 commit comments

Comments
 (0)