预训练模型的所有地址
GitHub参考
GitHub辅助参考(划分测试集和训练集数据在data/io 中加入divide_data.py文件)
辅助参考
参考博客一
参考博客二
参考博客三
参考博客四
data文件夹:包括io、lib_coco、pretrained_weights文件夹。VOC是下载的VOC数据集。pretrained_weights存放预训练的模型框架。地址在如上预训练模型的所有框架。我放入了resnet_v1_50.ckpt。
io文件夹包括了一系列数据转换代码。随后会加入一个divide_data.py,此程序会把数据集划分为训练集和测试集。
libs文件夹下有configs、box_utils、networks等文件夹。
configs:下面是一些模型配置的超参数。
box_utils里cython_utils是编译文件夹
tools里面有demos、inference_results等文件夹。demos里有模型训练好的训练影像、inference_results里是回归框保存文件夹,results是我自己新建的回归框保存文件夹。
train.py是是训练代码、test.py是测试代码、eval.py是评估模型的代码、inference.py是模型演示的代码。
请在Imagenet上下载resnet50_v1,resnet101_v1预训练的模型,并将其放置在$ PATH_ROOT / data / pretrained_weights中。
进入到cython_utils文件夹,执行命令后,在文件夹内新增build、cython_bbox.cp36-win_amd64.pyd、cython_nms.cp36-win_amd64.pyd
cd $PATH_ROOT/libs/box_utils/cython_utils
python setup.py build_ext --inplace
1、在文件夹($ PATH_ROOT / libs / configs /)中选择一个配置文件,并将其内容复制到cfgs.py,然后下载相应的权重
2、我们将下载的权重文件家解压到output文件夹内。
Unzip the weight $FPN_ROOT/output/res101_trained_weights/*.rar
然后进入到tools文件夹:cd $PATH_ROOT/tools
运行:python inference.py --data_dir=’/PATH/TO/IMAGES/’
–save_dir=’/PATH/TO/SAVE/RESULTS/’
–GPU=‘0’
–data_dir是影像的路径、–save_dir是检测图片保存的路径
python inference.py --data_dir="D:/Python base/Test2\FPN_Tensorflow-master/tools/demos/" --save_dir="D:/Python base/Test2/FPN_Tensorflow-master/tools/results/" --GPU='0'
观察一下代码:这部分是对输入参数的定义,可根据我们的实际情况修改default的内容
def parse_args():
"""
Parse input arguments
"""
parser = argparse.ArgumentParser(description='TestImgs...U need provide the test dir')
parser.add_argument('--data_dir', dest='data_dir',
help='data path',
default='D:\\Python base\\Test2\\FPN_Tensorflow-master\\tools\\demos\\', type=str)
parser.add_argument('--save_dir', dest='save_dir',
help='demo imgs to save',
default='D:\\Python base\\Test2\\FPN_Tensorflow-master\\tools\\results\\', type=str)
parser.add_argument('--GPU', dest='GPU',
help='gpu id ',
default='0', type=str)
新建了两个文件夹:存放评估图片和标签数据。我只放了三张图片,分别是火车、人和椅子。
cd $PATH_ROOT/tools
python eval.py --eval_imgs=’/PATH/TO/IMAGES/’
–annotation_dir=’/PATH/TO/TEST/ANNOTATION/’
–GPU=‘0’
python eval.py --eval_imgs="D:/Python base/Test2/FPN_Tensorflow-master/tools/eval_images/" --annotation_dir="D:/Python base/Test2/FPN_Tensorflow-master/tools/image_annotation/" --GPU="0"
将自己的PASCAL_VOC数据集拆分为训练集、测试集合。适用/data/io/divide_data.py
具体的拆分比例,调节divide_data.py中的divide_rate = 0.8。
python /data/io/divide_data.py
在根目录下,将会生成两个文件夹:VOCdevkit_train 和 VOCdevkit_test
# -*- coding: utf-8 -*-
from __future__ import division, print_function, absolute_import
import sys
sys.path.append('../../')
import shutil
import os
import random
import math
def mkdir(path):
if not os.path.exists(path):
os.makedirs(path)
divide_rate = 0.8
#root_path = '/mnt/ExtraDisk/yangxue/data_ship_clean'
root_path="D:/Python base/Test2/FPN_Tensorflow-master" ##注释 修改成我们自己的主路径
#image_path = root_path + '/VOCdevkit/JPEGImages'
image_path = root_path + "/data/VOC/VOC_test/VOC2007/JPEGImages/" ##注释 修改成图像存放的主路径
xml_path = root_path + "/data/VOC/VOC_test/VOC2007/Annotations/" ##注释 修改成图像标注的存放的主路径
image_list = os.listdir(image_path)
image_name = [n.split('.')[0] for n in image_list]
random.shuffle(image_name)
train_image = image_name[:int(math.ceil(len(image_name)) * divide_rate)]
test_image = image_name[int(math.ceil(len(image_name)) * divide_rate):]
image_output_train = os.path.join(root_path, 'VOCdevkit_train/JPEGImages') ##注释 输出的train影像的路径
mkdir(image_output_train)
image_output_test = os.path.join(root_path, 'VOCdevkit_test/JPEGImages')#注释 输出的test影像的路径
mkdir(image_output_test)
xml_train = os.path.join(root_path, 'VOCdevkit_train/Annotations')##注释 输出的train影像的标注路径
mkdir(xml_train)
xml_test = os.path.join(root_path, 'VOCdevkit_test/Annotations')##注释 输出的test影像的标注路径
mkdir(xml_test)
count = 0
for i in train_image:
shutil.copy(os.path.join(image_path, i + '.jpg'), image_output_train) ##影像数据格式.jpg
shutil.copy(os.path.join(xml_path, i + '.xml'), xml_train)
if count % 1000 == 0:
print("process step {}".format(count))
count += 1
for i in test_image:
shutil.copy(os.path.join(image_path, i + '.jpg'), image_output_test)
shutil.copy(os.path.join(xml_path, i + '.xml'), xml_test)
if count % 1000 == 0:
print("process step {}".format(count))
count += 1
在此次实验,我们利用了PASCAL_VOC的数据集,代码中已经有了pascal的数据名称字典
在/libs/label_name_dict/label_dict.py中添加自己的数据集标签类别。具体如下:
# -*- coding: utf-8 -*-
from __future__ import division, print_function, absolute_import
from libs.configs import cfgs
if cfgs.DATASET_NAME == 'ship':
NAME_LABEL_MAP = {
'back_ground': 0,
"ship": 1
}
##########################
###插入以下:**--dataset='mydataset**'中的名字一致就是调用到这个字典的。
别问我为什么需要自己数据集训练数据类别的字典- -
因为字典不同训练的模型后面的softmax层大小不一样。2类就2个。
4类的话softmax就有4个节点。这个需要训练师自己确认。
(而不是因为无法从你的dataset自动的统计你的类别名字及其数量。)
##########################
elif cfgs.DATASET_NAME == 'mydataset':#这个名字就是你数据集类别字典的名字了。
NAME_LABEL_MAP = {
'back_ground': 0,
"你的类1": 1
"你的类2": 2
"你的类3": 3
......
}
##########################
###实际上和下面的格式都一样。
##########################
elif cfgs.DATASET_NAME == 'SSDD':
NAME_LABEL_MAP = {
'back_ground': 0,
"ship": 1
}
elif cfgs.DATASET_NAME == 'airplane':
NAME_LABEL_MAP = {
'back_ground': 0,
"airplane": 1
}
elif cfgs.DATASET_NAME == 'nwpu':
NAME_LABEL_MAP = {
'back_ground': 0,
'airplane': 1,
'ship': 2,
'storage tank': 3,
'baseball diamond': 4,
'tennis court': 5,
'basketball court': 6,
'ground track field': 7,
'harbor': 8,
'bridge': 9,
'vehicle': 10,
}
....
.....
......
.......
在此次实验,我们利用了PASCAL_VOC的数据集,代码中已经有了pascal的数据名称字典,所以这里不用修改
如果是自己的数据集,进入$PATH_ROOT/data/io/read_tfrecord.py第76行,添加上面自定义的数据集名字。
if dataset_name not in ['ship', 'spacenet', 'pascal', 'coco','train']:
raise ValueError('dataSet name must be in pascal, coco spacenet and ship')
下一步,需要分别将训练和测试数据转换成 TFrecord 格式。该格式是TensorFlow的高效存储格式,连续的内存二进制存储能够有效的加快数据的读取和写入。而像原始文件夹那样每个数据独立存储。
转换的代码为 /data/io/convert_data_to_tfrecord.py
cd $PATH_ROOT/data/io/
python convert_data_to_tfrecord.py --VOC_dir=’/PATH/TO/VOCdevkit/VOCdevkit_train/’
–xml_dir=‘Annotation’
–image_dir=‘JPEGImages’
–save_name=‘train’
–img_format=’.jpg’
–dataset=‘pascal’
python convert_data_to_tfrecord.py --VOC_dir='***/VOCdevkit/VOCdevkit_train/' --save_name='train' --img_format='.jpg' --dataset='ship'
我的实验代码:
python convert_data_to_tfrecord.py --VOC_dir="D:/Python base/Test2/FPN_Tensorflow-master/VOCdevkit_train/" --save_name="train_TF"
python convert_data_to_tfrecord.py --VOC_dir="D:/Python base/Test2/FPN_Tensorflow-master/VOCdevkit_test/" --save_name="test_TF"
运行结果就是得到训练、测试数据的tfrecord格式数据,在 /data/tfrecords/ 里面。你可以自己检查一下。
–VOC_dir=‘你的FPN路径/VOCdevkit/VOCdevkit_train/’
#tfrecord名字,训练数据用’train’ ,测试数据用’test’
–save_name=‘train’ ,train是转换为TF格式的数据集
#你的图片格式。有Png\tif\jpeg
–img_format=’.jpg’
#你的数据集名称,这个需要在/libs/label_name_dict/label_dict.py中添加自己的数据集
–dataset='mydataset’
对应里面的model,应先下载好预训练模型,放在 /data/pretrained_weights/ 中。本人上面是下载的Resnet50
Res50
Res101
数据准备好了,那么训练就要调参和调一些路径啦。打开/libs/configs/cfgs.py,将模型所对应的配置文件复制cfgs.py,然后修改参数。
下面是参照博客的参数修改:博客参数修改
# -*- coding: utf-8 -*-
from __future__ import division, print_function, absolute_import
import os
#####
初始化设置
#####
# 你的FPN目录地址
ROOT_PATH = os.path.abspath(r'C:\Users\yangxue\Documents\GitHub\FPN_Tensorflow')
# pretrain weights path
#测试结果保存路径,上面我们已经测试过了 不用改。
TEST_SAVE_PATH = ROOT_PATH + '/tools/test_result'
INFERENCE_IMAGE_PATH = ROOT_PATH + '/tools/inference_image'
INFERENCE_SAVE_PATH = ROOT_PATH + '/tools/inference_result'
#使用的model。
NET_NAME = 'resnet_v1_101'
#你的本次训练项目名字。每当重新训练一次,最好在后面加一个01\02区别。名字重复了就会训乱。按这个名字会有output里面生成对应名字的文件夹,保存训练的Net
VERSION = 'v1_mydataset'
#你的类别数,是几类就写几。
CLASS_NUM = 1
BASE_ANCHOR_SIZE_LIST = [15, 25, 40, 60, 80]
LEVEL = ['P2', 'P3', 'P4', 'P5', "P6"]
STRIDE = [4, 8, 16, 32, 64]
ANCHOR_SCALES = [1.]
ANCHOR_RATIOS = [1, 0.5, 2, 1 / 3., 3., 1.5, 1 / 1.5]
SCALE_FACTORS = [10., 10., 5., 5.]
OUTPUT_STRIDE = 16
SHORT_SIDE_LEN = 600
####改成自己数据集字典的名字
DATASET_NAME = 'mydataset'
####
BATCH_SIZE = 1
WEIGHT_DECAY = {'resnet_v1_50': 0.0001, 'resnet_v1_101': 0.0001}
EPSILON = 1e-5
MOMENTUM = 0.9
MAX_ITERATION = 50000
GPU_GROUP = "1"
LR = 0.001
# rpn
SHARE_HEAD = True
RPN_NMS_IOU_THRESHOLD = 0.5
MAX_PROPOSAL_NUM = 2000
RPN_IOU_POSITIVE_THRESHOLD = 0.5
RPN_IOU_NEGATIVE_THRESHOLD = 0.2
RPN_MINIBATCH_SIZE = 512
RPN_POSITIVE_RATE = 0.5
IS_FILTER_OUTSIDE_BOXES = True
RPN_TOP_K_NMS = 12000
# fast rcnn
ROI_SIZE = 14
ROI_POOL_KERNEL_SIZE = 2
USE_DROPOUT = False
KEEP_PROB = 0.5
FAST_RCNN_NMS_IOU_THRESHOLD = 0.2
FAST_RCNN_NMS_MAX_BOXES_PER_CLASS = 100
FINAL_SCORE_THRESHOLD = 0.5
FAST_RCNN_IOU_POSITIVE_THRESHOLD = 0.45
FAST_RCNN_MINIBATCH_SIZE = 256
FAST_RCNN_POSITIVE_RATE = 0.5
# -*- coding: utf-8 -*-
from __future__ import division, print_function, absolute_import
import os
import tensorflow as tf
'''
cls : aeroplane|| Recall: 0.9473684210526315 || Precison: 0.0006199030196164867|| AP: 0.826992691184208
____________________
cls : cow|| Recall: 0.9631147540983607 || Precison: 0.0005354526625668462|| AP: 0.8344652186720717
____________________
cls : dog|| Recall: 0.9652351738241309 || Precison: 0.0010528593384385115|| AP: 0.8848104631457077
____________________
cls : pottedplant|| Recall: 0.7708333333333334 || Precison: 0.000823124000293655|| AP: 0.4527288299945802
____________________
cls : diningtable|| Recall: 0.8980582524271845 || Precison: 0.00042887810125232407|| AP: 0.6700510019755388
____________________
cls : bird|| Recall: 0.9237472766884531 || Precison: 0.0009519832235409285|| AP: 0.7858394634006082
____________________
cls : tvmonitor|| Recall: 0.9415584415584416 || Precison: 0.0006423247726945524|| AP: 0.7532342429791412
____________________
cls : chair|| Recall: 0.8452380952380952 || Precison: 0.0014212159291838572|| AP: 0.5629849133883229
____________________
cls : train|| Recall: 0.925531914893617 || Precison: 0.0006022581218315107|| AP: 0.81368729431196
____________________
cls : horse|| Recall: 0.9454022988505747 || Precison: 0.0007562505602920185|| AP: 0.8603450848286776
____________________
cls : cat|| Recall: 0.9608938547486033 || Precison: 0.0007696817008175631|| AP: 0.8780370107529119
____________________
cls : sofa|| Recall: 0.9623430962343096 || Precison: 0.0005431753558979397|| AP: 0.748024582610825
____________________
cls : bottle|| Recall: 0.8571428571428571 || Precison: 0.0008744472166693132|| AP: 0.6253912291817303
____________________
cls : person|| Recall: 0.9149734982332155 || Precison: 0.009253199981238986|| AP: 0.8351147684067881
____________________
cls : car|| Recall: 0.9533721898417985 || Precison: 0.00259228066362385|| AP: 0.8841614814276471
____________________
cls : boat|| Recall: 0.8821292775665399 || Precison: 0.0005342347777629379|| AP: 0.6106671555293245
____________________
cls : motorbike|| Recall: 0.9323076923076923 || Precison: 0.0006731029825348658|| AP: 0.8421918380864666
____________________
cls : bicycle|| Recall: 0.9317507418397626 || Precison: 0.0007036524942688176|| AP: 0.8552669093308443
____________________
cls : bus|| Recall: 0.9765258215962441 || Precison: 0.00047651993823568495|| AP: 0.8420876315549962
____________________
cls : sheep|| Recall: 0.9049586776859504 || Precison: 0.000502333902950925|| AP: 0.7647489734437813
____________________
mAP is : 0.7665415392103065 USE_12_METRIC
cls : bicycle|| Recall: 0.9317507418397626 || Precison: 0.0007036524942688176|| AP: 0.8298982119397122
____________________
cls : sofa|| Recall: 0.9623430962343096 || Precison: 0.0005431753558979397|| AP: 0.7272523895735249
____________________
cls : bus|| Recall: 0.9765258215962441 || Precison: 0.00047651993823568495|| AP: 0.8137027123104137
____________________
cls : diningtable|| Recall: 0.8980582524271845 || Precison: 0.00042887810125232407|| AP: 0.6530525394835751
____________________
cls : person|| Recall: 0.9149734982332155 || Precison: 0.009253199981238986|| AP: 0.803256081733613
____________________
cls : car|| Recall: 0.9533721898417985 || Precison: 0.00259228066362385|| AP: 0.8577825832291308
____________________
cls : boat|| Recall: 0.8821292775665399 || Precison: 0.0005342347777629379|| AP: 0.5979719282542533
____________________
cls : chair|| Recall: 0.8452380952380952 || Precison: 0.0014212159291838572|| AP: 0.5599343653732526
____________________
cls : aeroplane|| Recall: 0.9473684210526315 || Precison: 0.0006199030196164867|| AP: 0.7917730109896329
____________________
cls : cat|| Recall: 0.9608938547486033 || Precison: 0.0007696817008175631|| AP: 0.8475644227001603
____________________
cls : sheep|| Recall: 0.9049586776859504 || Precison: 0.000502333902950925|| AP: 0.7327379110779253
____________________
cls : train|| Recall: 0.925531914893617 || Precison: 0.0006022581218315107|| AP: 0.7743045860493956
____________________
cls : horse|| Recall: 0.9454022988505747 || Precison: 0.0007562505602920185|| AP: 0.8223412836194737
____________________
cls : cow|| Recall: 0.9631147540983607 || Precison: 0.0005354526625668462|| AP: 0.8058877343148467
____________________
cls : tvmonitor|| Recall: 0.9415584415584416 || Precison: 0.0006423247726945524|| AP: 0.7310441973657807
____________________
cls : pottedplant|| Recall: 0.7708333333333334 || Precison: 0.000823124000293655|| AP: 0.4646864671975241
____________________
cls : dog|| Recall: 0.9652351738241309 || Precison: 0.0010528593384385115|| AP: 0.8525619478862897
____________________
cls : bird|| Recall: 0.9237472766884531 || Precison: 0.0009519832235409285|| AP: 0.7610720209528306
____________________
cls : bottle|| Recall: 0.8571428571428571 || Precison: 0.0008744472166693132|| AP: 0.6127328834288011
____________________
cls : motorbike|| Recall: 0.9323076923076923 || Precison: 0.0006731029825348658|| AP: 0.8119378019468331
____________________
mAP is : 0.7425747539713485 USE_07_METRIC
'''
# ------------------------------------------------
VERSION = 'FPN_Res50_20181201' #注释 你的本次训练项目名字。每当重新训练一次,最好在后面加一个01\02区别。名字重复了就会训乱。按这个名字会有output里面生成对应名字的文件夹,保存训练的Net
NET_NAME = 'resnet_v1_50' #注释 使用的网络的名称
ADD_BOX_IN_TENSORBOARD = True
# ---------------------------------------- System_config
# 注释FPN的目录地址
ROOT_PATH = os.path.abspath('../')
print (20*"++--")
print (ROOT_PATH)
GPU_GROUP = "1"
SHOW_TRAIN_INFO_INTE = 10
SMRY_ITER = 100
SAVE_WEIGHTS_INTE = 10000
SUMMARY_PATH = ROOT_PATH + '/output/summary'
#注释 测试结果保存路径
TEST_SAVE_PATH = ROOT_PATH + '/tools/test_result'
INFERENCE_IMAGE_PATH = ROOT_PATH + '/tools/inference_image'
INFERENCE_SAVE_PATH = ROOT_PATH + '/tools/inference_results'
if NET_NAME.startswith("resnet"):
weights_name = NET_NAME
elif NET_NAME.startswith("MobilenetV2"):
weights_name = "mobilenet/mobilenet_v2_1.0_224"
else:
raise NotImplementedError
PRETRAINED_CKPT = ROOT_PATH + '/data/pretrained_weights/' + weights_name + '.ckpt'
TRAINED_CKPT = os.path.join(ROOT_PATH, 'output/trained_weights')
EVALUATE_DIR = ROOT_PATH + '/output/evaluate_result_pickle/'
test_annotate_path = '/home/yjr/DataSet/VOC/VOC_test/VOC2007/Annotations' ##注释 可根据自己的测试数据集标注存放位置更改
# ------------------------------------------ Train config
RESTORE_FROM_RPN = False
IS_FILTER_OUTSIDE_BOXES = False
FIXED_BLOCKS = 0 # allow 0~3
USE_07_METRIC = False
CUDA9 = True
RPN_LOCATION_LOSS_WEIGHT = 1. ##注释 RPN回归loss
RPN_CLASSIFICATION_LOSS_WEIGHT = 1.0 ##注释 RPN 分类loss
FAST_RCNN_LOCATION_LOSS_WEIGHT = 1.0
FAST_RCNN_CLASSIFICATION_LOSS_WEIGHT = 1.0
RPN_SIGMA = 3.0
FASTRCNN_SIGMA = 1.0
MUTILPY_BIAS_GRADIENT = None # 2.0 # if None, will not multipy
GRADIENT_CLIPPING_BY_NORM = None # 10.0 if None, will not clip
EPSILON = 1e-5
MOMENTUM = 0.9 ##动量超参数,为解决梯度下降
LR = 0.001 # 0.001 # 0.0003 ##注释 学习率
DECAY_STEP = [60000, 80000] # 50000, 70000 decay_step 和 decay_rate一起决定了 learning rate的变化
MAX_ITERATION = 150000 ##注释 最大得迭代次数
# -------------------------------------------- Data_preprocess_config
DATASET_NAME = 'pascal' # 'ship', 'spacenet', 'pascal', 'coco' ##注释可根据自己的数据集,自定义名字
PIXEL_MEAN = [123.68, 116.779, 103.939] # R, G, B. In tf, channel is RGB. In openCV, channel is BGR
IMG_SHORT_SIDE_LEN = 600 # 600 # 600
IMG_MAX_LENGTH = 1000 # 1000 # 1000 #图片的最长多大
CLASS_NUM = 20 ##注释 可根据自己的的数据集类别数进行更改
# --------------------------------------------- Network_config
BATCH_SIZE = 1 ##注释 每一次迭代训练的批度训练样本数量
INITIALIZER = tf.random_normal_initializer(mean=0.0, stddev=0.01)
BBOX_INITIALIZER = tf.random_normal_initializer(mean=0.0, stddev=0.001)
WEIGHT_DECAY = 0.00004 if NET_NAME.startswith('Mobilenet') else 0.0001 ##注释 权重衰减也叫L2正则化
# ---------------------------------------------Anchor config
USE_CENTER_OFFSET = False
LEVLES = ['P2', 'P3', 'P4', 'P5', 'P6']
BASE_ANCHOR_SIZE_LIST = [32, 64, 128, 256, 512] ##注释 voc数据集得喵町得尺寸# addjust the base anchor size for voc.
ANCHOR_STRIDE_LIST = [4, 8, 16, 32, 64] ##注释 模型的步长stride
ANCHOR_SCALES = [1.0] ##注释 对base_anchor进行大小缩放的系数
ANCHOR_RATIOS = [0.5, 1., 2.0] ##注释 媌框的长宽尺度比例缩放
ROI_SCALE_FACTORS = [10., 10., 5.0, 5.0]## 注释scale_factor]则保存了此次缩放的所有信息
ANCHOR_SCALE_FACTORS = None
# --------------------------------------------FPN config
SHARE_HEADS = True
KERNEL_SIZE = 3 ##注释 卷积核的尺寸
RPN_IOU_POSITIVE_THRESHOLD = 0.7 ## 注释 positive box和 negative box 的阈值
RPN_IOU_NEGATIVE_THRESHOLD = 0.3 ##注释 rpn_Iou阈值
TRAIN_RPN_CLOOBER_POSITIVES = False
RPN_MINIBATCH_SIZE = 256
RPN_POSITIVE_RATE = 0.5
RPN_NMS_IOU_THRESHOLD = 0.7
RPN_TOP_K_NMS_TRAIN = 12000
RPN_MAXIMUM_PROPOSAL_TARIN = 2000
RPN_TOP_K_NMS_TEST = 6000
RPN_MAXIMUM_PROPOSAL_TEST = 1000
# specific settings for FPN
# FPN_TOP_K_PER_LEVEL_TRAIN = 2000
# FPN_TOP_K_PER_LEVEL_TEST = 1000
# -------------------------------------------Fast-RCNN config
ROI_SIZE = 14
ROI_POOL_KERNEL_SIZE = 2
USE_DROPOUT = False
KEEP_PROB = 1.0
SHOW_SCORE_THRSHOLD = 0.5 # only show in tensorboard
FAST_RCNN_NMS_IOU_THRESHOLD = 0.3 # 0.6
FAST_RCNN_NMS_MAX_BOXES_PER_CLASS = 100
FAST_RCNN_IOU_POSITIVE_THRESHOLD = 0.5
FAST_RCNN_IOU_NEGATIVE_THRESHOLD = 0.0 # 0.1 < IOU < 0.5 is negative
FAST_RCNN_MINIBATCH_SIZE = 256 # if is -1, that is train with OHEM
FAST_RCNN_POSITIVE_RATE = 0.25
ADD_GTBOXES_TO_TRAIN = False
cd $PATH_ROOT/tools
python train.py
cd $PATH_ROOT/tools
python multi_gpu_train.py ##多个gpu训练
cd $PATH_ROOT/output/summary
tensorboard --logdir=.
测试实际上包括指标验证和保存测试结果。如果只是像将测试集跑一边然后将结果保存下来,就用/tools/test.py
如果是想验证,就用/tools/eval.py
运行test.py的话你会在./tools/test_result里获得测试集的图片检测结果。
运行eval.py则得到 AP、Recall 和mAP。
如果数据集所使用图片格式不属于’.jpg’, ‘jpeg’, ‘.png’, ‘.tif’, ‘.tiff’,则修改eval.py 119行。比如本示例所使用的是bmp格式
test_imgname_list = [item for item in os.listdir(eval_dir)
if item.endswith(('.jpg', 'jpeg', '.png', '.tif', '.tiff','.bmp'))]