我的运行环境
python3.6
tensorflow-gpu 1.4.0,
cuda_8.0.61_win10
cudnn-8.0-windows10-x64-v6.0
Keras 2.2.4
下载需要的文件
开始完成以前,需要配置安装完成以上环境。注意版本的兼容性;
下载keras-yolo3-master.zip,下载 YOLOv3 权重
(推荐下载地址:https://download.csdn.net/download/plsong_csdn/10862712)
转换 Darknet YOLO 模型为 Keras 模型
直接运行下面的语句即可。
下载好的《yolov3.weights》放在同一目录下。
python convert.py yolov3.cfg yolov3.weights model_data/yolo.h5
转换的过程:
中间省略。。。。
运行目标检测文件
这里将yolo.py文件修改了一下。
在原文件下添加下面语句
# 添加的
def detect_img(yolo,img_path = 'test.png'):
image = Image.open(img_path)
import time
t1 = time.time()
r_image = yolo.detect_image(image)
print('time: {}'.format(time.time()-t1))
r_image.show()
yolo.close_session()
if __name__ == '__main__':
detect_img(YOLO(),img_path = '7.jpg')#检测输入图片的路径
运行效果
原图
检测结果:
训练自己数据集,请参看《【YOLO初探】之 keras-yolov3训练自己数据集》
传送门:https://blog.csdn.net/plSong_CSDN/article/details/85194719
★finished by songpl,2018.12.19