Refactor with simplifications (#19329)

Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
Glenn Jocher 2025-02-20 19:43:53 +08:00 committed by GitHub
parent f4307339ad
commit 82b1ce44cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 14 additions and 19 deletions

View file

@ -317,8 +317,7 @@ def model_info(model, detailed=False, verbose=True, imgsz=640):
if len(m._parameters):
for pn, p in m.named_parameters():
LOGGER.info(
f"{i:>5g}{mn + '.' + pn:>40}{mt:>20}{p.requires_grad!r:>10}{p.numel():>12g}"
f"{str(list(p.shape)):>20}{p.mean():>10.3g}{p.std():>10.3g}{str(p.dtype).replace('torch.', ''):>15}"
f"{i:>5g}{f'{mn}.{pn}':>40}{mt:>20}{p.requires_grad!r:>10}{p.numel():>12g}{str(list(p.shape)):>20}{p.mean():>10.3g}{p.std():>10.3g}{str(p.dtype).replace('torch.', ''):>15}"
)
else: # layers with no learnable params
LOGGER.info(f"{i:>5g}{mn:>40}{mt:>20}{False!r:>10}{0:>12g}{str([]):>20}{'-':>10}{'-':>10}{'-':>15}")