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

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

问题描述

我正在使用 YOLOv3 来检测视频中的汽车.我下载了代码中使用的三个文件 coco.namesyolov3.cfgyolov3.weights,它们针对 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 :

  • 修改(或复制备份)darknetdatacoco.names
  • 中的coco.names文件
  • 删除除car
  • 之外的所有其他类
  • 修改您的 cfg 文件(例如 yolov3.cfg),将第 610、696、783 行的 3 个从 80 更改为 1
  • 将 cfg 文件中第 603、689、776 行的 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 darknetdatacoco.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 数据集的高级方法,您可以使用这个 repo 来创建基于 voc、coco 或开放图像的 yolo 数据集.https://github.com/holger-prause/yolo_utils.
另请参阅:如何下载特定部分Coco 数据集?

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 模型,那就太好了.互联网上有很多关于如何构建自己的数据集的教程.像这个this, thisthis.

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天全站免登陆