Pneumonia is a fatal disease that arises from a bacterial infection in the lungs. If it is not detected in an early stage, it can cause death among young children. Early detection of this disease can play an important role in the effectiveness of the treatment process. The diagnosis is usually monitored from chest X-ray images by an expert radiologist. Due to a lack of confidence in the diagnosis process regarding ambiguous X-ray images or being mistaken for other medical diseases, the application of computer vision is needed to assist radiologists in the decision-making process. In this study, we utilized techniques from transfer learning alongside three architectures based on convolutional neural networks (CNNs) to facilitate the detection of pneumonia and improve the interpretability of diagnostic outcomes. To achieve this, we used a publicly available dataset of 5,863 grayscale chest X-ray images. These images include standard anterior-posterior (AP) and lateral views obtained from unique patients from Guangzhou Women and Children's Medical Center in China (1,583 normal and 4,280 pneumonia images). Before the training, validation, and testing phases, data preprocessing techniques including image resizing and data augmentation were used to prepare the dataset for binary classification. To enhance the generalizability and efficacy of our findings, we utilized high-performing pre-trained models such as DenseNet121, DenseNet169, and ResNet101, evaluating the performance of each architecture against an external validation, and test set. The evaluation results of deep learning models for binary classification of pneumonia demonstrated that DenseNet121 outperformed its counterparts achieving the highest validation accuracy of 98.68% and the lowest loss value of 0.04.