From b8c870711fe86d51c79a4580642d27bc6ecf18bf Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 17 Aug 2019 14:09:38 +0200 Subject: [PATCH] updates --- utils/utils.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/utils/utils.py b/utils/utils.py index 497dab38..10e39fc6 100755 --- a/utils/utils.py +++ b/utils/utils.py @@ -56,9 +56,15 @@ def model_info(model, report='summary'): def labels_to_class_weights(labels, nc=80): # Get class weights (inverse frequency) from training labels + ni = len(labels) # number of images labels = np.concatenate(labels, 0) # labels.shape = (866643, 5) for COCO classes = labels[:, 0].astype(np.int) # labels = [class xywh] 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]) # prepend gridpoints to start + weights[weights == 0] = 1 # replace empty bins with 1 weights = 1 / weights # number of targets per class weights /= weights.sum() # normalize