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
目录
3-在Pycharm上,利用flow.py测试视频non-GPU下FPS
4-可视化检测图片。在Pycharm上,参考reademe中“Using darkflow from another python application” 修改
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.028001785278320312sBuilding 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.3720784187316895sPress [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)