pcb defect detetcion application
[ealt-edge.git] / example-apps / PDD / pcb-defect-detection / libs / configs / cfgs_res50_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 : aeroplane|| Recall: 0.9473684210526315 || Precison: 0.0006199030196164867|| AP: 0.826992691184208
7 ____________________
8 cls : cow|| Recall: 0.9631147540983607 || Precison: 0.0005354526625668462|| AP: 0.8344652186720717
9 ____________________
10 cls : dog|| Recall: 0.9652351738241309 || Precison: 0.0010528593384385115|| AP: 0.8848104631457077
11 ____________________
12 cls : pottedplant|| Recall: 0.7708333333333334 || Precison: 0.000823124000293655|| AP: 0.4527288299945802
13 ____________________
14 cls : diningtable|| Recall: 0.8980582524271845 || Precison: 0.00042887810125232407|| AP: 0.6700510019755388
15 ____________________
16 cls : bird|| Recall: 0.9237472766884531 || Precison: 0.0009519832235409285|| AP: 0.7858394634006082
17 ____________________
18 cls : tvmonitor|| Recall: 0.9415584415584416 || Precison: 0.0006423247726945524|| AP: 0.7532342429791412
19 ____________________
20 cls : chair|| Recall: 0.8452380952380952 || Precison: 0.0014212159291838572|| AP: 0.5629849133883229
21 ____________________
22 cls : train|| Recall: 0.925531914893617 || Precison: 0.0006022581218315107|| AP: 0.81368729431196
23 ____________________
24 cls : horse|| Recall: 0.9454022988505747 || Precison: 0.0007562505602920185|| AP: 0.8603450848286776
25 ____________________
26 cls : cat|| Recall: 0.9608938547486033 || Precison: 0.0007696817008175631|| AP: 0.8780370107529119
27 ____________________
28 cls : sofa|| Recall: 0.9623430962343096 || Precison: 0.0005431753558979397|| AP: 0.748024582610825
29 ____________________
30 cls : bottle|| Recall: 0.8571428571428571 || Precison: 0.0008744472166693132|| AP: 0.6253912291817303
31 ____________________
32 cls : person|| Recall: 0.9149734982332155 || Precison: 0.009253199981238986|| AP: 0.8351147684067881
33 ____________________
34 cls : car|| Recall: 0.9533721898417985 || Precison: 0.00259228066362385|| AP: 0.8841614814276471
35 ____________________
36 cls : boat|| Recall: 0.8821292775665399 || Precison: 0.0005342347777629379|| AP: 0.6106671555293245
37 ____________________
38 cls : motorbike|| Recall: 0.9323076923076923 || Precison: 0.0006731029825348658|| AP: 0.8421918380864666
39 ____________________
40 cls : bicycle|| Recall: 0.9317507418397626 || Precison: 0.0007036524942688176|| AP: 0.8552669093308443
41 ____________________
42 cls : bus|| Recall: 0.9765258215962441 || Precison: 0.00047651993823568495|| AP: 0.8420876315549962
43 ____________________
44 cls : sheep|| Recall: 0.9049586776859504 || Precison: 0.000502333902950925|| AP: 0.7647489734437813
45 ____________________
46 mAP is : 0.7665415392103065   USE_12_METRIC
47
48 cls : bicycle|| Recall: 0.9317507418397626 || Precison: 0.0007036524942688176|| AP: 0.8298982119397122
49 ____________________
50 cls : sofa|| Recall: 0.9623430962343096 || Precison: 0.0005431753558979397|| AP: 0.7272523895735249
51 ____________________
52 cls : bus|| Recall: 0.9765258215962441 || Precison: 0.00047651993823568495|| AP: 0.8137027123104137
53 ____________________
54 cls : diningtable|| Recall: 0.8980582524271845 || Precison: 0.00042887810125232407|| AP: 0.6530525394835751
55 ____________________
56 cls : person|| Recall: 0.9149734982332155 || Precison: 0.009253199981238986|| AP: 0.803256081733613
57 ____________________
58 cls : car|| Recall: 0.9533721898417985 || Precison: 0.00259228066362385|| AP: 0.8577825832291308
59 ____________________
60 cls : boat|| Recall: 0.8821292775665399 || Precison: 0.0005342347777629379|| AP: 0.5979719282542533
61 ____________________
62 cls : chair|| Recall: 0.8452380952380952 || Precison: 0.0014212159291838572|| AP: 0.5599343653732526
63 ____________________
64 cls : aeroplane|| Recall: 0.9473684210526315 || Precison: 0.0006199030196164867|| AP: 0.7917730109896329
65 ____________________
66 cls : cat|| Recall: 0.9608938547486033 || Precison: 0.0007696817008175631|| AP: 0.8475644227001603
67 ____________________
68 cls : sheep|| Recall: 0.9049586776859504 || Precison: 0.000502333902950925|| AP: 0.7327379110779253
69 ____________________
70 cls : train|| Recall: 0.925531914893617 || Precison: 0.0006022581218315107|| AP: 0.7743045860493956
71 ____________________
72 cls : horse|| Recall: 0.9454022988505747 || Precison: 0.0007562505602920185|| AP: 0.8223412836194737
73 ____________________
74 cls : cow|| Recall: 0.9631147540983607 || Precison: 0.0005354526625668462|| AP: 0.8058877343148467
75 ____________________
76 cls : tvmonitor|| Recall: 0.9415584415584416 || Precison: 0.0006423247726945524|| AP: 0.7310441973657807
77 ____________________
78 cls : pottedplant|| Recall: 0.7708333333333334 || Precison: 0.000823124000293655|| AP: 0.4646864671975241
79 ____________________
80 cls : dog|| Recall: 0.9652351738241309 || Precison: 0.0010528593384385115|| AP: 0.8525619478862897
81 ____________________
82 cls : bird|| Recall: 0.9237472766884531 || Precison: 0.0009519832235409285|| AP: 0.7610720209528306
83 ____________________
84 cls : bottle|| Recall: 0.8571428571428571 || Precison: 0.0008744472166693132|| AP: 0.6127328834288011
85 ____________________
86 cls : motorbike|| Recall: 0.9323076923076923 || Precison: 0.0006731029825348658|| AP: 0.8119378019468331
87 ____________________
88 mAP is : 0.7425747539713485    USE_07_METRIC
89
90 '''
91
92 # ------------------------------------------------
93 VERSION = 'FPN_Res50_20181201'
94 NET_NAME = 'resnet_v1_50'
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 = "1"
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
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
129
130 RPN_LOCATION_LOSS_WEIGHT = 1.
131 RPN_CLASSIFICATION_LOSS_WEIGHT = 1.0
132
133 FAST_RCNN_LOCATION_LOSS_WEIGHT = 1.0
134 FAST_RCNN_CLASSIFICATION_LOSS_WEIGHT = 1.0
135 RPN_SIGMA = 3.0
136 FASTRCNN_SIGMA = 1.0
137
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
140
141 EPSILON = 1e-5
142 MOMENTUM = 0.9
143 LR = 0.001  # 0.001  # 0.0003
144 DECAY_STEP = [60000, 80000]  # 50000, 70000
145 MAX_ITERATION = 150000
146
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
152 CLASS_NUM = 20
153
154 # --------------------------------------------- Network_config
155 BATCH_SIZE = 1
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
159
160 # ---------------------------------------------Anchor config
161 USE_CENTER_OFFSET = False
162
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
170
171 # --------------------------------------------FPN config
172 SHARE_HEADS = True
173 KERNEL_SIZE = 3
174 RPN_IOU_POSITIVE_THRESHOLD = 0.7
175 RPN_IOU_NEGATIVE_THRESHOLD = 0.3
176 TRAIN_RPN_CLOOBER_POSITIVES = False
177
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
183
184 RPN_TOP_K_NMS_TEST = 6000
185 RPN_MAXIMUM_PROPOSAL_TEST = 1000
186
187 # specific settings for FPN
188 # FPN_TOP_K_PER_LEVEL_TRAIN = 2000
189 # FPN_TOP_K_PER_LEVEL_TEST = 1000
190
191 # -------------------------------------------Fast-RCNN config
192 ROI_SIZE = 14
193 ROI_POOL_KERNEL_SIZE = 2
194 USE_DROPOUT = False
195 KEEP_PROB = 1.0
196 SHOW_SCORE_THRSHOLD = 0.5  # only show in tensorboard
197
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
204
205 ADD_GTBOXES_TO_TRAIN = False
206
207
208