# Useful Tools We provide some useful tools under `mmocr/tools` directory. ## Publish a Model Before you upload a model to AWS, you may want to (1) convert the model weights to CPU tensors, (2) delete the optimizer states and (3) compute the hash of the checkpoint file and append the hash id to the filename. These functionalities could be achieved by `tools/publish_model.py`. ```shell python tools/publish_model.py ${INPUT_FILENAME} ${OUTPUT_FILENAME} ``` For example, ```shell python tools/publish_model.py work_dirs/psenet/latest.pth psenet_r50_fpnf_sbn_1x_20190801.pth ``` The final output filename will be `psenet_r50_fpnf_sbn_1x_20190801-{hash id}.pth`. ## Convert txt annotation to lmdb format Sometimes, loading a large txt annotation file with multiple workers can cause OOM (out of memory) error. You can convert the file into lmdb format using `tools/data/utils/txt2lmdb.py` and use LmdbLoader in your config to avoid this issue. ```bash python tools/data/utils/txt2lmdb.py -i -o ``` For example, ```bash python tools/data/utils/txt2lmdb.py -i data/mixture/Syn90k/label.txt -o data/mixture/Syn90k/label.lmdb ```