Skip to content

go125/PolyLaneNet_eval

Repository files navigation

PolyLaneNet_eval

original

This is a copied code for evaluation.

モデルを内部に置いたままのコミット禁止!!

Table of Contents

  1. Installation
  2. Usage
  3. Reproducing the paper results

The code requires Python 3, and has been tested on Python 3.5.2, but should work on newer versions of Python too.

Pytorchのバージョンを1.4.0にしないと初期重みが読めない。AWSのPytorchは1.0.1である。Pytorchを1.4.0にするとCUDAのバージョンが合わず、GPUを使えない。

TuSimple dataset

mkdir tusimple
cd tusimple
wget https://s3.us-east-2.amazonaws.com/benchmark-frontend/datasets/1/train_set.zip
wget https://s3.us-east-2.amazonaws.com/benchmark-frontend/datasets/1/test_set.zip
unzip train_set.zip
unzip test_set.zip

Training

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:

# Training settings
exps_dir: 'experiments' # Path to the root for the experiments directory (not only the one you will run)
iter_log_interval: 1 # Log training iteration every N iterations
iter_time_window: 100 # Moving average iterations window for the printed loss metric
model_save_interval: 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:
    num_outputs: 35 # (5 lanes) * (1 conf + 2 (upper & lower) + 4 poly coeffs)
    pretrained: true
    backbone: 'efficientnet-b0'
    pred_category: false
loss_parameters:
  conf_weight: 1
  lower_weight: 1
  upper_weight: 1
  cls_weight: 0
  poly_weight: 300
batch_size: 16
epochs: 2695
optimizer:
  name: Adam
  parameters:
    lr: 3.0e-4
lr_scheduler:
  name: CosineAnnealingLR
  parameters:
    T_max: 385

# Testing settings
test_parameters:
  conf_threshold: 0.5 # Set predictions with confidence lower than this to 0 (i.e., set as invalid for the metrics)

# Dataset settings
datasets:
  train:
    type: PointsDataset
    parameters:
      dataset: tusimple
      split: train
      img_size: [360, 640]
      normalize: true
      aug_chance: 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:

python train.py --exp_name tusimple --cfg config.yaml

config.yamlのパスを通す

python train.py --exp_name tusimple --cfg ./cfgs/tusimple.yaml

初期重みが読み込めないため本格的な実験は未実施

nohup python train.py --exp_name tusimple --cfg ./cfgs/tusimple.yaml &

This 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

Testing

After training, run the test.py script to get the metrics:

python test.py --exp_name tusimple --cfg ./cfgs/tusimple.yaml --epoch 2695

This 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.

Models

All models trained for the paper can be found here.

Datasets

How to

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 cfgs directory. 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).
  2. Modify all path related fields (i.e., dataset paths and exps_dir) in the config.yaml file inside the experiment directory.
  3. Move the downloaded experiment to your exps_dir folder.

Then, run:

python test.py --exp_name tusimple --cfg ./cfgs/tusimple.yaml --epoch 2695
python test.py --exp_name tusimple --cfg ./cfgs/tusimple.yaml --epoch 2695 --view

Replacing $exp_name with the name of the directory you downloaded (the name of the experiment) and $exps_dir with the exps_dir value you defined inside the config.yaml file. The script will look for a directory named $exps_dir/$exp_name/models to load the model.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published