This repo contains the CycleCrash dataset and the code for our [WACV2025 paper] on bicycle collision prediction and analysis.
The dataset consists of 3,000 dashcam videos with 436,347 frames that capture cyclists in a range of critical situations, from collisions to safe interactions. This dataset enables 9 different cyclist collision prediction and classification tasks focusing on potentially hazardous conditions for cyclists and is annotated with collision-related, cyclist-related, and scene-related labels. Please refer to the dataset.csv
file for detailed annotations and additional information about each video in the dataset.
This code also contains PyTorch implementation for VidNeXt, a novel method that uses a non-stationary transformer on the defined tasks within our dataset, along with 7 baseline models.
- dataset.csv: CSV file containing the CycleCrash dataset.
- download: This folder contains the source code for downloading and preparing the CycleCrash dataset.
- download_dataset.py: Python script to download the videos of the dataset.
- preprocess.py: Python script to Pre-process videos for background cropping and uniform temporal and spatial dimensions.
- src: This folder contains the source code for executing the VidNeXt and baseline models on the tasks of CycleCrash dataset.
- data_loader.py: Python script for implementing PyTorch-based Data loader for CycleCrash dataset
- get_model.py: Python script to load the baseline models, the proposed VidNeXt and its ablation variants.
- get_model.py: Python script to run the training and evaluation of the proposed VidNeXt and its ablation variants on CycleCrash dataset.
-
Clone the Github repository:
- Run the following command in a terminal to clone the GitHub repository in your current location.
git clone https://github.com/DeSinister/CycleCrash.git cd CycleCrash
-
Installing Packages
- Run the following command to make sure the necessary packages are installed.
pip install -r requirements.txt
-
FFmpeg:
- Download the full build of FFmpeg from FFmpeg Releases.
- Extract the downloaded ZIP file to a location on your system, e.g.,
C:\ffmpeg-6.0-full_build
.
-
yt-dlp:
- Download
yt-dlp
from the yt-dlp GitHub repository. - Place the
yt-dlp.exe
in thebin
directory of the FFmpeg folder, e.g.,C:\ffmpeg-6.0-full_build\ffmpeg-6.0-full_build\bin
.
- Download
-
Downloading the dataset
- Set the paths for the dataset.csv, output folder, and folder path containing yt-dlp.exe in download_dataset.py.
- Run the python file download.py to collect the videos.
python download/download_dataset.py
-
Preprocessing the videos
- Set the paths for the dataset.csv, the directory where videos are stored, and the output directory in pre_process.py
- Run the preprocess.py file.
python download/preprocess.py
- Run src/main.py with the required hyperparameter setting in arguments.
python src/main.py -vid_dir PATH_TO_PREPROCESSED_VIDEOS -csv_file PATH_TO_DATASET_CSV -task TASK_TYPE
Method | Risk | Right-of-way | Collision | Time-to-coll. | Severity | Fault | Age | Direction | Object | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Acc. ↑ | F1 ↑ | Acc. ↑ | F1 ↑ | Acc. ↑ | F1 ↑ | MSE ↓ | Acc. ↑ | F1 ↑ | Acc. ↑ | F1 ↑ | Acc. ↑ | F1 ↑ | Acc. ↑ | F1 ↑ | Acc. ↑ | F1 ↑ | |
TimeSformer | 65.74 | 41.79 | 60.20 | 55.71 | 66.45 | 69.69 | 1.41 | 36.49 | 23.01 | 59.65 | 51.03 | 93.77 | 66.68 | 47.19 | 31.38 | 45.02 | 29.00 |
ViViT | 65.12 | 39.06 | 52.84 | 53.74 | 57.01 | 69.92 | 1.33 | 47.51 | 24.47 | 53.37 | 50.42 | 93.56 | 66.34 | 36.29 | 27.99 | 46.30 | 26.34 |
ResNet50 3D | 65.76 | 39.53 | 59.41 | 53.97 | 63.10 | 60.24 | 1.38 | 56.60 | 26.12 | 59.37 | 54.91 | 94.21 | 54.86 | 46.30 | 30.12 | 43.27 | 27.77 |
R(2+1)D | 66.54 | 39.56 | 60.31 | 53.42 | 67.71 | 63.33 | 1.43 | 56.63 | 25.46 | 50.53 | 52.62 | 94.41 | 53.24 | 47.49 | 30.36 | 40.75 | 25.48 |
X3D-M | 64.76 | 38.75 | 59.83 | 57.57 | 63.72 | 61.08 | 1.44 | 54.45 | 24.70 | 52.16 | 52.19 | 94.34 | 53.78 | 47.82 | 31.85 | 42.72 | 23.79 |
X3D-S | 63.37 | 36.28 | 60.10 | 56.90 | 61.49 | 61.13 | 1.47 | 51.80 | 24.09 | 60.47 | 51.88 | 94.38 | 54.30 | 45.62 | 30.05 | 42.03 | 22.38 |
X3D-XS | 64.77 | 37.23 | 59.37 | 53.43 | 60.59 | 60.73 | 1.47 | 51.39 | 23.77 | 56.10 | 52.59 | 93.87 | 52.37 | 46.77 | 30.22 | 41.73 | 26.57 |
ConvNeXt+VT | 64.89 | 40.05 | 61.13 | 54.00 | 63.50 | 65.06 | 1.56 | 53.80 | 26.54 | 56.74 | 55.72 | 94.55 | 66.78 | 46.46 | 32.62 | 42.85 | 25.16 |
ResNet+NST | 67.18 | 40.74 | 61.77 | 58.62 | 60.79 | 62.28 | 1.39 | 53.88 | 24.67 | 57.17 | 54.08 | 94.52 | 53.49 | 45.12 | 28.48 | 44.17 | 26.91 |
VidNeXt (Ours) | 66.20 | 41.96 | 64.28 | 57.51 | 64.84 | 70.84 | 1.38 | 59.66 | 31.78 | 65.16 | 52.51 | 94.57 | 67.88 | 47.94 | 31.20 | 42.31 | 28.37 |
Combined experimental results for tasks 1 through 9. The methods include the 7 baselines based on prior works, 2 ablation variants, and VidNeXt.
If you find this repository useful, please consider giving it a star ⭐ and citing the paper:
@inproceedings{desai2025cyclecrash,
title={CycleCrash: A Dataset of Bicycle Collision Videos for Collision Prediction and Analysis},
author={Desai, Nishq Poorav and Etemad, Ali and Greenspan, Michael},
booktitle={Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision},
year={2025}
}
This project includes code borrowed from the following repositories:
- ViViT by Google Research.
- Non-stationary Trasnformer.
- ConvNeXt by Facebook Research.
- TimeSformer by Facebook Research.
- 3D ResNet, R(2+1)D, X3D by Facebook Research.