Keras-retinanet Resnet 图像目标检测完全手册

因为要在不同的电脑上安装,记录在此备查【2020年6月】

环境: windows 10 64位系统
参考: https://blog.csdn.net/qq_27171347/article/details/88878346

一、下载并安装python3.7(exe版)
二、下载数据标注工具labelImg.py  https://github.com/tzutalin/labelImg
pip3 install PyQt5
pip3 install PyQt5_tools
pip3 install lxml 
pyrcc5 -o libs/resources.py resources.qrc
三、使用Labelimg.py进行数据标注
    标注完成后,再使用工具xml2csv.py(https://www.lanzous.com/i3l1xha)生成train.csv、class.csv、val.csv文件
四、下载安装Visual C++ Builder tools
       下载安装Microsoft C++ Redistributable for Visual Studio 2015
                     Microsoft C++ Redistributable for Visual Studio 2017
                     Microsoft C++ Redistributable for Visual Studio 2019
五、安装tensorflow:
pip install tensorflow -i https://pypi.tuna.tsinghua.edu.cn/simple
会自动安装Keras、numpy、scipy、h5py、cv2等

测试tensowflow:

# -*- coding: utf-8 -*-
import tensorflow as tf
import os 
tf.compat.v1.disable_eager_execution()
hello = tf.constant('Hello tensorfolw')
#for v1 :
#sess = tf.Session()
sess=tf.compat.v1.Session()
print(sess.run(hello))

【最近发现Keras变成了2.4.0,但之前的代码会报错:TypeError: data type not understood,不得已,只能卸载Keras,再单独安装Keras 2.3.1版】

六、安装keras-retinanet
pip install keras_retinanet  -i https://pypi.tuna.tsinghua.edu.cn/simple 
pip install matplotlib -i https://pypi.tuna.tsinghua.edu.cn/simple
下载代码库:https://github.com/fizyr/keras-retinanet
解压代码库文件
在代码库主目录keras-retinanet-master中执行:pip install . --user


测试:下载resnet50_coco_best_v2.1.0.h5(https://github.com/fizyr/keras-retinanet/releases/download/0.5.1/resnet50_coco_best_v2.1.0.h5)到keras-retinanet-master\snapshots\下,然后运行examples\ResNet50RetinaNet.py代码测试(需要修改ResNet50RetinaNet.py中的模型文件路径和图片文件路径)
七、训练:
1、从https://github.com/fizyr/keras-models/releases/下载ResNet-50-model.keras.h5、ResNet-101-model.keras.h5、ResNet-152-model.keras.h5,复制到 C:\Users\用户名\.keras\models下
训练(使用resnet 101层):
keras_retinanet\bin\train.py --backbone resnet101 --steps 1280 --epochs 6 --gpu 0 --workers=0 csv train.csv class.csv --val-annotations val.csv
若遇到keras_retinanet.utils.compute_overlap错误,执行一下python setup.py build_ext --inplace
2、转换成推断模型
keras_retinanet\bin\convert_model.py  snapshots\resnet101_csv_06.h5 snapshots\retinanet_resnet101_inference.h5
八、使用模型进行图像分类或图像检测:(代码参照keras-retinanet-master\examples\ResNet50RetinaNet.py)

你可能感兴趣的:(Keras-retinanet Resnet 图像目标检测完全手册)