In order to further improve the generalization, robustness and real-time performance of traffic intelligent system for vehicle and different vehicle types recognition. According to the characteristics of the detection region, the data set is constructed pertinently, and the updating method of cosine decay with warm up (CD) learning rate is changed. An Adam GC based on gradient compression (GC) is proposed to improve the training speed, detection accuracy and generalization ability of YOLO (you only look once) V4 algorithm. In order to verify the effectiveness of the algorithm proposed in this paper, after collecting the traffic flow of the actual road conditions, the trained network model is used to verify the quantitative vehicle type detection experiment of different density traffic flow. The experimental results show that the overall detection result of the improved method is better than that of the original method. The accuracy rates of the network models trained by YOLO v4 and YOLO v4-GC-CD under the blocking flow samples are 94.59% and 96.46%, respectively; the accuracy rates of the detection under synchronous flow samples are 95.34% and 97.20%, respectively; the accuracy rates of detection under free flow samples are 95.98% and 97.88%, respectively.