栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Windows下Python+基于Keras的yolov3环境搭建

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Windows下Python+基于Keras的yolov3环境搭建

环境很重要

YOLOv3用的都是低版本的。

使用Anaconda创建yolov3虚拟环境

推荐以下版本:

安装keras
 pip install -i https://pypi.tuna.tsinghua.edu.cn/simple keras==2.1.5

安装tensorflow
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow==1.12.0

安装Pillow
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple Pillow==7.2.0

安装matplotlib
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple matplotlib

安装 ffmpeg
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple ffmpeg

安装opencv
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-contrib-python==4.5.5.64
安装numpy
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple numpy==1.16.0
安装h5py
pip install h5py==2.9.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

下载yolov3工程及权重文件

YOLOv3工程代码:https://github.com/qqwweee/keras-yolo3

权重文件:https://pjreddie.com/media/files/yolov3.weights

把权重文件放在keras-yolo3-master目录下

pycharm配置yolov3工程 把权重文件转换成h5文件

点击左下方的 Terminal (和IDLE一个功能,就是命令行),输入并回车等待:

 python convert.py yolov3.cfg yolov3.weights model_data/yolo.h5

最后会显示有句提示:Saved Keras model to model_data/yolo.h5 

测试:方式一

在工程目录下新建一个py程序,名字自拟如testYolov3,粘贴下面的代码:

from yolo3.model import yolo_body
from keras.layers import Input
from yolo import YOLO
from PIL import Image
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
 
 
yolo = YOLO()
 
while True:
    img = 'img/0.jpg'
    try:
        image = Image.open(img)
    except:
        print('Open Error!')
        continue
    else:
        rel_image = yolo.detect_image(image)
        rel_image.show()
yolo.close_session()

再在工程目录下新建img文件夹,并放入一张照片,命名为0.jpg 

运行 testYolov3程序:

 至此yolov3配置完成

参考链接:https://blog.csdn.net/weixin_41967600/article/details/107753260

 方式二

在终端输入python yolo_video.py --image 之后输入图片路径即可如:img.jpg。

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/892792.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号