Melamine and its derivative, cyanuric acid, are occasionally added to pet meals because of their nitrogen-rich qualities, leading to the development of several health-related issues. A nondestructive sensing technique that offers effective detection must be developed to address this problem. In conjunction with machine learning and deep learning technique, Fourier transform infrared (FT-IR) spectroscopy was employed in this investigation for the nondestructive quantitative measurement of eight different concentrations of melamine and cyanuric acid added to pet food. The effectiveness of the one-dimensional convolutional neural network (1D CNN) technique was compared with that of partial least squares regression (PLSR), principal component regression (PCR), and a net analyte signal (NAS)-based methodology, called hybrid linear analysis (HLA/GO). The 1D CNN model developed for the FT-IR spectra attained correlation coefficients of 0.995 and 0.994 and root mean square error of prediction values of 0.090% and 0.110% for the prediction datasets on the melamine- and cyanuric acid-contaminated pet food samples, respectively, which were superior to those of the PLSR and PCR models. Therefore, when FT-IR spectroscopy is employed in conjunction with a 1D CNN model, it serves as a potentially rapid and nondestructive method for identifying toxic chemicals added to pet food.