Text Recognition (CRNN)
Training Parameters and Value Ranges
Table 1 describes the names, types, value ranges, default values, and descriptions of the CRNN training parameters.
Parameter |
Type |
Value Range |
Default Value |
Description |
|---|---|---|---|---|
--save_best_ckpt |
Bool |
True or False |
True |
Save the best checkpoint during training and verification. (This parameter will be deleted in later versions.) Currently, the optimal CKPT is saved by default when run_eval is set to True. |
--eval_start_epoch |
Integer |
[1,10000] |
5 |
Sequence number of epochs from which evaluation is performed during training. |
--eval_interval |
Integer |
[1,10000] |
5 |
Evaluation interval. Retain the default value. |
--split |
Float |
(0,1) |
0.8 |
Ratio of the training dataset to the validation dataset. |
--device_id |
Integer |
[0,7] |
0 |
ID of the NPU used for training. |
--device_num |
Integer |
Currently, only one device is supported, that is, the value can only be 1. |
1 |
Number of NPUs used for training. |
--epoch_size |
Integer |
[1,10000] |
10 |
Number of training epochs. |
--batch_size |
Integer |
Less than or equal to the number of images in the dataset. [1, 8192] |
4 |
Batch size for training. |
--pretrained_ckpt_path |
String |
- |
"pre_trained_ckpt" |
Path for storing the pre-trained model. |
--input_width |
Integer |
[1, 10000) |
100 |
Model input width. |
--init_lr |
Float |
(0,1) |
0.02 |
Training learning rate. |
--train_dataset_path |
String |
- |
None |
Path of the training dataset. |
--train_output_path |
String |
- |
"train_output_path" |
Training output path. |
--run_eval |
Bool |
True or False |
True |
Whether to perform evaluation during training. |
Training Command Reference
Run the following command to start the CRNN model training:
python3 model_train.py --train_dataset_path={train_dataset_path} -- train_output_path =./train_output_path --input_width=100 --batch_size=4 --epoch_size=10 --init_lr=0.02 --run_eval=True --device_id=1 --device_num=1
The model training process is random. Use the evaluated accuracy. Figure 1 shows the training accuracy results.
Figure 2 shows the log information after the training is complete.
After the training is complete, the .ckpt, .a310.om, .a310p.om, and .air model files are generated in the output directory specified by the --train_output_path parameter.
Evaluation Parameters and Value Ranges
Table 2 describes the names, types, value ranges, default values, and descriptions of the CRNN evaluation parameters.
Parameter |
Type |
Value Range |
Default Value |
Description |
|---|---|---|---|---|
--eval_dataset_path |
String |
- |
None |
Path of the evaluation dataset. |
--eval_ckpt_path |
String |
- |
None |
CKPT path used for evaluation. |
--device_id |
Integer |
[0,7] |
0 |
ID of the NPU for evaluation. |
--eval_output_path |
String |
- |
"eval_output_path" |
Evaluation output path. |
Evaluation Command Reference
Run the following command to evaluate the CRNN model:
python3 model_eval.py --eval_dataset_path={eval_dataset_path} --eval_ckpt_path=./train_output_path --eval_output_path=./eval_output_path --device_id=0
Use the checkpoint output during the training to evaluate the model accuracy. See Figure 3.
The files shown in Figure 4 are generated in the evaluation directory. statistics.csv collects statistics on the evaluation accuracy, statistics_ng_samples.csv collects statistics on the images with incorrect evaluation and prediction values, and statistics_ok_samples.csv collects statistics on the images with correct evaluation and prediction values.



