zoukankan      html  css  js  c++  java
  • AlexeyAB大神版yolo 待完善

    darknet优化经验

    主要来自于:AlexeyAB 版本darknet

    1. AlexeyAB改进项

    • 提供window支持

    • 相较于原版pjreddie版本darknet提升了训练速度

    • 添加了二值化网络,XNOR(bit) ,速度快,准确率稍低https://github.com/AlexeyAB/darknet/blob/master/cfg/yolov3-tiny_xnor.cfg

    • 提升7%通过将卷积层和BN层合并为一个(*_*)不太懂。

    • 多GPU训练提升

    • 修补了[reorg]层

    • 添加了mAP, IOU,Precision-Recall计算

      darknet detector map...

    • 可以在训练过程中画loss图像

    • 添加了根据自己数据集的anchor生成

    • 提升视频检测,网络摄像头,opencv相关问题

    • 提出了一个INT8的网络,提升了检测速度,但是准确率稍有下降

      https://github.com/AlexeyAB/yolo2_light

    2. Linux下编译选项

    • GPU=1 to build with CUDA to accelerate by using GPU (CUDA should be in /usr/local/cuda)
    • CUDNN=1 to build with cuDNN v5-v7 to accelerate training by using GPU (cuDNN should be in /usr/local/cudnn)
    • CUDNN_HALF=1 to build for Tensor Cores (on Titan V / Tesla V100 / DGX-2 and later) speedup Detection 3x, Training 2x
    • OPENCV=1 to build with OpenCV 3.x/2.4.x - allows to detect on video files and video streams from network cameras or web-cams
    • DEBUG=1 to bould debug version of Yolo
    • OPENMP=1 to build with OpenMP support to accelerate Yolo by using multi-core CPU
    • LIBSO=1 to build a library darknet.so and binary runable file uselib that uses this library. Or you can try to run so LD_LIBRARY_PATH=./:$LD_LIBRARY_PATH ./uselib test.mp4 How to use this SO-library from your own code - you can look at C++ example: https://github.com/AlexeyAB/darknet/blob/master/src/yolo_console_dll.cpp or use in such a way: LD_LIBRARY_PATH=./:$LD_LIBRARY_PATH ./uselib data/coco.names cfg/yolov3.cfg yolov3.weights test.mp4

    3. 训练经验

    • 首先对数据集进行检错,使用提供的如下库进行检测:

    https://github.com/AlexeyAB/Yolo_mark

    • 什么时候停止训练

      • avg loss不再下降的时候

      • 通常每个类需要2000-4000次迭代训练即可

      • 防止过拟合:需要在Early stopping point停止训练

        使用以下命令:

        darknet.exe detector map...

        建议训练的时候带上-map,可以画图

        loss_chart_map_chart

    4. 提升检测效果

    • random=1可以设置适应多分辨率

    • 提升分辨率:416--> 608等必须是32倍数

    • 重新计算你的数据集的anchor:(注意设置的时候计算问题)

      darknet.exe detector calc_anchors data/obj.data -num_of_clusters 9 -width 416 -height 416

    • 检查数据集通过https://github.com/AlexeyAB/Yolo_mark

    • 数据集最好每个类有2000张图片,至少需要迭代2000*类的个数

    • 数据集最好有没有标注的对象,即负样本,对应空的txt文件,最好有多少样本就设计多少负样本。

    • 对于一张图有很多个样本的情况,使用max=200属性(yolo层或者region层)

    • for training for small objects - set layers = -1, 11 instead of https://github.com/AlexeyAB/darknet/blob/6390a5a2ab61a0bdf6f1a9a6b4a739c16b36e0d7/cfg/yolov3.cfg#L720 and set stride=4 instead of https://github.com/AlexeyAB/darknet/blob/6390a5a2ab61a0bdf6f1a9a6b4a739c16b36e0d7/cfg/yolov3.cfg#L717

    • 训练数据需要满足以下条件:

      • train_network_width * train_obj_width / train_image_width ~= detection_network_width * detection_obj_width / detection_image_width
      • train_network_height * train_obj_height / train_image_height ~= detection_network_height * detection_obj_height / detection_image_height
    • 为了加速训练,可以做fine-tuning而不是从头开始训练,设置stopbackward=1在网络的结束部分(以####作为分割)

    • 在训练完以后,进行目标检测的时候,可以提高网络的分辨率,以便刚好检测小目标。

      • 不需要重新训练,需要使用原先低分辨率的权重,测用更高分辨率。
      • 为了得到更高的检测效果,可以提升分辨率至608*608甚至832*832

    5. 总结

    为了小目标:

    • 提升分辨率
    • 在测试时候提升分辨率
    • 数据集添加跟正样本数量一样多的负样本
    • 数据集每个类至少2000张,训练迭代次数2000*classes个数
    • 设置自己数据集的anchor

    6. AlexeyAB大神改进

    • web-cam版本:

    ./darknet detector demo ... -json_port 8070 -mjpeg_port 8090

    • 计算mAP, F1, IoU, Precision-Recall

    ./darknet detector map ...

    • 展示map-loss曲线(需要opencv)

    ./darknet detector train cfg/voc.data cfg/yolo.cfg -dont_show -mjpeg_port 8090 -map

    • 计算聚类产生的anchor

    ./darknet detector calc_anchors data/voc.data -num_of_clusters 12 -width 608 -height 608

    • 分离前部基础网络

    ./darknet partial cfg/darknet19_448.cfg darknet19_448.weights darknet19_448.conv.23 23

    • 测试opencv

    ./darknet imtest data/eagle.jpg

    • 阈值设置

    -thresh 0

    代码改变世界
  • 相关阅读:
    【基础算法】- 全排列
    【基础算法】- 2分查找
    区块链培训
    Static Binding (Early Binding) vs Dynamic Binding (Late Binding)
    test
    No data is deployed on the contract address!
    "throw" is deprecated in favour of "revert()", "require()" and "assert()".
    Variable is declared as a storage pointer. Use an explicit "storage" keyword to silence this warning.
    京都行
    Failed to write genesis block: database already contains an incompatible
  • 原文地址:https://www.cnblogs.com/clemente/p/10660001.html
Copyright © 2011-2022 走看看