The potential of technology to revolutionize healthcare is exemplified by the synergy between artificial intelligence (AI) and early detection of cardiomegaly, demonstrating the power of proactive intervention in cardiovascular health. This paper presents an innovative approach that leverages advanced AI algorithms, specifically deep learning (DL) technology, for the early detection of cardiomegaly. The methodology consists of five key steps, including data collection, image preprocessing, data augmentation, feature extraction, and classification. Utilizing chest X-ray (CXR) images from the National Institutes of Health (NIH), the study applies rigorous image preprocessing operations, including color transformation and normalization. To enhance model generalization, data augmentation is employed, paving the way for two distinct DL models, a convolutional neural network (CNN) developed from scratch and a pretrained residual network with 50 layers (ResNet50), and adapted to the problem domain. Both models are systematically evaluated with five optimizers, revealing the AdaMax optimizer’s superiority for the CNN model and AdaGrad’s efficacy for the modified ResNet50. The proposed CNN with AdaMax achieves an impressive 99.91% accuracy, outperforming recent techniques in precision, recall, and F1−score. This research underscores the transformative potential of AI in cardiovascular health diagnostics, emphasizing the significance of timely intervention.