Skip to content

Commit

Permalink
Improved yolo.py profiling (ultralytics#2940)
Browse files Browse the repository at this point in the history
* Improved yolo.py profiling

Improved column order and labelling.

* Update yolo.py
  • Loading branch information
glenn-jocher committed Apr 26, 2021
1 parent 1e1d085 commit c917343
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions models/yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ def forward_once(self, x, profile=False):
for _ in range(10):
_ = m(x)
dt.append((time_synchronized() - t) * 100)
logger.info('%10.1f%10.0f%10.1fms %-40s' % (o, m.np, dt[-1], m.type))
if m == self.model[0]:
logger.info(f"{'time (ms)':>10s} {'GFLOPS':>10s} {'params':>10s} {'module'}")
logger.info(f'{dt[-1]:10.2f} {o:10.2f} {m.np:10.0f} {m.type}')

x = m(x) # run
y.append(x if m.i in self.save else None) # save output
Expand All @@ -157,7 +159,8 @@ def _print_biases(self):
m = self.model[-1] # Detect() module
for mi in m.m: # from
b = mi.bias.detach().view(m.na, -1).T # conv.bias(255) to (3,85)
logger.info(('%6g Conv2d.bias:' + '%10.3g' * 6) % (mi.weight.shape[1], *b[:5].mean(1).tolist(), b[5:].mean()))
logger.info(
('%6g Conv2d.bias:' + '%10.3g' * 6) % (mi.weight.shape[1], *b[:5].mean(1).tolist(), b[5:].mean()))

# def _print_weights(self):
# for m in self.model.modules():
Expand Down

0 comments on commit c917343

Please sign in to comment.