Skip to content

Commit

Permalink
Model summary pathlib fix (#7104)
Browse files Browse the repository at this point in the history
Stems not working correctly for YOLOv5l with current .rstrip() implementation. After fix:
```
YOLOv5l summary: 468 layers, 46563709 parameters, 46563709 gradients, 109.3 GFLOPs
```
  • Loading branch information
glenn-jocher committed Mar 22, 2022
1 parent ee0b3b2 commit 6134ec5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion utils/torch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import warnings
from contextlib import contextmanager
from copy import deepcopy
from pathlib import Path

import torch
import torch.distributed as dist
Expand Down Expand Up @@ -229,7 +230,7 @@ def model_info(model, verbose=False, img_size=640):
except (ImportError, Exception):
fs = ''

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


Expand Down

0 comments on commit 6134ec5

Please sign in to comment.