zoukankan      html  css  js  c++  java
  • Darknet--YOLO的基本使用

    安装Darknet

    Darknet--YOLO的基本使用

    测试图片

    Joseph大佬已经训练好了一个权重, 我们要拿来用吧。

    wget https://pjreddie.com/media/files/yolov3.weights # yolov3权重
    wget https://pjreddie.com/media/files/yolov3-tiny.weights  # 小的yolov3权重
    

    由于一些原因,下载速度可能非常慢,我保存了。
    链接: https://pan.baidu.com/s/1rX5IY-FtBIrNABObzsLp-A 提取码: 2us8
    虽然百度云也慢的不行。。链接失效了, 嫌百度云速度慢,留个邮箱吧。

    检测一张图片吧,注意权重文件的路径

    ./darknet detect cfg/yolov3-tiny.cfg yolov3.weights data/dog.jpg
    

    cpu上一张图片大概十秒吧,GPU就快得很了。
    如果没有编译opencv, 那么最终结果是这样的

    layer     filters    size              input                output
        0 conv     32  3 x 3 / 1   416 x 416 x   3   ->   416 x 416 x  32  0.299 BFLOPs
        1 conv     64  3 x 3 / 2   416 x 416 x  32   ->   208 x 208 x  64  1.595 BFLOPs
        .......
      105 conv    255  1 x 1 / 1    52 x  52 x 256   ->    52 x  52 x 255  0.353 BFLOPs
      106 detection
    truth_thresh: Using default '1.000000'
    Loading weights from yolov3.weights...Done!
    data/dog.jpg: Predicted in 0.029329 seconds.
    dog: 99%
    truck: 93%
    bicycle: 99%
    

    结果保存在了predictions.png。编译了opencv才会直接显示图片, 中间出现了一堆窗口?那就对了!让你看懂YOLO咋工作的。

    还可以这样做。

    ./darknet detect cfg/yolov3.cfg yolov3.weights
    

    然后会提示让你输入图片的路径。

    ./darknet detect cfg/yolov3.cfg yolov3.weights
    layer     filters    size              input                output
        0 conv     32  3 x 3 / 1   416 x 416 x   3   ->   416 x 416 x  32  0.299 BFLOPs
        1 conv     64  3 x 3 / 2   416 x 416 x  32   ->   208 x 208 x  64  1.595 BFLOPs
        .......
      104 conv    256  3 x 3 / 1    52 x  52 x 128   ->    52 x  52 x 256  1.595 BFLOPs
      105 conv    255  1 x 1 / 1    52 x  52 x 256   ->    52 x  52 x 255  0.353 BFLOPs
      106 detection
    Loading weights from yolov3.weights...Done!
    Enter Image Path:
    

    输入图片路径就可以啦。

    关于Thresh, YOLO只会展示确信值高于0.25的对象。

    ./darknet detect cfg/yolov3.cfg yolov3.weights data/dog.jpg -thresh 0 # 你可以设置为0, 或者任意0-1的值
    

    测试视频

    测试视频必须要编译opencv了。把Makefile中的opencv=0 改成 opencv = 1。
    这是我[安装opencv c++的过程] (https://www.cnblogs.com/hichens/p/12665897.html)
    最好再GPU下测试, CPU, 嘿嘿,谁试谁知道。

    ./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights <video file> # <video file>是视频问价的路径
    ./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights -c num # num 是电脑摄像头(webcam)的代号, 默认为 0
    

    参考

    YOLO: Real-Time Object Detection

  • 相关阅读:
    Win10 WSL Ubuntu18.04 编译安装MySQL5.7
    PHP7 深入理解
    php session 测试
    nginx 匹配路由分发php和golang
    composer 库无法提交git
    Win10 1803安装Ubuntu1804子系统
    dhtmlxTreeGrid使用
    win7 64位系统下安装PL/SQL连接Oracle服务器的解决方法
    转载--eclipse快捷键
    JUnit4学习笔记2-Eclipse中使用JUint4进行单元测试
  • 原文地址:https://www.cnblogs.com/hichens/p/12861370.html
Copyright © 2011-2022 走看看