端到端车道线检测

Ultralytics recently launched YOLOv5 amid controversy surrounding its name. For context, the first three versions of YOLO (You Only Look Once) were created by Joseph Redmon. Following this, Alexey Bochkovskiy created YOLOv4 on darknet, which boasted higher Average Precision (AP) and faster results than previous iterations.

Ultralytics最近在围绕其名称的争议中推出了YOLOv5。 对于上下文,约瑟夫·雷德蒙(Joseph Redmon)创建了YOLO的前三个版本。 此后,Alexey Bochkovskiy在Darknet上创建了YOLOv4,与以前的迭代相比,它拥有更高的平均精度(AP)和更快的结果。

Now, Ultralytics has released YOLOv5, with comparable AP and faster inference times than YOLOv4. This has left many asking: is a new version warranted given similar accuracy to YOLOv4? Whatever the answer may be, it’s definitely a sign of how quickly the detection community is evolving.

现在,Ultralytics已发布YOLOv5,具有可比的AP和比YOLOv4更快的推理时间。 这引起了很多人的疑问:是否应授予与YOLOv4相似的准确性的新版本? 无论答案是什么,这绝对标志着检测社区发展的速度有多快。

Source: Ultralytics Yolov5资料来源 :Ultralytics Yolov5

Since they first ported YOLOv3, Ultralytics has made it very simple to create and deploy models using Pytorch, so I was eager to try out YOLOv5. As it turns out, Ultralytics has further simplified the process, and the results speak for themselves.

自从他们首次移植YOLOv3以来,Ultralytics就使使用Pytorch创建和部署模型非常简单,所以我很想尝试YOLOv5。 事实证明,Ultralytics进一步简化了流程,其结果不言而喻。

In this article, we’ll create a detection model using YOLOv5, from creating our dataset and annotating it to training and inferencing using their remarkable library. This post focuses on the implementation of YOLOv5, including:

在本文中,我们将使用YOLOv5创建检测模型,从创建数据集并对其进行注释到使用其卓越的库进行训练和推理。 这篇文章重点介绍YOLOv5的实现,包括:

  • Creating a toy dataset创建玩具数据集
  • Annotating the image data注释图像数据
  • Creating the project structure创建项目结构
  • Training YOLOv5培训YOLOv5

创建自定义数据集 (Creating Custom Dataset)

You can forgo the first step if you have your image Dataset. Since I don’t have images, I am downloading data from the Open Image Dataset(OID), which is an excellent resource for getting annotated image data that can be used for classification as well as detection. Note that we won’t be using the provided annotations from OID and create our own for the sake of learning.

如果您有图像数据集,则可以放弃第一步。 由于我没有图像,因此我正在从开放图像数据集(OID)下载数据,这是获取可用于分类和检测的带注释图像数据的绝佳资源。 请注意,我们不会使用OID提供的注释,而是为了学习而创建自己的注释。

1. OIDv4下载图片: (1. OIDv4 Download Images:)

To download images from the Open Image dataset, we start by cloning the OIDv4_ToolKit and installing all requirements.

要从Open Image数据集下载图像,我们首先克隆OIDv4_ToolKit并安装所有要求。

git clone https://github.com/EscVM/OIDv4_ToolKitcd OIDv4_ToolKitpip install -r requirements.txt

We can now use the main.py script within this folder to download images as well as labels for multiple classes.

现在,我们可以使用此文件夹中的main.py脚本来下载图像以及多个类的标签。

Below I am downloading the data for Cricketball and Football to create our Custom Dataset. That is, we will be creating a dataset with footballs and cricket balls, and the learning task is to detect these balls.

下面,我正在下载板球和橄榄球的数据以创建我们的自定义数据集。 也就是说,我们将创建一个包含足球和板球的数据集,学习任务是检测这些球。

python3 main.py downloader --classes Cricket_ball  Football --type_csv all -y --limit 500

The below command creates a directory named “OID” with the following structure:

下面的命令使用以下结构创建一个名为“ OID”的目录:

OID directory structure. We will take only the image files(.jpgs) from here and not the labels as we will annotate manually to create our Custom Dataset, though we can use them if required for a different project.
OID目录结构。 我们将仅从此处获取图像文件(.jpgs),而不从标签中获取标签,因为我们将手动添加注释以创建“自定义数据集”,尽管如果不同项目需要,我们也可以使用它们。

Before we continue, we will need to copy all the images in the same folder to start our labeling exercise from Scratch. You can choose to do this manually, but this can also be quickly done programmatically using recursive glob function:

在继续之前,我们需要复制同一文件夹中的所有图像,以便从头开始我们的标签练习。 您可以选择手动执行此操作,但是也可以使用递归glob函数以编程方式快速完成此操作:

import osfrom glob import globos.system("mkdir Images")images = glob(r'OID/**/*.jpg', recursive=True)for img in images:    os.system(f"cp {img} Images/")

2.使用HyperLabel标记图像 (2. Label Images with HyperLabel)

We will use a tool called Hyperlabel to label our images. In the past, I have used many tools to create annotations like labelimg, labelbox, etc. but never came across a tool so straightforward and that too open source. The only downside is that you cannot get this tool for Linux and only for Mac and Windows, but I guess that is fine for most of us.

我们将使用称为Hyperlabel的工具来标记图像。 过去,我曾使用过许多工具来创建诸如labelimg,labelbox等的批注,但从未遇到过如此简单,过于开源的工具。 唯一的缺点是您无法在Linux以及Mac和Windows上使用此工具,但是我认为这对我们大多数人都很好。

1. Create Project, 2, Set up Labels, 3. Add Local Image data source, 4. Annotate
1.创建项目,2,设置标签,3.添加本地图像数据源,4.注释

The best part of this tool is the variety of output formats it provides. Since we want to get the data for Yolo, we will close Yolo Format and export it after being done with our annotations. But you can choose to use this tool if you want to get annotations in JSON format(COCO) or XML format(Pascal VOC) too.

该工具最好的部分是它提供的各种输出格式。 由于我们要获取Yolo的数据,因此我们将关闭Yolo格式并在完成注释后将其导出。 但是,如果您也想以JSON格式(COCO)或XML格式(Pascal VOC)获得注释,则可以选择使用此工具。

5. Export
5.出口

Exporting in Yolo format essentially creates a .txt file for each of our images, which contains the class_id, x_center, y_center, width, and the height of the image. It also creates a file named obj.names , which helps map the class_id to the class name. For example:

以Yolo格式导出实际上会为我们的每个图像创建一个.txt文件,其中包含class_id,x_center,y_center,图像的宽度和高度。 它还创建一个名为obj.names的文件,该文件有助于将class_id映射到类名。 例如:

Image, its annotation, and the obj.names file
图像,其注释和obj.names文件

Notice that the coordinates are scaled from 0 to 1 in the annotation file. Also, note that the class_id is 0 for Cricketball and 1 for football as per obj.names file, which starts from 0. There are a few other files we create using this, but we won’t be using them in this example.

请注意,注释文件中的坐标从0缩放到1。 另外,请注意,根据obj.names文件,板球的class_id为0,橄榄球为1,从0开始。我们使用此文件创建了一些其他文件,但在本示例中将不再使用它们。

Once we have done this, we are mostly set up with our custom dataset and would only need to rearrange some of these files for subsequent training and validation splits later when we train our model. The dataset currently will be a single folder like below containing both the images as well as annotations:

完成此操作后,我们大部分将使用自定义数据集进行设置,并且在我们训练模型时,仅需要重新排列其中一些文件即可进行后续的训练和验证拆分。 数据集当前将是一个单独的文件夹,如下所示,其中既包含图像又包含注释:

dataset    - 0027773a6d54b960.jpg      - 0027773a6d54b960.txt    - 2bded1f9cb587843.jpg    - 2bded1f9cb587843.txt    --    --

设置项目 (Setting up the project)

To train our custom object detector, we will be using Yolov5 from Ultralytics. We start by cloning the repository and installing the dependencies:

为了训练我们的自定义对象检测器,我们将使用Ultralytics的Yolov5。 我们首先克隆存储库并安装依赖项:

git clone https://github.com/ultralytics/yolov5 # clone repocd yolov5pip install -U -r requirements.txt

We then start with creating our own folder named training in which we will keep our custom dataset.

然后,我们从创建自己的名为training的文件夹开始,在其中保留我们的自定义数据集。

!mkdir training

We start by copying our custom dataset folder in this folder and creating the train validation folders using the simple train_val_folder_split.ipynb notebook. This code below just creates some train and validation folders and populates them with images.

我们首先将自定义数据集文件夹复制到此文件夹中,然后使用简单的train_val_folder_split.ipynb笔记本创建火车验证文件夹。 下面的代码仅创建了一些train和validation文件夹,并在其中填充了图像。

import glob, osimport random# put your own path heredataset_path = 'dataset'# Percentage of images to be used for the validation setpercentage_test = 20!mkdir data!mkdir data/images!mkdir data/labels!mkdir data/images/train!mkdir data/images/valid!mkdir data/labels/train!mkdir data/labels/valid# Populate the foldersp = percentage_test/100for pathAndFilename in glob.iglob(os.path.join(dataset_path, "*.jpg")):      title, ext = os.path.splitext(os.path.basename(pathAndFilename))    if random.random() <=p :        os.system(f"cp {dataset_path}/{title}.jpg data/images/valid")        os.system(f"cp {dataset_path}/{title}.txt data/labels/valid")    else:        os.system(f"cp {dataset_path}/{title}.jpg data/images/train")        os.system(f"cp {dataset_path}/{title}.txt data/labels/train")

After running this, your data folder structure should look like below. It should have two directories images and labels.

运行此命令后,您的data文件夹结构应如下所示。 它应该有两个目录imageslabels

We now have to add two configuration files to training folder:

现在,我们必须向training文件夹添加两个配置文件:

1. Dataset.yaml: We create a file “dataset.yaml” that contains the path of training and validation images and also the classes.

1. Dataset.yaml:我们创建一个文件“ dataset.yaml ”,其中包含训练和验证图像的路径以及类。

# train and val datasets (image directory or *.txt file with image paths)train: training/data/images/train/val: training/data/images/valid/# number of classesnc: 2# class namesnames: ['Cricketball', 'Football']

2. Model.yaml: We can use multiple models ranging from small to large while creating our network. For example, yolov5s.yaml file in the yolov5/models directory is the small Yolo model with 7M parameters, while the yolov5x.yaml is the largest Yolo model with 96M Params. For this project, I will use the yolov5l.yaml which has 50M params. We start by copying the file from yolov5/models/yolov5l.yaml to the training folder and changing nc , which is the number of classes to 2 as per our project requirements.

2. Model.yaml:创建网络时,我们可以使用从小到大的多种模型。 例如, yolov5s.yaml yolov5/models目录中的yolov5s.yaml文件是具有7M参数的小型Yolo模型,而yolov5x.yaml是具有96M Params的最大Yolo模型。 对于这个项目,我将使用具有50M参数的yolov5l.yaml 。 我们首先将文件从yolov5/models/yolov5l.yaml到training文件夹,然后将nc更改为nc ,根据我们的项目要求, yolov5/models/yolov5l.yaml的数量为2。

# parametersnc: 2  # change number of classesdepth_multiple: 1.0  # model depth multiplewidth_multiple: 1.0  # layer channel multiple

培养 (Train)

At this point our training folder looks like:

此时,我们的训练文件夹如下所示:

Once we are done with the above steps, we can start training our model. This is as simple as running the below command, where we provide the locations of our config files and various other params. You can check out the different other options in train.py file, but these are the ones I found noteworthy.

完成上述步骤后,就可以开始训练模型了。 这就像运行以下命令一样简单,我们在其中提供配置文件和各种其他参数的位置。 您可以在train.py文件中签出其他不同的选项,但是这些是我发现值得注意的选项。

# Train yolov5l on custom dataset for 300 epochs$ python train.py --img 640 --batch 16 --epochs 300--data training/dataset.yaml --cfg training/yolov5l.yaml --weights ''

Sometimes you might get an error with PyTorch version 1.5 in that case run on a single GPU using:

有时,在那种情况下,使用以下命令在单个GPU上运行的PyTorch 1.5版可能会出错:

# Train yolov5l on custom dataset for 300 epochs$ python train.py --img 640 --batch 16 --epochs 300--data training/dataset.yaml --cfg training/yolov5l.yaml --weights '' --device 0

Once you start the training, you can check whether the training has been set up by checking the automatically created filetrain_batch0.jpg , which contains the training labels for the first batch and test_batch0_gt.jpg which includes the ground truth for test images. This is how they look for me.

开始训练后,您可以通过检查自动创建的文件train_batch0.jpg来检查训练是否已设置,该文件包含第一批的训练标签和test_batch0_gt.jpg ,其中包括测试图像的基本情况。 这就是他们寻找我的方式。

Left: train_batch0.jpg, Right: test_batch0_gt.jpg
左:train_batch0.jpg,右:test_batch0_gt.jpg

结果 (Results)

To see the results for the training at localhost:6006 in your browser using tensorboard, run this command in another terminal tab

要使用tensorboard在浏览器中的localhost:6006上查看培训的结果,请在另一个终端选项卡中运行此命令

tensorboard --logdir=runs

Here are the various validation metrics. These metrics also get saved in a file results.png at the end of the training run.

以下是各种验证指标。 在训练运行结束时,这些指标也会保存在文件results.png中。

预测 (Predict)

Ultralytics Yolov5 provides a lot of different ways to check the results on new data.

Ultralytics Yolov5提供了许多不同的方法来检查新数据的结果。

To detect some images you can simply put them in the folder named inference/images and run the inference using the best weights as per validation AP:

要检测一些图像,您可以将它们简单地放在名为inference/images的文件夹中,并根据验证AP使用最佳权重运行推理:

python detect.py --weights weights/best.pt
Results
结果

You can also detect in a video using the detect.py file:

您还可以使用detect.py文件在视频中进行检测:

python detect.py --weights weights/best.pt --source inference/videos/messi.mp4 --view-img --output inference/output

Here I specify that I want to see the output using the — view-img flag, and we store the output at the location inference/output. This will create a .mp4 file in this location. It's impressive that the network can see the ball, the speed at which inference is made here, and also the mindblowing accuracy on never observed data.

在这里,我指定使用— view-img标志— view-img输出,并将输出存储在位置推断/输出中。 这将在此位置创建一个.mp4文件。 令人印象深刻的是,网络可以看到球,在这里进行推理的速度,以及从未观察到的数据的惊人准确性。

And, Here is Messi…..
而且,这是梅西…..

You can also use the webcam as a source by specifying the --source as 0. You can check out the various other options in detect.py file.

您也可以通过将--source指定为0来将网络摄像头用作源。您可以在detect.py文件中签出各种其他选项。

结论 (Conclusion)

In this post, I talked about how to create a Yolov5 object detection model using a Custom Dataset. I love the way Ultralytics has made it so easy to create an object detection model.

在本文中,我讨论了如何使用“自定义数据集”创建Yolov5对象检测模型。 我喜欢Ultralytics轻松创建对象检测模型的方式。

Additionally, the various ways that they have provided to see the model results make it a complete package I have seen in a long time.

此外,他们提供的各种方式来查看模型结果使之成为我很长一段时间以来看到的完整软件包。

If you would like to experiment with the custom dataset yourself, you can download the annotated data on Kaggle and the code at Github.

如果您想自己尝试使用自定义数据集,则可以在Kaggle上下载带注释的数据,并在Github上下载代码。

If you want to know more about various Object Detection techniques, motion estimation, object tracking in video, etc., I would like to recommend this excellent course on Deep Learning in Computer Vision in the Advanced machine learning specialization. If you wish to know more about how the object detection field has evolved over the years, you can also take a look at my last post on Object detection.

如果您想了解各种对象检测技术,运动估计,视频中的对象跟踪等更多信息 ,我想向您推荐这本关于高级机器学习专业的 计算机视觉深度学习的优秀课程。 如果您想进一步了解对象检测领域多年来的发展,还可以查看我关于对象检测的最新文章 。

Thanks for the read. I am going to be writing more beginner-friendly posts in the future too. Follow me up at Medium or Subscribe to my blog to be informed about them. As always, I welcome feedback and constructive criticism and can be reached on Twitter @mlwhiz

感谢您的阅读。 我将来也会写更多对初学者友好的文章。 在Medium上关注我,或订阅我的博客以了解有关它们的信息。 与往常一样,我欢迎您提供反馈和建设性的批评,可以在Twitter @mlwhiz上与他们联系。

翻译自: https://towardsdatascience.com/how-to-create-an-end-to-end-object-detector-using-yolov5-35fbb1a02810

端到端车道线检测


http://www.taodudu.cc/news/show-1874112.html

相关文章:

  • 深度学习 检测异常_深度学习用于异常检测:全面调查
  • 自我监督学习和无监督学习_弱和自我监督的学习-第3部分
  • 聊天工具机器人开发_聊天机器人-精致的交流工具? 还是您的客户服务团队不可或缺的成员?...
  • 自我监督学习和无监督学习_弱和自我监督的学习-第4部分
  • ai星际探索 爪子_探索AI地牢
  • 循环神经网络 递归神经网络_递归神经网络-第5部分
  • 用于小儿肺炎检测的无代码AI
  • 建筑业建筑业大数据行业现状_建筑—第2部分
  • 脸部识别算法_面部识别技术是种族主义者吗? 先进算法的解释
  • ai人工智能对话了_产品制造商如何缓解对话式AI中的偏见
  • 深度神经网络 轻量化_正则化对深度神经网络的影响
  • dbscan js 实现_DBSCAN在PySpark上的实现
  • 深度学习行人检测简介_深度学习简介
  • ai初创企业商业化落地_初创企业需要问的三个关于人工智能的问题
  • scikit keras_使用Scikit-Learn,Scikit-Opt和Keras进行超参数优化
  • 异常检测时间序列_DeepAnT —时间序列的无监督异常检测
  • 机器学习 结构化数据_聊天机器人:根据结构化数据创建自然语言
  • mc2180 刷机方法_MC控制和时差方法
  • 城市ai大脑_激发AI研究的大脑五个功能
  • 神经网络算法优化_训练神经网络的各种优化算法
  • 算法偏见是什么_人工智能中的偏见有什么作用?
  • 查看-增强会话_会话助手平台-Hinglish Voice等!
  • 可解释ai_人工智能解释
  • 机器学习做自动聊天机器人_聊天机器人业务领袖指南
  • 神经网络 代码python_详细使用Python代码和数学构建神经网络— II
  • tensorflow架构_TensorFlow半监督对象检测架构
  • 最牛ai波士顿动力上台阶_波士顿动力的位置如何使美国成为人工智能的关键参与者...
  • 阿里ai人工智能平台_AI标签众包平台
  • 标记偏见_人工智能的偏见
  • lstm预测单词_从零开始理解单词嵌入| LSTM模型|

端到端车道线检测_如何使用Yolov5创建端到端对象检测器?相关推荐

  1. 鲁汶大学提出可端到端学习的车道线检测算法

    点击我爱计算机视觉标星,更快获取CVML新技术 近日,比利时鲁汶大学提出基于可微最小二乘拟合的端到端车道线检测算法,使该任务的学习过程不再割裂,实现整体的系统最优化. 该文作者信息: 背景 众所周知, ...

  2. 基于实例分割方法的端到端车道线检测 论文+代码解读

    Towards End-to-End Lane Detection: an Instance Segmentation Approach 论文原文 https://arxiv.org/pdf/1802 ...

  3. 带你读AI论文丨LaneNet基于实体分割的端到端车道线检测

    摘要:LaneNet是一种端到端的车道线检测方法,包含 LanNet + H-Net 两个网络模型. 本文分享自华为云社区<[论文解读]LaneNet基于实体分割的端到端车道线检测>,作者 ...

  4. 【论文解读】LaneNet 基于实体分割的端到端车道线检测

    前言 这是一种端到端的车道线检测方法,包含 LanNet + H-Net 两个网络模型. LanNet 是一种多任务模型,它将 实例分割 任务拆解成"语义分割"和"对像素 ...

  5. HybridNets:多任务端到端感知网络 目标检测+可行驶区域+车道线检测

    端到端的多任务感知网络:目标检测.车道线检测.可行驶区域分割,性能优于YOLOP,速度可实时. 论文 HybridNets: End-to-End Perception Network,代码已开源. ...

  6. 空间中的语义直线检测_基于语义分割的车道线检测算法研究

    龙源期刊网 http://www.qikan.com.cn 基于语义分割的车道线检测算法研究 作者:张道芳 张儒良 来源:<科技创新与应用> 2019 年第 06 期 摘 ; 要:随着半自 ...

  7. 基于摄像头的车道线检测方法一览

    首发于 自动驾驶的挑战和发展 写文章 基于摄像头的车道线检测方法一览 黄浴 ​ 自动驾驶话题下的优秀答主 174 人 赞同了该文章 车道线,重要的路上语义信息,检测车道线对L2-L3-L4级别的自动驾 ...

  8. 3D车道线检测:Gen-LaneNet

    3D车道线检测:Gen-LaneNet Gen-LaneNet: A Generalized and Scalable Approach for 3D Lane Detection 论文链接:http ...

  9. Transformer 又立功了!又快(420 fps)又好的车道线检测算法

    点击上方↑↑↑"视学算法"关注我 来源:公众号 我爱计算机视觉 授权 分享一篇新出的论文 End-to-end Lane Shape Prediction with Transfo ...

  10. ECCV2020 | Gen-LaneNet:百度Apollo提出两阶段的3D车道线检测算法,已开源

    点击上方"3D视觉工坊",选择"星标 干货第一时间送达 这篇文章收录于ECCV2020,是百度Apollo团队发表的关于3D车道线检测的文章,针对3D-LaneNet做了 ...

最新文章

  1. java中8种基本类型与运算符
  2. 汇编中数据处理的基本问题
  3. win10系统mongodDB安装过程
  4. 扩展 junit 框架_JUnit 5扩展模型的生命周期
  5. 【期外】 (一)关于LSH :局部敏感哈希算法
  6. oppo手机维语字体_老年人上网困难重重?学会OPPO这几个功能无后顾之忧
  7. Loonframework-DAO-Alpha-0.1.0发布
  8. Delphi 中的MD5实现方法及delphi2009和delphi2010中用法
  9. mysql 分表查询外连接_SQL多表连接查询实例(内连接外连接)
  10. Hadamard 分数阶微分/积分定义
  11. 玩游戏降频?跑分不行?给你的CPU降降压,提提速!
  12. 永久免费!永洪科技发布桌面智能数据分析工具Desktop,推动数据应用平民化
  13. 程度性数据python分析_python数据分析实战之AQI分析
  14. latex beamer 制作ppt,包括动画效果。插入gif图
  15. 密码库LibTomCrypt学习记录——(1.5)分组密码算法——示例代码AES-ECB
  16. python函数返回多个变量_Python中接收函数多个返回结果的两种方法
  17. shp与geojson互转
  18. 视频剪辑用计算机,剪辑视频用的电脑该如何配置 真的配置越高越好?
  19. 飞利浦 V808 android
  20. 逻辑推理题(C语言实现)

热门文章

  1. 在WPF控件上添加Windows窗口式调整大小行为
  2. [backbone] Getting Started with Backbone.js
  3. repeater 实现分列(两列的简单办法)
  4. 2020-11-30 04_机器视觉中的特征提取与描述
  5. Hololens中的虚拟物体通过Vuforia的码实现虚实融合打开hololens像机
  6. CHI2019 ChewIt. An Intraoral Interface for Discreet Interactions
  7. 每日一句090516
  8. Atitit 接受post raw数据目录1. 接受get参数 11.1. //req.query只能拿到get参数 //post请求使用 body-parser拿到 12. 原生expre
  9. Atitit.你这些项目不都是模板吗?不是原创  集成和整合的方式大总结
  10. Atitit.android播放smb 网络邻居视频文件解决方案