Awesome
Generating Dynamic Kernels via Transformers for Lane Detection
In this work, we propose a transformer-based dynamic kernel generation architecture for lane detection. It utilizes a transformer to generate dynamic convolutional kernels for each lane line in the input image, and then detect these lane lines with dynamic convolution.
Framework
Installation
- Create python environment:
conda create -n hdmapnet python=3.10 conda activate hdmapnet
- Install pytorch (>=2.0.0):
pip install torch torchvision torchaudio torchdata
- Install mmcv (>=2.0.0):
pip install -U openmim mim install mmcv
- Install requirements:
pip install -r requirements.txt
- Install cuda11.7 (add to your ~/.bashrc and then
source ~/.bashrc
)export CUDA_HOME=/usr/local/cuda-11 export PATH=$PATH:$CUDA_HOME/bin export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Prepare Dataset
- Put your dataset into
/path/to/datasets/
- Rename the dataset directory with the parameter after
-d
, e.g.,/path/to/datasets/openlane
- A more convenient way is
ln -s /path/to/datasets/original_name /path/to/datasets/openlane
- The directory structure should look like this:
/path/to/datasets/ ├── openlane │ ├── images │ │ ├── training │ │ └── validation │ ├── lane3d_1000 │ │ ├── training │ │ ├── validation │ │ └── test │ │ ├── curve_case │ │ ├── merge_split_case │ │ └── ... │ └── lane3d_3000.tar ├── curvelanes ├── culane └── tusimple
Install Evaluation Tools
- Install opencv:
git clone https://github.com/opencv/opencv.git cd ~/opencv mkdir build cd build cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local .. make -j7 sudo make install
- Install openlane evaluation tool:
cd /path/to/project/tools/metrics/lane/openlane/lane2d # specify your opencv path in ./Makefile#L40,41 (OPENCV_INCLUDE and OPENCV_LIB_PATH) make
Training & Evaluation
- Training debug:
python tools/train.py -a CondLSTR2DRes34 -d openlane -v 2d -c 21 -t lane_det_2d --data-dir /path/to/datasets/ --logs-dir /path/to/checkpoint -b 4 -j 4
- Evaluation debug:
python tools/train.py -a CondLSTR2DRes34 -d openlane -v 2d -c 21 -t lane_det_2d --data-dir /path/to/datasets/ --logs-dir /path/to/checkpoint -b 4 -j 4 --eval
- Test/visualization debug:
python tools/test.py -a CondLSTR2DRes34 -d openlane -v 2d -c 21 -t lane_det_2d --data-dir /path/to/datasets/ --logs-dir /path/to/checkpoint --test-dir /path/to/output -b 4 -j 4
- Multi-gpu training:
python -m torch.distributed.launch --nproc_per_node=4 tools/train.py -a CondLSTR2DRes34 -d openlane -v 2d -c 21 -t lane_det_2d --data-dir /path/to/datasets/ --logs-dir /path/to/checkpoint --gpu-ids 0,1,2,3 -b 4 -j 4
- Multi-gpu evaluation:
python -m torch.distributed.launch --nproc_per_node=4 tools/train.py -a CondLSTR2DRes34 -d openlane -v 2d -c 21 -t lane_det_2d --data-dir /path/to/datasets/ --logs-dir /path/to/checkpoint --gpu-ids 0,1,2,3 -b 4 -j 4 --eval
- Multi-gpu test/visualization:
python -m torch.distributed.launch --nproc_per_node=4 tools/test.py -a CondLSTR2DRes34 -d openlane -v 2d -c 21 -t lane_det_2d --data-dir /path/to/datasets/ --logs-dir /path/to/checkpoint --test-dir /path/to/output --gpu-ids 0,1,2,3 -b 4 -j 4
- Resume from checkpoint:
python -m torch.distributed.launch --nproc_per_node=4 tools/train.py -a CondLSTR2DRes34 -d openlane -v 2d -c 21 -t lane_det_2d --data-dir /path/to/datasets/ --logs-dir /path/to/checkpoint --gpu-ids 0,1,2,3 -b 4 -j 4 --resume
- Training with AMP (Automated Mixed Precision):
python -m torch.distributed.launch --nproc_per_node=4 tools/train.py -a CondLSTR2DRes34 -d openlane -v 2d -c 21 -t lane_det_2d --data-dir /path/to/datasets/ --logs-dir /path/to/checkpoint --gpu-ids 0,1,2,3 -b 4 -j 4 -p amp
- Finetune with a pretrained model (Put its
checkpoint.pth.tar
under/path/to/checkpoint
):python -m torch.distributed.launch --nproc_per_node=4 tools/train.py -a CondLSTR2DRes34 -d openlane -v 2d -c 21 -t lane_det_2d --data-dir /path/to/datasets/ --logs-dir /path/to/checkpoint --gpu-ids 0,1,2,3 -b 4 -j 4 --resume --load-model-only
Test
- OpenLane
python -m torch.distributed.launch --nproc_per_node=4 tools/test.py -a CondLSTR2DRes34 -d openlane -v 2d -c 21 -t lane_det_2d --data-dir /path/to/datasets/ --logs-dir /path/to/checkpoint --test-dir /path/to/checkpoint --gpu-ids 0,1,2,3 -b 4 -j 4 python tools/metrics/lane/openlane/openlane_2d.py --pred-dir /path/to/output --anno-dir /path/to/datasets/openlane --translate
- CurveLanes