DOI: 10.4121/4619cab6-ae4a-40d5-af77-582a77f3d821
title: Code underlying the publication: Efficient Sequential Neural Network based on Spatial-Temporal Attention and Linear LSTM for Robust Lane Detection Using Multi-Frame Images

description: This is the source code of the paper: Patil, S.#, <strong>Dong, Y.#</strong>,*, Farah, H, & Hellendoorn, J. (2024). Efficient Sequential Neural Network Based on Spatial-Temporal Attention and Linear LSTM for Robust Lane Detection Using Multi-Frame Images (Under Review)<br>How to use the codes<strong>(1) Download tvtLANE Dataset:</strong>You can download this **dataset** from the link in the '**Dataset-Description-v1.2.pdf**' file. BaiduYun：https://pan.baidu.com/s/1lE2CjuFa9OQwLIbi-OomTQ passcodes：tf9xOr Google Drive: https://drive.google.com/drive/folders/1MI5gMDspzuV44lfwzpK6PX0vKuOHUbb_?usp=sharing The **pretrained model** is also provided in the "<strong>/model</strong>" folder, named as 98.48263448061671_RAd_lr0.001_batch70_FocalLoss_poly_alpha0.25_gamma2.0_Attention_UNet_LSTM.pth . <strong>(2) Set up</strong><em>## Requirements</em>PyTorch 0.4.0 Python 3.9 CUDA 8.0 <em>## Preparation</em><em>### Data Preparation</em>The dataset contains 19383 continuous driving scenes image sequences, and 39460 frames of them are labeled. The size of images is 128*256.The training set contains 19096 image sequences. Each 13th and 20th frame in a sequence are labeled, and the image and their labels are in “clips_13(_truth)” and “clips_20(_truth)”. All images are contained in “clips_all”. Sequences in “0313”, “0531” and “0601” subfolders are constructed on TuSimple lane detection dataset, containing scenes in American highway. The four “weadd” folders are added images in rural road in China. The testset has two parts: Testset #1 (270 sequences, each 13th and 20th image is labeled) for testing the overall performance of algorithms. The Testset #2 (12 kinds of hard scenes, all frames are labeled) for testing the robustness of algorithms. To input the data, we provide three index files(train_index, val_index, and test_index). Each row in the index represents for a sequence and its label, including the former 5 input images and the last ground truth (corresponding to the last frame of 5 inputs).The dataset needs to be put into a folder with regards to the location in index files, (i.e., txt files in "./data/". The index files should also be modified add cording to your local computer settings. If you want to use your own data, please refer to the format of our dataset and indexes. <strong>(3) Training</strong>Before training, change the paths including "train_path"(for train_index.txt), "val_path"(for val_index.txt), "pretrained_path" in<strong> config_Att.py</strong> to adapt to your environment. Choose the models (<strong>UNet_ConvLSTM</strong> | SCNN_UNet_ConvLSTM | SCNN_UNet_Attention) as the default one which is also indicated by <em>default='UNet-ConvLSTM'</em> thus you do not need to make change for this. And adjust the arguments such as <em>class weights </em>(now the weights are set to fit the tvtLANE dataset), <em>batch size</em>, <em>learning rate</em>, and <em>epochs</em> in <strong>config_Att.py</strong>. You can also adjust other settings, e.g., optimizer, check in the codes for details.Then simply run: <strong>train.py</strong>. If running successfully, there will be model files saved in the "./model" folder. The validating results will also be printed. <strong>(4) Test</strong>To evaluate the performance of a trained model, please select the trained model or put your own models into the "./model/" folder and change "pretrained_path" in <strong>test.py</strong> according to the local setting, then change "test_path" to the location of <em>test_index.txt</em>, and "save_path" for the saved results.Choose the right model that would be evaluated, and then simply run: <strong>test.py</strong>. The quantitative evaluations of Accuracy, Precision, Recall, and F1 measure would be printed, and the lane detection segmented results will be saved in the "./save/" folder as pictures. AuthorsYongqi Dong (yongqidong369@gmail.com), Sandeep Patil, Haneen Farah, Hans Hellendoorn<br>