The arrival of the digital era has brought new opportunities for the protection and inheritance of traditional culture. Ethnic patterns, as an important carrier of cultural heritage, carry deep historical heritage and national spirit. This study constructs an intelligent generation system of ethnic patterns based on CA-GAN model and applies it to the teaching of ethnic pattern design courses to enhance the cultural inheritance effect and national identity. The methodology adopts generative adversarial network technology, extracts the content features and style attributes of patterns through content encoder and attribute encoder respectively, and realizes high-quality ethnic pattern generation by combining the attention mechanism. The study uses a database containing 6438 ethnic patterns for model training, and sets the number of training rounds to 10000 epochs and the batch size to 128. The experimental results show that the CA-GAN model performs well in objective evaluation indexes, with the PSNR value reaching 33.15, the SSIM value reaching 0.927, and the FID value decreasing to 10.44, which is an improvement from 10.65% to 19.93% compared with the comparison methods, respectively. 10.65% to 19.93%, 4.51% to 15.59% and reduced 22.38% to 38.77% respectively compared to the comparison method. The subjective evaluation showed that the composite score of the generated pattern reached 4.63. The results of the cultural heritage and national identity survey showed that students and teachers recognized the generative schema, and the emotional resonance dimension of the national identity survey was rated at 4.63 points. The study shows that the introduction of computer vision technology effectively improves the teaching effect of ethnic pattern design courses and provides a new path for the digital inheritance of traditional culture.