Code Monkey home page Code Monkey logo

pplanedet's Introduction

简体中文 | English

🚀PPLanedet: 基于PaddlePaddle的车道线检测的工具包

在这个项目中,我们开发了PPLanedet用于车道线检测。PPLanedet中包含了很多先进的车道线检测算法以方便车道线检测的科学研究和工程应用。欢迎加入我们来完善PPLanedet。如果您觉得PPLanedet不错,可以给我们项目一个star。

如果您没有充足的计算资源,我们建议您可以在百度AiStudio上运行PPLanedet。在Aistudio上您可以免费获得V100、A100两种高性能GPU计算资源,我们也在AIstudio上公开了PPLanedet的运行demo,项目链接在这里。由于在Windows系统上可能存在权限问题,我们建议您在linux系统上运行PPLanedet。

🆕新闻

在这个部分中,我们展示PPLanedet中最新的改进,如果您想要了解更多关于PPLanedet的改动,您可以浏览改动历史

  • [2024-04-09] 🔥 发布v6版本,该版本中复现了ADNet, CLRerNet, 欢迎大家使用。
  • [2024-02-27] 🔥 Lane2Seq被CVPR2024接收! 欢迎大家阅读交流, 论文地址
  • [2024-01-17] : 基于OneFlow框架开源车道线检测工具包FlowLane, 欢迎大家使用!
  • [2023-05-01] : 我们基于DETR提出一个端到端的车道线检测模型O2SFormer, 欢迎大家使用!

👀介绍

PPLanedet是一个基于PaddlePaddle的车道线检测工具包。PaddlePaddle是一种高性能的深度学习框架。PPLanedet开发的初衷是希望科研人员或者工程师能够通过一个框架方便地开发各类车道线检测算法。如果您对PPLanedet有任何疑问或者建议,欢迎和我联系。

🌟框架总览

模型 框架组件
Backbones
Necks
Losses
Metrics
  • Accuracy
  • FP
  • FN
Datasets
Data Augmentation
  • RandomLROffsetLABEL
  • Resize
  • RandomUDoffsetLABEL
  • RandomCrop
  • CenterCrop
  • RandomRotation
  • RandomBlur
  • Normalize
  • RandomHorizontalFlip
  • Colorjitters
  • RandomErasings
  • GaussianBlur
  • RandomGrayScale
  • Alaug

🛠️安装

具体步骤

步骤1 安装 PaddlePaddle==2.4.2(如果有疑问可以参考官方文档)

conda create -n pplanedet python=3.8 -y
conda activate pplanedet
conda install paddlepaddle-gpu==2.4.2 cudatoolkit=10.2 --channel https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/Paddle/

步骤2 Git clone PPlanedet

git clone https://github.com/zkyseu/PPlanedet

步骤3 安装 PPlanedet

cd PPlanedet
pip install -r requirements.txt
python setup.py build develop

📘数据集准备(CULane和Tusimple为例)

CULane

CULane数据集准备步骤

下载 CULane. 接着解压到 $CULANEROOT. 创建 data 目录.

cd $LANEDET_ROOT
mkdir -p data
ln -s $CULANEROOT data/CULane

对于CULane数据集, 完成以上步骤你应该有下列数据集结构:

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

Tusimple

Tusimple数据集准备步骤 下载 [Tusimple](TuSimple/tusimple-benchmark#3). 然后解压到 `$TUSIMPLEROOT`. 创建 `data` 文件夹.
cd $LANEDET_ROOT
mkdir -p data
ln -s $TUSIMPLEROOT data/tusimple

对于Tusimple数据集, 完成以上步骤你应该有下列数据集结构:

$TUSIMPLEROOT/clips # data folders
$TUSIMPLEROOT/lable_data_xxxx.json # label json file x4
$TUSIMPLEROOT/test_tasks_0627.json # test tasks json file
$TUSIMPLEROOT/test_label.json # test label json file

对于Tusimple数据集,分割地标签并没有提供,因此为了方便分割模型的训练,我们运行下列命令从json文件中生成分割的mask。

python tools/generate_seg_tusimple.py --root $TUSIMPLEROOT
# python tools/generate_seg_tusimple.py --root /root/paddlejob/workspace/train_data/datasets --savedir /root/paddlejob/workspace/train_data/datasets/seg_label

自制数据集

如果你想在自己数据集上进行训练,我们在issue #1中对该问题进行了讨论,大家可以进行参考

💎开始快乐炼丹

1、训练的命令

开启训练

对于训练, 运行以下命令(shell脚本在script文件夹下)。更多的训练命令可以参考documentation

# training on single-GPU
export CUDA_VISIBLE_DEVICES=0
python tools/train.py -c configs/scnn/resnet50_tusimple.py

多卡训练(基于分割的模型可以稳定运行,其他模型训练还不太稳定)

# training on multi-GPU
export CUDA_VISIBLE_DEVICES=0,1,2,3
python -m paddle.distributed.launch tools/train.py -c configs/scnn/resnet50_tusimple.py

2、测试

开启测试

运行以下命令开启模型的测试

python tools/train.py -c configs/scnn/resnet50_tusimple.py \
                      --load /home/fyj/zky/tusimple/new/pplanedet/output_dir/resnet50_tusimple/latest.pd \
                      --evaluate-only 

3、推理/Demo

开启推理

想了解更多细节,请参考 tools/detect.py.

python tools/detect.py --help

usage: detect.py [-h] [--img IMG] [--show] [--savedir SAVEDIR]
                 [--load_from LOAD_FROM]
                 config

positional arguments:
  config                The path of config file

optional arguments:
  -h, --help            show this help message and exit
  --img IMG             The path of the img (img file or img_folder), for
                        example: data/*.png
  --show                Whether to show the image
  --savedir SAVEDIR     The root of save directory
  --load_from LOAD_FROM
                        The path of model

运行以下命令对一个文件夹下的图片进行预测,可视化结果保存在文件夹 vis下,如果您的模型不是分割模型,需要在配置文件中加上 seg=False,具体可见issue3

# first you should add 'seg = False' in your config 
python tools/detect.py configs/scnn/resnet50_tusimple.py --img images\
          --load_from model.pd --savedir ./vis

如果想要获取基于分割的车道线检测模型的分割结果,可以运行以下命令

# first you should add 'seg = True' in your config 
python tools/detect.py configs/scnn/resnet50_tusimple.py --img images\
          --load_from model.pd --savedir ./vis

4、测试模型检测速度

开启速度测试

如果你想要测试模型的速度,你可以运行以下的命令。但是需要注意的是测试脚本使用python进行编写并未采用常见的C++,因此测试得到的模型检测速度会低于论文报告的结果,但是也可以用来衡量不同模型间检测速度快慢

 python tools/test_speed.py configs/condlane/cspresnet_50_culane.py --model_path output_dir/cspresnet_50_culane/model.pd

5、VisualDL可视化

开启可视化

如果你想可视化中间过程的loss,请在终端运行以下命令,其中log为存放日志的文件夹,更多的命令以及功能请参考VisualDL

# 首先你需要在配置文件中加上use_visual = True,训练完后即可得到日志文件,将其放在log文件夹下
visualdl --logdir ./log

6、模型导出

开启模型导出

如果你想将模型导出为预训练的格式(只保留模型权重去除优化器以及学习率的权重),可以使用以下命令

python tools/train.py -c configs/ufld/mobilenetv3_culane.py --export output_dir/mobilenetv3_culane/epoch_51.pd
#如果模型权重中包含RepVGG模块,可以运行以下命令来将RepVGG中卷积进行重参数化。
#python tools/train.py -c config path --export model path --export_repvgg

License

PPLanedet使用MIT license。但是我们仅允许您将PPLanedet用于学术用途。

致谢

  • 非常感谢PASSL提供HOOK代码
  • 非常感谢lanedet提供模型代码

引用

如果您认为我们的项目对您的研究有用,请引用我们的项目

@misc{PPlanedet,
    title={PPlanedet, A Toolkit for lane detection based on PaddlePaddle},
    author={Kunyang Zhou},
    howpublished = {\url{https://github.com/zkyseu/PPlanedet}},
    year={2022}
}

PPLanedet中复现的方法

@Inproceedings{pan2018SCNN,  
  author = {Xingang Pan, Jianping Shi, Ping Luo, Xiaogang Wang, and Xiaoou Tang},  
  title = {Spatial As Deep: Spatial CNN for Traffic Scene Understanding},  
  booktitle = {AAAI Conference on Artificial Intelligence (AAAI)},  
  month = {February},  
  year = {2018}  
}

@InProceedings{qin2020ultra,
author = {Qin, Zequn and Wang, Huanyu and Li, Xi},
title = {Ultra Fast Structure-aware Deep Lane Detection},
booktitle = {The European Conference on Computer Vision (ECCV)},
year = {2020}
}

@article{2017ERFNet,
author = {E.Romera, J.M.Alvarez, L.M.Bergasa and R.Arroyo},
title = {ERFNet: Efficient Residual Factorized ConvNet for Real-time Semantic Segmentation},
journal = {IEEE Transactions on Intelligent Transportation Systems(T-ITS)},
year = {2017}
}

@InProceedings{2021RESA,
author = {Zheng, Tu and Fang, Hao and Zhang, Yi and Tang, Wenjian and Yang, Zheng and Liu, Haifeng and Cai, Deng},
title = {RESA: Recurrent Feature-Shift Aggregator for Lane Detection},
booktitle = {Proceedings of the AAAI Conference on Artificial Intelligence},
year = {2021}
}

@InProceedings{DeepLabV3+,
author = {Chen, Liang-Chieh, Yukun Zhu, George Papandreou, Florian Schroff, and Hartwig Adam},
title = {Encoder-decoder with atrous separable convolution for semantic image segmentation},
booktitle = {In Proceedings of the European conference on computer vision(ECCV)},
year = {2018}
}

@InProceedings{CondLaneNet,
author = {Liu, Lizhe and Chen, Xiaohao and Zhu, Siyu and Tan, Ping},
title = {CondLaneNet: a Top-to-down Lane Detection Framework Based on Conditional Convolution},
booktitle = {Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV)},
year = {2021}
}

@article{RTFormer,
author = {Wang, Jian, Chenhui Gou, Qiman Wu, Haocheng Feng, Junyu Han, Errui Ding, and Jingdong Wang},
title = {RTFormer: Efficient Design for Real-Time Semantic Segmentation with Transformer},
journal = {arXiv preprint arXiv:2210.07124 (2022)},
year = {2022}
}

pplanedet's People

Contributors

zkyseu avatar xd256 avatar

Stargazers

S.A avatar  avatar chenyu_wang avatar  avatar  avatar  avatar  avatar 张多阔 avatar Giaming avatar  avatar  avatar upupbo avatar TK9798 avatar  avatar  avatar syzygyChen avatar  avatar Byronnar avatar Nw avatar Mingfu Yan avatar  avatar ma-chenglin avatar using su avatar  avatar  avatar Hyggge avatar  avatar larry avatar An-zhi WANG avatar  avatar Jiawei Zhao avatar noringname avatar  avatar Elsa_0511 avatar  avatar Yunqian Fan avatar  avatar Furkan Küçük avatar  avatar  avatar Jeff.zhu avatar Coder Franklin avatar  avatar weiWang avatar 思无邪 avatar  avatar  avatar Seasoning avatar Franklin Tao avatar  avatar  avatar  avatar QQQ avatar  avatar  avatar 舞影凌风 avatar  avatar xiaofei sun avatar  avatar Walter Arca Yi avatar XianchiMeng avatar Kunyang Zhou avatar  avatar  avatar  avatar

Watchers

 avatar

pplanedet's Issues

关于动态分配里分类成本的计算问题

作者您好!我想请教一下在pplanedet/model/common_model/dynamic_assign.py里关于分类成本focal_cost计算,这个是不是只是针对背景/车道线两个类别?如果我现在希望对背景/实线/虚线进行区分,在这里我是否还需要做一些修改?另外还想请教一下在多分类的时候例如背景/实线/虚线,正负样本该怎么定义呢?是实线虚线都算正样本吗?
感谢百忙之余抽空查看,还望不吝赐教!

静态图

您好,这种格式pd适合导出静态图吗

可以用自制数据集训练吗

我想用自己用labelme标注的数据集训练,我看这里只给出了culane和tusimple的格式,请问需要做哪些修改呢?

windows平台运行时总是显示permission deny

您好,我在安装过程都挺顺利,但是无论是在训练或者推断的时候都会出现一个PermissionError, 长这样:

PermissionError: [Errno 13] Permission denied: 'C:\\Users\\genwe\\AppData\\Local\\Temp\\tmp8vlqnvn3\\tmplpyzwhyo.py'

显示的是tools/detect.py里这行代码所致:

with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:

我在您库里直接下载了CLRNet的训练权重model.pd.
运行推断的命令是:

python tools/detect.py configs/clrnet/resnet34_culane.py --img data\test_data\road_image.png --load_from trained_models\resnet34_culine_pretrained\model.pd --savedir data\test_data\output

我也试过用管理员模式运行,但是我一直得到这个错误,请问是这个detect.py尝试往这个local/temp文件夹里写入什么东西才导致被拒的吗?我应该如何绕过,或者修改script才能成功的使用预训练模型推断单张图片呢。

还请不吝赐教。

整体报错长这样:

C:\software\anaconda3\envs\pplanedet\lib\site-packages\setuptools\sandbox.py:13: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
import pkg_resources
C:\software\anaconda3\envs\pplanedet\lib\site-packages\pkg_resources_init_.py:2871: DeprecationWarning: Deprecated call to pkg_resources.declare_namespace('mpl_toolkits').
Implementing implicit namespace packages (as specified in PEP 420) is preferred to pkg_resources.declare_namespace. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
declare_namespace(pkg)
C:\software\anaconda3\envs\pplanedet\lib\site-packages\pkg_resources_init_.py:2871: DeprecationWarning: Deprecated call to pkg_resources.declare_namespace('google').
Implementing implicit namespace packages (as specified in PEP 420) is preferred to pkg_resources.declare_namespace. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
declare_namespace(pkg)
C:\software\anaconda3\envs\pplanedet\lib\site-packages\albumentations\augmentations\geometric\functional.py:7: DeprecationWarning: Please use gaussian_filter from the scipy.ndimage namespace, the scipy.ndimage.filters namespace is deprecated.
from scipy.ndimage.filters import gaussian_filter
C:\software\anaconda3\envs\pplanedet\lib\site-packages\albumentations\augmentations\transforms.py:14: DeprecationWarning: Please use gaussian_filter from the scipy.ndimage namespace, the scipy.ndimage.filters namespace is deprecated.
from scipy.ndimage.filters import gaussian_filter
Traceback (most recent call last):
File "tools/detect.py", line 190, in
process(args)
File "tools/detect.py", line 172, in process
cfg = Config.fromfile(args.config)
File "c:\users\genwe\onedrive\desktop\projects\traffic_light\real_camera_tsc\lane_detection\pplanedet-5\pplanedet\utils\py_config.py", line 178, in fromfile
cfg_dict, cfg_text = Config._file2dict(filename)
File "c:\users\genwe\onedrive\desktop\projects\traffic_light\real_camera_tsc\lane_detection\pplanedet-5\pplanedet\utils\py_config.py", line 103, in _file2dict
shutil.copyfile(filename,
File "C:\software\anaconda3\envs\pplanedet\lib\shutil.py", line 264, in copyfile
with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied: 'C:\Users\genwe\AppData\Local\Temp\tmp8vlqnvn3\tmplpyzwhyo.py'

训练ADnet,进行val时报错

一开始报错
image
修改为
start_points_hm = start_points_hm[:,1::-1]
解决问题,后续报错
image
查询文档发现paddle2.4.2确实没有hstack方法,使用stack替换,后续报错
image

训练condlane时报错

1679902396846

PermissionError: [Errno 13] Permission denied: 'C:\\Users\\83809\\AppData\\Local\\Temp\\tmp8h5xag6e\\tmpxnn_wbqm.py'

在文件夹中找不到这个报错文件。
每一次报错这个.py文件的名称还不一样。

请问有遇到过同样问题吗?

Lane2Seq

你好,请问会发布Lane2Seq的训练代码和模型吗?谢谢您的杰出工作!

我在测试culane时,KeyError: 'seg'

python tools/detect.py configs/condlane/resnet50_culane.py --img /data/our_testset --load_from /PPlanedet/models/resnet50_culane/model.pd --savedir ./vis
出现下面的错误:
image
dict_keys(['seeds', 'hm'])是我打印出来的 out[1].keys(),没有'seg'这个键值。

请问怎么破?

train

When I was training, I got the following error, all my configurations are according to yours, why is this?

Traceback (most recent call last):
File "C:\Users\xiaoxu\Desktop\PPlanedet\tools\train.py", line 49, in
main(args, cfg)
File "C:\Users\xiaoxu\Desktop\PPlanedet\tools\train.py", line 39, in main
trainer.train()
File "C:\Users\xiaoxu\Desktop\PPlanedet\pplanedet\engine\trainer.py", line 325, in train
self.outputs = self.model(data)
File "D:\Anaconda\envs\ppl\lib\site-packages\paddle\fluid\dygraph\layers.py", line 1012, in call
return self.forward(*inputs, **kwargs)
File "C:\Users\xiaoxu\Desktop\PPlanedet\pplanedet\model\architecture\detector.py", line 40, in forward
return self.forward_train(batch)
File "C:\Users\xiaoxu\Desktop\PPlanedet\pplanedet\model\architecture\detector.py", line 33, in forward_train
output.update(self.heads.loss(out, batch))
File "C:\Users\xiaoxu\Desktop\PPlanedet\pplanedet\model\heads\clr_head.py", line 341, in loss
target = target[target[:, 1] == 1]
File "D:\Anaconda\envs\ppl\lib\site-packages\paddle\fluid\dygraph\varbase_patch_methods.py", line 749, in getitem
return getitem_impl(self, item)
File "D:\Anaconda\envs\ppl\lib\site-packages\paddle\fluid\variable_index.py", line 445, in getitem_impl
return get_value_for_bool_tensor(var, slice_item)
File "D:\Anaconda\envs\ppl\lib\site-packages\paddle\fluid\variable_index.py", line 318, in get_value_for_bool_tensor
return cond(item.any(), lambda: idx_not_empty(var, item),
File "D:\Anaconda\envs\ppl\lib\site-packages\paddle\fluid\layers\control_flow.py", line 2780, in cond
return true_fn()
File "D:\Anaconda\envs\ppl\lib\site-packages\paddle\fluid\variable_index.py", line 318, in
return cond(item.any(), lambda: idx_not_empty(var, item),
File "D:\Anaconda\envs\ppl\lib\site-packages\paddle\fluid\variable_index.py", line 309, in idx_not_empty
bool_2_idx = where(item == True)
File "D:\Anaconda\envs\ppl\lib\site-packages\paddle\fluid\layers\nn.py", line 15541, in where
return _C_ops.where_index(condition)
RuntimeError: (PreconditionNotMet) The Tensor's element number must be equal or greater than zero. The Tensor's shape is [-4871612750214200964, 1] now
[Hint: Expected numel() >= 0, but received numel():-4871612750214200964 < 0:0.] (at ..\paddle\phi\core\dense_tensor_impl.cc:110)

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.