ultralytics 8.3.39__py3-none-any.whl → 8.3.40__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ultralytics/__init__.py +1 -1
- ultralytics/cfg/__init__.py +9 -6
- ultralytics/solutions/__init__.py +2 -0
- ultralytics/solutions/ai_gym.py +1 -1
- ultralytics/solutions/solutions.py +5 -1
- ultralytics/solutions/trackzone.py +68 -0
- {ultralytics-8.3.39.dist-info → ultralytics-8.3.40.dist-info}/METADATA +2 -2
- {ultralytics-8.3.39.dist-info → ultralytics-8.3.40.dist-info}/RECORD +12 -11
- {ultralytics-8.3.39.dist-info → ultralytics-8.3.40.dist-info}/LICENSE +0 -0
- {ultralytics-8.3.39.dist-info → ultralytics-8.3.40.dist-info}/WHEEL +0 -0
- {ultralytics-8.3.39.dist-info → ultralytics-8.3.40.dist-info}/entry_points.txt +0 -0
- {ultralytics-8.3.39.dist-info → ultralytics-8.3.40.dist-info}/top_level.txt +0 -0
ultralytics/__init__.py
CHANGED
ultralytics/cfg/__init__.py
CHANGED
@@ -41,6 +41,7 @@ SOLUTION_MAP = {
|
|
41
41
|
"speed": ("SpeedEstimator", "estimate_speed"),
|
42
42
|
"workout": ("AIGym", "monitor"),
|
43
43
|
"analytics": ("Analytics", "process_data"),
|
44
|
+
"trackzone": ("TrackZone", "trackzone"),
|
44
45
|
"help": None,
|
45
46
|
}
|
46
47
|
|
@@ -74,13 +75,12 @@ ARGV = sys.argv or ["", ""] # sometimes sys.argv = []
|
|
74
75
|
SOLUTIONS_HELP_MSG = f"""
|
75
76
|
Arguments received: {str(['yolo'] + ARGV[1:])}. Ultralytics 'yolo solutions' usage overview:
|
76
77
|
|
77
|
-
yolo
|
78
|
-
|
79
|
-
Where SOLUTIONS (required) is a keyword
|
80
|
-
SOLUTION (optional) is one of {list(SOLUTION_MAP.keys())}
|
81
|
-
ARGS (optional) are any number of custom 'arg=value' pairs like 'show_in=True' that override defaults.
|
82
|
-
See all ARGS at https://docs.ultralytics.com/usage/cfg or with 'yolo cfg'
|
78
|
+
yolo solutions SOLUTION ARGS
|
83
79
|
|
80
|
+
Where SOLUTION (optional) is one of {list(SOLUTION_MAP.keys())}
|
81
|
+
ARGS (optional) are any number of custom 'arg=value' pairs like 'show_in=True' that override defaults
|
82
|
+
at https://docs.ultralytics.com/usage/cfg
|
83
|
+
|
84
84
|
1. Call object counting solution
|
85
85
|
yolo solutions count source="path/to/video/file.mp4" region=[(20, 400), (1080, 400), (1080, 360), (20, 360)]
|
86
86
|
|
@@ -95,6 +95,9 @@ SOLUTIONS_HELP_MSG = f"""
|
|
95
95
|
|
96
96
|
5. Generate analytical graphs
|
97
97
|
yolo solutions analytics analytics_type="pie"
|
98
|
+
|
99
|
+
6. Track Objects Within Specific Zones
|
100
|
+
yolo solutions trackzone source="path/to/video/file.mp4" region=[(150, 150), (1130, 150), (1130, 570), (150, 570)]
|
98
101
|
"""
|
99
102
|
CLI_HELP_MSG = f"""
|
100
103
|
Arguments received: {str(['yolo'] + ARGV[1:])}. Ultralytics 'yolo' commands use the following syntax:
|
@@ -10,6 +10,7 @@ from .queue_management import QueueManager
|
|
10
10
|
from .region_counter import RegionCounter
|
11
11
|
from .speed_estimation import SpeedEstimator
|
12
12
|
from .streamlit_inference import inference
|
13
|
+
from .trackzone import TrackZone
|
13
14
|
|
14
15
|
__all__ = (
|
15
16
|
"AIGym",
|
@@ -23,4 +24,5 @@ __all__ = (
|
|
23
24
|
"Analytics",
|
24
25
|
"inference",
|
25
26
|
"RegionCounter",
|
27
|
+
"TrackZone",
|
26
28
|
)
|
ultralytics/solutions/ai_gym.py
CHANGED
@@ -71,7 +71,7 @@ class AIGym(BaseSolution):
|
|
71
71
|
>>> processed_image = gym.monitor(image)
|
72
72
|
"""
|
73
73
|
# Extract tracks
|
74
|
-
tracks = self.model.track(source=im0, persist=True, classes=self.CFG["classes"])[0]
|
74
|
+
tracks = self.model.track(source=im0, persist=True, classes=self.CFG["classes"], **self.track_add_args)[0]
|
75
75
|
|
76
76
|
if tracks.boxes.id is not None:
|
77
77
|
# Extract and check keypoints
|
@@ -74,6 +74,10 @@ class BaseSolution:
|
|
74
74
|
self.model = YOLO(self.CFG["model"])
|
75
75
|
self.names = self.model.names
|
76
76
|
|
77
|
+
self.track_add_args = { # Tracker additional arguments for advance configuration
|
78
|
+
k: self.CFG[k] for k in ["verbose", "iou", "conf", "device", "max_det", "half", "tracker"]
|
79
|
+
}
|
80
|
+
|
77
81
|
if IS_CLI and self.CFG["source"] is None:
|
78
82
|
d_s = "solutions_ci_demo.mp4" if "-pose" not in self.CFG["model"] else "solution_ci_pose_demo.mp4"
|
79
83
|
LOGGER.warning(f"⚠️ WARNING: source not provided. using default source {ASSETS_URL}/{d_s}")
|
@@ -98,7 +102,7 @@ class BaseSolution:
|
|
98
102
|
>>> frame = cv2.imread("path/to/image.jpg")
|
99
103
|
>>> solution.extract_tracks(frame)
|
100
104
|
"""
|
101
|
-
self.tracks = self.model.track(source=im0, persist=True, classes=self.CFG["classes"])
|
105
|
+
self.tracks = self.model.track(source=im0, persist=True, classes=self.CFG["classes"], **self.track_add_args)
|
102
106
|
|
103
107
|
# Extract tracks for OBB or object detection
|
104
108
|
self.track_data = self.tracks[0].obb or self.tracks[0].boxes
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
2
|
+
|
3
|
+
import cv2
|
4
|
+
import numpy as np
|
5
|
+
|
6
|
+
from ultralytics.solutions.solutions import BaseSolution
|
7
|
+
from ultralytics.utils.plotting import Annotator, colors
|
8
|
+
|
9
|
+
|
10
|
+
class TrackZone(BaseSolution):
|
11
|
+
"""
|
12
|
+
A class to manage region-based object tracking in a video stream.
|
13
|
+
|
14
|
+
This class extends the BaseSolution class and provides functionality for tracking objects within a specific region
|
15
|
+
defined by a polygonal area. Objects outside the region are excluded from tracking. It supports dynamic initialization
|
16
|
+
of the region, allowing either a default region or a user-specified polygon.
|
17
|
+
|
18
|
+
Attributes:
|
19
|
+
region (ndarray): The polygonal region for tracking, represented as a convex hull.
|
20
|
+
|
21
|
+
Methods:
|
22
|
+
trackzone: Processes each frame of the video, applying region-based tracking.
|
23
|
+
|
24
|
+
Examples:
|
25
|
+
>>> tracker = TrackZone()
|
26
|
+
>>> frame = cv2.imread("frame.jpg")
|
27
|
+
>>> processed_frame = tracker.trackzone(frame)
|
28
|
+
>>> cv2.imshow("Tracked Frame", processed_frame)
|
29
|
+
"""
|
30
|
+
|
31
|
+
def __init__(self, **kwargs):
|
32
|
+
"""Initializes the TrackZone class for tracking objects within a defined region in video streams."""
|
33
|
+
super().__init__(**kwargs)
|
34
|
+
default_region = [(150, 150), (1130, 150), (1130, 570), (150, 570)]
|
35
|
+
self.region = cv2.convexHull(np.array(self.region or default_region, dtype=np.int32))
|
36
|
+
|
37
|
+
def trackzone(self, im0):
|
38
|
+
"""
|
39
|
+
Processes the input frame to track objects within a defined region.
|
40
|
+
|
41
|
+
This method initializes the annotator, creates a mask for the specified region, extracts tracks
|
42
|
+
only from the masked area, and updates tracking information. Objects outside the region are ignored.
|
43
|
+
|
44
|
+
Args:
|
45
|
+
im0 (numpy.ndarray): The input image or frame to be processed.
|
46
|
+
|
47
|
+
Returns:
|
48
|
+
(numpy.ndarray): The processed image with tracking id and bounding boxes annotations.
|
49
|
+
|
50
|
+
Examples:
|
51
|
+
>>> tracker = TrackZone()
|
52
|
+
>>> frame = cv2.imread("path/to/image.jpg")
|
53
|
+
>>> tracker.trackzone(frame)
|
54
|
+
"""
|
55
|
+
self.annotator = Annotator(im0, line_width=self.line_width) # Initialize annotator
|
56
|
+
# Create a mask for the region and extract tracks from the masked image
|
57
|
+
masked_frame = cv2.bitwise_and(im0, im0, mask=cv2.fillPoly(np.zeros_like(im0[:, :, 0]), [self.region], 255))
|
58
|
+
self.extract_tracks(masked_frame)
|
59
|
+
|
60
|
+
cv2.polylines(im0, [self.region], isClosed=True, color=(255, 255, 255), thickness=self.line_width * 2)
|
61
|
+
|
62
|
+
# Iterate over boxes, track ids, classes indexes list and draw bounding boxes
|
63
|
+
for box, track_id, cls in zip(self.boxes, self.track_ids, self.clss):
|
64
|
+
self.annotator.box_label(box, label=f"{self.names[cls]}:{track_id}", color=colors(track_id, True))
|
65
|
+
|
66
|
+
self.display_output(im0) # display output with base class function
|
67
|
+
|
68
|
+
return im0 # return output image for more usage
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: ultralytics
|
3
|
-
Version: 8.3.
|
3
|
+
Version: 8.3.40
|
4
4
|
Summary: Ultralytics YOLO 🚀 for SOTA object detection, multi-object tracking, instance segmentation, pose estimation and image classification.
|
5
5
|
Author-email: Glenn Jocher <glenn.jocher@ultralytics.com>, Jing Qiu <jing.qiu@ultralytics.com>
|
6
6
|
Maintainer-email: Ultralytics <hello@ultralytics.com>
|
@@ -168,7 +168,7 @@ YOLO may be used directly in the Command Line Interface (CLI) with a `yolo` comm
|
|
168
168
|
yolo predict model=yolo11n.pt source='https://ultralytics.com/images/bus.jpg'
|
169
169
|
```
|
170
170
|
|
171
|
-
`yolo` can be used for a variety of tasks and modes and accepts additional arguments,
|
171
|
+
`yolo` can be used for a variety of tasks and modes and accepts additional arguments, e.g. `imgsz=640`. See the YOLO [CLI Docs](https://docs.ultralytics.com/usage/cli/) for examples.
|
172
172
|
|
173
173
|
### Python
|
174
174
|
|
@@ -7,10 +7,10 @@ tests/test_exports.py,sha256=1MvhcQ2qHdbJImHII-bFarcaIcm-kPlEK-OdFLxnj7o,8769
|
|
7
7
|
tests/test_integrations.py,sha256=f5-QCUk1SU_-qn4mBCZwS3GN3tXEBIIXo4z2EhExbHw,6126
|
8
8
|
tests/test_python.py,sha256=I1RRdCwLdrc3jX06huVxct8HX8ccQOmQgVpuEflRl0U,23560
|
9
9
|
tests/test_solutions.py,sha256=HlDe-XOgBX0k1cLhRTAhhawMHk6p-5dg5xl2AIRjfdk,3790
|
10
|
-
ultralytics/__init__.py,sha256=
|
10
|
+
ultralytics/__init__.py,sha256=g043TDkiEqdLx6EEsZlBx5SW4RgiiHq5CUtD78wMHIo,681
|
11
11
|
ultralytics/assets/bus.jpg,sha256=wCAZxJecGR63Od3ZRERe9Aja1Weayrb9Ug751DS_vGM,137419
|
12
12
|
ultralytics/assets/zidane.jpg,sha256=Ftc4aeMmen1O0A3o6GCDO9FlfBslLpTAw0gnetx7bts,50427
|
13
|
-
ultralytics/cfg/__init__.py,sha256=
|
13
|
+
ultralytics/cfg/__init__.py,sha256=LgTvW_Rd_phZoLzC8p5UEh8o7pIjx9xc67I91Xh5llY,38910
|
14
14
|
ultralytics/cfg/default.yaml,sha256=FcXbvTXXvMpssk9fSwdlnVTtyqfmlYE9gAcHsf0OMf8,8347
|
15
15
|
ultralytics/cfg/datasets/Argoverse.yaml,sha256=FyeuJT5CHq_9d4hlfAf0kpZlnbUMO0S--UJ1yIqcdKk,3134
|
16
16
|
ultralytics/cfg/datasets/DOTAv1.5.yaml,sha256=QVfp_Qp-4rukuicaB4qx86NxSHM8Mrzym8l_fIDo8gw,1195
|
@@ -179,8 +179,8 @@ ultralytics/nn/modules/conv.py,sha256=DPLZCRno_ZOjsuajAXIq-GbJdOh2jp1WayRXfDEd8z
|
|
179
179
|
ultralytics/nn/modules/head.py,sha256=Bg_WXtvO004fAKF7qExFreywWFrgQoc5Tc3fA9KVoL4,27780
|
180
180
|
ultralytics/nn/modules/transformer.py,sha256=tGiK8NmPfswwW1rbF21r5ILUkkZQ6Nk4s8j16vFBmps,18069
|
181
181
|
ultralytics/nn/modules/utils.py,sha256=a88cKl2wz1nMVSEBiajtvaCbDBQIkESWOKTZ_WAJy90,3195
|
182
|
-
ultralytics/solutions/__init__.py,sha256=
|
183
|
-
ultralytics/solutions/ai_gym.py,sha256=
|
182
|
+
ultralytics/solutions/__init__.py,sha256=lpTOauaJf7dFlymZB9lHiH_feDlS8Vlrp4TC7GuM8SU,761
|
183
|
+
ultralytics/solutions/ai_gym.py,sha256=Jv8ERJqcSjQeFh78zCAH2XnXoTIngCK7X_7XOQ6cPzs,5255
|
184
184
|
ultralytics/solutions/analytics.py,sha256=C57pIghXeKN8hul8QOV7W9YDMpfFfSfPTBb-lE9HeAc,11535
|
185
185
|
ultralytics/solutions/distance_calculation.py,sha256=KN3CC-dm2dTQylj79IrifCJT8ZhE7hc2EweH3KK31mE,5461
|
186
186
|
ultralytics/solutions/heatmap.py,sha256=-1VtMCJRmpHnLqgna0i2HOBsxNoqFernzpKQnICngUM,5449
|
@@ -188,9 +188,10 @@ ultralytics/solutions/object_counter.py,sha256=MuxQG4a22458WwciAB96m5AxVXwH98AIW
|
|
188
188
|
ultralytics/solutions/parking_management.py,sha256=Hh28FTuP_TaO7x5RadYm-JSVJuEu1M2SSgHqgdYYtr8,11198
|
189
189
|
ultralytics/solutions/queue_management.py,sha256=D9TqwJSVrZQFxp_M8O62WfBAxkAuDWWnXe7FFmnp7_w,4881
|
190
190
|
ultralytics/solutions/region_counter.py,sha256=w0c0Sz9XG6rwzr5nA6nb1zFW8IVkTQuatfZNBtOik68,4947
|
191
|
-
ultralytics/solutions/solutions.py,sha256=
|
191
|
+
ultralytics/solutions/solutions.py,sha256=BqkMDAq9A8kqL4TkjHLkMYXrJAdZPK-VAdNSObS1kNQ,7502
|
192
192
|
ultralytics/solutions/speed_estimation.py,sha256=A10DmuZlGkoZUyfHhZWcDRjj1-9GXiDhEjyBbAzfaDs,4936
|
193
193
|
ultralytics/solutions/streamlit_inference.py,sha256=w4dnvSv2FOrpji9W1Ir86phka3OXc7jd_38-OCbQdZw,5701
|
194
|
+
ultralytics/solutions/trackzone.py,sha256=jsSuvW3ExoQl5JyUF-5ZLQMou8h4qbkCGGGP831cHSY,2952
|
194
195
|
ultralytics/trackers/__init__.py,sha256=j72IgH2dZHQArMPK4YwcV5ieIw94fYvlGdQjB9cOQKw,227
|
195
196
|
ultralytics/trackers/basetrack.py,sha256=kPOeAX2ihvANtQJk-zUsN0C7JjhlJbx0UhjaCFk_ovQ,4423
|
196
197
|
ultralytics/trackers/bot_sort.py,sha256=766grVQExvonb087Wy-SB32TSwYYsTEM22yoWeQ_EEo,10494
|
@@ -229,9 +230,9 @@ ultralytics/utils/callbacks/neptune.py,sha256=IbGQfEltamUKXJt93uSLQFn8c2rYh3DMTg
|
|
229
230
|
ultralytics/utils/callbacks/raytune.py,sha256=Ck_yFzg7UZXiDWrLHaltjQybzVWSFDfzpdrx9ZYTRfI,700
|
230
231
|
ultralytics/utils/callbacks/tensorboard.py,sha256=SHlE58Fb-sg-uZKtgy-ybIO3SAIfK55aj8kTYGA0Cyg,4167
|
231
232
|
ultralytics/utils/callbacks/wb.py,sha256=sizfTa-xI9k2pnDSP_Q9pHZEFwcl__gSFM0AcneuRpY,7058
|
232
|
-
ultralytics-8.3.
|
233
|
-
ultralytics-8.3.
|
234
|
-
ultralytics-8.3.
|
235
|
-
ultralytics-8.3.
|
236
|
-
ultralytics-8.3.
|
237
|
-
ultralytics-8.3.
|
233
|
+
ultralytics-8.3.40.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
|
234
|
+
ultralytics-8.3.40.dist-info/METADATA,sha256=765LKLYZ8BHcGLWpKO5pQFPka_hilm8fl_96W_xvp2c,35332
|
235
|
+
ultralytics-8.3.40.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
236
|
+
ultralytics-8.3.40.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
|
237
|
+
ultralytics-8.3.40.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
|
238
|
+
ultralytics-8.3.40.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|