EG version upgrade to 1.3
[ealt-edge.git] / example-apps / PDD / pcb-defect-detection / libs / configs / cfgs_res101_fpn.py
1 # -*- coding: utf-8 -*-
2 from __future__ import division, print_function, absolute_import
3 import os
4 import tensorflow as tf
5 '''
6 cls : person|| Recall: 0.9200530035335689 || Precison: 0.009050166947990866|| AP: 0.8413662097687251
7 ____________________
8 cls : cat|| Recall: 0.9608938547486033 || Precison: 0.0007414480221227399|| AP: 0.886410933036462
9 ____________________
10 cls : horse|| Recall: 0.9626436781609196 || Precison: 0.0007370072226707821|| AP: 0.880462817781879
11 ____________________
12 cls : boat|| Recall: 0.8783269961977186 || Precison: 0.000509740231082238|| AP: 0.6456185469835614
13 ____________________
14 cls : bottle|| Recall: 0.8656716417910447 || Precison: 0.0008665714718695106|| AP: 0.6480626365413494
15 ____________________
16 cls : bicycle|| Recall: 0.9228486646884273 || Precison: 0.0006832296772124229|| AP: 0.8550508887926864
17 ____________________
18 cls : bus|| Recall: 0.9577464788732394 || Precison: 0.00045156820340048565|| AP: 0.8631526839193041
19 ____________________
20 cls : sheep|| Recall: 0.9132231404958677 || Precison: 0.0004864327094081809|| AP: 0.7741568397678364
21 ____________________
22 cls : car|| Recall: 0.9600333055786844 || Precison: 0.0025449055537652685|| AP: 0.8914023804170609
23 ____________________
24 cls : motorbike|| Recall: 0.9538461538461539 || Precison: 0.0006737519288865706|| AP: 0.8495072139551133
25 ____________________
26 cls : chair|| Recall: 0.873015873015873 || Precison: 0.001433311906044233|| AP: 0.5759698175528438
27 ____________________
28 cls : aeroplane|| Recall: 0.9438596491228071 || Precison: 0.0006024690030817745|| AP: 0.8353670052573003
29 ____________________
30 cls : tvmonitor|| Recall: 0.9415584415584416 || Precison: 0.0006278089036291684|| AP: 0.7613581746623427
31 ____________________
32 cls : sofa|| Recall: 0.9707112970711297 || Precison: 0.0005222178954168627|| AP: 0.7987407803525022
33 ____________________
34 cls : bird|| Recall: 0.9281045751633987 || Precison: 0.0009227090390830091|| AP: 0.8159836473038345
35 ____________________
36 cls : dog|| Recall: 0.9611451942740287 || Precison: 0.0010255447933963644|| AP: 0.8951754362513265
37 ____________________
38 cls : cow|| Recall: 0.9467213114754098 || Precison: 0.0005056795917786568|| AP: 0.8497306852549179
39 ____________________
40 cls : diningtable|| Recall: 0.883495145631068 || Precison: 0.0004040099093419522|| AP: 0.7307392356452687
41 ____________________
42 cls : pottedplant|| Recall: 0.7729166666666667 || Precison: 0.0008064077902035582|| AP: 0.4738700691112566
43 ____________________
44 cls : train|| Recall: 0.9290780141843972 || Precison: 0.0005804331981204598|| AP: 0.8427500500899303
45 ____________________
46 mAP is : 0.7857438026222752   (USE_12_METRIC)
47
48 cls : train|| Recall: 0.9290780141843972 || Precison: 0.0005804331981204598|| AP: 0.8101152343436091
49 ____________________
50 cls : bus|| Recall: 0.9577464788732394 || Precison: 0.00045156820340048565|| AP: 0.830722622273239
51 ____________________
52 cls : chair|| Recall: 0.873015873015873 || Precison: 0.001433311906044233|| AP: 0.5698849842652579
53 ____________________
54 cls : pottedplant|| Recall: 0.7729166666666667 || Precison: 0.0008064077902035582|| AP: 0.48047763621440476
55 ____________________
56 cls : horse|| Recall: 0.9626436781609196 || Precison: 0.0007370072226707821|| AP: 0.8512804991519783
57 ____________________
58 cls : person|| Recall: 0.9200530035335689 || Precison: 0.009050166947990866|| AP: 0.8107708491164711
59 ____________________
60 cls : bottle|| Recall: 0.8656716417910447 || Precison: 0.0008665714718695106|| AP: 0.63789938616088
61 ____________________
62 cls : bicycle|| Recall: 0.9228486646884273 || Precison: 0.0006832296772124229|| AP: 0.8166723684624742
63 ____________________
64 cls : dog|| Recall: 0.9611451942740287 || Precison: 0.0010255447933963644|| AP: 0.864470680916449
65 ____________________
66 cls : diningtable|| Recall: 0.883495145631068 || Precison: 0.0004040099093419522|| AP: 0.7122255048941863
67 ____________________
68 cls : bird|| Recall: 0.9281045751633987 || Precison: 0.0009227090390830091|| AP: 0.7832546811459113
69 ____________________
70 cls : sofa|| Recall: 0.9707112970711297 || Precison: 0.0005222178954168627|| AP: 0.778305908921783
71 ____________________
72 cls : sheep|| Recall: 0.9132231404958677 || Precison: 0.0004864327094081809|| AP: 0.7463330859344937
73 ____________________
74 cls : boat|| Recall: 0.8783269961977186 || Precison: 0.000509740231082238|| AP: 0.6291419623367831
75 ____________________
76 cls : car|| Recall: 0.9600333055786844 || Precison: 0.0025449055537652685|| AP: 0.8630428431995184
77 ____________________
78 cls : motorbike|| Recall: 0.9538461538461539 || Precison: 0.0006737519288865706|| AP: 0.8224280778332824
79 ____________________
80 cls : aeroplane|| Recall: 0.9438596491228071 || Precison: 0.0006024690030817745|| AP: 0.8001448356711514
81 ____________________
82 cls : cat|| Recall: 0.9608938547486033 || Precison: 0.0007414480221227399|| AP: 0.8582414148566436
83 ____________________
84 cls : cow|| Recall: 0.9467213114754098 || Precison: 0.0005056795917786568|| AP: 0.8242904910827928
85 ____________________
86 cls : tvmonitor|| Recall: 0.9415584415584416 || Precison: 0.0006278089036291684|| AP: 0.7388745216642896
87 ____________________
88 mAP is : 0.76142887942228   (USE_07_METRIC)
89
90 '''
91
92 # ------------------------------------------------
93 VERSION = 'FPN_Res101_20181204'
94 NET_NAME = 'resnet_v1_101'
95 ADD_BOX_IN_TENSORBOARD = True
96
97 # ---------------------------------------- System_config
98 ROOT_PATH = os.path.abspath('../')
99 print (20*"++--")
100 print (ROOT_PATH)
101 GPU_GROUP = "4"
102 SHOW_TRAIN_INFO_INTE = 10
103 SMRY_ITER = 100
104 SAVE_WEIGHTS_INTE = 10000
105
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'
110
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"
115 else:
116     raise NotImplementedError
117
118 PRETRAINED_CKPT = ROOT_PATH + '/data/pretrained_weights/' + weights_name + '.ckpt'
119 TRAINED_CKPT = os.path.join(ROOT_PATH, 'output/trained_weights')
120
121 EVALUATE_DIR = ROOT_PATH + '/output/evaluate_result_pickle/'
122 #test_annotate_path = '/home/yjr/DataSet/VOC/VOC_test/VOC2007/Annotations'
123 test_annotate_path = '/home/gq123/dailinhui/FPN_success_dlh/data/pcb/Annotations'
124
125 # ------------------------------------------ Train config
126 RESTORE_FROM_RPN = False
127 IS_FILTER_OUTSIDE_BOXES = False
128 FIXED_BLOCKS = 0  # allow 0~3
129 USE_07_METRIC = False
130
131 RPN_LOCATION_LOSS_WEIGHT = 1.
132 RPN_CLASSIFICATION_LOSS_WEIGHT = 1.0
133
134 FAST_RCNN_LOCATION_LOSS_WEIGHT = 1.0
135 FAST_RCNN_CLASSIFICATION_LOSS_WEIGHT = 1.0
136 RPN_SIGMA = 3.0
137 FASTRCNN_SIGMA = 1.0
138
139 MUTILPY_BIAS_GRADIENT = None   # 2.0  # if None, will not multipy
140 GRADIENT_CLIPPING_BY_NORM = None   # 10.0  if None, will not clip
141
142 EPSILON = 1e-5
143 MOMENTUM = 0.9
144 LR = 0.001  # 0.001  # 0.0003
145 #DECAY_STEP = [60000, 80000]  # 50000, 70000
146 DECAY_STEP = [1000, 1500]  # 50000, 70000
147 #MAX_ITERATION = 150000
148 MAX_ITERATION = 2000
149
150 # ------------------------------------------- Data_preprocess_config
151 DATASET_NAME = 'pcb'  # 'ship', 'spacenet', 'pascal', 'coco'
152 #PIXEL_MEAN = [123.68, 116.779, 103.939]  # R, G, B. In tf, channel is RGB. In openCV, channel is BGR
153 PIXEL_MEAN = [21.25, 85.936, 28.729]
154 IMG_SHORT_SIDE_LEN = 1586  # 600  # 600
155 IMG_MAX_LENGTH = 3034  # 1000  # 1000
156 CLASS_NUM = 6
157
158 # --------------------------------------------- Network_config
159 BATCH_SIZE = 1
160 INITIALIZER = tf.random_normal_initializer(mean=0.0, stddev=0.01)
161 BBOX_INITIALIZER = tf.random_normal_initializer(mean=0.0, stddev=0.001)
162 WEIGHT_DECAY = 0.00004 if NET_NAME.startswith('Mobilenet') else 0.0001
163
164 # ---------------------------------------------Anchor config
165 USE_CENTER_OFFSET = False
166
167 LEVLES = ['P2', 'P3', 'P4', 'P5', 'P6']
168 BASE_ANCHOR_SIZE_LIST = [32, 64, 128, 256, 512]  # addjust the base anchor size for voc.
169 ANCHOR_STRIDE_LIST = [4, 8, 16, 32, 64]
170 ANCHOR_SCALES = [1.0]
171 ANCHOR_RATIOS = [0.5, 1., 2.0]
172 ROI_SCALE_FACTORS = [10., 10., 5.0, 5.0]
173 ANCHOR_SCALE_FACTORS = None
174
175 # --------------------------------------------FPN config
176 SHARE_HEADS = True
177 KERNEL_SIZE = 3
178 RPN_IOU_POSITIVE_THRESHOLD = 0.7
179 RPN_IOU_NEGATIVE_THRESHOLD = 0.3
180 TRAIN_RPN_CLOOBER_POSITIVES = False
181
182 RPN_MINIBATCH_SIZE = 256
183 RPN_POSITIVE_RATE = 0.5
184 RPN_NMS_IOU_THRESHOLD = 0.7
185 RPN_TOP_K_NMS_TRAIN = 12000
186 RPN_MAXIMUM_PROPOSAL_TARIN = 2000
187
188 RPN_TOP_K_NMS_TEST = 6000
189 RPN_MAXIMUM_PROPOSAL_TEST = 1000
190
191 # specific settings for FPN
192 # FPN_TOP_K_PER_LEVEL_TRAIN = 2000
193 # FPN_TOP_K_PER_LEVEL_TEST = 1000
194
195 # -------------------------------------------Fast-RCNN config
196 ROI_SIZE = 14
197 ROI_POOL_KERNEL_SIZE = 2
198 USE_DROPOUT = False
199 KEEP_PROB = 1.0
200 SHOW_SCORE_THRSHOLD = 0.6  # only show in tensorboard
201
202 FAST_RCNN_NMS_IOU_THRESHOLD = 0.3  # 0.6
203 FAST_RCNN_NMS_MAX_BOXES_PER_CLASS = 100
204 FAST_RCNN_IOU_POSITIVE_THRESHOLD = 0.5
205 FAST_RCNN_IOU_NEGATIVE_THRESHOLD = 0.0   # 0.1 < IOU < 0.5 is negative
206 FAST_RCNN_MINIBATCH_SIZE = 256  # if is -1, that is train with OHEM
207 FAST_RCNN_POSITIVE_RATE = 0.25
208
209 ADD_GTBOXES_TO_TRAIN = False
210
211
212