Convert 'labelme' project's output data to a dataset for OCR model training.
- 'labelme' project: https://github.com/wkentaro/labelme
- Read 'label' and 'bbox' from json file.
- Crop the image using 'bbox' and save it.
- Write a label for each cropped image to the label file.
python3 convert.py \
--input_path ./input \
--output_path ./output
/input
├── image00001.png
├── image00001.json
├── image00002.png
├── image00002.json
└── ...
- For the 'images.json' file structure, refer to the 'https://github.com/wkentaro/labelme'
/output
└── /images
# [filename]_[idx].[ext]
├── image00001_00001.png
├── image00001_00002.png
├── image00002_00001.png
├── image00002_00002.png
├── ...
└── labels.txt
-
Label file structure:
image00001_00001.png abcd image00001_00002.png efgh image00002_00001.png ijkl image00002_00002.png mnop ...