Minor import and spelling updates (#1133)

This commit is contained in:
Glenn Jocher authored and GitHub committed 2020-10-13 17:24:27 +02:00
1 parent 4346b13a40
commit 4d3680c81d
3 files changed
+7 -8

No files matched your search

-1
View File
@@ -1,6 +1,5 @@
import argparse import argparse
import os import os
import platform
import shutil import shutil
import time import time
from pathlib import Path from pathlib import Path
+1 -1
View File
@@ -1,12 +1,12 @@
import argparse import argparse
import logging import logging
import math
import os import os
import random import random
import shutil import shutil
import time import time
from pathlib import Path from pathlib import Path
import math
import numpy as np import numpy as np
import torch.distributed as dist import torch.distributed as dist
import torch.nn.functional as F import torch.nn.functional as F
+6 -6
View File
@@ -143,7 +143,7 @@ def check_dataset(dict):
if val and len(val): if val and len(val):
val = [os.path.abspath(x) for x in (val if isinstance(val, list) else [val])] # val path val = [os.path.abspath(x) for x in (val if isinstance(val, list) else [val])] # val path
if not all(os.path.exists(x) for x in val): if not all(os.path.exists(x) for x in val):
print('\nWARNING: Dataset not found, nonexistant paths: %s' % [*val]) print('\nWARNING: Dataset not found, nonexistent paths: %s' % [*val])
if s and len(s): # download script if s and len(s): # download script
print('Downloading %s ...' % s) print('Downloading %s ...' % s)
if s.startswith('http') and s.endswith('.zip'): # URL if s.startswith('http') and s.endswith('.zip'): # URL
@@ -158,7 +158,7 @@ def check_dataset(dict):
def make_divisible(x, divisor): def make_divisible(x, divisor):
# Returns x evenly divisble by divisor # Returns x evenly divisible by divisor
return math.ceil(x / divisor) * divisor return math.ceil(x / divisor) * divisor
@@ -169,9 +169,9 @@ def labels_to_class_weights(labels, nc=80):
labels = np.concatenate(labels, 0) # labels.shape = (866643, 5) for COCO labels = np.concatenate(labels, 0) # labels.shape = (866643, 5) for COCO
classes = labels[:, 0].astype(np.int) # labels = [class xywh] classes = labels[:, 0].astype(np.int) # labels = [class xywh]
weights = np.bincount(classes, minlength=nc) # occurences per class weights = np.bincount(classes, minlength=nc) # occurrences per class
# Prepend gridpoint count (for uCE trianing) # Prepend gridpoint count (for uCE training)
# gpi = ((320 / 32 * np.array([1, 2, 4])) ** 2 * 3).sum() # gridpoints per image # gpi = ((320 / 32 * np.array([1, 2, 4])) ** 2 * 3).sum() # gridpoints per image
# weights = np.hstack([gpi * len(labels) - weights.sum() * 9, weights * 9]) ** 0.5 # prepend gridpoints to start # weights = np.hstack([gpi * len(labels) - weights.sum() * 9, weights * 9]) ** 0.5 # prepend gridpoints to start
@@ -820,7 +820,7 @@ def kmean_anchors(path='./data/coco128.yaml', n=9, img_size=640, thr=4.0, gen=10
k, dist = kmeans(wh / s, n, iter=30) # points, mean distance k, dist = kmeans(wh / s, n, iter=30) # points, mean distance
k *= s k *= s
wh = torch.tensor(wh, dtype=torch.float32) # filtered wh = torch.tensor(wh, dtype=torch.float32) # filtered
wh0 = torch.tensor(wh0, dtype=torch.float32) # unflitered wh0 = torch.tensor(wh0, dtype=torch.float32) # unfiltered
k = print_results(k) k = print_results(k)
# Plot # Plot
@@ -1281,7 +1281,7 @@ def plot_results(start=0, stop=0, bucket='', id=(), labels=(), save_dir=''):
for i in range(10): for i in range(10):
y = results[i, x] y = results[i, x]
if i in [0, 1, 2, 5, 6, 7]: if i in [0, 1, 2, 5, 6, 7]:
y[y == 0] = np.nan # dont show zero loss values y[y == 0] = np.nan # don't show zero loss values
# y /= y[0] # normalize # y /= y[0] # normalize
label = labels[fi] if len(labels) else Path(f).stem label = labels[fi] if len(labels) else Path(f).stem
ax[i].plot(x, y, marker='.', label=label, linewidth=1, markersize=6) ax[i].plot(x, y, marker='.', label=label, linewidth=1, markersize=6)