Fix region-counting indents (#17835)

Signed-off-by: UltralyticsAssistant <web@ultralytics.com>
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
pull/17813/head^2
Glenn Jocher 2 weeks ago committed by GitHub
parent 55b2137f18
commit 386a3b7625
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      docs/en/guides/region-counting.md
  2. 1
      ultralytics/cfg/__init__.py
  3. 2
      ultralytics/models/yolo/detect/train.py
  4. 16
      ultralytics/utils/torch_utils.py

@ -4,7 +4,7 @@ description: Learn how to use Ultralytics YOLOv8 for precise object counting in
keywords: object counting, regions, YOLOv8, computer vision, Ultralytics, efficiency, accuracy, automation, real-time, applications, surveillance, monitoring
---
# Object Counting in Different Regions using Ultralytics YOLOv8 🚀
# Object Counting in Different Regions using Ultralytics YOLO 🚀
## What is Object Counting in Regions?
@ -40,6 +40,7 @@ keywords: object counting, regions, YOLOv8, computer vision, Ultralytics, effici
```python
import cv2
from ultralytics import solutions
cap = cv2.VideoCapture("Path/to/video/file.mp4")
@ -52,7 +53,7 @@ keywords: object counting, regions, YOLOv8, computer vision, Ultralytics, effici
# pass region as dictionary
region_points = {
"region-01": [(50, 50), (250, 50), (250, 250), (50, 250)],
"region-02": [(640, 640), (780, 640), (780, 720), (640, 720)]
"region-02": [(640, 640), (780, 640), (780, 720), (640, 720)],
}
# Video writer

@ -11,7 +11,6 @@ import cv2
from ultralytics.utils import (
ASSETS,
ASSETS_URL,
DEFAULT_CFG,
DEFAULT_CFG_DICT,
DEFAULT_CFG_PATH,

@ -146,5 +146,5 @@ class DetectionTrainer(BaseTrainer):
"""Get batch size by calculating memory occupation of model."""
train_dataset = self.build_dataset(self.trainset, mode="train", batch=16)
# 4 for mosaic augmentation
max_num_obj = max(len(l["cls"]) for l in train_dataset.labels) * 4
max_num_obj = max(len(label["cls"]) for label in train_dataset.labels) * 4
return super().auto_batch(max_num_obj)

@ -301,28 +301,22 @@ def fuse_deconv_and_bn(deconv, bn):
def model_info(model, detailed=False, verbose=True, imgsz=640):
"""
Model information.
imgsz may be int or list, i.e. imgsz=640 or imgsz=[640, 320].
"""
"""Print and return detailed model information layer by layer."""
if not verbose:
return
n_p = get_num_params(model) # number of parameters
n_g = get_num_gradients(model) # number of gradients
n_l = len(list(model.modules())) # number of layers
if detailed:
LOGGER.info(
f"{'layer':>5} {'name':>40} {'gradient':>9} {'parameters':>12} {'shape':>20} {'mu':>10} {'sigma':>10}"
)
LOGGER.info(f"{'layer':>5}{'name':>40}{'gradient':>10}{'parameters':>12}{'shape':>20}{'mu':>10}{'sigma':>10}")
for i, (name, p) in enumerate(model.named_parameters()):
name = name.replace("module_list.", "")
LOGGER.info(
"%5g %40s %9s %12g %20s %10.3g %10.3g %10s"
% (i, name, p.requires_grad, p.numel(), list(p.shape), p.mean(), p.std(), p.dtype)
f"{i:>5g}{name:>40s}{p.requires_grad!r:>10}{p.numel():>12g}{str(list(p.shape)):>20s}"
f"{p.mean():>10.3g}{p.std():>10.3g}{str(p.dtype):>15s}"
)
flops = get_flops(model, imgsz)
flops = get_flops(model, imgsz) # imgsz may be int or list, i.e. imgsz=640 or imgsz=[640, 320]
fused = " (fused)" if getattr(model, "is_fused", lambda: False)() else ""
fs = f", {flops:.1f} GFLOPs" if flops else ""
yaml_file = getattr(model, "yaml_file", "") or getattr(model, "yaml", {}).get("yaml_file", "")

Loading…
Cancel
Save