Abstract
Rapid and reproducible interpretation of electrocardiograms (ECGs) is essential for distinguishing acute myocardial infarction from chronic infarction patterns, rhythm abnormalities, and normal recordings. This study presents a controlled comparison of three transfer-learned Vision Transformer architectures—DeiT-Small, Swin-Tiny, and ViT-Tiny—for four-class classification of 12-lead ECG report images. A total of 3,951 images were stratified into training (n = 3, 159), validation (n = 393), and independent test (n = 399) subsets representing abnormal heartbeat, history of myocardial infarction, myocardial infarction, and normal ECG. All models were initialized with ImageNet-pretrained weights and fine-tuned under the same input resolution, augmentation policy, optimizer, and stopping criterion. Performance was assessed using accuracy, macro-precision, macro-recall, macro-F1 score, parameter count, floating-point operations, and inference latency. DeiT-Small achieved the highest macro-F1 score (0.9971) with an accuracy of 0.9975, while ViT-Tiny reached the same accuracy and a macro-F1 score of 0.9969 using only 5.53 million parameters, 2.1493 GFLOPs, and 0.1275 ms per image. Swin-Tiny remained accurate (0.9825) but required the greatest computational cost. The DeiT-Small confusion matrix contained a single error, in which one normal ECG was assigned to the history-of-myocardial-infarction class. These findings indicate that compact global-attention models can retain near-perfect internal discrimination while substantially reducing computational demand. Nevertheless, patient-independent and multi-center external validation is required before clinical use.
References
Aghababaei, Z., L. Tapak, M. Rasoulinia, M. Afrasiabi, S. K. Hosseini, et al., 2025 Optimizing myocardial infarction detection: a hybrid cnn-gru deep learning approach. BMC Medical Informatics and Decision Making 25: 408.
Ahmad, M., A. Ahmed, H. Hashim, M. Farsi, and N. Mahmoud, 2025 Enhancing heart disease diagnosis using ecg signal reconstruction and deep transfer learning classification with optional svm integration. Diagnostics 15: 1501.
Alghieth, M., 2025 Deepecg-net: a hybrid transformer-based deep learning model for real-time ecg anomaly detection. Scientific Reports 15: 20714.
Alsayat, A. et al., 2025 Enhancing cardiac diagnostics: a deep learning ensemble approach for precise ecg image classification. Journal of Big Data 12: 7.
Ashtaiwi, A., T. Khalifa, and O. Alirr, 2024 Enhancing heart disease diagnosis through ecg image vectorization-based classification. Heliyon 10: e37574.
Atwa, A. E. M., E.-S. Atlam, A. Ahmed, M. A. Atwa, E. M. Abdelrahim, et al., 2025 Interpretable deep learning models for arrhythmia classification based on ecg signals using ptb-x dataset. Diagnostics 15: 1950.
Bai, X., X. Dong, Y. Li, R. Liu, and H. Zhang, 2024 A hybrid deep learning network for automatic diagnosis of cardiac arrhythmia based on 12-lead ecg. Scientific Reports 14: 24441.
Dosovitskiy, A. et al., 2021 An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations.
Eleyan, A. and E. Alboghbaish, 2024 Electrocardiogram signals classification using deep-learning-based incorporated convolutional neural network and long short-term memory framework. Computers 13: 55.
Gupta, V. et al., 2026 Multimodal deep learning for acute myocardial infarction detection from 12-lead electrocardiogram: a multi-centre study with cross-hospital validation. European Heart Journal - Digital Health 7: ztaf125.
Gustafsson, S. et al., 2026 A deep learning ecg model for identification and localization of occlusion myocardial infarction. Nature Communications 17: 4336.
Hasan, M. N., M. A. Hossain, and M. A. Rahman, 2025 An ensemble based lightweight deep learning model for the prediction of cardiovascular diseases from electrocardiogram images. Engineering Applications of Artificial Intelligence 141: 109782.
Hilgendorf, L. et al., 2025 Fully automated diagnosis of acute myocardial infarction using electrocardiograms and multimodal deep learning. JACC: Advances 4: 102011.
Kaggle, 2026 Ecg image. https://www.kaggle.com/datasets/kanishkarathore1604/ecg-image?resource=download, Accessed July 4, 2026.
Kalmady, S. V. et al., 2024 Development and validation of machine learning algorithms based on electrocardiograms for cardiovascular diagnoses at the population level. NPJ Digital Medicine 7: 133.
Khalid, M., C. Pluempitiwiriyawej, A. A. Abdulkadhem, I. Afzal, and T. Truong, 2024 Ecgconvt: A hybrid cnn and vision transformer model for enhanced 12-lead ecg images classification. IEEE Access 12: 193043–193056.
Kolhar, M. and A. M. Al Rajeh, 2024 Deep learning hybrid model ecg classification using alexnet and parallel dual branch fusion network model. Scientific Reports 14: 26919.
Lin, C.-H. et al., 2025 A multitask deep learning model utilizing electrocardiograms for major cardiovascular adverse events prediction. NPJ Digital Medicine 8: 1.
Liu, Z. et al., 2021 Swin transformer: Hierarchical vision transformer using shifted windows.
Liu, Z.-Y. et al., 2025 Universal representations in cardiovascular ecg assessment: A self-supervised learning approach. International Journal of Medical Informatics 195: 105742.
Ma, L. and F. Zhang, 2024 A novel real-time detection and classification method for ecg signal images based on deep learning. Sensors 24: 5087.
Malleswari, P. N., V. K. Odugu, T. J. V. S. Rao, and T. V. N. L. Aswini, 2024 Deep learning-assisted arrhythmia classification using 2-d ecg spectrograms. EURASIP Journal on Advances in Signal Processing 2024: 104.
Mohan, A., D. C. Elbers, O. Zilbershot, F. Afghah, and D. Vorchheimer, 2024 Deciphering heartbeat signatures: A vision transformer approach to explainable atrial fibrillation detection from ecg signals. In 2024 46th Annual International Conference of the IEEE Engineering in Medicine and Biology Society (EMBC), pp. 1–6.
Narotamo, H., M. Dias, R. Santos, A. V. Carreiro, H. Gamboa, et al., 2024 Deep learning for ecg classification: A comparative study of 1d and 2d representations and multimodal fusion approaches. Biomedical Signal Processing and Control 93: 106141.
Nayyab, R. et al., 2025 Enhancing ecg disease detection accuracy through deep learning models and p-qrs-t waveform features. PLoS ONE 20: e0325358.
Park, B. E. et al., 2025 Signal-guided multitask learning for myocardial infarction classification using images of electrocardiogram. Cardiology 150: 347–356.
Qiang, Y., X. Dong, and Y. Yang, 2024 Automatic detection and localisation of myocardial infarction using multi-channel dense attention neural network. Biomedical Signal Processing and Control 89: 105766.
Riek, N. T. et al., 2024 Clinical usability of deep learning-based saliency maps for occlusion myocardial infarction identification from the prehospital 12-lead electrocardiogram. Journal of Electrocardiology 87: 153792.
Riek, N. T. et al., 2025 Ecg-smart-net: A deep learning architecture for precise ecg diagnosis of occlusion myocardial infarction. IEEE Transactions on Biomedical Engineering 72: 3613–3620.
Sattar, S. et al., 2024 Cardiac arrhythmia classification using advanced deep learning techniques on digitized ecg datasets. Sensors 24: 2484.
Selvam, I. J., M. Madhavan, and S. K. Kumarasamy, 2025 Detection and classification of electrocardiography using hybrid deep learning models. Hellenic Journal of Cardiology 81: 75–84.
Shivashankara, K. K., Deepanshi, A. M. Shervedani, G. D. Clifford, M. A. Reyna, et al., 2024 Ecg-image-kit: a synthetic image generation toolbox to facilitate deep learning-based electrocardiogram digitization. Physiological Measurement 45: 055019.
Touvron, H., M. Cord, M. Douze, F. Massa, A. Sablayrolles, et al., 2021 Training data-efficient image transformers and distillation through attention. In Proceedings of the 38th International Conference on Machine Learning, volume 139.
Wu, Z. and C. Guo, 2025 Deep learning and electrocardiography: systematic review of current techniques in cardiovascular disease diagnosis and management. Biomedical Engineering Online 24: 23.

This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.
