glenn-jocher commited on
Commit
4d3680c
·
unverified ·
1 Parent(s): 4346b13

Minor import and spelling updates (#1133)

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