From e58f0a68b6325e93d9ce98f66bcc3abb4b75a04e Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Wed, 20 Nov 2019 12:05:40 -0800 Subject: [PATCH] updates --- train.py | 2 +- utils/utils.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/train.py b/train.py index d9d120e2..1cde2012 100644 --- a/train.py +++ b/train.py @@ -204,7 +204,7 @@ def train(): model.nc = nc # attach number of classes to model model.arc = opt.arc # attach yolo architecture model.hyp = hyp # attach hyperparameters to model - # model.class_weights = labels_to_class_weights(dataset.labels, nc).to(device) # attach class weights + model.class_weights = labels_to_class_weights(dataset.labels, nc).to(device) # attach class weights torch_utils.model_info(model, report='summary') # 'full' or 'summary' nb = len(dataloader) maps = np.zeros(nc) # mAP per class diff --git a/utils/utils.py b/utils/utils.py index 29bef278..11e72978 100755 --- a/utils/utils.py +++ b/utils/utils.py @@ -49,8 +49,8 @@ def labels_to_class_weights(labels, nc=80): weights = np.bincount(classes, minlength=nc) # occurences per class # Prepend gridpoint count (for uCE trianing) - gpi = ((320 / 32 * np.array([1, 2, 4])) ** 2 * 3).sum() # gridpoints per image - weights = np.hstack([gpi * ni - weights.sum() * 9, weights * 9]) ** 0.5 # prepend gridpoints to start + # gpi = ((320 / 32 * np.array([1, 2, 4])) ** 2 * 3).sum() # gridpoints per image + # weights = np.hstack([gpi * ni - weights.sum() * 9, weights * 9]) ** 0.5 # prepend gridpoints to start weights[weights == 0] = 1 # replace empty bins with 1 weights = 1 / weights # number of targets per class