如何减少YOLOv3文件中的类数? [英] How to reduce number of classes in YOLOv3 files?

查看:413
本文介绍了如何减少YOLOv3文件中的类数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用YOLOv3来检测视频中的汽车。我下载了代码 coco.names yolov3.cfg yolov3中使用的三个文件。重量,它们针对80种不同类别的待检测对象进行了训练。代码可以正常工作,但速度很慢,每帧花费5秒钟以上。我相信,如果我减少课程数量,它将运行得更快。我可以从 coco.names 中删除​​不必要的类,但是不幸的是,我不理解 yolov3.cfg ,我什至无法阅读 yolov3.weights
我当时正在考虑训练自己的模型,但是我遇到了很多问题,所以我放弃了这个主意。
有人可以帮我修改这些文件吗?

I am using YOLOv3 to detect cars in videos. I downloaded three files used in my code coco.names, yolov3.cfg and yolov3.weights which are trained for 80 different classes of objects to be detected. The code worked but very slowly, it takes more than 5 seconds for each frame. I believe that if I reduced the number of classes, it would run much faster. I can delete the unnecessary classes from coco.names, but unfortunately, I don't understand all the contents from yolov3.cfg, and I can't even read yolov3.weights. I was thinking about training my own model, but I faced a lot of problems, so I gave up the idea. Can anyone help me in modifying these files?

推荐答案

使用COCO数据集的简便方法,请按照以下步骤操作:

For easy and simple way using COCO dataset, follow these steps :


  • 修改(或复制以备份) coco.names darknet\data\coco.names

  • 中的c $ c>文件删除除 car 以外的所有其他类strong>

  • 修改您的cfg文件(例如 yolov3.cfg ),更改3个 610、696、783从80变为1

  • 将603、689、776行的cfg文件中的3个过滤器从255更改为18(源自(classes + 5)x3

  • 运行检测器 ./ darknet检测器测试cfg / coco.data cfg /yolov3.cfg yolov3.weights data / your_image.jpg

  • Modify (or copy for backup) the coco.names file in darknet\data\coco.names
  • Delete all other classes except car
  • Modify your cfg file (e.g. yolov3.cfg), change the 3 classes on line 610, 696, 783 from 80 to 1
  • Change the 3 filters in cfg file on line 603, 689, 776 from 255 to 18 (derived from (classes+5)x3)
  • Run the detector ./darknet detector test cfg/coco.data cfg/yolov3.cfg yolov3.weights data/your_image.jpg

更多使用高级方式您可以使用COCO数据集来基于voc,coco或开放图像创建yolo数据集。 https://github.com/holger-prause/yolo_utils

另请参阅:如何下载特定部分

For more advance way using COCO dataset you can use this repo to create yolo datasets based on voc, coco or open images. https://github.com/holger-prause/yolo_utils .
Also refer to this : How can I download a specific part of Coco Dataset?

如果您可以使用您自己的数据集来训练YOLO模型,那就太好了。互联网上有太多关于如何构建自己的数据集的教程。像

Would be great if you can train YOLO model using your own dataset. There are so many tutorial on the internet of how to build your own dataset. Like this this, this or this.

注意:减少类的数量不会使您的推理速度更快。通过减少类,您将检测到较少的对象,并且如果对每个检测进行后期处理,则可能以某种方式使程序运行更快。

Note : reducing number of classes won't make your inference speed faster. By reducing classes, you will detect less object and somehow will probably make your program run faster if you do post-processing for each detection.

这篇关于如何减少YOLOv3文件中的类数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆