training updates

This commit is contained in:
Glenn Jocher
2020-04-08 21:01:58 -07:00
parent c7f5b6cc21
commit 4120ac3aa6
3 changed files with 8 additions and 8 deletions
+1 -1
View File
@@ -149,7 +149,7 @@ class ModelEMA:
self.ema = deepcopy(model)
self.ema.eval()
self.updates = 0 # number of EMA updates
self.decay = lambda x: decay * (1 - math.exp(-x / 1000)) # decay exponential ramp (to help early epochs)
self.decay = lambda x: decay * (1 - math.exp(-x / 2000)) # decay exponential ramp (to help early epochs)
self.device = device # perform ema on different device from model if set
if device:
self.ema.to(device=device)
+4 -4
View File
@@ -688,11 +688,11 @@ def coco_single_class_labels(path='../coco/labels/train2014/', label_class=43):
shutil.copyfile(src=img_file, dst='new/images/' + Path(file).name.replace('txt', 'jpg')) # copy images
def kmean_anchors(path='../coco/train2017.txt', n=9, img_size=(608, 608)):
def kmean_anchors(path='../coco/train2017.txt', n=12, img_size=(320, 1024)):
# from utils.utils import *; _ = kmean_anchors()
# Produces a list of target kmeans suitable for use in *.cfg files
# Creaters kmeans anchors for use in *.cfg files
from utils.datasets import LoadImagesAndLabels
thr = 0.20 # IoU threshold
thr = 0.225 # IoU threshold
def print_results(k):
k = k[np.argsort(k.prod(1))] # sort small to large
@@ -709,7 +709,7 @@ def kmean_anchors(path='../coco/train2017.txt', n=9, img_size=(608, 608)):
def fitness(k): # mutation fitness
iou = wh_iou(wh, torch.Tensor(k)) # iou
max_iou = iou.max(1)[0]
return max_iou.mean() # product
return (max_iou * (max_iou > thr).float()).mean() # product
# Get label wh
wh = []