Browse Source

remove NBSP

5.0
Glenn Jocher 4 years ago
parent
commit
d989bc9260
2 changed files with 4 additions and 4 deletions
  1. +2
    -2
      models/yolo.py
  2. +2
    -2
      utils/utils.py

+ 2
- 2
models/yolo.py View File

@@ -127,7 +127,7 @@ class Model(nn.Module):
def _initialize_biases(self, cf=None): # initialize biases into Detect(), cf is class frequency
# cf = torch.bincount(torch.tensor(np.concatenate(dataset.labels, 0)[:, 0]).long(), minlength=nc) + 1.
m = self.model[-1] # Detect() module
for mi, s in zip(m.m, m.stride): #  from
for mi, s in zip(m.m, m.stride): # from
b = mi.bias.view(m.na, -1) # conv.bias(255) to (3,85)
b[:, 4] += math.log(8 / (640 / s) ** 2) # obj (8 objects per 640 image)
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):

def _print_biases(self):
m = self.model[-1] # Detect() module
for mi in m.m: #  from
for mi in m.m: # from
b = mi.bias.detach().view(m.na, -1).T # conv.bias(255) to (3,85)
print(('%6g Conv2d.bias:' + '%10.3g' * 6) % (mi.weight.shape[1], *b[:5].mean(1).tolist(), b[5:].mean()))


+ 2
- 2
utils/utils.py View File

@@ -21,7 +21,7 @@ import yaml
from scipy.signal import butter, filtfilt
from tqdm import tqdm

from . import torch_utils #  torch_utils, google_utils
from . import torch_utils # torch_utils, google_utils

# Set printoptions
torch.set_printoptions(linewidth=320, precision=5, profile='long')
@@ -84,7 +84,7 @@ def check_anchors(dataset, model, thr=4.0, imgsz=640):
r = wh[:, None] / k[None]
x = torch.min(r, 1. / r).min(2)[0] # ratio metric
best = x.max(1)[0] # best_x
return (best > 1. / thr).float().mean() #  best possible recall
return (best > 1. / thr).float().mean() # best possible recall

bpr = metric(m.anchor_grid.clone().cpu().view(-1, 2))
print('Best Possible Recall (BPR) = %.4f' % bpr, end='')

Loading…
Cancel
Save