In this paper, we propose a method for predicting potential accidents using object detection and object relationship analysis. We use YOLOv7 object detector to identify various objects on roads and highways, and analyze the relationships between them to predict potential accidents. Our model is trained on a large dataset from Kaggle competitions, which includes driving record videos of different types of vehicles such as buses, cars, trailers, trucks, and lorries. We analyze the patterns of detected accident vehicle objects to determine whether an accident occurred in consecutive frames. Experimental results show that our method can reasonably predict whether an accident will occur in the next 20 frames. The use of object detection allows for the identification of multiple objects, thus improving the accuracy of accident prediction. Although we did not achieve better performance or accuracy, this approach has the potential to improve the safety performance of autonomous vehicles and reduce the occurrence of traffic accidents.