At present, China is moving towards the direction of "Industry 4.0". The development of the automobile industry, especially intelligent automobiles, is in full swing, which brings great convenience to people's life and travel. However, at the same time, urban traffic pressure is also increasingly prominent, and the situation of traffic congestion and traffic safety is not optimistic. In this context, the Internet of Vehicles (also known as "IoV") opens up a new way to relieve urban traffic pressure. Therefore, in order to further optimize the road network traffic conditions in the IoV environment, this research focuses on the traffic flow prediction algorithm on the basis of deep learning to enhance traffic efficiency and safety. First, the study investigates the short-time traffic flow prediction by combining the characteristics of the IoV environment. To address the issues that existing algorithms cannot automatically extract data features and the model expression capability is weak, the study chooses to build a deep neural network using GRU model in deep learning for short-time traffic flow prediction, thereby improving the prediction accuracy of algorithm. Secondly, a fine-grained traffic flow statistics approach suitable for the IoV situation is suggested in accordance with the deep learning model that was built. The algorithm sends the vehicle characteristic data obtained through GRU model training into the fine-grained traffic flow statistics algorithm, so as to realize the statistics of traffic information of various types of vehicles. The advantage of this algorithm is that it can well count the traffic flow of multiple lanes, so as to better predict the current traffic status and achieve traffic optimization. Finally, the IoV environment is constructed to confirm the effectiveness of the prediction model. The prediction results prove that the new algorithm has good performance in traffic flow statistics in different scenarios.