This document shows how to convert ocr annotation to the general format (not including LMDB) for model training.
You may also refer to convert_datasets.sh
which is a quick solution for converting annotation files of all datasets under a given directory.
The format of the converted annotation file should follow:
img_61.jpg\t[{"transcription": "MASA", "points": [[310, 104], [416, 141], [418, 216], [312, 179]]}, {...}]
Taking ICDAR2015 (ic15) dataset as an example, to convert the ic15 dataset to the required format, please run
# convert training anotation
python tools/dataset_converters/convert.py \
--dataset_name ic15 \
--task det \
--image_dir /path/to/ic15/det/train/ch4_training_images \
--label_dir /path/to/ic15/det/train/ch4_training_localization_transcription_gt \
--output_path /path/to/ic15/det/train/det_gt.txt
# convert testing anotation
python tools/dataset_converters/convert.py \
--dataset_name ic15 \
--task det \
--image_dir /path/to/ic15/det/test/ch4_test_images \
--label_dir /path/to/ic15/det/test/ch4_test_localization_transcription_gt \
--output_path /path/to/ic15/det/test/det_gt.txt
The annotation format for text recognition dataset follows
word_7.png fusionopolis
word_8.png fusionopolis
word_9.png Reserve
word_10.png CAUTION
word_11.png citi
Note that image name and text label are seperated by \t.
To convert, please run:
# convert training anotation
python tools/dataset_converters/convert.py \
--dataset_name ic15 \
--task rec \
--label_dir /path/to/ic15/rec/ch4_training_word_images_gt/gt.txt
--output_path /path/to/ic15/rec/train/ch4_training_word_images_gt/rec_gt.txt
# convert testing anotation
python tools/dataset_converters/convert.py \
--dataset_name ic15 \
--task rec \
--label_dir /path/to/ic15/rec/ch4_test_word_images_gt/gt.txt
--output_path /path/to/ic15/rec/ch4_test_word_images_gt/rec_gt.txt
Some of the dataset can be converted to LMDB format. Currently, this is only supported for the SynthText
and SynthAdd
datasets.
To convert to LMDB format, please run
python tools/dataset_converters/convert.py \
--dataset_name synthtext \
--task rec_lmdb \
--image_dir /path/to/SynthText \
--label_dir /path/to/SynthText_gt.mat \
--output_path ST_full
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》