Skip to content

Commit b53d70a

Browse files
authored
Model summary pathlib fix (ultralytics#7104)
Stems not working correctly for YOLOv5l with current .rstrip() implementation. After fix: ``` YOLOv5l summary: 468 layers, 46563709 parameters, 46563709 gradients, 109.3 GFLOPs ```
1 parent e393d73 commit b53d70a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

utils/torch_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import warnings
1212
from contextlib import contextmanager
1313
from copy import deepcopy
14+
from pathlib import Path
1415

1516
import torch
1617
import torch.distributed as dist
@@ -229,7 +230,7 @@ def model_info(model, verbose=False, img_size=640):
229230
except (ImportError, Exception):
230231
fs = ''
231232

232-
name = model.yaml_file.rstrip('.yaml').replace('yolov5', 'YOLOv5') if hasattr(model, 'yaml_file') else 'Model'
233+
name = Path(model.yaml_file).stem.replace('yolov5', 'YOLOv5') if hasattr(model, 'yaml_file') else 'Model'
233234
LOGGER.info(f"{name} summary: {len(list(model.modules()))} layers, {n_p} parameters, {n_g} gradients{fs}")
234235

235236

0 commit comments

Comments
 (0)