glenn-jocher commited on
Commit
d989bc9
1 Parent(s): 023e378

remove NBSP

Browse files
Files changed (2) hide show
  1. models/yolo.py +2 -2
  2. utils/utils.py +2 -2
models/yolo.py CHANGED
@@ -127,7 +127,7 @@ class Model(nn.Module):
127
  def _initialize_biases(self, cf=None): # initialize biases into Detect(), cf is class frequency
128
  # cf = torch.bincount(torch.tensor(np.concatenate(dataset.labels, 0)[:, 0]).long(), minlength=nc) + 1.
129
  m = self.model[-1] # Detect() module
130
- for mi, s in zip(m.m, m.stride): #  from
131
  b = mi.bias.view(m.na, -1) # conv.bias(255) to (3,85)
132
  b[:, 4] += math.log(8 / (640 / s) ** 2) # obj (8 objects per 640 image)
133
  b[:, 5:] += math.log(0.6 / (m.nc - 0.99)) if cf is None else torch.log(cf / cf.sum()) # cls
@@ -135,7 +135,7 @@ class Model(nn.Module):
135
 
136
  def _print_biases(self):
137
  m = self.model[-1] # Detect() module
138
- for mi in m.m: #  from
139
  b = mi.bias.detach().view(m.na, -1).T # conv.bias(255) to (3,85)
140
  print(('%6g Conv2d.bias:' + '%10.3g' * 6) % (mi.weight.shape[1], *b[:5].mean(1).tolist(), b[5:].mean()))
141
 
 
127
  def _initialize_biases(self, cf=None): # initialize biases into Detect(), cf is class frequency
128
  # cf = torch.bincount(torch.tensor(np.concatenate(dataset.labels, 0)[:, 0]).long(), minlength=nc) + 1.
129
  m = self.model[-1] # Detect() module
130
+ for mi, s in zip(m.m, m.stride): # from
131
  b = mi.bias.view(m.na, -1) # conv.bias(255) to (3,85)
132
  b[:, 4] += math.log(8 / (640 / s) ** 2) # obj (8 objects per 640 image)
133
  b[:, 5:] += math.log(0.6 / (m.nc - 0.99)) if cf is None else torch.log(cf / cf.sum()) # cls
 
135
 
136
  def _print_biases(self):
137
  m = self.model[-1] # Detect() module
138
+ for mi in m.m: # from
139
  b = mi.bias.detach().view(m.na, -1).T # conv.bias(255) to (3,85)
140
  print(('%6g Conv2d.bias:' + '%10.3g' * 6) % (mi.weight.shape[1], *b[:5].mean(1).tolist(), b[5:].mean()))
141
 
utils/utils.py CHANGED
@@ -21,7 +21,7 @@ import yaml
21
  from scipy.signal import butter, filtfilt
22
  from tqdm import tqdm
23
 
24
- from . import torch_utils #  torch_utils, google_utils
25
 
26
  # Set printoptions
27
  torch.set_printoptions(linewidth=320, precision=5, profile='long')
@@ -84,7 +84,7 @@ def check_anchors(dataset, model, thr=4.0, imgsz=640):
84
  r = wh[:, None] / k[None]
85
  x = torch.min(r, 1. / r).min(2)[0] # ratio metric
86
  best = x.max(1)[0] # best_x
87
- return (best > 1. / thr).float().mean() #  best possible recall
88
 
89
  bpr = metric(m.anchor_grid.clone().cpu().view(-1, 2))
90
  print('Best Possible Recall (BPR) = %.4f' % bpr, end='')
 
21
  from scipy.signal import butter, filtfilt
22
  from tqdm import tqdm
23
 
24
+ from . import torch_utils # torch_utils, google_utils
25
 
26
  # Set printoptions
27
  torch.set_printoptions(linewidth=320, precision=5, profile='long')
 
84
  r = wh[:, None] / k[None]
85
  x = torch.min(r, 1. / r).min(2)[0] # ratio metric
86
  best = x.max(1)[0] # best_x
87
+ return (best > 1. / thr).float().mean() # best possible recall
88
 
89
  bpr = metric(m.anchor_grid.clone().cpu().view(-1, 2))
90
  print('Best Possible Recall (BPR) = %.4f' % bpr, end='')