Code for the paper entitled "PolyLaneNet: Lane Estimation via Deep Polynomial Regression" (ICPR 2020)
News: The source code for our new state-of-the-art lane detection method, LaneATT, has been released. Check it out here.
The code requires Python 3, and has been tested on Python 3.5.2, but should work on newer versions of Python too.
pip install -r requirements.txt
Every setting for a training is set through a YAML configuration file. Thus, in order to train a model you will have to setup the configuration file. An example is shown: ```yaml
expsdir: 'experiments' # Path to the root for the experiments directory (not only the one you will run) iterloginterval: 1 # Log training iteration every N iterations itertimewindow: 100 # Moving average iterations window for the printed loss metric modelsaveinterval: 1 # Save model every N epochs seed: 0 # Seed for randomness backup: drive:polylanenet-experiments # The experiment directory will be automatically uploaded using rclone after the training ends. Leave empty if you do not want this. model: name: PolyRegression parameters: numoutputs: 35 # (5 lanes) * (1 conf + 2 (upper & lower) + 4 poly coeffs) pretrained: true backbone: 'efficientnet-b0' predcategory: false lossparameters: confweight: 1 lowerweight: 1 upperweight: 1 clsweight: 0 polyweight: 300 batchsize: 16 epochs: 2695 optimizer: name: Adam parameters: lr: 3.0e-4 lrscheduler: name: CosineAnnealingLR parameters: Tmax: 385
testparameters: confthreshold: 0.5 # Set predictions with confidence lower than this to 0 (i.e., set as invalid for the metrics)
datasets: train: type: PointsDataset parameters: dataset: tusimple split: train imgsize: [360, 640] normalize: true augchance: 0.9090909090909091 # 10/11 augmentations: # ImgAug augmentations - name: Affine parameters: rotate: !!python/tuple [-10, 10] - name: HorizontalFlip parameters: p: 0.5 - name: CropToFixedSize parameters: width: 1152 height: 648 root: "datasets/tusimple" # Dataset root
test: &test type: PointsDataset parameters: dataset: tusimple split: val img_size: [360, 640] root: "datasets/tusimple" normalize: true augmentations: 
# val = test val: <<: *test ```
With the config file created, run the training script:
bash python train.py --exp_name tusimple --cfg config.yamlThis script's options are:
--exp_name Experiment name. --cfg Config file for the training (.yaml) --resume Resume training. If a training session was interrupted, run it again with the same arguments and this option to resume the training from the last checkpoint. --validate Wheter to validate during the training session. Was not in our experiments, which means it has not been thoroughly tested. --deterministic set cudnn.deterministic = True and cudnn.benchmark = False
After training, run the
test.pyscript to get the metrics:
bash python test.py --exp_name tusimple --cfg config.yaml --epoch 2695This script's options are:
--exp_name Experiment name. --cfg Config file for the test (.yaml). (probably the same one used in the training) --epoch EPOCH Epoch to test the model on --batch_size Number of images per batch --view Show predictions. Will draw the predictions in an image and then show it (cv.imshow)
If you have any issues with either training or testing feel free to open an issue.
All models trained for the paper can be found here.
To reproduce the results, you can either retrain a model with the same settings (which should yield results pretty close to the reported ones) or just test the model. If you want to retrain, you only need the appropriate YAML settings file, which you can find in the
cfgsdirectory. If you just want to reproduce the exact reported metrics by testing the model, you'll have to: 1. Download the experiment directory. You don't need to download all model checkpoints if you want, you'll only need the last one (
model_2695.pt, with the exception of the experiments on ELAS and LLAMAS). 1. Modify all path related fields (i.e., dataset paths and
exps_dir) in the
config.yamlfile inside the experiment directory. 1. Move the downloaded experiment to your
python test.py --exp_name $exp_name --cfg $exps_dir/$exp_name/config.yaml --epoch 2695
$exp_namewith the name of the directory you downloaded (the name of the experiment) and
exps_dirvalue you defined inside the
config.yamlfile. The script will look for a directory named
$exps_dir/$exp_name/modelsto load the model.