Abstract
Computer programming textbooks and software documentations often contain flowcharts to illustrate the flow of an algorithm or procedure. Modern OCR engines often tag these flowcharts as graphics and ignore them in further processing. In this paper, we work towards making flowchart images machine-interpretable by converting them to executable Python codes. To this end, inspired by the recent success in natural language to code generation literature, we present a novel transformer-based framework, namely FloCo-T5. Our model is well-suited for this task, as it can effectively learn semantics, structure, and patterns of programming languages, which it leverages to generate syntactically correct code. We also used a task-specific pre-training objective to pre-train FloCo-T5 using a large number of logic-preserving augmented code samples. Further, to perform a rigorous study of this problem, we introduce the FloCo dataset that contains 11,884 flowchart images and their corresponding Python codes. Our experiments show promising results, and FloCo-T5 clearly outperforms related competitive baselines on code generation metrics. We make our dataset and implementation publicly available (https://vl2g.github.io/projects/floco).
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
References
Easy OCR (2022). https://pypi.org/project/easyocr/1.6.2/
Ahmad, W., Chakraborty, S., Ray, B., Chang, K.W.: Unified pre-training for program understanding and generation. In: Proceedings of NAACL-HLT (2021)
Akermi, I., Heinecke, J., Herledan, F.: Transformer based natural language generation for question-answering. In: Proceedings of the 13th International Conference on Natural Language Generation (2020)
Austin, J., et al.: Program synthesis with large language models. CoRR abs/2108.07732 (2021)
Awal, A.M., Feng, G., Mouchère, H., Viard-Gaudin, C.: Handwritten flowchart dataset (OHFCD). Document Recognition and Retrieval XVIII, January 2011, San Fransisco, United States, pp. 7874–78740A (2011). https://doi.org/10.1117/12.876624
Baek, Y., Lee, B., Han, D., Yun, S., Lee, H.: Character region awareness for text detection. In: Proceedings of CVPR (2019)
Bradski, G.: The OpenCV library. Dr. Dobb’s J. Softw. Tools 120, 122–125 (2000)
Brown, T., et al.: Language models are few-shot learners. In: Proceedings of NeurIPS (2020)
Carton, C., Lemaitre, A., Coüasnon, B.: Fusion of statistical and structural information for flowchart recognition. In: Proceedings of ICDAR (2013)
Chaudhuri, A.: Flowchart and Algorithm Basics: The Art of Programming. Mercury Learning and Information (2020)
Clark, K., Luong, M.T., Le, Q.V., Manning, C.D.: ELECTRA: pre-training text encoders as discriminators rather than generators. In: Proceedings of ICLR (2020)
Cook, D.: Flowgorithm (2022). https://www.flowgorithm.org/
Fang, J., Feng, Z., Cai, B.: DrawnNet: offline hand-drawn diagram recognition based on keypoint prediction of aggregating geometric characteristics. Entropy 24(3), 425 (2022)
Feng, Z., et al.: CodeBERT: a pre-trained model for programming and natural languages. In: Findings of the ACL: EMNLP (2020)
Guo, D., et al.: GraphCodeBERT: pre-training code representations with data flow. In: Proceedings of ICLR (2020)
Herrera-Camara, J.I., Hammond, T.: Flow2Code: from hand-drawn flowcharts to code execution. In: Proceedings of the Symposium on Sketch-Based Interfaces and Modeling (2017)
Kenton, J.D.M.W.C., Toutanova, L.K.: BERT: pre-training of deep bidirectional transformers for language understanding. In: Proceedings of NAACL-HLT (2019)
Kingma, D.P., Ba, J.: Adam: a method for stochastic optimization. In: Bengio, Y., LeCun, Y. (eds.) Proceedings of ICLR (2015)
Lewis, M., et al.: BART: denoising sequence-to-sequence pre-training for natural language generation, translation, and comprehension. In: Proceedings of ACL (2020)
Li, M., et al.: TrOCR: transformer-based optical character recognition with pre-trained models. arXiv preprint arXiv:2109.10282 (2021)
Liu, Y., et al.: RoBERTa: a robustly optimized BERT pretraining approach. CoRR abs/1907.11692 (2019)
Lu, S., et al.: CodeXGLUE: a machine learning benchmark dataset for code understanding and generation. arXiv (2021)
Montellano, C.D.B., Garcia, C.O.F.C., Leija, R.O.C.: Recognition of handwritten flowcharts using convolutional neural networks. Int. J. Comput. Appl. (2022)
Papineni, K., Roukos, S., Ward, T., Zhu, W.J.: BLEU: a method for automatic evaluation of machine translation. In: Proceedings of ACL (2002)
Radford, A., Narasimhan, K., Salimans, T., Sutskever, I., et al.: Improving language understanding by generative pre-training. OpenAI (2018)
Raffel, C., et al.: Exploring the limits of transfer learning with a unified text-to-text transformer. J. Mach. Learn. Res. 21, 1–67 (2020)
Ren, S., et al.: CodeBLEU: a method for automatic evaluation of code synthesis. CoRR abs/2009.10297 (2020)
Schäfer, B., Stuckenschmidt, H.: Arrow R-CNN for flowchart recognition. In: Proceedings of ICDAR Workshop (2019)
Song, K., Tan, X., Qin, T., Lu, J., Liu, T.Y.: MASS: masked sequence to sequence pre-training for language generation. In: Proceedings of ICML (2019)
Supaartagorn, C.: Web application for automatic code generator using a structured flowchart. In: 2017 8th IEEE International Conference on Software Engineering and Service Science (ICSESS) (2017)
Tannert, S., Feighelstein, M., Bogojeska, J., Shtok, J., Staar, A.A.P., Karlinsky, A.S.J.K.L.: FlowchartQA: the first large-scale benchmark for reasoning over flowcharts. In: Document Intelligence Workshop @ KDD (2022)
Vaswani, A., et al.: Attention is all you need. In: Proceedings of NeurIPS (2017)
Wang, Y., Wang, W., Joty, S., Hoi, S.C.: CodeT5: identifier-aware unified pre-trained encoder-decoder models for code understanding and generation. In: Proceedings of EMNLP (2021)
Wolf, T., et al.: Transformers: state-of-the-art natural language processing. In: Proceedings of EMNLP: System Demonstrations (2020)
Wu, X.H., Qu, M.C., Liu, Z.Q., Li, J.Z., et al.: Research and application of code automatic generation algorithm based on structured flowchart. J. Softw. Eng. Appl. 4, 534–545 (2011)
Acknowledgements
This work was partly supported by MeitY, Govt. of India (project number: S/MeitY/AM/20210114). Yogesh Kumar is supported by a UGC fellowship.
Author information
Authors and Affiliations
Corresponding authors
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2023 The Author(s), under exclusive license to Springer Nature Switzerland AG
About this paper
Cite this paper
Shukla, S., Gatti, P., Kumar, Y., Yadav, V., Mishra, A. (2023). Towards Making Flowchart Images Machine Interpretable. In: Fink, G.A., Jain, R., Kise, K., Zanibbi, R. (eds) Document Analysis and Recognition - ICDAR 2023. ICDAR 2023. Lecture Notes in Computer Science, vol 14191. Springer, Cham. https://doi.org/10.1007/978-3-031-41734-4_31
Download citation
DOI: https://doi.org/10.1007/978-3-031-41734-4_31
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-031-41733-7
Online ISBN: 978-3-031-41734-4
eBook Packages: Computer ScienceComputer Science (R0)