EG version upgrade to 1.3
[ealt-edge.git] / example-apps / PDD / pcb-defect-detection / libs / configs / cfgs_res101_fpn_v2.py
1 # -*- coding: utf-8 -*-
2 from __future__ import division, print_function, absolute_import
3 import os
4 import tensorflow as tf
5
6 """
7 cls : car|| Recall: 0.9542048293089093 || Precison: 0.002486730925298256|| AP: 0.8861557852184543
8 ____________________
9 cls : aeroplane|| Recall: 0.9333333333333333 || Precison: 0.0005925041542114572|| AP: 0.842025283046165
10 ____________________
11 cls : diningtable|| Recall: 0.8932038834951457 || Precison: 0.00040969553387335954|| AP: 0.7380756727563009
12 ____________________
13 cls : cow|| Recall: 0.9672131147540983 || Precison: 0.0005127837421479989|| AP: 0.8598673192007477
14 ____________________
15 cls : boat|| Recall: 0.870722433460076 || Precison: 0.0005048556531707801|| AP: 0.614924861322453
16 ____________________
17 cls : person|| Recall: 0.9112190812720848 || Precison: 0.00890183387270766|| AP: 0.8403573910074297
18 ____________________
19 cls : bottle|| Recall: 0.8550106609808102 || Precison: 0.0008528612324589202|| AP: 0.6431100249936452
20 ____________________
21 cls : bus|| Recall: 0.9624413145539906 || Precison: 0.00045113940207524124|| AP: 0.8462278674877455
22 ____________________
23 cls : chair|| Recall: 0.8465608465608465 || Precison: 0.0013795928045612787|| AP: 0.5683751395230314
24 ____________________
25 cls : train|| Recall: 0.9361702127659575 || Precison: 0.0005837401825514753|| AP: 0.8364460305413468
26 ____________________
27 cls : dog|| Recall: 0.9754601226993865 || Precison: 0.0010383537847668929|| AP: 0.9033364857501106
28 ____________________
29 cls : motorbike|| Recall: 0.92 || Precison: 0.0006513139551094382|| AP: 0.8295629935581179
30 ____________________
31 cls : cat|| Recall: 0.9608938547486033 || Precison: 0.0007397197236372707|| AP: 0.8871965890034861
32 ____________________
33 cls : sofa|| Recall: 0.9539748953974896 || Precison: 0.0005096076691483964|| AP: 0.8040267075520897
34 ____________________
35 cls : bird|| Recall: 0.9150326797385621 || Precison: 0.0009065830883400464|| AP: 0.8237404489482196
36 ____________________
37 cls : horse|| Recall: 0.9568965517241379 || Precison: 0.0007317362585204424|| AP: 0.8735567893480496
38 ____________________
39 cls : pottedplant|| Recall: 0.7895833333333333 || Precison: 0.0008196455411498826|| AP: 0.4870711669635938
40 ____________________
41 cls : bicycle|| Recall: 0.9109792284866469 || Precison: 0.0006712950308861314|| AP: 0.8361496835573192
42 ____________________
43 cls : tvmonitor|| Recall: 0.9512987012987013 || Precison: 0.0006329305331737686|| AP: 0.7944641602539069
44 ____________________
45 cls : sheep|| Recall: 0.9214876033057852 || Precison: 0.0004898504308706817|| AP: 0.7823429444259854
46 ____________________
47 mAP is : 0.7848506672229101    USE_12_METRIC
48
49 cls : tvmonitor|| Recall: 0.9512987012987013 || Precison: 0.0006329305331737686|| AP: 0.7680923930233127
50 ____________________
51 cls : sheep|| Recall: 0.9214876033057852 || Precison: 0.0004898504308706817|| AP: 0.7605331894258903
52 ____________________
53 cls : cat|| Recall: 0.9608938547486033 || Precison: 0.0007397197236372707|| AP: 0.8561115936556246
54 ____________________
55 cls : train|| Recall: 0.9361702127659575 || Precison: 0.0005837401825514753|| AP: 0.7978443126776701
56 ____________________
57 cls : aeroplane|| Recall: 0.9333333333333333 || Precison: 0.0005925041542114572|| AP: 0.8033498986573708
58 ____________________
59 cls : motorbike|| Recall: 0.92 || Precison: 0.0006513139551094382|| AP: 0.7991141448766482
60 ____________________
61 cls : bus|| Recall: 0.9624413145539906 || Precison: 0.00045113940207524124|| AP: 0.8181027979596772
62 ____________________
63 cls : bird|| Recall: 0.9150326797385621 || Precison: 0.0009065830883400464|| AP: 0.7851247014320806
64 ____________________
65 cls : pottedplant|| Recall: 0.7895833333333333 || Precison: 0.0008196455411498826|| AP: 0.49033575375142174
66 ____________________
67 cls : cow|| Recall: 0.9672131147540983 || Precison: 0.0005127837421479989|| AP: 0.8304367006298838
68 ____________________
69 cls : person|| Recall: 0.9112190812720848 || Precison: 0.00890183387270766|| AP: 0.797530517185023
70 ____________________
71 cls : bottle|| Recall: 0.8550106609808102 || Precison: 0.0008528612324589202|| AP: 0.6320745719617634
72 ____________________
73 cls : sofa|| Recall: 0.9539748953974896 || Precison: 0.0005096076691483964|| AP: 0.7868518534567335
74 ____________________
75 cls : boat|| Recall: 0.870722433460076 || Precison: 0.0005048556531707801|| AP: 0.6036612374959088
76 ____________________
77 cls : car|| Recall: 0.9542048293089093 || Precison: 0.002486730925298256|| AP: 0.8623955910304107
78 ____________________
79 cls : bicycle|| Recall: 0.9109792284866469 || Precison: 0.0006712950308861314|| AP: 0.8029062441256611
80 ____________________
81 cls : dog|| Recall: 0.9754601226993865 || Precison: 0.0010383537847668929|| AP: 0.8661350949646617
82 ____________________
83 cls : diningtable|| Recall: 0.8932038834951457 || Precison: 0.00040969553387335954|| AP: 0.7127169697539509
84 ____________________
85 cls : horse|| Recall: 0.9568965517241379 || Precison: 0.0007317362585204424|| AP: 0.8422342978325045
86 ____________________
87 cls : chair|| Recall: 0.8465608465608465 || Precison: 0.0013795928045612787|| AP: 0.563170854101135
88 ____________________
89 mAP is : 0.7589361358998666   USE_07_METRIC
90 """
91
92 # ------------------------------------------------
93 VERSION = 'FPN_Res101_20181201_v2'
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 = "3"
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 = False
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