From 682c2b27e7018c1ff3aae4607c48a2f742a985fe Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Fri, 3 Apr 2020 12:42:09 -0700 Subject: [PATCH] smart bias bug fix --- models.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/models.py b/models.py index 3ead81f9..5558dee3 100755 --- a/models.py +++ b/models.py @@ -77,11 +77,12 @@ def create_modules(module_defs, img_size): elif mdef['type'] == 'yolo': yolo_index += 1 stride = [32, 16, 8, 4, 2][yolo_index] # P3-P7 stride + layers = mdef['from'] if 'from' in mdef else [] modules = YOLOLayer(anchors=mdef['anchors'][mdef['mask']], # anchor list nc=mdef['classes'], # number of classes img_size=img_size, # (416, 416) yolo_index=yolo_index, # 0, 1, 2... - layers=mdef['from'] if 'from' in mdef else [], # output layers + layers=layers, # output layers stride=stride) # Initialize preceding Conv2d() bias (https://arxiv.org/pdf/1708.02002.pdf section 3.3) @@ -89,7 +90,7 @@ def create_modules(module_defs, img_size): bo = -4.5 #  obj bias bc = math.log(1 / (modules.nc - 0.99)) # cls bias: class probability is sigmoid(p) = 1/nc - j = l[yolo_index] if 'from' in mdef else -1 + j = layers[yolo_index] if 'from' in mdef else -1 bias_ = module_list[j][0].bias # shape(255,) bias = bias_[:modules.no * modules.na].view(modules.na, -1) # shape(3,85) bias[:, 4] += bo - bias[:, 4].mean() # obj