GithubHelp home page GithubHelp logo

inhwanbae / enet-sad_pytorch Goto Github PK

View Code? Open in Web Editor NEW
72.0 4.0 19.0 31.07 MB

Pytorch implementation of "Learning Lightweight Lane Detection CNNs by Self Attention Distillation (ICCV 2019)"

License: MIT License

Python 79.34% CMake 0.41% Shell 1.91% C++ 18.34%
lane-detection enet self-attention-distillation pytorch-implementation deep-learning semantic-segmentation pytorch python

enet-sad_pytorch's Introduction

ENet-SAD Pytorch

Pytorch implementation of "Learning Lightweight Lane Detection CNNs by Self Attention Distillation (ICCV 2019)"

drawing

News

  • BDD100K Dataloader is released. now support all the three datasets (CULane, TuSimple, BDD100K)
  • ENET_SAD model has been updated to be more similar to the original implementation. (generated model is the same as before).
  • Fixed issue with calculating IoU by taking softmax excluding BG.
  • Evaluation codes for CULane, TuSimple dataset have been updated.

You can find the previous version here

Demo

Video

demo_gif

Demo trained with CULane dataset & tested with \driver_193_90frame\06051123_0635.MP4

gpu_runtime: 0.016253232955932617 FPS: 61

total_runtime: 0.017553091049194336 FPS: 56 on RTX 2080 TI

Comparison

Category 40k episode (before SAD) 60k episode (after SAD)
Image img1 img2
Lane img3 img4

Train

Requirements

  • pytorch
  • tensorflow (for tensorboard)
  • opencv

Datasets

  • CULane

    CULane dataset path (click to expand)
    CULane_path
    ├─ driver_100_30frame
    ├─ driver_161_90frame
    ├─ driver_182_30frame
    ├─ driver_193_90frame
    ├─ driver_23_30frame
    ├─ driver_37_30frame
    ├─ laneseg_label_w16
    ├─ laneseg_label_w16_test
    └─ list
    
  • TuSimple

    TuSimple dataset path (click to expand)
    Tusimple_path
    ├─ clips
    ├─ label_data_0313.json
    ├─ label_data_0531.json
    ├─ label_data_0601.json
    └─ test_label.json
    
  • BDD100K

    • Download modified labels and lists generated by author's method (train, val and list) and put the BDD100K dataset in the desired folder.
    BDD100K dataset path (click to expand)
    BDD100K_path
    ├─ images
    │  ├─ 10k
    │  └─ 100k
    ├─ list
    │  ├─ test_gt_bdd.txt
    │  ├─ train_gt_bdd.txt
    │  └─ val_gt_bdd.txt
    ├─ train_label
    │  └─ final_train
    └─ val_label
       └─ final_val
    

You need to change the correct dataset path in ./config.py

Dataset_Path = dict(
    CULane = "/workspace/CULANE_DATASET",
    Tusimple = "/workspace/TUSIMPLE_DATASET",
    BDD100K = "/workspace/BDD100K_DATASET",
    VPGNet = "/workspace/VPGNet_DATASET"
)

Training

First, change some hyperparameters in ./experiments/*/cfg.json

{
  "model": "enet_sad",               <- "scnn" or "enet_sad"
  "dataset": {
    "dataset_name": "CULane",        <- "CULane" or "Tusimple"
    "batch_size": 12,
    "resize_shape": [800, 288]       <- [800, 288] with CULane, [640, 368] with Tusimple, and [640, 360] with BDD100K
                                        This size is defined in the ENet-SAD paper, any size is fine if it is a multiple of 8.
  },
  ...
}

And then, start training with train.py

python train.py --exp_dir ./experiments/exp1
Optional

If you write your own code using ENet-SAD model, you can init ENet_SAD with some parameters.

class ENet_SAD(nn.Module):
    """
    Generate the ENet-SAD model.
    Keyword arguments:
    - input_size (tuple): Size of the input image to segment.
    - encoder_relu (bool, optional): When ``True`` ReLU is used as the
    activation function in the encoder blocks/layers; otherwise, PReLU
    is used. Default: False.
    - decoder_relu (bool, optional): When ``True`` ReLU is used as the
    activation function in the decoder blocks/layers; otherwise, PReLU
    is used. Default: True.
    - sad (bool, optional): When ``True``, SAD is added to model;
    otherwise, SAD is removed. Default: False.
    - weight_share (bool, optional): When ``True``, weights are shared
    with encoder blocks (E2, E3 and E4); otherwise, encoders will each
    learn with their own weights. Default: True.
    """

Performance

Will continue to be updated.

  • TuSimple dataset

    Category ENet-SAD Pytorch ENet-SAD paper
    Accuracy 93.93% 96.64%
    FP 0.2279 0.0602
    FN 0.0838 0.0205
  • CULane dataset (F1-measure, FP measure for crossroad)

    Category ENet-SAD Pytorch ENet-SAD paper
    Normal 86.8 90.1
    Crowded 65.3 68.8
    Night 54.0 66.0
    No line 37.3 41.6
    Shadow 52.4 65.9
    Arrow 78.2 84.0
    Dazzle light 51.0 60.2
    Curve 58.6 65.7
    Crossroad 2278 1995
    Total 65.5 70.8
  • BDD100K

    Category ENet-SAD Pytorch ENet-SAD paper
    Accuracy 37.09% 36.56%
    IoU 15.14 16.02

Acknowledgement

This repo is built upon official implementation ENet-SAD and based on PyTorch-ENet, SCNN_Pytorch.

enet-sad_pytorch's People

Contributors

inhwanbae avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

enet-sad_pytorch's Issues

SAD loss

hi, thank you for the good job. When I train with my dataset, the sad loss is very small. Do you know why?

Having trouble replicating results

Hey, I'm using this repository for some research. I've trained the model (the only change I made to parameters was lowering batch size to 5 for my gpu), and I'm having trouble replicating the model's results. I am capping out at 85.8% accuracy. Do you have a pre-trained model available? Would really appreciate it :)

bdd100k evaluation code

우선 좋은 코드를 공유해주셔서 감사합니다.

혹시 BDD100K를 평가할때 사용한 코드도 공유 가능한가요?

감사합니다.

Evaluation Code for BDD100K Dataset

Hi,
Thanks for sharing this nice repo. Would you please provide the evaluation code for BDD100K dataset? Or give an advice where to find such code? This would be a great help. Thanks!

When I run demo_video.py,I got the model mismatched

Traceback (most recent call last):
File "demo_video.py", line 184, in
main()
File "demo_video.py", line 120, in main
net.load_state_dict(save_dict['net'])
File "/home/zty/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py", line 847, in load_state_dict
self.class.name, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for ENet_SAD:
size mismatch for fc.0.weight: copying a param with shape torch.Size([128, 4500]) from checkpoint, the shape in current model is torch.Size([128, 4400]).

Can somebody help me?Thanks in advance.

Codes for testing and evaluation

Hey I'm very grateful for your work, and now I further need your codes for testing and evaluation, can you please provide it? Thanks a lot!

안녕하세요, 코드 관련해서 몇가지 질문이 있습니다.

안녕하세요! 저는 생태 관련해서 연구하고 있는 석사과정 대학원생입니다.

다름이 아니라, 어쩌다보니 lane-detection에 대해 공부하고 있는 중인데, 관련 코드를 찾던중 선생님의 코드를 찾게되어 문의드립니다.

train.py의 경우에는 CULane에 대해서만 학습을 할 수 있는 것인가요?

그거랑 또 한가지 궁금한 점이, test를 하려면 반드시 CULane이나 tuSimple 데이터셋의 format과 동일하게 만들어야 test가 가능한지 궁금합니다.

왜냐하면 제가 학습/테스트를 하고자 하는 제 이미지 사이즈가 다소 차이가 좀 있어서, 그대로 테스트해도 되는지, 그리고 어노테이션을 할 수는 있는 것인지가 궁금합니다.

좋은 코드 만들어주셔서 감사합니다!

测试

您好,您可以提供一下训练的权重吗~
我这边自己训练的权重,测试出来很多图片的lines.txt都是空的,在多个机器上试了是相同的结果。可以提供一下您的权重,进行测试吗

Question about training

Hi,
I was digging into your code recently. Nice work!

Just had question about your CULane training dataset. It seems that you didnt use txt which contains axis for lanes in the given dataset.

Could your give a little hint why this would work?

Thanks!

About Runtime

In the Paper, it can reach 13.4ms on titan X, but why your code is 16ms on 2080ti, shouldn’t it be faster? Hope to answer it, thank you very much

Problems of the code

I check your Enet-SAD-model.py,and I found that the lane prediction branch in your code is different from the paper,can you tell me if there is any reason for this?Thanks in advance.

BDD100K pixel accuracy

Thank you for your open source, it is very profitable. I would like to ask the author what is the calculation formula of the BDD100K evaluation index pixel accuracy. The formula is not listed in the paper. Is it category pixel accuracy (acc = (TP) / TP + FP)?

training based on bdd100k?

Hi, I want to trian the net based on bdd100k, What should I pay attention to? For example, setting hyperparameters or Is there anything that needs to be changed in train.py. Looking forward to your reply

Images with 5 lanes

There are 75 images that have 5 lanes but the architecture is to detect 5 categories (background + 4 lanes). I have removed those images from training and used the images (3193) that have less than 5 lanes. In the paper 3268 images are used for training. Can someone explain if those images were used or not and if they were used what was the approach taken?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.