基于keras 版本的调参,首先要搞清楚每一个文件的用处,其次是每句代码的意思。本文简单指明几个要点。
在datagenerator以及test.py中注意修改几个overlap
from keras import backend as K
import math
class Config:
def __init__(self):
self.verbose = True
self.network = 'resnet50'
#选用网络
# setting for data augmentation
#是否图像增强,水平垂直以及翻转
self.use_horizontal_flips = False
self.use_vertical_flips = False
self.rot_90 = False
# anchor box scales
#anchor尺寸以及rations比率,是自己数据集以及目标尺寸而定
self.anchor_box_scales = [30, 50, 20]
# anchor box ratios
self.anchor_box_ratios = [[1, 1], [1./math.sqrt(2), 2./math.sqrt(2)], [2./math.sqrt(2), 1./math.sqrt(2)]]
# size to resize the smallest side of the image
#最短边规整尺寸
self.im_size = 1200
# image channel-wise mean to subtract
#通道像素值减少多少,我的目标很小,所以我设置为0.
#self.img_channel_mean = [103.939, 116.779, 123.68]
self.img_channel_mean = [0, 0, 0]
self.img_scaling_factor = 1.0
# number of ROIs at once
#训练回归框,设置ROI数目
self.num_rois = 4
# stride at the RPN (this depends on the network configuration)
#特征图缩小比例,如果图片较大就缩小的多一些,反之亦然
self.rpn_stride = 16
self.balanced_classes = False
# scaling the stdev
#是否类平衡
self.std_scaling = 4.0
self.classifier_regr_std = [8.0, 8.0, 4.0, 4.0]
# overlaps for RPN
#设置交并比大小,小于0.3为负样本,大于0.7为正样本,两者之间中性样本丢弃
self.rpn_min_overlap = 0.3
self.rpn_max_overlap = 0.7
# overlaps for classifier ROIs
#第一次两分类识别中阈值大小,两分类小目标检测最好设置为-1
self.classifier_min_overlap = -1
self.classifier_max_overlap = 0.5
# placeholder for the class mapping, automatically generated by the parser类别映射表
self.class_mapping = None
#location of pretrained weights for the base network
# weight files can be found at:
# https://github.com/fchollet/deep-learning-models/releases/download/v0.2/resnet50_weights_th_dim_ordering_th_kernels_notop.h5
# https://github.com/fchollet/deep-learning-models/releases/download/v0.2/resnet50_weights_tf_dim_ordering_tf_kernels_notop.h5
self.model_path = 'model_frcnn.vgg.hdf5'