基于ubuntu18的Yolo V4的keras识别

配置

ubuntu下安装keras和tensorflow
值得注意的是keras和tensorflow要匹配,不然会导致后面出现各种问题
这里可以参考博客查看匹配型号
参考博客

keras安装

我是在python2.7下面操作的,下载的版本是keras2.2.5
基于ubuntu18的Yolo V4的keras识别
基于ubuntu18的Yolo V4的keras识别

tensorflow安装

python2.7下安装
版本是1.14.0
基于ubuntu18的Yolo V4的keras识别
测试:
输入python

已经安装好了
基于ubuntu18的Yolo V4的keras识别

下载

Yolo V4下载

https://github.com/Ma-Dan/keras-yolo4

yolo4_weights.h5可在百度网盘中下载。
链接: https://pan.baidu.com/s/1FF79PmRc8BzZk8M_ARdMmw 提取码: dc2j

yolo4_weights.h5是coco数据集的权重。
yolo4_voc_weights.h5是voc数据集的权重。

基于ubuntu18的Yolo V4的keras识别
基于ubuntu18的Yolo V4的keras识别
权重下载好之后就可以进行测试了

测试

如果没有.h5文件

只有.weights,可以通过convert.py生成
基于ubuntu18的Yolo V4的keras识别
基于ubuntu18的Yolo V4的keras识别
当然这里要修改convert.py的代码
基于ubuntu18的Yolo V4的keras识别

如果有.h5文件

这里我导入了一张图片,命名为1.png

基于ubuntu18的Yolo V4的keras识别
然后修改test.py代码
基于ubuntu18的Yolo V4的keras识别

使用yolov4_weight.h5时

基于ubuntu18的Yolo V4的keras识别
我出现了错误
基于ubuntu18的Yolo V4的keras识别
于是我把voc_classes.txt换成了coco_classes.txt
基于ubuntu18的Yolo V4的keras识别
coco_classes.txt更全面

由于图片太大了,缩小不了,就看到一部分
基于ubuntu18的Yolo V4的keras识别
基于ubuntu18的Yolo V4的keras识别
基于ubuntu18的Yolo V4的keras识别

使用yolov4_voc_weight.h5

基于ubuntu18的Yolo V4的keras识别
运行如下
基于ubuntu18的Yolo V4的keras识别
由于图片太大了,缩小不了,就看到一部分基于ubuntu18的Yolo V4的keras识别
基于ubuntu18的Yolo V4的keras识别

参考文献

https://zhuanlan.zhihu.com/p/136941514
https://blog.****.net/qq_42451251/article/details/107137508