Amid the increasing global challenge of foodborne diseases, there is an urgent need for rapid and precise pathogen detection methods. This study innovatively integrates surface-enhanced Raman Spectroscopy (SERS) with deep learning technology to develop an efficient tool for the detection of foodborne pathogens. Utilizing an automated design of mixed networks (ADMIN) strategy, coupled with neural architecture search (NAS) technology, we optimized convolutional neural networks (CNNs) architectures, significantly enhancing SERS data analysis capabilities. This research introduces the U-Net architecture and attention mechanisms, which improve not only classification accuracy but also the model's ability to identify critical spectral features. Compared to traditional detection methods, our approach demonstrates significant advantages in accuracy. In testing samples from 22 foodborne pathogens, the optimized NAS-Unet model achieved an average precision of 92.77 %, surpassing current technologies. Additionally, we explored how different network depths affect classification performance and validated the model's generalization capabilities on the Bacteria-ID dataset, laying the groundwork for practical applications. Our study provides an innovative detection approach for the food safety sector and opens new avenues for applying deep learning technologies in microbiology. Looking ahead, we aim to further explore diverse network modules to enhance model generalization and promote the application of these technologies in real-world food safety testing, playing a crucial role in the fight against foodborne diseases.