{"id":15033908,"url":"https://github.com/cardwing/codes-for-lane-detection","last_synced_at":"2025-05-16T10:08:54.582Z","repository":{"id":37602081,"uuid":"152700563","full_name":"cardwing/Codes-for-Lane-Detection","owner":"cardwing","description":"Learning Lightweight Lane Detection CNNs by Self Attention Distillation (ICCV 2019)","archived":false,"fork":false,"pushed_at":"2022-06-21T21:48:30.000Z","size":47961,"stargazers_count":1048,"open_issues_count":6,"forks_count":333,"subscribers_count":32,"default_branch":"master","last_synced_at":"2025-05-16T10:08:44.881Z","etag":null,"topics":["cnn","deep-learning","lane-detection","lua","pytorch","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cardwing.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-12T05:53:41.000Z","updated_at":"2025-05-11T14:12:42.000Z","dependencies_parsed_at":"2022-07-12T16:33:09.384Z","dependency_job_id":null,"html_url":"https://github.com/cardwing/Codes-for-Lane-Detection","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cardwing%2FCodes-for-Lane-Detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cardwing%2FCodes-for-Lane-Detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cardwing%2FCodes-for-Lane-Detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cardwing%2FCodes-for-Lane-Detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cardwing","download_url":"https://codeload.github.com/cardwing/Codes-for-Lane-Detection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254509477,"owners_count":22082892,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cnn","deep-learning","lane-detection","lua","pytorch","tensorflow"],"created_at":"2024-09-24T20:23:11.124Z","updated_at":"2025-05-16T10:08:49.569Z","avatar_url":"https://github.com/cardwing.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"Codes for [\"Learning Lightweight Lane Detection CNNs by Self Attention Distillation\"](https://arxiv.org/abs/1908.00821)\n\nThis repo also contains Tensorflow implementation of [\"Spatial As Deep: Spatial CNN for Traffic Scene Understanding\"](https://arxiv.org/abs/1712.06080). (SCNN-Tensorflow) \n\n# News\n\n1. [ERFNet-CULane-PyTorch](./ERFNet-CULane-PyTorch) has been released. (It can achieve **73.1** F1-measure in CULane testing set)\n\n2. [ENet-Label-Torch](./ENet-Label-Torch), [ENet-TuSimple-Torch](./ENet-TuSimple-Torch) and [ENet-BDD100K-Torch](./ENet-BDD100K-Torch) have been released. \n\nKey features:\n\n(1) ENet-label is a **light-weight** lane detection model based on [ENet](https://arxiv.org/abs/1606.02147) and adopts **self attention distillation** (more details can be found in our paper). \n\n(2) It has **20** × fewer parameters and runs **10** × faster compared to the state-of-the-art SCNN, and achieves **72.0** (F1-measure) on CULane testing set (better than SCNN which achieves 71.6). It also achieves **96.64%** accuracy in TuSimple testing set (better than SCNN which achieves 96.53%) and **36.56%** accuracy in BDD100K testing set (better than SCNN which achieves 35.79%). \n\n(3) Applying ENet-SAD to [LLAMAS](https://unsupervised-llamas.com/llamas/) dataset yields **0.635** mAP in the [multi-class lane marker segmentation task](https://unsupervised-llamas.com/llamas/benchmark_multi), which is much better than the baseline algorithm which achieves 0.500 mAP. Details can be found in [this repo](https://github.com/cardwing/unsupervised_llamas/tree/master/ENet-SAD-Simple).\n\n(Do not hesitate to try our model!!!)\n\n3. Multi-GPU training has been supported. Just change BATCH_SIZE and GPU_NUM in global_config.py, and then use `CUDA_VISIBLE_DEVICES=\"0,1,2,3\" python file_name.py`. Thanks @ yujincheng08.\n\n# Content\n\n* [Installation](#Installation)\n* [Datasets](#Datasets)\n  * [TuSimple](#TuSimple)\n  * [CULane](#CULane)\n  * [BDD100K](#BDD100K)\n* [SCNN-Tensorflow](#SCNN-Tensorflow)\n  * [Test](#Test)\n  * [Train](#Train)\n* [Performance](#Performance)\n* [Others](#Others)\n  * [Citation](#Citation)\n  * [Acknowledgement](#Acknowledgement)\n  * [Contact](#Contact)\n\n# Installation\n\n1. Install necessary packages:\n```\n    conda create -n tensorflow_gpu pip python=3.5\n    source activate tensorflow_gpu\n    pip install --upgrade tensorflow-gpu==1.3.0\n    pip3 install -r SCNN-Tensorflow/lane-detection-model/requirements.txt\n```\n\n2. Download VGG-16:\n\nDownload the vgg.npy [here](https://github.com/machrisaa/tensorflow-vgg) and put it in SCNN-Tensorflow/lane-detection-model/data.\n\n3. Pre-trained model for testing:\n\nDownload the pre-trained model [here](https://drive.google.com/open?id=1-E0Bws7-v35vOVfqEXDTJdfovUTQ2sf5).\n\n# Datasets\n\n## TuSimple\n\nThe ground-truth labels of TuSimple testing set is now available at [TuSimple](https://github.com/TuSimple/tusimple-benchmark/issues/3). The annotated training (#frame = 3268) and validation labels (#frame = 358) can be found [here](https://github.com/cardwing/Codes-for-Lane-Detection/issues/11), please use them (list-name.txt) to replace the train_gt.txt and val_gt.txt in [train_lanenet.py](./SCNN-Tensorflow/lane-detection-model/tools/train_lanenet.py). Moreover, you need to resize the image to 256 x 512 instead of 288 x 800 in TuSimple. Remember to change the maximum index of rows and columns, and detailed explanations can be seen [here](https://github.com/cardwing/Codes-for-Lane-Detection/issues/18). Please evaluate your pred.json using the labels and [this script](https://github.com/TuSimple/tusimple-benchmark/blob/master/evaluate/lane.py). Besides, to generate pred.json, you can refer to [this issue](https://github.com/cardwing/Codes-for-Lane-Detection/issues/4).\n\n## CULane\n\nThe whole dataset is available at [CULane](https://xingangpan.github.io/projects/CULane.html).\n\n## BDD100K\n\nThe whole dataset is available at [BDD100K](http://bdd-data.berkeley.edu/).\n\n# SCNN-Tensorflow\n\n## Test\n    cd SCNN-Tensorflow/lane-detection-model\n    CUDA_VISIBLE_DEVICES=\"0\" python tools/test_lanenet.py --weights_path path/to/model_weights_file --image_path path/to/image_name_list --save_dir to_be_saved_dir\n\nNote that path/to/image_name_list should be like [test_img.txt](./SCNN-Tensorflow/lane-detection-model/demo_file/test_img.txt). Now, you get the probability maps from our model. To get the final performance, you need to follow [SCNN](https://github.com/XingangPan/SCNN) to get curve lines from probability maps as well as calculate precision, recall and F1-measure.\n\nReminder: you should check [lanenet_data_processor.py](./SCNN-Tensorflow/lane-detection-model/data_provider/lanenet_data_processor.py) and [lanenet_data_processor_test.py](./SCNN-Tensorflow/lane-detection-model/data_provider/lanenet_data_processor.py) to ensure that the processing of image path is right. You are recommended to use the absolute path in your image path list. Besides, this code needs batch size used in training and testing to be consistent. To enable arbitrary batch size in the testing phase, please refer to [this issue](https://github.com/cardwing/Codes-for-Lane-Detection/issues/10).\n\n## Train\n    CUDA_VISIBLE_DEVICES=\"0\" python tools/train_lanenet.py --net vgg --dataset_dir path/to/CULane-dataset/\n\nNote that path/to/CULane-dataset/ should contain files like [train_gt.txt](./SCNN-Tensorflow/lane-detection-model/demo_file/train_gt.txt) and [val_gt.txt](./SCNN-Tensorflow/lane-detection-model/demo_file/train_gt.txt).\n\n# Performance\n\n1. TuSimple testing set:\n\n|Model|Accuracy|FP|FN|\n|:---:|:---:|:---:|:---:|\n|[SCNN-Torch](https://github.com/XingangPan/SCNN)|96.53%|0.0617|0.0180|\n|SCNN-Tensorflow|--|--|--|\n|ENet-Label-Torch|96.64%|0.0602|0.0205|\n\nThe pre-trained model for testing is here. (coming soon!) Note that in TuSimple, SCNN-Torch is based on ResNet-101 while SCNN-Tensorflow is based on VGG-16. In CULane and BDD100K, both SCNN-Torch and SCNN-Tensorflow are based on VGG-16.\n\n2. CULane testing set (F1-measure):\n\n|Category|[SCNN-Torch](https://github.com/XingangPan/SCNN)|SCNN-Tensorflow|ENet-Label-Torch|ERFNet-CULane-PyTorch|\n|:---:|:---:|:---:|:---:|:---:|\n|Normal|90.6|90.2|90.7|**91.5**|\n|Crowded|69.7|71.9|70.8|71.6|\n|Night|66.1|64.6|65.9|**67.1**|\n|No line|43.4|45.8|44.7|45.1|\n|Shadow|66.9|73.8|70.6|71.3|\n|Arrow|84.1|83.8|85.8|**87.2**|\n|Dazzle light|58.5|59.5|64.4|**66.0**|\n|Curve|64.4|63.4|65.4|**66.3**|\n|Crossroad|1990|4137|2729|2199|\n|Total|71.6|71.3|72.0|**73.1**|\n|Runtime(ms)|133.5|--|13.4|**10.2**|\n|Parameter(M)|20.72|--|**0.98**|2.49|\n\nThe pre-trained model for testing is [here](https://drive.google.com/open?id=1-E0Bws7-v35vOVfqEXDTJdfovUTQ2sf5). Note that you need to exchange the order of VGG-MEAN in test_lanenet.py and change the order of input images from RGB to BGR since the pre-trained model uses opencv to read images. You can further boost the performance by referring to [this issue](https://github.com/cardwing/Codes-for-Lane-Detection/issues/5).\n\n3. BDD100K testing set:\n\n|Model|Accuracy|IoU|\n|:---:|:---:|:---:|\n|[SCNN-Torch](https://github.com/XingangPan/SCNN)|35.79%|15.84|\n|SCNN-Tensorflow|--|--|\n|ENet-Label-Torch|36.56%|16.02|\n\nThe accuracy and IoU of lane pixels are computed. The pre-trained model for testing is here. (coming soon!)\n\n# Others\n\n## Citation\n\nIf you use the codes, please cite the following publications:\n\n``` \n@article{hou2019learning,\n  title={Learning Lightweight Lane Detection CNNs by Self Attention Distillation},\n  author={Hou, Yuenan and Ma, Zheng and Liu, Chunxiao and Loy, Chen Change},\n  journal={arXiv preprint arXiv:1908.00821},\n  year={2019}\n}\n\n@inproceedings{pan2018SCNN,  \n  author = {Xingang Pan, Jianping Shi, Ping Luo, Xiaogang Wang, and Xiaoou Tang},  \n  title = {Spatial As Deep: Spatial CNN for Traffic Scene Understanding},  \n  booktitle = {AAAI Conference on Artificial Intelligence (AAAI)},  \n  month = {February},  \n  year = {2018}  \n}\n\n@misc{hou2019agnostic,\n    title={Agnostic Lane Detection},\n    author={Yuenan Hou},\n    year={2019},\n    eprint={1905.03704},\n    archivePrefix={arXiv},\n    primaryClass={cs.CV}\n}\n```\n\n## Acknowledgement\nThis repo is built upon [SCNN](https://github.com/XingangPan/SCNN) and [LaneNet](https://github.com/MaybeShewill-CV/lanenet-lane-detection).\n\n## Contact\nIf you have any problems in reproducing the results, just raise an issue in this repo.\n\n## To-Do List\n- [ ] Test SCNN-Tensorflow in TuSimple and BDD100K\n- [x] Provide detailed instructions to run SCNN-Tensorflow in TuSimple and BDD100K\n- [x] Upload our light-weight model (ENet-SAD) and its training \u0026 testing scripts\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcardwing%2Fcodes-for-lane-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcardwing%2Fcodes-for-lane-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcardwing%2Fcodes-for-lane-detection/lists"}