{"id":13542987,"url":"https://github.com/jiangxiluning/MASTER-TF","last_synced_at":"2025-04-02T12:31:01.360Z","repository":{"id":39738918,"uuid":"277276885","full_name":"jiangxiluning/MASTER-TF","owner":"jiangxiluning","description":"MASTER","archived":false,"fork":false,"pushed_at":"2023-03-24T22:51:27.000Z","size":73,"stargazers_count":139,"open_issues_count":7,"forks_count":44,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-03T09:33:36.980Z","etag":null,"topics":["cv","deep-learning","ocr","ocr-recognition","scene-text-recognition","transformer"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jiangxiluning.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-07-05T10:17:30.000Z","updated_at":"2024-08-26T15:12:31.000Z","dependencies_parsed_at":"2024-01-15T23:26:59.759Z","dependency_job_id":"4ee71357-8657-4b42-816e-050d6b31a6eb","html_url":"https://github.com/jiangxiluning/MASTER-TF","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiangxiluning%2FMASTER-TF","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiangxiluning%2FMASTER-TF/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiangxiluning%2FMASTER-TF/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiangxiluning%2FMASTER-TF/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jiangxiluning","download_url":"https://codeload.github.com/jiangxiluning/MASTER-TF/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246815369,"owners_count":20838434,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cv","deep-learning","ocr","ocr-recognition","scene-text-recognition","transformer"],"created_at":"2024-08-01T11:00:20.873Z","updated_at":"2025-04-02T12:30:56.344Z","avatar_url":"https://github.com/jiangxiluning.png","language":"Python","funding_links":[],"categories":["Optical Character Recognition Engines and Frameworks"],"sub_categories":["CTPN [paper:2016](https://arxiv.org/pdf/1609.03605.pdf)"],"readme":"# MASTER-TensorFlow ![](https://img.shields.io/badge/license-MIT-blue)\n\n\u003cdiv align=center\u003e\n\u003cimg src=\"https://github.com/wenwenyu/MASTER-pytorch/blob/main/assets/logo.jpeg\" width=\"200\" height=\"200\" /\u003e\n\u003c/div\u003e\n\n\nTensorFlow reimplementation of [\"MASTER: Multi-Aspect Non-local Network for Scene Text Recognition\"](https://arxiv.org/abs/1910.02562)\n(Pattern Recognition 2021). This project is different from our original implementation that builds on the privacy codebase FastOCR of the company.\nYou can also find PyTorch reimplementation at [MASTER-pytorch](https://github.com/wenwenyu/MASTER-pytorch) repository,\nand the performance is almost identical. (PS. Logo inspired by the Master Oogway in Kung Fu Panda)\n\n\n## News\n* 2021/07: [MASTER-mmocr](https://github.com/JiaquanYe/MASTER-mmocr), reimplementation of MASTER by mmocr. [@Jiaquan Ye](https://github.com/JiaquanYe)\n* 2021/07: [TableMASTER-mmocr](https://github.com/JiaquanYe/TableMASTER-mmocr), 2nd solution of ICDAR 2021 Competition on Scientific Literature Parsing Task B based on MASTER. [@Jiaquan Ye](https://github.com/JiaquanYe)\n* 2021/07: Talk can be found at [here](https://www.bilibili.com/video/BV1T44y1m7vc) (Chinese).\n* 2021/05: [Savior](https://github.com/novioleo/Savior), which aims to provide a simple, lightweight, fast integrated, pipelined deployment framework for RPA,\n  is now integrated MASTER for captcha recognition. [@Tao Luo](https://github.com/novioleo)\n* 2021/04: Slides can be found at [here](https://github.com/wenwenyu/MASTER-pytorch/blob/main/assets/MASTER.pdf).\n\n\n## Honors based on MASTER\n* 1st place (2021/05) solution to [ICDAR 2021 Competition on Scientific Table Image Recognition to LaTeX (Subtask I: Table structure reconstruction)](https://competitions.codalab.org/competitions/26979)\n* 1st place (2021/05) solution to [ICDAR 2021 Competition on Scientific Table Image Recognition to LaTeX (Subtask II: Table content reconstruction)](https://competitions.codalab.org/competitions/26979)\n* 2nd place (2021/05) solution to [ICDAR 2021 Competition on Scientific Literature Parsing Task B: Table recognition](https://icdar2021.org/program-2/competitions/competition-on-scientific-literature-parsing/)\n* 1st place (2020/10) solution to [ICDAR 2019 Robust Reading Challenge on Reading Chinese Text on Signboard (task2)](https://rrc.cvc.uab.es/?ch=12\u0026com=evaluation\u0026task=2)\n* 2nd and 5th places (2020/10) in [The 5th China Innovation Challenge on Handwritten Mathematical Expression Recognition](https://www.heywhale.com/home/competition/5f703ac023f41e002c3ed5e4/content/6)\n* 4th place (2019/08) of [ICDAR 2017 Robust Reading Challenge on COCO-Text (task2)](https://rrc.cvc.uab.es/?ch=5\u0026com=evaluation\u0026task=2)\n* More will be released\n\n\n## Introduction\nMASTER is a self-attention based scene text recognizer that (1) not only encodes the input-output attention,\nbut also learns self-attention which encodes feature-feature and target-target relationships inside the encoder\nand decoder and (2) learns a more powerful and robust intermediate representation to spatial distortion and\n(3) owns a better training and evaluation efficiency. Overall architecture shown follows.\n\n\u003cdiv align=center\u003e\n\u003cimg src=\"https://github.com/wenwenyu/MASTER-pytorch/blob/main/assets/overall.png\" /\u003e\n\u003c/div\u003e\n          \nThis repo contains the following features.\n\n- [x] Multi-gpu Training\n- [x] Greedy Decoding\n- [x] Single image inference\n- [x] Eval iiit5k\n- [x] Convert Checkpoint to SavedModel format\n- [x] Refactory codes to be more tensorflow-style and be more consistent to graph mode\n- [x] Support tensorflow serving mode\n\n\n## Preparation  \nIt is highly recommended that install tensorflow-gpu using conda.\n\nPython3.7 is preferred.\n\n```bash\npip install -r requirements.txt\n```\n\n## Dataset\n\n\nI use Clovaai's MJ training split for training. \n\nplease check `src/dataset/benchmark_data_generator.py` for details.\n\nEval datasets are some real scene text datasets. You can downloaded directly from [here](https://drive.google.com/drive/folders/1OG4ufr-kj2jFLmM4gyFEI0tMGYZrz8HI).\n\n\n## Training\n\n```bash\n# training from scratch\npython train.py -c [your_config].yaml\n\n# resume training from last checkpoint\npython train.py -c [your_config].yaml -r\n\n# finetune with some checkpoint\npython train.py -c [your_config].yaml -f [checkpoint]\n```\n\n\n## Eval\n\n**Since I made change to the usage of gcb block, the weight could not be suitable to HEAD. If you want to test the model, please use https://github.com/jiangxiluning/MASTER-TF/commit/85f9217af8697e41aefe5121e580efa0d6d04d92**\n\nCurrently, you can download checkpoint from [here](https://pan.baidu.com/s/1ijpo8WRZHR-AyDclxQVDiw) with code **o6g9**, or from [Google Driver](https://drive.google.com/file/d/1gpfMvnQWZimogQLFM_teOwiLNz-ZEF02/view?usp=sharing), this checkpoint was trained with MJ and selected\nfor the best performance of iiit5k dataset. Below is the comparision between pytorch version and tensorflow version.\n\n| Framework | Dataset | Word Accuracy | Training Details |\n| --- | --- | --- | --- |\n| Pytorch | MJ | 85.05% | 3 V100 4 epochs Batch Size: 3*128|\n| Tensorflow | MJ | 85.53% | 2 2080ti 4 epochs Batch Size: 2 * 50 |\n\n\n\nPlease download the checkpoint and model config from [here](https://pan.baidu.com/s/1ijpo8WRZHR-AyDclxQVDiw) with code **o6g9** and unzip it, and you can get this metric by running:\n\n```bash\npython eval_iiit5k.py --ckpt [checkpoint file] --cfg [model config] -o [output dir] -i [iiit5k lmdb test dataset]\n```\nThe checkpoint file argument should be `${where you unzip}/backup/512_8_3_3_2048_2048_0.2_0_Adam_mj_my/checkpoints/OCRTransformer-Best` \n\n## Tensorflow Serving\n\nFor tensorflow serving, you should use savedModel format, I provided test case to show you how to convert a checkpoint to savedModel and how to use it.\n\n```bash\npytest -s tests/test_units::test_savedModel  #check the test case test_savedModel in tests/test_units\npytest -s tests/test_units::test_loadModel  # call decode to inference and get predicted transcript and logits out.\n```\n\n\n## Citations\nIf you find MASTER useful please cite our [paper](https://arxiv.org/abs/1910.02562):\n```bibtex\n@article{Lu2021MASTER,\n  title={{MASTER}: Multi-Aspect Non-local Network for Scene Text Recognition},\n  author={Ning Lu and Wenwen Yu and Xianbiao Qi and Yihao Chen and Ping Gong and Rong Xiao and Xiang Bai},\n  journal={Pattern Recognition},\n  year={2021}\n}\n```\n\n\n## License\nThis project is licensed under the MIT License. See LICENSE for more details.\n\n## Acknowledgements\n\nThanks to the authors and their repo:\n - [SAR_TF](https://github.com/Pay20Y/SAR_TF)\n - [deep-text-recognition-benchmark](https://github.com/clovaai/deep-text-recognition-benchmark)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiangxiluning%2FMASTER-TF","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjiangxiluning%2FMASTER-TF","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiangxiluning%2FMASTER-TF/lists"}