Skip to content

Commit

Permalink
refactor & add lanedet
Browse files Browse the repository at this point in the history
  • Loading branch information
Turoad committed May 7, 2021
1 parent c957e1f commit 911b048
Show file tree
Hide file tree
Showing 87 changed files with 3,229 additions and 2,736 deletions.
Binary file added .cache/culane_anchors_freq.pt
Binary file not shown.
Binary file added .cache/tusimple_anchors_freq.pt
Binary file not shown.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ __pycache__/

*.egg-info/
*.egg
*.eggs

output.txt
.vscode/*
Expand All @@ -19,6 +20,8 @@ tmp.*
*.pt
*.pth
*.un~
*.so
build

lane
debug
Expand Down
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Supported detectors:
- [x] [SCNN](configs/scnn)
- [x] [UFLD](configs/ufld)
- [x] [RESA](configs/resa)
- [ ] LaneATT (comming sonn)
- [x] [LaneATT](configs/laneatt)
- [ ] LaneAF (comming sonn)

## Installation
Expand Down Expand Up @@ -55,7 +55,7 @@ conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
pip install torch torchvision

# Install python packages
pip install -r requirements.txt
python setup.py build develop
```

### Data preparation
Expand Down Expand Up @@ -98,7 +98,7 @@ $TUSIMPLEROOT/test_label.json # test label json file
For Tusimple, the segmentation annotation is not provided, hence we need to generate segmentation from the json annotation.

```Shell
python scripts/generate_seg_tusimple.py --root $TUSIMPLEROOT
python tools/generate_seg_tusimple.py --root $TUSIMPLEROOT
# this will generate seg_label directory
```

Expand Down Expand Up @@ -128,7 +128,13 @@ For example, run
python main.py configs/resa/resa50_culane.py --validate --load_from culane_resnet50.pth --gpus 0 1 2 3
```

For visualization, just add `--view`.
Currently, this code can output the visualization result when testing, just add `--view`.
We will get the visualization result in `work_dirs/xxx/xxx/visualization`.

For example, run
```Shell
python main.py configs/resa/resa50_culane.py --validate --load_from culane_resnet50.pth --gpus 0 --view
```


## Contributing
Expand All @@ -146,6 +152,7 @@ This project is released under the [Apache 2.0 license](LICNESE).
* [XingangPan/SCNN](https://github.com/XingangPan/SCNN)
* [ZJULearning/resa](https://github.com/ZJULearning/resa)
* [cfzd/Ultra-Fast-Lane-Detection](https://github.com/cfzd/Ultra-Fast-Lane-Detection)
* [lucastabelini/LaneATT](https://github.com/lucastabelini/LaneATT)
<!--te-->

<!--
Expand Down
25 changes: 25 additions & 0 deletions configs/laneatt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Keep your Eyes on the Lane: Real-time Attention-guided Lane Detection

## Introduction

```latex
@InProceedings{tabelini2021cvpr,
author = {Lucas Tabelini
and Rodrigo Berriel
and Thiago M. Paix\~ao
and Claudine Badue
and Alberto Ferreira De Souza
and Thiago Oliveira-Santos},
title = {{Keep your Eyes on the Lane: Real-time Attention-guided Lane Detection}},
booktitle = {Conference on Computer Vision and Pattern Recognition (CVPR)},
year = {2021}
}
```

## Models

| Architecture| Backbone |Dataset | Metric | Config| Checkpoints |
|-------------|----------|--------|--------|-------|--------------|
| LaneATT | ResNet18 | CULane || [config](https://github.com/Turoad/lanedet/blob/main/configs/laneatt/resnet18_culane.py) | comming soon|
| LaneATT | ResNet18 | TuSimple || [config](https://github.com/Turoad/lanedet/blob/main/configs/laneatt/resnet18_tusimple.py) | comming soon|
| LaneATT | ResNet34 | TuSimple || [config](https://github.com/Turoad/lanedet/blob/main/configs/laneatt/resnet34_tusimple.py) | comming soon|
119 changes: 119 additions & 0 deletions configs/laneatt/resnet18_culane.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
net = dict(
type='Detector',
)

backbone = dict(
type='ResNetWrapper',
resnet='resnet18',
pretrained=True,
replace_stride_with_dilation=[False, False, False],
out_conv=False,
)
featuremap_out_channel = 512
featuremap_out_stride = 32

aggregator = None

num_points = 72
max_lanes = 4
sample_y = range(589, 230, -20)

heads = dict(type='LaneATT',
anchors_freq_path='.cache/culane_anchors_freq.pt',
topk_anchors=1000)

train_parameters = dict(
conf_threshold=None,
nms_thres=15.,
nms_topk=3000
)
test_parameters = dict(
conf_threshold=0.5,
nms_thres=50,
nms_topk=max_lanes
)

optimizer = dict(
type = 'AdamW',
lr = 0.0003,
)

epochs = 15
batch_size = 8
total_iter = (88880 // batch_size) * epochs
scheduler = dict(
type = 'CosineAnnealingLR',
T_max = total_iter
)

eval_ep = 1
save_ep = 1

img_norm = dict(
mean=[103.939, 116.779, 123.68],
std=[1., 1., 1.]
)
ori_img_w=1640
ori_img_h=590
img_w=640
img_h=360
cut_height=0

train_process = [
dict(type='GenerateLaneLine',
transforms = (
dict(
name = 'Affine',
parameters = dict(
translate_px = dict(
x = (-25, 25),
y = (-10, 10)
),
rotate=(-6, 6),
scale=(0.85, 1.15)
)
),
dict(
name = 'HorizontalFlip',
parameters = dict(
p=0.5
),
)
),
wh = (img_w, img_h),
),
dict(type='ToTensor', keys=['img', 'lane_line']),
]

val_process = [
dict(type='GenerateLaneLine'),
dict(type='ToTensor', keys=['img']),
]

dataset_path = './data/CULane'
dataset_type = 'CULane'
dataset = dict(
train=dict(
type=dataset_type,
data_root=dataset_path,
split='train',
processes=train_process,
),
val=dict(
type=dataset_type,
data_root=dataset_path,
split='test',
processes=val_process,
),
test=dict(
type=dataset_type,
data_root=dataset_path,
split='test',
processes=val_process,
)
)


workers = 12
log_interval = 100
seed=0
117 changes: 117 additions & 0 deletions configs/laneatt/resnet18_tusimple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
net = dict(
type='Detector',
)

backbone = dict(
type='ResNetWrapper',
resnet='resnet18',
pretrained=True,
replace_stride_with_dilation=[False, False, False],
out_conv=False,
)
featuremap_out_channel = 512
featuremap_out_stride = 32

aggregator = None

num_points = 72
max_lanes = 5
sample_y=range(710, 150, -10)

heads = dict(type='LaneATT',
anchors_freq_path='.cache/tusimple_anchors_freq.pt',
topk_anchors=1000)

train_parameters = dict(
conf_threshold=None,
nms_thres=15.,
nms_topk=3000
)
test_parameters = dict(
conf_threshold=0.2,
nms_thres=45,
nms_topk=max_lanes
)

optimizer = dict(
type = 'Adam',
lr = 0.0003,
)

epochs = 100
batch_size = 8
total_iter = (3616 // batch_size) * epochs
scheduler = dict(
type = 'CosineAnnealingLR',
T_max = total_iter
)

eval_ep = 1
save_ep = epochs

ori_img_w=1280
ori_img_h=720
img_w=640
img_h=360
cut_height=0

train_process = [
dict(type='GenerateLaneLine',
transforms = (
dict(
name = 'Affine',
parameters = dict(
translate_px = dict(
x = (-25, 25),
y = (-10, 10)
),
rotate=(-6, 6),
scale=(0.85, 1.15)
)
),
dict(
name = 'HorizontalFlip',
parameters = dict(
p=0.5
),
)
),
wh = (img_w, img_h),
),
dict(type='ToTensor', keys=['img', 'lane_line']),
]

val_process = [
dict(type='GenerateLaneLine', wh=(img_w, img_h)),
dict(type='ToTensor', keys=['img']),
]

dataset_path = './data/tusimple'
test_json_file = 'data/tusimple/test_label.json'
dataset_type = 'TuSimple'

dataset = dict(
train=dict(
type=dataset_type,
data_root=dataset_path,
split='trainval',
processes=train_process,
),
val=dict(
type=dataset_type,
data_root=dataset_path,
split='test',
processes=val_process,
),
test=dict(
type=dataset_type,
data_root=dataset_path,
split='test',
processes=val_process,
)
)


workers = 12
log_interval = 100
seed=0
Loading

0 comments on commit 911b048

Please sign in to comment.