1 # -*- coding: utf-8 -*-
2 from __future__ import division, print_function, absolute_import
4 import tensorflow as tf
7 cls : car|| Recall: 0.9542048293089093 || Precison: 0.002486730925298256|| AP: 0.8861557852184543
9 cls : aeroplane|| Recall: 0.9333333333333333 || Precison: 0.0005925041542114572|| AP: 0.842025283046165
11 cls : diningtable|| Recall: 0.8932038834951457 || Precison: 0.00040969553387335954|| AP: 0.7380756727563009
13 cls : cow|| Recall: 0.9672131147540983 || Precison: 0.0005127837421479989|| AP: 0.8598673192007477
15 cls : boat|| Recall: 0.870722433460076 || Precison: 0.0005048556531707801|| AP: 0.614924861322453
17 cls : person|| Recall: 0.9112190812720848 || Precison: 0.00890183387270766|| AP: 0.8403573910074297
19 cls : bottle|| Recall: 0.8550106609808102 || Precison: 0.0008528612324589202|| AP: 0.6431100249936452
21 cls : bus|| Recall: 0.9624413145539906 || Precison: 0.00045113940207524124|| AP: 0.8462278674877455
23 cls : chair|| Recall: 0.8465608465608465 || Precison: 0.0013795928045612787|| AP: 0.5683751395230314
25 cls : train|| Recall: 0.9361702127659575 || Precison: 0.0005837401825514753|| AP: 0.8364460305413468
27 cls : dog|| Recall: 0.9754601226993865 || Precison: 0.0010383537847668929|| AP: 0.9033364857501106
29 cls : motorbike|| Recall: 0.92 || Precison: 0.0006513139551094382|| AP: 0.8295629935581179
31 cls : cat|| Recall: 0.9608938547486033 || Precison: 0.0007397197236372707|| AP: 0.8871965890034861
33 cls : sofa|| Recall: 0.9539748953974896 || Precison: 0.0005096076691483964|| AP: 0.8040267075520897
35 cls : bird|| Recall: 0.9150326797385621 || Precison: 0.0009065830883400464|| AP: 0.8237404489482196
37 cls : horse|| Recall: 0.9568965517241379 || Precison: 0.0007317362585204424|| AP: 0.8735567893480496
39 cls : pottedplant|| Recall: 0.7895833333333333 || Precison: 0.0008196455411498826|| AP: 0.4870711669635938
41 cls : bicycle|| Recall: 0.9109792284866469 || Precison: 0.0006712950308861314|| AP: 0.8361496835573192
43 cls : tvmonitor|| Recall: 0.9512987012987013 || Precison: 0.0006329305331737686|| AP: 0.7944641602539069
45 cls : sheep|| Recall: 0.9214876033057852 || Precison: 0.0004898504308706817|| AP: 0.7823429444259854
47 mAP is : 0.7848506672229101 USE_12_METRIC
49 cls : tvmonitor|| Recall: 0.9512987012987013 || Precison: 0.0006329305331737686|| AP: 0.7680923930233127
51 cls : sheep|| Recall: 0.9214876033057852 || Precison: 0.0004898504308706817|| AP: 0.7605331894258903
53 cls : cat|| Recall: 0.9608938547486033 || Precison: 0.0007397197236372707|| AP: 0.8561115936556246
55 cls : train|| Recall: 0.9361702127659575 || Precison: 0.0005837401825514753|| AP: 0.7978443126776701
57 cls : aeroplane|| Recall: 0.9333333333333333 || Precison: 0.0005925041542114572|| AP: 0.8033498986573708
59 cls : motorbike|| Recall: 0.92 || Precison: 0.0006513139551094382|| AP: 0.7991141448766482
61 cls : bus|| Recall: 0.9624413145539906 || Precison: 0.00045113940207524124|| AP: 0.8181027979596772
63 cls : bird|| Recall: 0.9150326797385621 || Precison: 0.0009065830883400464|| AP: 0.7851247014320806
65 cls : pottedplant|| Recall: 0.7895833333333333 || Precison: 0.0008196455411498826|| AP: 0.49033575375142174
67 cls : cow|| Recall: 0.9672131147540983 || Precison: 0.0005127837421479989|| AP: 0.8304367006298838
69 cls : person|| Recall: 0.9112190812720848 || Precison: 0.00890183387270766|| AP: 0.797530517185023
71 cls : bottle|| Recall: 0.8550106609808102 || Precison: 0.0008528612324589202|| AP: 0.6320745719617634
73 cls : sofa|| Recall: 0.9539748953974896 || Precison: 0.0005096076691483964|| AP: 0.7868518534567335
75 cls : boat|| Recall: 0.870722433460076 || Precison: 0.0005048556531707801|| AP: 0.6036612374959088
77 cls : car|| Recall: 0.9542048293089093 || Precison: 0.002486730925298256|| AP: 0.8623955910304107
79 cls : bicycle|| Recall: 0.9109792284866469 || Precison: 0.0006712950308861314|| AP: 0.8029062441256611
81 cls : dog|| Recall: 0.9754601226993865 || Precison: 0.0010383537847668929|| AP: 0.8661350949646617
83 cls : diningtable|| Recall: 0.8932038834951457 || Precison: 0.00040969553387335954|| AP: 0.7127169697539509
85 cls : horse|| Recall: 0.9568965517241379 || Precison: 0.0007317362585204424|| AP: 0.8422342978325045
87 cls : chair|| Recall: 0.8465608465608465 || Precison: 0.0013795928045612787|| AP: 0.563170854101135
89 mAP is : 0.7589361358998666 USE_07_METRIC
92 # ------------------------------------------------
93 VERSION = 'FPN_Res101_20181201_v2'
94 NET_NAME = 'resnet_v1_101'
95 ADD_BOX_IN_TENSORBOARD = True
97 # ---------------------------------------- System_config
98 ROOT_PATH = os.path.abspath('../')
102 SHOW_TRAIN_INFO_INTE = 10
104 SAVE_WEIGHTS_INTE = 10000
106 SUMMARY_PATH = ROOT_PATH + '/output/summary'
107 TEST_SAVE_PATH = ROOT_PATH + '/tools/test_result'
108 INFERENCE_IMAGE_PATH = ROOT_PATH + '/tools/inference_image'
109 INFERENCE_SAVE_PATH = ROOT_PATH + '/tools/inference_results'
111 if NET_NAME.startswith("resnet"):
112 weights_name = NET_NAME
113 elif NET_NAME.startswith("MobilenetV2"):
114 weights_name = "mobilenet/mobilenet_v2_1.0_224"
116 raise NotImplementedError
118 PRETRAINED_CKPT = ROOT_PATH + '/data/pretrained_weights/' + weights_name + '.ckpt'
119 TRAINED_CKPT = os.path.join(ROOT_PATH, 'output/trained_weights')
121 EVALUATE_DIR = ROOT_PATH + '/output/evaluate_result_pickle/'
122 test_annotate_path = '/home/yjr/DataSet/VOC/VOC_test/VOC2007/Annotations'
124 # ------------------------------------------ Train config
125 RESTORE_FROM_RPN = False
126 IS_FILTER_OUTSIDE_BOXES = False
127 FIXED_BLOCKS = 0 # allow 0~3
128 USE_07_METRIC = False
130 RPN_LOCATION_LOSS_WEIGHT = 1.
131 RPN_CLASSIFICATION_LOSS_WEIGHT = 1.0
133 FAST_RCNN_LOCATION_LOSS_WEIGHT = 1.0
134 FAST_RCNN_CLASSIFICATION_LOSS_WEIGHT = 1.0
138 MUTILPY_BIAS_GRADIENT = None # 2.0 # if None, will not multipy
139 GRADIENT_CLIPPING_BY_NORM = None # 10.0 if None, will not clip
143 LR = 0.001 # 0.001 # 0.0003
144 DECAY_STEP = [60000, 80000] # 50000, 70000
145 MAX_ITERATION = 150000
147 # -------------------------------------------- Data_preprocess_config
148 DATASET_NAME = 'pascal' # 'ship', 'spacenet', 'pascal', 'coco'
149 PIXEL_MEAN = [123.68, 116.779, 103.939] # R, G, B. In tf, channel is RGB. In openCV, channel is BGR
150 IMG_SHORT_SIDE_LEN = 600 # 600 # 600
151 IMG_MAX_LENGTH = 1000 # 1000 # 1000
154 # --------------------------------------------- Network_config
156 INITIALIZER = tf.random_normal_initializer(mean=0.0, stddev=0.01)
157 BBOX_INITIALIZER = tf.random_normal_initializer(mean=0.0, stddev=0.001)
158 WEIGHT_DECAY = 0.00004 if NET_NAME.startswith('Mobilenet') else 0.0001
160 # ---------------------------------------------Anchor config
161 USE_CENTER_OFFSET = False
163 LEVLES = ['P2', 'P3', 'P4', 'P5', 'P6']
164 BASE_ANCHOR_SIZE_LIST = [32, 64, 128, 256, 512] # addjust the base anchor size for voc.
165 ANCHOR_STRIDE_LIST = [4, 8, 16, 32, 64]
166 ANCHOR_SCALES = [1.0]
167 ANCHOR_RATIOS = [0.5, 1., 2.0]
168 ROI_SCALE_FACTORS = [10., 10., 5.0, 5.0]
169 ANCHOR_SCALE_FACTORS = None
171 # --------------------------------------------FPN config
174 RPN_IOU_POSITIVE_THRESHOLD = 0.7
175 RPN_IOU_NEGATIVE_THRESHOLD = 0.3
176 TRAIN_RPN_CLOOBER_POSITIVES = False
178 RPN_MINIBATCH_SIZE = 256
179 RPN_POSITIVE_RATE = 0.5
180 RPN_NMS_IOU_THRESHOLD = 0.7
181 RPN_TOP_K_NMS_TRAIN = 12000
182 RPN_MAXIMUM_PROPOSAL_TARIN = 2000
184 RPN_TOP_K_NMS_TEST = 6000
185 RPN_MAXIMUM_PROPOSAL_TEST = 1000
187 # specific settings for FPN
188 # FPN_TOP_K_PER_LEVEL_TRAIN = 2000
189 # FPN_TOP_K_PER_LEVEL_TEST = 1000
191 # -------------------------------------------Fast-RCNN config
193 ROI_POOL_KERNEL_SIZE = 2
196 SHOW_SCORE_THRSHOLD = 0.5 # only show in tensorboard
198 FAST_RCNN_NMS_IOU_THRESHOLD = 0.3 # 0.6
199 FAST_RCNN_NMS_MAX_BOXES_PER_CLASS = 100
200 FAST_RCNN_IOU_POSITIVE_THRESHOLD = 0.5
201 FAST_RCNN_IOU_NEGATIVE_THRESHOLD = 0.0 # 0.1 < IOU < 0.5 is negative
202 FAST_RCNN_MINIBATCH_SIZE = 256 # if is -1, that is train with OHEM
203 FAST_RCNN_POSITIVE_RATE = 0.25
205 ADD_GTBOXES_TO_TRAIN = False