TensorFlow2.x-YOLOv3在Win10中运行Demo
TensorFlow2.x-YOLOv3是一个基于TensorFlow2.X版本实现的YOLO3仓库,支持训练和测试自己的数据库。要训练自己的数据库,首先要确认该仓库在当前环境下可以成功运行其demo,本文记录在Win10+Python3.6环境下成功运行demo的过程。
致谢
tensorflow-yolov3 基于tensorflow-gpu==1.11.0版本实现的yolo3版本
TensorFlow2.0-Examples基于tensorflow-gpu==2.0版本实现的yolo3版本
向原作者致敬,非常感谢!
运行环境
Win10 + Python 3.6
TensorFlow-cpu 2.2
Keras 2.3.1
TensorFlow2.x-YOLOv3运行Demo
1. 下载TensorFlow2.x-YOLOv3
1 |
git clone https://github.com/YunYang1994/TensorFlow2.0-Examples.git |
2. 安装必要项
在运行此命令之前,我们先打开TensorFlow2.0-Examples/4-Object_Detection/YOLOV3/docs/requirements.txt文件看看,其中有tensorflow=2.0.0的要求。针对支持GPU和不支持GPU的电脑,tensorflow的安装要求不同,下面我们分别说明。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
numpy>=1.16.0 pillow==6.2.0 scipy==1.1.0 wget==3.2 seaborn==0.9.0 easydict==1.9 grpcio>=1.24.3 tensorflow==2.0.0 |
2.1 支持GPU的电脑
requirements.txt中tensorflow的版本要求为2.0.0,默认会安装GPU版本。如果当前电脑中没有安装过tensorflow任何版本,且支持GPU,可以打开cmd.exe,来到TensorFlow2.0-Examples/4-Object_Detection/YOLOV3/路径下,运行下面的安装命令。
1 |
pip3 install -r ./docs/requirements.txt |
除了requirements.txt要求的安装包之外,Demo的运行还需要Keras,若电脑中没有keras,请安装。若有需要,请参考Install keras and tensorflow cpu on Windows。
2.2 不支持GPU的电脑
如果电脑不支持GPU,建议先删掉requirements.txt中的tensorflow==2.0.0,删除tensorflow后的requirements.txt文件如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
numpy>=1.16.0 pillow==6.2.0 scipy==1.1.0 wget==3.2 seaborn==0.9.0 easydict==1.9 grpcio>=1.24.3 |
打开cmd.exe,来到TensorFlow2.0-Examples/4-Object_Detection/YOLOV3/路径下,运行以下命令安装必要项:
1 |
pip3 install -r ./docs/requirements.txt |
requirements.txt要求的项目安装完成后,再参考Install keras and tensorflow cpu on Windows安装tensorflow和keras。
特别注意:使用pip安装tensorflow时,并不会先卸载原有版本再安装新版本,而是会让电脑中同时存在多个版本的tensorflow。若同时存在多个版本,会让后续的Demo运行困难重重。因此,若电脑中有tensorflow2.0以下的版本,需要先将其卸载再安装。
3. 下载yolov3.weights
打开cmd.exe,来到TensorFlow2.0-Examples/4-Object_Detection/YOLOV3/路径下,下载yolov3.weights。
1 |
wget https://pjreddie.com/media/files/yolov3.weights |
4. 运行image_demo
打开cmd.exe,来到TensorFlow2.0-Examples/4-Object_Detection/YOLOV3/路径下,运行下面的命令:
1 |
python image_demo.py |
下一篇文章将分享如何使用TensorFlow2.x-YOLOv3训练自己的数据库。
本文到此结束,感谢阅读,谢谢支持。
可以再写一下目标检测其他方法的使用方法 吗