CLRNet Test

SSW·2023년 3월 20일
0

Deep Learning

목록 보기
7/8

CLRNet Lane Detection Model Results

Prerequisites

Ubuntu 20.04
Python 3.8
Pytorch 1.8
CUDA 11.1 (10.2도 가능)
Other dependencies described in requirements.txt

CUDA Toolkit 11.1 version

Installation Instructions

Install Type은 runfile(local) 선택

$ wget https://developer.download.nvidia.com/compute/cuda/11.1.0/local_installers/cuda_11.1.0_455.23.05_linux.run
$ sudo sh cuda_11.1.0_455.23.05_linux.run --silent --toolkit --toolkitpath=/usr/local/cuda-11.1
$ cd /usr/local
# symbolic link된 directory 삭제
$ sudo rm cuda
# 원하는 CUDA version으로 symbolic link 설정
$ sudo ln -s cuda-11.1 cuda

환경 변수 설정

$ gedit ~/.bashrc
# 아래 환경 변수 설정이 되어있는지 확인 및 입력 후 저장
$ source ~/.bashrc
export CUDA_HOME=/usr/local/cuda
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64
PATH=${CUDA_HOME}/bin:${PATH}
export PATH

CUDA version 변경 확인

$ nvcc -V

conda 환경 setting

$ conda create -y -n clrnet python=3.8
$ conda activate clrnet
$ pip install torch==1.8.0 torchvision==0.9.0
$ pip install -r requirements.txt
$ python setup.py build develop
$ pip install scikit-learn

Data Preparation

Download CULane Dataset

# $CLRNET_ROOT는 CLRNet 폴더 경로
$ cd $CLRNET_ROOT
$ mkdir -p data
# symbolic link 생성, $CULANEROOT는 CULane dataset이 설치된 경로
$ ln -s $CULANEROOT data/CULane
$ cd $CLRNET_ROOT/data/CULane
$ tar -zxvf list.tar.gz && tar -zxvf laneseg_label_w16.tar.gz $$ unzip laneseg_label_w16_test.tar.gz
$ tar -zxvf driver_23_30frame.tar.gz && tar -zxvf driver_37_30frame.tar.gz && tar -zxvf driver_100_30frame.tar.gz && tar -zxvf driver_161_90frame.tar.gz && tar -zxvf driver_182_30frame.tar.gz && tar -zxvf driver_193_90frame.tar.gz

Dataset Structure

$CULANEROOT/driver_xx_xxframe    # data folders x6
$CULANEROOT/laneseg_label_w16    # lane segmentation labels
$CULANEROOT/list                 # data lists

Pretrained Models

Download Pretrained Models

$ cd $CLRNET_ROOT/clrnet/models/backbones
# dla34
$ wget https://github.com/Turoad/CLRNet/releases/download/models/culane_dla34.pth.zip
# resnet18
$ wget https://github.com/Turoad/CLRNet/releases/download/models/culane_r18.pth.zip
# resnet34
$ wget https://github.com/Turoad/CLRNet/releases/download/models/culane_r34.pth.zip
# resnet101
$ wget https://github.com/Turoad/CLRNet/releases/download/models/culane_r101.pth.zip
$ unzip culane_dla34.pth.zip
$ unzip culane_r18.pth.zip
$ unzip culane_r34.pth.zip
$ unzip culane_r101.pth.zip

Test

Command

# python main.py [configs/path_to_your_config] --[test|validate] --load_from [path_to_your_model] --gpus [gpu_num]
# Adding --view to get visualization output
$ python main.py configs/clrnet/clr_dla34_culane.py --test --load_from ./clrnet/models/backbones/culane_dla34.pth --gpus 0 --view

Output

2023-03-21 16:19:34,557 - clrnet.datasets.base_dataset - INFO - Loading CULane annotations...
Testing: 100%|█████████████████████████████████████████| 1445/1445 [24:34<00:00,  1.02s/it]
Generating prediction output...
2023-03-21 16:44:18,066 - clrnet.utils.culane_metric - INFO - Calculating metric for List: ./data/CULane/list/test_split/test0_normal.txt
2023-03-21 16:48:18,942 - clrnet.utils.culane_metric - INFO - iou thr: 0.50, tp: 30371, fp: 1664, fn: 2406,precision: 0.9480568128609334, recall: 0.9265948683528084, f1: 0.937202987101154
2023-03-21 16:48:19,073 - clrnet.utils.culane_metric - INFO - Calculating metric for List: ./data/CULane/list/test_split/test1_crowd.txt
2023-03-21 16:51:22,716 - clrnet.utils.culane_metric - INFO - iou thr: 0.50, tp: 20681, fp: 3264, fn: 7322,precision: 0.8636876174566716, recall: 0.7385280148555512, f1: 0.7962192962192963
2023-03-21 16:51:22,806 - clrnet.utils.culane_metric - INFO - Calculating metric for List: ./data/CULane/list/test_split/test2_hlight.txt
2023-03-21 16:51:34,085 - clrnet.utils.culane_metric - INFO - iou thr: 0.50, tp: 1143, fp: 209, fn: 542,precision: 0.8454142011834319, recall: 0.6783382789317507, f1: 0.7527164965426406
2023-03-21 16:51:34,090 - clrnet.utils.culane_metric - INFO - Calculating metric for List: ./data/CULane/list/test_split/test3_shadow.txt
2023-03-21 16:51:52,712 - clrnet.utils.culane_metric - INFO - iou thr: 0.50, tp: 2217, fp: 283, fn: 659,precision: 0.8868, recall: 0.7708623087621697, f1: 0.8247767857142857
2023-03-21 16:51:52,721 - clrnet.utils.culane_metric - INFO - Calculating metric for List: ./data/CULane/list/test_split/test4_noline.txt
2023-03-21 16:52:58,386 - clrnet.utils.culane_metric - INFO - iou thr: 0.50, tp: 6008, fp: 1986, fn: 8013,precision: 0.7515636727545659, recall: 0.42850010698238356, f1: 0.54580967522144
2023-03-21 16:52:58,423 - clrnet.utils.culane_metric - INFO - Calculating metric for List: ./data/CULane/list/test_split/test5_arrow.txt
2023-03-21 16:53:22,560 - clrnet.utils.culane_metric - INFO - iou thr: 0.50, tp: 2801, fp: 200, fn: 381,precision: 0.9333555481506165, recall: 0.8802639849151477, f1: 0.90603267022481
2023-03-21 16:53:22,570 - clrnet.utils.culane_metric - INFO - Calculating metric for List: ./data/CULane/list/test_split/test6_curve.txt
2023-03-21 16:53:30,517 - clrnet.utils.culane_metric - INFO - iou thr: 0.50, tp: 852, fp: 140, fn: 460,precision: 0.8588709677419355, recall: 0.649390243902439, f1: 0.7395833333333333
2023-03-21 16:53:30,521 - clrnet.utils.culane_metric - INFO - Calculating metric for List: ./data/CULane/list/test_split/test7_cross.txt
2023-03-21 16:53:32,287 - clrnet.utils.culane_metric - INFO - iou thr: 0.50, tp: 0, fp: 1154, fn: 0,precision: 0, recall: 0, f1: 0
2023-03-21 16:53:32,290 - clrnet.utils.culane_metric - INFO - Calculating metric for List: ./data/CULane/list/test_split/test8_night.txt
2023-03-21 16:55:41,424 - clrnet.utils.culane_metric - INFO - iou thr: 0.50, tp: 14342, fp: 2699, fn: 6688,precision: 0.8416172759814565, recall: 0.6819781264859724, f1: 0.7534343726195794
2023-03-21 16:55:41,497 - clrnet.utils.culane_metric - INFO - Calculating metric for List: ./data/CULane/list/test.txt
2023-03-21 17:06:53,356 - clrnet.utils.culane_metric - INFO - iou thr: 0.50, tp: 78415, fp: 11599, fn: 26471,precision: 0.8711422667585043, recall: 0.7476212268558244, f1: 0.8046690610569524
2023-03-21 17:06:53,388 - clrnet.utils.culane_metric - INFO - iou thr: 0.55, tp: 76615, fp: 13399, fn: 28271,precision: 0.85114537738574, recall: 0.7304597372385256, f1: 0.7861980502821959
2023-03-21 17:06:53,420 - clrnet.utils.culane_metric - INFO - iou thr: 0.60, tp: 74215, fp: 15799, fn: 30671,precision: 0.8244828582220544, recall: 0.7075777510821273, f1: 0.7615700359158543
2023-03-21 17:06:53,459 - clrnet.utils.culane_metric - INFO - iou thr: 0.65, tp: 71206, fp: 18808, fn: 33680,precision: 0.7910547248205835, recall: 0.6788894609385427, f1: 0.7306926629040533
2023-03-21 17:06:53,510 - clrnet.utils.culane_metric - INFO - iou thr: 0.70, tp: 67122, fp: 22892, fn: 37764,precision: 0.7456840047103784, recall: 0.6399519478290716, f1: 0.6887839917906619
2023-03-21 17:06:53,548 - clrnet.utils.culane_metric - INFO - iou thr: 0.75, tp: 61177, fp: 28837, fn: 43709,precision: 0.6796387228653321, recall: 0.5832713612874931, f1: 0.6277783478707029
2023-03-21 17:06:53,589 - clrnet.utils.culane_metric - INFO - iou thr: 0.80, tp: 52581, fp: 37433, fn: 52305,precision: 0.584142466727398, recall: 0.5013157142039929, f1: 0.5395690097485891
2023-03-21 17:06:53,623 - clrnet.utils.culane_metric - INFO - iou thr: 0.85, tp: 39125, fp: 50889, fn: 65761,precision: 0.4346546092830004, recall: 0.373024045153786, f1: 0.40148794253463316
2023-03-21 17:06:53,659 - clrnet.utils.culane_metric - INFO - iou thr: 0.90, tp: 19910, fp: 70104, fn: 84976,precision: 0.2211878152287422, recall: 0.18982514348912152, f1: 0.20430990251410983
2023-03-21 17:06:53,688 - clrnet.utils.culane_metric - INFO - iou thr: 0.95, tp: 1841, fp: 88173, fn: 103045,precision: 0.020452374075143866, recall: 0.017552390214137254, f1: 0.01889173935351462
2023-03-21 17:06:53,689 - clrnet.utils.culane_metric - INFO - mean result, total_tp: 542207, total_fp: 357933, total_fn: 506653,precision: 0.6023585220076877, recall: 0.5169488778292622, f1: 0.5563950743971267
2023-03-21 17:06:54,014 - clrnet.utils.recorder - INFO - metric: 0.8046690610569524
# Final Output
mean result, total_tp: 542207, total_fp: 357933, total_fn: 506653,precision: 0.6023585220076877, recall: 0.5169488778292622, f1: 0.5563950743971267

아래의 그림처럼 CLRNet github에 나와있는 result 값과 동일하게 도출됨

Visualization Output

Trouble Shooting

Error Message

RuntimeError: CUDA error: no kernel image is available for execution on the device

Solution

$ pip uninstall torch torchvision
$ conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=11.1 -c pytorch -c conda-forge

[References]

CLRNet Paper
CLRNet Github
CULane Dataset

profile
ssw

1개의 댓글

comment-user-thumbnail
2023년 9월 4일

글 감사히 잘 읽었습니다!! 구현하면서 궁금증이 생겨 댓글 남깁니다.
Validation 과정 중에서 오류가 발생하지 않던가요?
data tree에서 clrnet/ops/init.py에서 nms_impl 모듈이 없다고 뜨던데, 전체 코드를 디버깅해봐도 저 모듈을 찾을 수가 없더라고요
혹시 이 문제는 어떻게 해결했는지 여쭤볼 수 있을까요?

답글 달기