This repository is for running the experiments of paper: Action-Based Representation Learning for Autonomous Driving
We kindly ask to cite our paper if you find this work useful:
Yi Xiao, Felipe Codevilla, Christopher Pal, Antonio M. Lopez, Action-Based Representation Learning for Autonomous Driving.
@inproceedings{xiao2021action,
title={Action-Based Representation Learning for Autonomous Driving},
author={Xiao, Yi and Codevilla, Felipe and Pal, Christopher and Lopez, Antonio},
booktitle={Conference on Robot Learning},
pages={232--246},
year={2021},
organization={PMLR}
}
Please check our online video
Our work is built using the following frameworks:
The processes can be defined as four types:
Download the dataset. The full dataset is not yet ready for publishing, here we provide a small dataset for simple test. Note that in the following steps, we will use this small dataset for both training and validation, just to illustrate how to run our framework. Once the full dataset is ready, we will provide different datasets for training and validation.
Define the path to your dataset folder with SRL_DATASET_PATH:
export SRL_DATASET_PATH = <Path to where your datasets are>
Download the repository
git clone https://github.com/yixiao1/Action-Based-Representation-Learning.git
Go to your downloaded repository, and define ACTIONDIR with this directory
cd ~/Action-Based-Representation-Learning
export ACTIONDIR=$(pwd)
Download the CARLA version we used with this link, and put it inside your downloaded repository folder
To add the following packages to your PYTHONPATH:
you need to run:
export PYTHONPATH=$ACTIONDIR/Carla96ped4/PythonAPI/carla:$ACTIONDIR/Carla96ped4/PythonAPI/carla/dist/carla-0.9.6-py3.5-linux-x86_64.egg:$ACTIONDIR/scenario_runner:$ACTIONDIR/carl
Define configuration files for training. Refer to files in configs folder
Run the main.py file with "train_encoder" process:
python3 main.py --single-process train_encoder --gpus 0 --encoder-folder ENCODER --encoder-exp BC_smallDataset_seed1
where --single-process
defines the process type, --gpus
defines the gpu to be used, --encoder-folder
is the experiment folder you defined in config folder, and --encoder-exp
is the experiment you defined inside the experiment folder.
Define configuration files for training. Refer to files in configs folder
Run the main.py file with "train" process:
python3 main.py --single-process train --gpus 0 --encoder-folder ENCODER --encoder-exp BC_smallDataset_seed1 --encoder-checkpoint 1000 -f EXP -e BC_smallDataset_seed1_encoder_frozen_1FC_smallDataset_s1
where --single-process
defines the process type, --gpus
defined the gpu to be used, --encoder-folder
is the experiment folder name of the encoder to be used, --encoder-exp
is the experiment name of encoder to be used, --encoder-checkpoint
is the specific encoder checkpoint to be used, -f
is the experiment folder you defined in config folder for affordances prediction, -e
is the experiment name you defined in the experiment folder for affordances prediction.
Run the main.py file with "validation" process. You will need to define the path to the json file of validation dataset:
python3 main.py --single-process validation --gpus 0 --encoder-folder ENCODER --encoder-exp BC_smallDataset_seed1 --encoder-checkpoint 1000 -f EXP -e BC_smallDataset_seed1_encoder_frozen_1FC_smallDataset_s1 -vj $ACTIONDIR/carl/database/CoRL2020/small_dataset.json
where -vj
defines the path to your validation json file
The driving results will be saved to your SRL_DATASET_PATH, you could re-define it if you want to save to another path
Build a docker with your carla version:
docker image build -f /.../carla/Util/Docker/Release.Dockerfile -t carlaped $ACTIONDIR/Carla96ped4/
where -f
is the path to the Realease.Dockerfile, -t
defines the name of the docker you want to created, and $ACTIONDIR/Carla96ped4/ is the path to your Carla package
Set up PYTHONPATH for CARLA driving:
export PYTHONPATH=$ACTIONDIR:$ACTIONDIR/cad:$ACTIONDIR/Carla96ped4/PythonAPI/carla/dist/carla-0.9.6-py3.5-linux-x86_64.egg/:$ACTIONDIR/Carla96ped4/PythonAPI/carla:$ACTIONDIR/scenario_runner
Define a config.json for using a specific model, and put it into the directory of your model in _logs folder: _logs/(experiment folder)/(experiment name)
check an example on this config.json example
To run the benchmark, go to driving-benchmarks folder:
cd driving-benchmarks-carla_09_cexp/
and run:
python3 benchmark_runner.py -b NoCrash -a $ACTIONDIR/drive/AffordancesAgent.py -d carlaped -c $ACTIONDIR/_logs/EXP/BC_im_50Hours_seed1_encoder_finetuning_3FC_5Hours_s1_100000/config.json --gpu 2
where `-b` is the benchmark, `-a` is the path to the agent class, `-c` is the configuration file for driving