Artificial intelligence has radically altered the world, and it continues to progress at an alarming rate as time passes. AI applications include healthcare and medical solutions, illness diagnostics, agriculture, constructing security infrastructures, autonomous cars, intelligent systems, industrial production, robotics, and much more. COVID19 is a deadly virus that first appeared in China in 2019 and soon spread over the world. By 2020, the globe had witnessed a tremendous epidemic, with countless lives lost as a result of this dreadful virus, which has now become a severe health danger. Furthermore, in 2021, several nations will be infected with new Covid19 forms that are more deadly and spread quicker. The research describes the proposed methodology for diagnosing covid-19 and pneumonia from human chest X-ray images using transfer learning with Resnet-18 and VGG-16 neural networks. The focal loss function was also used to homogenize the imbalanced dataset, which included X-ray images of normal, pneumonia, and Covid-19 patients. The purpose is to assess the performance and accuracy of fine-tuned neural networks after including Binary Cross-Entropy (BCE) and Focal Loss (FL) functions. However, when we used our Resnet-18 and VGG-16 neural networks with BCE and FL functions, the VGG-16 with FL function outperformed all other models, with training and validation accuracy of 98.37 percent and 97.37 percent, correspondingly.