This commit is contained in:
Glenn Jocher
2019-11-20 12:51:05 -08:00
parent e58f0a68b6
commit bac4cc58fd
2 changed files with 823 additions and 2 deletions
+2 -2
View File
@@ -671,7 +671,7 @@ 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 kmeans_targets(path='../coco/trainvalno5k.txt', n=9, img_size=512): # from utils.utils import *; kmeans_targets()
def kmeans_targets(path='../coco/trainvalno5k.txt', n=9, img_size=416): # from utils.utils import *; kmeans_targets()
# Produces a list of target kmeans suitable for use in *.cfg files
from utils.datasets import LoadImagesAndLabels
from scipy import cluster
@@ -681,7 +681,7 @@ def kmeans_targets(path='../coco/trainvalno5k.txt', n=9, img_size=512): # from
for s, l in zip(dataset.shapes, dataset.labels):
l[:, [1, 3]] *= s[0] # normalized to pixels
l[:, [2, 4]] *= s[1]
l[:, 1:] *= img_size / max(s) * random.uniform(0.99, 1.01) # nominal img_size for training
l[:, 1:] *= img_size / max(s) * random.uniform(0.5, 1.5) # nominal img_size for training
wh = np.concatenate(dataset.labels, 0)[:, 3:5] # wh from cxywh
# Kmeans calculation