Automated disease prediction has now become a key concern in medical research due to exponential population growth. The automated disease identification framework aids physicians in diagnosing disease, which delivers accurate disease prediction that provides rapid outcomes and decreases the mortality rate. The spread of Coronavirus disease 2019 (COVID-19) has a significant effect on public health and the everyday lives of individuals currently residing in more than 100 nations. Despite effective attempts to reach an appropriate trend to forecast COVID-19, the origin and mutation of the virus is a crucial obstacle in the diagnosis of the detected cases. Even so, the development of a model to forecast COVID-19 from chest X-ray (CXR) and computerized tomography (CT) images with the correct decision is critical to assist with intelligent detection. In this paper, a proposed hybrid model of the artificial neural network (ANN) with parameters optimization by the butterfly optimization algorithm has been introduced. The proposed model was compared with the pretrained AlexNet, GoogLeNet, and the SVM to identify the publicly accessible COVID-19 chest X-ray and CT images. There were six datasets for the examinations: three datasets with X-ray pictures and three with CT images. The experimental results approved the superiority of the proposed model for cognitive COVID-19 pattern recognition with average accuracy 90.48, 81.09, 86.76, and 84.97% for the proposed model, support vector machine (SVM), AlexNet, and GoogLeNet, respectively.