Coder Social home page Coder Social logo

tad-iros2019's Introduction

Unsupervised Traffic Accident Detection in First-Person Videos

Yu Yao*, Mingze Xu*, Yuchen Wang, David Crandall and Ella Atkins

Updates

💥 May 19th 2020: Our new Detection of Traffic Anomaly (DoTA) dataset is available here! DoTA can be considered an extention of A3D, which provides more videos (4677 raw videos) and annotations (anomaly types, anomaly objects, and tracking ids).

DoTA also provides more benchmarks in driving videos, such as anomaly detection, action recognition, and online action detection. The corresponding paper can be found here.

Introduction

This repo contains the A3D dataset and the code for our IROS2019 paper on unsupervised traffic accident detection.

This code also contains an improved PyTorch implementation for our ICRA paper Egocentric Vision-based Future Vehicle Localization for Intelligent Driving Assistance Systems, which is an important building block for the traffic accident detection. The original project repo is https://github.com/MoonBlvd/fvl-ICRA2019.

Requirements

To run the code on feature-ready HEV-I dataset or dataset prepared in HEV-I style:

cuda 9.0 or newer
pytorch 1.0
torchsummaryX
tensorboardX

Train and test

Note that we apply a FOL and ego-motion prediction model for unsupervised anomaly detection. Thus, the model is only trained for FOL and ego-motion prediction on normal driving datasets. In the paper, we used HEV-I as our training data.

Train

The training script and a config file template are provided. We first train the ego motion predictor and then train the FOL and ego motion predictor jointly:

python train_ego_pred.py --load_config config/fol_ego_train.yaml
python train_fol.py --load_config config/fol_ego_train.yaml

Test FOL and anomaly detection

For evaluation purpose, we first run our fol_ego model on test dataset, e.g. A3D, to generate all predictions

python run_fol_for_AD.py --load_config config/test_A3D.yaml

This will save one .pkl file for each video clip. Then, we can use the saved predictions to calculate anomaly detection metrics. The following command will print results similar to the paper.

python run_AD.py --load_config config/test_A3D.yaml

The only anomaly detection script is not provided, but the users are free to write another script to do FOL and anomaly detection online.

Dataset and features

A3D dataset

The A3D dataset contains videos from YouTube and a .pkl file including human annotated video start/end times and anomaly start/end times. We provide scripts and url files to download the videos. Running the pre-process script will get the same frames we used in the paper.

Download the videos from YouTube:

python datasets/A3D_download.py --download_dir VIDEO_DIR --url_file datasets/A3D_urls.txt

Then convert the videos to frames in 10Hz:

python scripts/video2frames.py -v VIDEO_DIR -f 10 -o IMAGE_DIR -e jpg

Note that each downloaded video is a combination of several short clips, to split them into clips we used, run:

python datasets/A3D_split.py --root_dir DATA_ROOT --label_dir DIR_TO_PKL_LABEL

The annotations can be found in datasets/A3D_labels.pkl

HEV-I dataset

Honda Egocentric View-Intersection (HEV-I) dataset is owned by HRI and the users can follow the link to request the dataset.

However, we provide the newly generated features here in case that you are interested in using the input features to test your models:

Training features

Validation features

Training ego-motion extracted from ORBSLAM2

Validation ego-motion extracted from ORBSLAM2

Each feature file is name as "VideoName_ObjectID.pkl". Each .pkl file includes 4 attributes:.

  • frame_id: the temporal location of the object in the video;
  • bbox: the bounding box of the object from its appearing to disappearing;
  • flow: the corresponding optical flow features of the object obtained from the ROIPool;
  • ego_motion: the corresponding [yaw, x, z] value of ego car odometry obtained from the orbslam2.

To prepare the features used in this work, we used:

Future Object Localization

To train the model, run:

python train_fol.py --load_config YOUR_CONFIG_FILE

To test the model, run:

python test_fol.py --load_config YOUR_CONFIG_FILE

An example of the config file can be found in config/fol_ego_train.yaml

Evaluation results on HEV-I dataset

We do not split the dataset into easy and challenge cases as we did in the original repo. Instead, we evalute all cases together. We are still updating the following results table by changing the prediction horizon and the ablation models.

Model train seg length pred horizon FDE ADE FIOU
FOL + Ego pred 1.6 sec 0.5 sec 11.0 6.7 0.85
FOL + Ego pred 1.6 sec 1.0 sec 24.7 12.6 0.73
FOL + Ego pred 1.6 sec 1.5 sec 44.1 20.4 0.61
FOL + Ego pred 3.2 sec 2.0 sec N/A N/A N/A
FOL + Ego pred 3.2 sec 2.5 sec N/A N/A N/A

Note: Due to the change of model structure, the above evaluation results can be different from the original paper. The users are encouraged to compare with the result listed in this repo since the new model structure is more efficient than the model proposed in the original paper.

Traffic Accident Detection Demo

Alt Text

Citation

If you found this repo is useful, please feel free to cite our papers:

@inproceedings{yao2018egocentric,
	title={Egocentric Vision-based Future Vehicle Localization for Intelligent Driving Assistance Systems},
	author={Yao, Yu and Xu, Mingze and Choi, Chiho and Crandall, David J and Atkins, Ella M and Dariush, Behzad},
	journal={IEEE International Conference on Robotics and Automation (ICRA)},
	year={2019}
}

@inproceedings{yao2019unsupervised,
	title={Unsupervised Traffic Accident Detection in First-Person Videos},
	author={Yao, Yu and Xu, Mingze and Wang, Yuchen and Crandall, David J and Atkins, Ella M},
	journal={IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS)},
	year={2019}
}

tad-iros2019's People

Contributors

moonblvd avatar xumingze0308 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

tad-iros2019's Issues

Unresolved reference 'OUT_DIR'

hi,author,thanks for your job first.I noticed a small problem while looking at the code
'save_dir = os.path.join(OUT_DIR, video_name)' in run_fol_for_AD.py,PyCharm prompts Unresolved reference 'OUT_DIR'.I don't know what the problem is.Please help me.

Numpy files for train_fol.py

Good morning.

First of all, thank you for your work.
I am trying to run the training procedure and I checked that for train_ego_pred.py the dataset is built over the pickle files you provided. But I noticed that for running train_fol.py it's necessary the ego_motion numpy files, that are imported inside the HEVIEgoDataset() class. What are these files? Are they outputs from the ego_pred or are they part of the HEVI dataset? (I can't require the dataset since I'm not from USA). Can we get them from the picke files and save it as numpy files?

Thank you very much.

Visualize

I'm sorry to bother you again, but I have some questions about some parts of the code:
Why Visualize is set to false in run_fol_for_AD.py . So we can't visualize it.
I have a faux pas question .if this whole project will work on a cloud server.
I want to understand the code through the results
I hope you can help me

License

The license of this repository is not defined.
Could you please define the license as Apache License 2.0 or MIT License?

Flow Features

Hi Brian,
Could you point me to the script where you did ROIPooling of flow features and saved it for different datasets?

Thank you,
Srikanth

HEV-I data processed information

Hi Brian,

  1. When I print the processed data information for HEV-I (from the your .pkl data):
    session, frame_id, flow, ego_motion, bounding box
    201806061148002559_432.pkl (82,) (82, 5, 5, 2) (92, 3) (92, 4)
    why are they not equal?

  2. for the ego motion:
    did you use CAN information for [yaw, tx, ty] for HEV-I? and did what are the units, if not?

Model was trained, how to run anomaly detection on custom video file?

Have followed the steps to train the model on the HEVI features and ego-motion files provided by the author. Now I have:

  • fol_epoch_091_loss_0.0113.pt
  • ego_pred_epoch_091_loss_0.0180.pt

Then I need to run anomaly detection on a custom video file downloaded from the internet. How to do this?

Currently my understanding is to follow the below steps to process the video:
Detection: MaskRCNN
Tracking: DeepSort
Dense optical flow: FlowNet2.0
Ego motion: ORBSLAM2

Then refer the code in run_fol_for_AD.py & run_AD.py for the anomaly detection?

Thanks.

Question about HEV test set

Hello,

Thank you very much for your contribution. I was wondering about the test set for HEV. The features provided in the readme file for the HEV dataset are train and validation. However, in Table 2. the results for HEV(test) are provided. Is the validation set used as the test set in this case?

A3D, DoTA features

I trained the model using the HEV-I features data you published.
A3D and DoTA data need to generate features with FlowNet or ORBSLAM the same as HEV-I data?
If so, can i get a code that creates a feature using FlowNet or ORBSLAM?
Thank you.

Doubt on the architecture

Are we using a different LSTM module per track ? If we directly feed all object Xt and the corresponding flow feature, how is the track information maintained?

Evaluation results are bad when the 'predict horizen' become longer.

I use your code, your features and parameters to train the model, but can not get your result. Here is mine:

Model train seg length pred horizon FDE ADE FIOU
FOL 1.6 sec 0.5 sec 10.5 6.6 0.85
FOL 1.6 sec 1.0 sec 73.2 23.6 0.48
FOL 1.6 sec 1.5 sec 145.2 50.5 0.28
FOL + Ego pred 1.6 sec 0.5 sec 10.2 6.3 0.86
FOL + Ego pred 1.6 sec 1.0 sec 83.2 25.0 0.46
FOL + Ego pred 1.6 sec 1.5 sec 166.2 57.5 0.27

Is anything wrong? @MoonBlvd

get the HEV-I dataset

Hello, the website shows that only students from American universities can get the HEV-I dataset. I am a Chinese student. Is there any other way to get it?

The tracking result of deep_sort.

I find that the tracking results getting from deep_sort are not always continuous. But these in the features provided by you are continuous. So have you done the linear interpolation? @MoonBlvd

Does the train_fol.py script require the lengths of bbox and ego_motion to be the same in order to run properly?

First of all, thank you for your hard work. I want to learn a model from my personal data set. To do this, we want to create pkl files for bbox, flow, and ego_motion to learn EgoRNNED, FolRNNED models through train_fol.py.
By the way, does the model run only when the length of the bbox is equal to the length of ego_motion?
If so, how do you set up a bbox if you have one ego_motion in one frame but recognize multiple objects in one frame?
The following error occurs when the bbox is longer than the length of ego_motion.

Please reply. Thank you!
Screenshot from 2023-07-11 01-34-28

Having Problem while Running it.

I'm trying to run train_ego_pred but I get this error
Traceback (most recent call last):
File "/home/dev007/Desktop/tad-IROS2019/train_ego_pred.py", line 41, in
val_gen = data.DataLoader(val_set, **dataloader_params)
File "/home/dev007/.local/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 351, in init
sampler = RandomSampler(dataset, generator=generator) # type: ignore[arg-type]
File "/home/dev007/.local/lib/python3.10/site-packages/torch/utils/data/sampler.py", line 107, in init
raise ValueError("num_samples should be a positive integer "
ValueError: num_samples should be a positive integer value, but got num_samples=0

What features are contained in the dataset?

Does this DoTA dataset contain optical flow features? Does it contain the features of the vehicle's ego-motion?
Do we need to preprocess the data set to obtain the features of the optical flow(using flownet2)?
Do we need to preprocess the dataset to obtain the features of vehicle's ego-motion(using orb-slam)?

Pretrained weights

Hello,First of all thank you very much for your work. Can you provide the pretrained weights of best_ego_pred_model

request for trained weight

Hello! thank you for great work!

I just want to run with your official trained weight, but I can't find in git page.

Can I get one?

thank you in advance!

Missing video2frames.py script

Could you share the video2frames script that has been mentioned in the readme file or let me know how you perform the sampling from 25hz to 10 hz.

Custom Dataset

Thanks for your repo. I want to ask you " Can I use your repo with custom dataset?" and If yes, how to generate label (.pkl file)

What is the camera's intrinsic matrix for HEV-I data?

Hi I was interested in your research, thanks for the great paper.

I was wondering about the camera intrinsic matrix of the HEV-I dataset mentioned in the paper, because I need it to extract the features of the ego motion of the A3D. And is the ego motion data required to run run_fol_for_AD.py?
When I run ORB SLAM2 on an A3D sequence, is it okay if I don't get output values for all frames (only some frames have ORB SLAM2 values)?

Thanks. All of the best.

cannot find HEVI_data/fol_data

Hi, author. I have downloaded the HEVI dataset, and prepare to train the model. But I am confused about the dataset definition in the config.yaml. For instance, in 'fol_ego_train.yaml', what the data_root mean? When I check my HEVI dataset, I don't find the 'fol_data'.
Please help me! Thanks.

How is the prediction horizon computed?

Hello, thanks for this nice repo.
I was curious about the observation and prediction horizon.
How do you slide through the time steps to move forward?
Let's say, you observed from frame 0 to 14 and predicted from 15 to 24, what will be your next observation? Will your next observation be from frame 1 to frame 15?

prediction result visualization

Hi, I want to do some visualization to make the predicted result more clear, just like the figure as presented in your paper. How should I do? Please help me.
Thanks!

The `predict` method of `FolRNNED` class

@MoonBlvd Is the predict method of FolRNNED class cooresponding to the Bounding Box Prediction subsection in the article Unsupervised Traffic Accident Detection in First-Person Videos ? Does it work well?

DataLoader error

<_io.TextIOWrapper name='/mimer/NOBACKUP/groups/deep-ssl/op/tad-IROS2019/config/fol_ego_train.yaml' mode='r' encoding='UTF-8'>
Traceback (most recent call last):
File "/mimer/NOBACKUP/groups/deep-ssl/op/tad-IROS2019/train_ego_pred.py", line 24, in
args = parse_args()
File "/mimer/NOBACKUP/groups/deep-ssl/op/tad-IROS2019/config/config.py", line 34, in parse_args
parser.set_defaults(**yaml.load(f))
TypeError: load() missing 1 required positional argument: 'Loader'

A3D Dataset - There are videos that are not used.

There are videos (A3D_urls.txt) that are not used in A3D_labels.pkl.

What I've done is as follows.

from joblib import load

data = load('datasets/A3D_labels.pkl')

used = set([value['video_name'] for _, value in data.items()])

prefix = len('https://www.youtube.com/watch?v=')

with open('datasets/A3D_urls.txt') as f:
    lines = f.read().split()
    total = [line[prefix:] for line in lines]
    
unused = set(total) - set(used)
print(len(total), len(used), len(unused))

Then, I got in total 204 videos, 80 are used and 124 are not.

dataset in HEV-I style

thanks for your job first. For some reason I cannot get the dataset. I tend to prepare a dataset like HEV-I. I hope you show me the style of the HEV-I dataset please.

A3D data calibration value

Hi, author.
I want to test A3D data.
I am trying to run ORB-SLAM2, but I want to know the calibration value of A3D data.
I'm trying to run it with an arbitrary value, but it doesn't work. (ex) [fx fy cx cy] = [938.0666, 843.003, 643.298, 366.1718]
Please help me! Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.