赞
踩
记录一下前期的一些配置:
首先要安装好python,博主这里用的是Python 3.6 64-bit。
path环境变量中加入python36和python36/Scripts的路径。
使用管理员权限进入cmd命令提示符,运行一下代码:
pip install --upgrade pip #更新pip
pip install tensorflow #安装 tensorflow
pip install --upgrade numpy #numpy是一个基础的数组计算包,有时候版本较老会报错
pip install keras #yolo train.py文件里面要用到keras这个高层神经网络API
pip install pillow #安装 图片处理模块PIL(pillow)
pip install matplotlib #安装 2D绘图库matplotlib
pip install opencv-python #安装 opencv视觉库
中间记得测试一下tensorflow安装有没有问题:
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
import tensorflow as tf
hello = tf.constant('Hello,TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
如果打算用 GPU版本 训练的话,可以参考我另外一篇文章:https://blog.csdn.net/qinchang1/article/details/90693983
给个版本建议:
Tensorflow-gpu 1.4.0 + Keras 2.2.4(我用的版本)
Tensorflow-cpu 1.13.1 + Keras2.2.4(网友提供成功的版本)
YOLOv3下载:
1)yolov3.weights权重文件:https://pjreddie.com/media/files/yolov3.weights
2)keras-yolo3代码: https://github.com/qqwweee/keras-yolo3 (工程文件如下,记得把 .weights权重文件也放进去)
推荐:百度网盘打包下载(* ̄︶ ̄):链接:https://pan.baidu.com/s/1OIQGthndfLSfMC1ZlZH6lA 提取码:rlkd
(建议用我的网盘资源下载,因为github上面的工程文件可能会有更改,导致后续的操作出现不同或问题)
这里首先要需要将 DarkNet 的.weights
文件转换成 Keras 的.h5
文件,在cmd中打开工程文件的路径,运行convert.py
并告知 “.weights的输入路径 ” 和 “.h5的输出路径” ,代码如下:
python convert.py yolov3.cfg yolov3.weights model_data/yolo.h5
会在model_data文件夹中生成一个yolo.h5文件。
+注意:这个权重文件要留着,后面可能会用上。
在工程文件中打开yolo_video.py,其用法如下:
usage: yolo_video.py [-h] [–model MODEL] [–anchors ANCHORS]
[–classes CLASSES] [–gpu_num GPU_NUM] [–image]
[–input] [–output]
positional arguments:
–input Video input path
–output Video output path
optional arguments:
-h, --help show this help message and exit
–model MODEL path to model weight file, default model_data/yolo.h5
–anchors ANCHORS path to anchor definitions, default
model_data/yolo_anchors.txt
–classes CLASSES path to class definitions, default
model_data/coco_classes.txt
–gpu_num GPU_NUM Number of GPU to use, default 1
–image Image detection mode, will ignore all positional arguments
例如:识别一张图片,则在cmd
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。