Dental caries is a bacterial infectious disease that destroys the structure of teeth. It is one of the main diseases that endanger human health [R. H. Selwitz, A. I. Ismail, and N. B. Pitts, Lancet 369(9555), 51–59 (2007)]. At present, dentists use both visual exams and radiographs for the detection of caries. Affected by the patient's dental health and the degree of caries demineralization, it is sometimes difficult to accurately identify some dental caries in x-ray images with the naked eye. Therefore, dentists need an intelligent and accurate dental caries recognition system to assist diagnosis, reduce the influence of doctors' subjective factors, and improve the efficiency of dental caries diagnosis. Therefore, this paper combines the U-Net model verified in the field of biomedical image segmentation with the convolution block attention module, designs an Attention U-Net model for caries image segmentation, and discusses the feasibility of deep learning technology in caries image recognition so as to prepare for the next clinical verification. After testing, the Dice similarity coefficient, mean pixel accuracy, mean intersection over union, and frequency-weighted intersection over the union of teeth segmentation with Attention U-Net are 95.30%, 94.46%, 93.10%, and 93.54%, respectively. The Dice similarity coefficient, mean pixel accuracy, mean intersection over union, and frequency-weighted intersection over the union of dental caries segmentation with Attention U-Net are 85.36%, 91.84%, 82.22%, and 97.08%, respectively. As a proof of concept study, this study was an initial evaluation of technology to assist dentists in the detection of caries. There is still more work needed before this can be used clinically.