Nowadays, it is an obvious fact that with the double blessing of economic growth and the diversity of human’s life, travel has become an indispensable activity during the leisure time. Meanwhile, due to the convenience, timesaving and accessibility, private cars gradually play a vital role on the road. However, it is conceivable that the increase in vehicles means that there will be inevitable congestion, especially during the peak hours of the day. In order to reverse the situation that private cars are from “convenience” to “inconvenience”, this paper decides to explore how to accurately predict the change of traffic flow over time, perceive the upcoming peak period in advance to provide reliable traffic information for publishing and allocate traffic resources reasonably. To capture the time features in traffic flow data, extract their internal laws and process them more accurately, this research applies a combined model of convolutional neural network (CNN) and transformer, that is, CNN is used for the feature extraction, and the extracted features are passed to the transformer model for further predictive analysis. The experimental dataset in the research comes from the official website of Highway England. The result displays that the iteration speed of this model is rapid, the prediction error is able to be minimized and it can be applied in the case of a huge dataset.