【目标检测】基于 darkflow 的 YOLO-LITE 测试代码(Non-GPU,Windows7,Pycharm,Python3.6)

Lite-YOLO 【paper】:https://arxiv.org/pdf/1811.05588v1.pdf

Lite-YOLO 【github】:https://github.com/reu2018DL/yolo-lite(460M,含预训练模型)

Dark Flow 【github】https://github.com/thtrieu/darkflow
百度网盘链接:https://pan.baidu.com/s/11apeoVJe4jday7tMgGyGGg  提取码  x5qq 


目录

1- darkflow 下载与配置

2- 观察Lite-YOLO-mater结构

3-在Pycharm上,利用flow.py测试视频non-GPU下FPS

4-可视化检测图片在Pycharm上,参考reademe中“Using darkflow from another python application”   修改

5-其他参考博文


1- darkflow 下载与配置

【环境要求】 Python3, tensorflow 1.0, numpy, opencv 3.以上

【配置方法】按着说明文档 Getting started部分配置,( 我配置成功,但是无法使用flow命令,直接跳过使用pychram

python3 setup.py build_ext --inplace
或者
pip install .

 配置过程可能出现的问题 :Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)(本人电脑只有VS2013)

解决方法 :下载  Visual C++ 2015 Build Tools. ,安装即可,不用安装VS2015


2- 观察Lite-YOLO-mater结构

 

                  图2-1   YOLO-LITE 文件夹内部结构

 

图2-2   tiny-yolov2结构上不同改进后在VOC上训练后得到的权值(对应性能见图2-3)

 

                                                      图 2-3 论文中不同结构YOLO-Lite的性能(non-GPU)

 

                                                          图 2-4 论文中不同结构YOLO-Lite在tiny-yolov2上具体修改(non-GPU)


3-在Pycharm上,利用flow.py测试视频non-GPU下FPS

D:\Anaconda3\python.exe E:/code/Asourse/darkflow-master/flow --model cfg/tiny-yolov2-trial3-noBatch.cfg --load bin/tiny-yolov2-trial3-noBatch.weights --demo E:/deeplearning_data/shixiong.flv

Parsing ./cfg/tiny-yolov2-trial3-noBatch.cfg
Parsing cfg/tiny-yolov2-trial3-noBatch.cfg
Loading bin/tiny-yolov2-trial3-noBatch.weights ...
Successfully identified 2289284 bytes
Finished in 0.028001785278320312s

Building net ...
Source | Train? | Layer description                | Output size
-------+--------+----------------------------------+---------------
       |        | input                            | (?, 224, 224, 3)
 Load  |  Yep!  | conv 3x3p1_1    leaky            | (?, 224, 224, 16)
 Load  |  Yep!  | maxp 2x2p0_2                     | (?, 112, 112, 16)
 Load  |  Yep!  | conv 3x3p1_1    leaky            | (?, 112, 112, 32)
 Load  |  Yep!  | maxp 2x2p0_2                     | (?, 56, 56, 32)
 Load  |  Yep!  | conv 3x3p1_1    leaky            | (?, 56, 56, 64)
 Load  |  Yep!  | maxp 2x2p0_2                     | (?, 28, 28, 64)
 Load  |  Yep!  | conv 3x3p1_1    leaky            | (?, 28, 28, 128)
 Load  |  Yep!  | maxp 2x2p0_2                     | (?, 14, 14, 128)
 Load  |  Yep!  | conv 3x3p1_1    leaky            | (?, 14, 14, 128)
 Load  |  Yep!  | maxp 2x2p0_2                     | (?, 7, 7, 128)
 Load  |  Yep!  | conv 3x3p1_1    leaky            | (?, 7, 7, 256)
 Load  |  Yep!  | conv 1x1p0_1    linear           | (?, 7, 7, 125)
-------+--------+----------------------------------+---------------
Running entirely on CPU
2019-03-29 14:09:46.806056: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\platform\cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX
2019-03-29 14:09:47.361088: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:1030] Found device 0 with properties: 
name: GeForce GTX 650 Ti major: 3 minor: 0 memoryClockRate(GHz): 1.006
pciBusID: 0000:01:00.0
totalMemory: 1.00GiB freeMemory: 321.41MiB
2019-03-29 14:09:47.362088: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 650 Ti, pci bus id: 0000:01:00.0, compute capability: 3.0)
Finished in 1.3720784187316895s

Press [ESC] to quit demo
34.35  FPS


4-在Pycharm上,参考reademe中“Using darkflow from another python application”

from darkflow.net.build import TFNet
import cv2

options = {"model": "cfg/yolo.cfg", "load": "bin/yolo.weights", "threshold": 0.1}

tfnet = TFNet(options)

imgcv = cv2.imread("./sample_img/sample_dog.jpg")
result = tfnet.return_predict(imgcv)
print(result)

修改后可视化检测图片

# -*- coding: utf-8 -*-
# author:zengxy time:2019/3/20

from darkflow.net.build import TFNet
import cv2


lite_cfg="cfg/tiny-yolov2-trial3-noBatch.cfg"
lite_weights="bin/tiny-yolov2-trial3-noBatch.weights"
options = {"model": lite_cfg, "load": lite_weights, "threshold": 0.6}

tfnet = TFNet(options)

imgcv = cv2.imread("./sample_img/sample_dog.jpg")
result = tfnet.return_predict(imgcv)
for box in result:
    print(box)
    bottomright=box["bottomright"]
    topleft = box["topleft"]
    xy_rightbottom=tuple(bottomright.values())
    xy_topleft=tuple(topleft.values())

    print(xy_topleft,xy_rightbottom)
    # rectangle(img, pt1, pt2, color, thickness=None, lineType=None,
    #           shift=None):  # real signature unknown; restored from __doc__
    cv2.rectangle(imgcv,xy_topleft,xy_rightbottom,(255,0,0),2)
    cv2.imshow("imgcv",imgcv)

    # print(bottomright)
    # cv2.rectangle()
cv2.waitKey(0)


5-其他参考博文

Windows下 C++ darknet 实现YOLO-LITE:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

曾小蛙

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值