 Pneumonia is a potentially fatal lung condition caused by either bacteria or virus. Early diagnosis is essential to prevent death, so it is important to develop automated methods for its detection. This paper proposes for CNN models for transfer learning to accurately identify bacterial and viral pneumonia from digital x-ray images. The results show that the proposed model achieves high accuracy rates of 98% for normal versus pneumonia, 95% for bacterial versus viral pneumonia, and 93.3% for normal, bacterial, and viral pneumonia. This is the highest accuracy reported in the literature, making it suitable for use in airport screenings. This article was authored by Tosafur Rahman, Muhammad E. H. Choudhury, Amith Khandekar, and others.