This study presents a deep learning model, covid-cxdnetv2, for real-time detection of COVID-19 and pneumonia from chest X-ray images, achieving an overall classification accuracy of 97.9%. The model is developed using a customized dataset of 3788 X-ray images and integrates the YOLOv2 architecture with residual neural networks to enhance detection capabilities. This method aims to support medical diagnostics amidst the increasing prevalence of these diseases while addressing limitations of existing detection methods.