ultralytics 8.1.41__py3-none-any.whl → 8.1.42__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.
Potentially problematic release.
This version of ultralytics might be problematic. Click here for more details.
- ultralytics/__init__.py +1 -1
- ultralytics/cfg/models/v9/yolov9c-seg.yaml +38 -0
- ultralytics/cfg/models/v9/yolov9c.yaml +3 -1
- ultralytics/cfg/models/v9/yolov9e-seg.yaml +62 -0
- ultralytics/cfg/models/v9/yolov9e.yaml +3 -1
- ultralytics/engine/trainer.py +10 -9
- ultralytics/solutions/queue_management.py +187 -0
- ultralytics/utils/__init__.py +18 -13
- ultralytics/utils/plotting.py +32 -0
- ultralytics/utils/torch_utils.py +3 -2
- {ultralytics-8.1.41.dist-info → ultralytics-8.1.42.dist-info}/METADATA +2 -1
- {ultralytics-8.1.41.dist-info → ultralytics-8.1.42.dist-info}/RECORD +16 -13
- {ultralytics-8.1.41.dist-info → ultralytics-8.1.42.dist-info}/LICENSE +0 -0
- {ultralytics-8.1.41.dist-info → ultralytics-8.1.42.dist-info}/WHEEL +0 -0
- {ultralytics-8.1.41.dist-info → ultralytics-8.1.42.dist-info}/entry_points.txt +0 -0
- {ultralytics-8.1.41.dist-info → ultralytics-8.1.42.dist-info}/top_level.txt +0 -0
ultralytics/__init__.py
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
|
2
|
+
# YOLOv9c-seg
|
|
3
|
+
# 654 layers, 27897120 parameters, 159.4 GFLOPs
|
|
4
|
+
|
|
5
|
+
# parameters
|
|
6
|
+
nc: 80 # number of classes
|
|
7
|
+
|
|
8
|
+
# gelan backbone
|
|
9
|
+
backbone:
|
|
10
|
+
- [-1, 1, Conv, [64, 3, 2]] # 0-P1/2
|
|
11
|
+
- [-1, 1, Conv, [128, 3, 2]] # 1-P2/4
|
|
12
|
+
- [-1, 1, RepNCSPELAN4, [256, 128, 64, 1]] # 2
|
|
13
|
+
- [-1, 1, ADown, [256]] # 3-P3/8
|
|
14
|
+
- [-1, 1, RepNCSPELAN4, [512, 256, 128, 1]] # 4
|
|
15
|
+
- [-1, 1, ADown, [512]] # 5-P4/16
|
|
16
|
+
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]] # 6
|
|
17
|
+
- [-1, 1, ADown, [512]] # 7-P5/32
|
|
18
|
+
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]] # 8
|
|
19
|
+
- [-1, 1, SPPELAN, [512, 256]] # 9
|
|
20
|
+
|
|
21
|
+
head:
|
|
22
|
+
- [-1, 1, nn.Upsample, [None, 2, 'nearest']]
|
|
23
|
+
- [[-1, 6], 1, Concat, [1]] # cat backbone P4
|
|
24
|
+
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]] # 12
|
|
25
|
+
|
|
26
|
+
- [-1, 1, nn.Upsample, [None, 2, 'nearest']]
|
|
27
|
+
- [[-1, 4], 1, Concat, [1]] # cat backbone P3
|
|
28
|
+
- [-1, 1, RepNCSPELAN4, [256, 256, 128, 1]] # 15 (P3/8-small)
|
|
29
|
+
|
|
30
|
+
- [-1, 1, ADown, [256]]
|
|
31
|
+
- [[-1, 12], 1, Concat, [1]] # cat head P4
|
|
32
|
+
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]] # 18 (P4/16-medium)
|
|
33
|
+
|
|
34
|
+
- [-1, 1, ADown, [512]]
|
|
35
|
+
- [[-1, 9], 1, Concat, [1]] # cat head P5
|
|
36
|
+
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]] # 21 (P5/32-large)
|
|
37
|
+
|
|
38
|
+
- [[15, 18, 21], 1, Segment, [nc, 32, 256]] # Segment(P3, P4, P5)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
|
2
|
+
# YOLOv9c-seg
|
|
3
|
+
# 1261 layers, 60512800 parameters, 248.4 GFLOPs
|
|
4
|
+
|
|
5
|
+
# parameters
|
|
6
|
+
nc: 80 # number of classes
|
|
7
|
+
|
|
8
|
+
# gelan backbone
|
|
9
|
+
backbone:
|
|
10
|
+
- [-1, 1, Silence, []]
|
|
11
|
+
- [-1, 1, Conv, [64, 3, 2]] # 1-P1/2
|
|
12
|
+
- [-1, 1, Conv, [128, 3, 2]] # 2-P2/4
|
|
13
|
+
- [-1, 1, RepNCSPELAN4, [256, 128, 64, 2]] # 3
|
|
14
|
+
- [-1, 1, ADown, [256]] # 4-P3/8
|
|
15
|
+
- [-1, 1, RepNCSPELAN4, [512, 256, 128, 2]] # 5
|
|
16
|
+
- [-1, 1, ADown, [512]] # 6-P4/16
|
|
17
|
+
- [-1, 1, RepNCSPELAN4, [1024, 512, 256, 2]] # 7
|
|
18
|
+
- [-1, 1, ADown, [1024]] # 8-P5/32
|
|
19
|
+
- [-1, 1, RepNCSPELAN4, [1024, 512, 256, 2]] # 9
|
|
20
|
+
|
|
21
|
+
- [1, 1, CBLinear, [[64]]] # 10
|
|
22
|
+
- [3, 1, CBLinear, [[64, 128]]] # 11
|
|
23
|
+
- [5, 1, CBLinear, [[64, 128, 256]]] # 12
|
|
24
|
+
- [7, 1, CBLinear, [[64, 128, 256, 512]]] # 13
|
|
25
|
+
- [9, 1, CBLinear, [[64, 128, 256, 512, 1024]]] # 14
|
|
26
|
+
|
|
27
|
+
- [0, 1, Conv, [64, 3, 2]] # 15-P1/2
|
|
28
|
+
- [[10, 11, 12, 13, 14, -1], 1, CBFuse, [[0, 0, 0, 0, 0]]] # 16
|
|
29
|
+
- [-1, 1, Conv, [128, 3, 2]] # 17-P2/4
|
|
30
|
+
- [[11, 12, 13, 14, -1], 1, CBFuse, [[1, 1, 1, 1]]] # 18
|
|
31
|
+
- [-1, 1, RepNCSPELAN4, [256, 128, 64, 2]] # 19
|
|
32
|
+
- [-1, 1, ADown, [256]] # 20-P3/8
|
|
33
|
+
- [[12, 13, 14, -1], 1, CBFuse, [[2, 2, 2]]] # 21
|
|
34
|
+
- [-1, 1, RepNCSPELAN4, [512, 256, 128, 2]] # 22
|
|
35
|
+
- [-1, 1, ADown, [512]] # 23-P4/16
|
|
36
|
+
- [[13, 14, -1], 1, CBFuse, [[3, 3]]] # 24
|
|
37
|
+
- [-1, 1, RepNCSPELAN4, [1024, 512, 256, 2]] # 25
|
|
38
|
+
- [-1, 1, ADown, [1024]] # 26-P5/32
|
|
39
|
+
- [[14, -1], 1, CBFuse, [[4]]] # 27
|
|
40
|
+
- [-1, 1, RepNCSPELAN4, [1024, 512, 256, 2]] # 28
|
|
41
|
+
- [-1, 1, SPPELAN, [512, 256]] # 29
|
|
42
|
+
|
|
43
|
+
# gelan head
|
|
44
|
+
head:
|
|
45
|
+
- [-1, 1, nn.Upsample, [None, 2, 'nearest']]
|
|
46
|
+
- [[-1, 25], 1, Concat, [1]] # cat backbone P4
|
|
47
|
+
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 2]] # 32
|
|
48
|
+
|
|
49
|
+
- [-1, 1, nn.Upsample, [None, 2, 'nearest']]
|
|
50
|
+
- [[-1, 22], 1, Concat, [1]] # cat backbone P3
|
|
51
|
+
- [-1, 1, RepNCSPELAN4, [256, 256, 128, 2]] # 35 (P3/8-small)
|
|
52
|
+
|
|
53
|
+
- [-1, 1, ADown, [256]]
|
|
54
|
+
- [[-1, 32], 1, Concat, [1]] # cat head P4
|
|
55
|
+
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 2]] # 38 (P4/16-medium)
|
|
56
|
+
|
|
57
|
+
- [-1, 1, ADown, [512]]
|
|
58
|
+
- [[-1, 29], 1, Concat, [1]] # cat head P5
|
|
59
|
+
- [-1, 1, RepNCSPELAN4, [512, 1024, 512, 2]] # 41 (P5/32-large)
|
|
60
|
+
|
|
61
|
+
# segment
|
|
62
|
+
- [[35, 38, 41], 1, Segment, [nc, 32, 256]] # Segment (P3, P4, P5)
|
ultralytics/engine/trainer.py
CHANGED
|
@@ -331,6 +331,10 @@ class BaseTrainer:
|
|
|
331
331
|
while True:
|
|
332
332
|
self.epoch = epoch
|
|
333
333
|
self.run_callbacks("on_train_epoch_start")
|
|
334
|
+
with warnings.catch_warnings():
|
|
335
|
+
warnings.simplefilter("ignore") # suppress 'Detected lr_scheduler.step() before optimizer.step()'
|
|
336
|
+
self.scheduler.step()
|
|
337
|
+
|
|
334
338
|
self.model.train()
|
|
335
339
|
if RANK != -1:
|
|
336
340
|
self.train_loader.sampler.set_epoch(epoch)
|
|
@@ -426,15 +430,12 @@ class BaseTrainer:
|
|
|
426
430
|
t = time.time()
|
|
427
431
|
self.epoch_time = t - self.epoch_time_start
|
|
428
432
|
self.epoch_time_start = t
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
self.scheduler.last_epoch = self.epoch # do not move
|
|
436
|
-
self.stop |= epoch >= self.epochs # stop if exceeded epochs
|
|
437
|
-
self.scheduler.step()
|
|
433
|
+
if self.args.time:
|
|
434
|
+
mean_epoch_time = (t - self.train_time_start) / (epoch - self.start_epoch + 1)
|
|
435
|
+
self.epochs = self.args.epochs = math.ceil(self.args.time * 3600 / mean_epoch_time)
|
|
436
|
+
self._setup_scheduler()
|
|
437
|
+
self.scheduler.last_epoch = self.epoch # do not move
|
|
438
|
+
self.stop |= epoch >= self.epochs # stop if exceeded epochs
|
|
438
439
|
self.run_callbacks("on_fit_epoch_end")
|
|
439
440
|
torch.cuda.empty_cache() # clear GPU memory at end of epoch, may help reduce CUDA out of memory errors
|
|
440
441
|
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
|
2
|
+
|
|
3
|
+
from collections import defaultdict
|
|
4
|
+
|
|
5
|
+
import cv2
|
|
6
|
+
|
|
7
|
+
from ultralytics.utils.checks import check_imshow, check_requirements
|
|
8
|
+
from ultralytics.utils.plotting import Annotator, colors
|
|
9
|
+
|
|
10
|
+
check_requirements("shapely>=2.0.0")
|
|
11
|
+
|
|
12
|
+
from shapely.geometry import Point, Polygon
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class QueueManager:
|
|
16
|
+
"""A class to manage the queue management in real-time video stream based on their tracks."""
|
|
17
|
+
|
|
18
|
+
def __init__(self):
|
|
19
|
+
"""Initializes the queue manager with default values for various tracking and counting parameters."""
|
|
20
|
+
|
|
21
|
+
# Mouse events
|
|
22
|
+
self.is_drawing = False
|
|
23
|
+
self.selected_point = None
|
|
24
|
+
|
|
25
|
+
# Region & Line Information
|
|
26
|
+
self.reg_pts = [(20, 60), (20, 680), (1120, 680), (1120, 60)]
|
|
27
|
+
self.counting_region = None
|
|
28
|
+
self.region_color = (255, 0, 255)
|
|
29
|
+
self.region_thickness = 5
|
|
30
|
+
|
|
31
|
+
# Image and annotation Information
|
|
32
|
+
self.im0 = None
|
|
33
|
+
self.tf = None
|
|
34
|
+
self.view_img = False
|
|
35
|
+
self.view_queue_counts = True
|
|
36
|
+
self.fontsize = 0.6
|
|
37
|
+
|
|
38
|
+
self.names = None # Classes names
|
|
39
|
+
self.annotator = None # Annotator
|
|
40
|
+
self.window_name = "Ultralytics YOLOv8 Queue Manager"
|
|
41
|
+
|
|
42
|
+
# Object counting Information
|
|
43
|
+
self.counts = 0
|
|
44
|
+
self.count_txt_color = (255, 255, 255)
|
|
45
|
+
|
|
46
|
+
# Tracks info
|
|
47
|
+
self.track_history = defaultdict(list)
|
|
48
|
+
self.track_thickness = 2
|
|
49
|
+
self.draw_tracks = False
|
|
50
|
+
self.track_color = None
|
|
51
|
+
|
|
52
|
+
# Check if environment support imshow
|
|
53
|
+
self.env_check = check_imshow(warn=True)
|
|
54
|
+
|
|
55
|
+
def set_args(
|
|
56
|
+
self,
|
|
57
|
+
classes_names,
|
|
58
|
+
reg_pts,
|
|
59
|
+
line_thickness=2,
|
|
60
|
+
track_thickness=2,
|
|
61
|
+
view_img=False,
|
|
62
|
+
region_color=(255, 0, 255),
|
|
63
|
+
view_queue_counts=True,
|
|
64
|
+
draw_tracks=False,
|
|
65
|
+
count_txt_color=(255, 255, 255),
|
|
66
|
+
track_color=None,
|
|
67
|
+
region_thickness=5,
|
|
68
|
+
fontsize=0.7,
|
|
69
|
+
):
|
|
70
|
+
"""
|
|
71
|
+
Configures the Counter's image, bounding box line thickness, and counting region points.
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
line_thickness (int): Line thickness for bounding boxes.
|
|
75
|
+
view_img (bool): Flag to control whether to display the video stream.
|
|
76
|
+
view_queue_counts (bool): Flag to control whether to display the counts on video stream.
|
|
77
|
+
reg_pts (list): Initial list of points defining the counting region.
|
|
78
|
+
classes_names (dict): Classes names
|
|
79
|
+
region_color (RGB color): Color of queue region
|
|
80
|
+
track_thickness (int): Track thickness
|
|
81
|
+
draw_tracks (Bool): draw tracks
|
|
82
|
+
count_txt_color (RGB color): count text color value
|
|
83
|
+
track_color (RGB color): color for tracks
|
|
84
|
+
region_thickness (int): Object counting Region thickness
|
|
85
|
+
fontsize (float): Text display font size
|
|
86
|
+
"""
|
|
87
|
+
self.tf = line_thickness
|
|
88
|
+
self.view_img = view_img
|
|
89
|
+
self.view_queue_counts = view_queue_counts
|
|
90
|
+
self.track_thickness = track_thickness
|
|
91
|
+
self.draw_tracks = draw_tracks
|
|
92
|
+
self.region_color = region_color
|
|
93
|
+
|
|
94
|
+
if len(reg_pts) >= 3:
|
|
95
|
+
print("Queue region initiated...")
|
|
96
|
+
self.reg_pts = reg_pts
|
|
97
|
+
self.counting_region = Polygon(self.reg_pts)
|
|
98
|
+
else:
|
|
99
|
+
print("Invalid region points provided...")
|
|
100
|
+
print("Using default region now....")
|
|
101
|
+
self.counting_region = Polygon(self.reg_pts)
|
|
102
|
+
|
|
103
|
+
self.names = classes_names
|
|
104
|
+
self.track_color = track_color
|
|
105
|
+
self.count_txt_color = count_txt_color
|
|
106
|
+
self.region_thickness = region_thickness
|
|
107
|
+
self.fontsize = fontsize
|
|
108
|
+
|
|
109
|
+
def extract_and_process_tracks(self, tracks):
|
|
110
|
+
"""Extracts and processes tracks for queue management in a video stream."""
|
|
111
|
+
|
|
112
|
+
# Annotator Init and queue region drawing
|
|
113
|
+
self.annotator = Annotator(self.im0, self.tf, self.names)
|
|
114
|
+
|
|
115
|
+
if tracks[0].boxes.id is not None:
|
|
116
|
+
boxes = tracks[0].boxes.xyxy.cpu()
|
|
117
|
+
clss = tracks[0].boxes.cls.cpu().tolist()
|
|
118
|
+
track_ids = tracks[0].boxes.id.int().cpu().tolist()
|
|
119
|
+
|
|
120
|
+
# Extract tracks
|
|
121
|
+
for box, track_id, cls in zip(boxes, track_ids, clss):
|
|
122
|
+
# Draw bounding box
|
|
123
|
+
self.annotator.box_label(box, label=f"{self.names[cls]}#{track_id}", color=colors(int(track_id), True))
|
|
124
|
+
|
|
125
|
+
# Draw Tracks
|
|
126
|
+
track_line = self.track_history[track_id]
|
|
127
|
+
track_line.append((float((box[0] + box[2]) / 2), float((box[1] + box[3]) / 2)))
|
|
128
|
+
if len(track_line) > 30:
|
|
129
|
+
track_line.pop(0)
|
|
130
|
+
|
|
131
|
+
# Draw track trails
|
|
132
|
+
if self.draw_tracks:
|
|
133
|
+
self.annotator.draw_centroid_and_tracks(
|
|
134
|
+
track_line,
|
|
135
|
+
color=self.track_color if self.track_color else colors(int(track_id), True),
|
|
136
|
+
track_thickness=self.track_thickness,
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
prev_position = self.track_history[track_id][-2] if len(self.track_history[track_id]) > 1 else None
|
|
140
|
+
|
|
141
|
+
if len(self.reg_pts) >= 3:
|
|
142
|
+
is_inside = self.counting_region.contains(Point(track_line[-1]))
|
|
143
|
+
if prev_position is not None and is_inside:
|
|
144
|
+
self.counts += 1
|
|
145
|
+
|
|
146
|
+
label = "Queue Counts : " + str(self.counts)
|
|
147
|
+
|
|
148
|
+
if label is not None:
|
|
149
|
+
self.annotator.queue_counts_display(
|
|
150
|
+
label,
|
|
151
|
+
points=self.reg_pts,
|
|
152
|
+
region_color=self.region_color,
|
|
153
|
+
txt_color=self.count_txt_color,
|
|
154
|
+
fontsize=self.fontsize,
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
self.counts = 0
|
|
158
|
+
self.display_frames()
|
|
159
|
+
|
|
160
|
+
def display_frames(self):
|
|
161
|
+
"""Display frame."""
|
|
162
|
+
if self.env_check:
|
|
163
|
+
self.annotator.draw_region(reg_pts=self.reg_pts, thickness=self.region_thickness, color=self.region_color)
|
|
164
|
+
cv2.namedWindow(self.window_name)
|
|
165
|
+
cv2.imshow(self.window_name, self.im0)
|
|
166
|
+
# Break Window
|
|
167
|
+
if cv2.waitKey(1) & 0xFF == ord("q"):
|
|
168
|
+
return
|
|
169
|
+
|
|
170
|
+
def process_queue(self, im0, tracks):
|
|
171
|
+
"""
|
|
172
|
+
Main function to start the queue management process.
|
|
173
|
+
|
|
174
|
+
Args:
|
|
175
|
+
im0 (ndarray): Current frame from the video stream.
|
|
176
|
+
tracks (list): List of tracks obtained from the object tracking process.
|
|
177
|
+
"""
|
|
178
|
+
self.im0 = im0 # store image
|
|
179
|
+
self.extract_and_process_tracks(tracks) # draw region even if no objects
|
|
180
|
+
|
|
181
|
+
if self.view_img:
|
|
182
|
+
self.display_frames()
|
|
183
|
+
return self.im0
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
if __name__ == "__main__":
|
|
187
|
+
QueueManager()
|
ultralytics/utils/__init__.py
CHANGED
|
@@ -230,37 +230,42 @@ def plt_settings(rcparams=None, backend="Agg"):
|
|
|
230
230
|
return decorator
|
|
231
231
|
|
|
232
232
|
|
|
233
|
-
def set_logging(name=LOGGING_NAME, verbose=True):
|
|
234
|
-
"""Sets up logging for the given name with UTF-8 encoding support
|
|
233
|
+
def set_logging(name="LOGGING_NAME", verbose=True):
|
|
234
|
+
"""Sets up logging for the given name with UTF-8 encoding support, ensuring compatibility across different
|
|
235
|
+
environments.
|
|
236
|
+
"""
|
|
235
237
|
level = logging.INFO if verbose and RANK in {-1, 0} else logging.ERROR # rank in world for Multi-GPU trainings
|
|
236
238
|
|
|
237
|
-
# Configure the console (stdout) encoding to UTF-8
|
|
239
|
+
# Configure the console (stdout) encoding to UTF-8, with checks for compatibility
|
|
238
240
|
formatter = logging.Formatter("%(message)s") # Default formatter
|
|
239
|
-
if WINDOWS and sys.stdout.encoding != "utf-8":
|
|
241
|
+
if WINDOWS and hasattr(sys.stdout, "encoding") and sys.stdout.encoding != "utf-8":
|
|
242
|
+
|
|
243
|
+
class CustomFormatter(logging.Formatter):
|
|
244
|
+
def format(self, record):
|
|
245
|
+
"""Sets up logging with UTF-8 encoding and configurable verbosity."""
|
|
246
|
+
return emojis(super().format(record))
|
|
247
|
+
|
|
240
248
|
try:
|
|
249
|
+
# Attempt to reconfigure stdout to use UTF-8 encoding if possible
|
|
241
250
|
if hasattr(sys.stdout, "reconfigure"):
|
|
242
251
|
sys.stdout.reconfigure(encoding="utf-8")
|
|
252
|
+
# For environments where reconfigure is not available, wrap stdout in a TextIOWrapper
|
|
243
253
|
elif hasattr(sys.stdout, "buffer"):
|
|
244
254
|
import io
|
|
245
255
|
|
|
246
256
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
|
|
247
257
|
else:
|
|
248
|
-
|
|
258
|
+
formatter = CustomFormatter("%(message)s")
|
|
249
259
|
except Exception as e:
|
|
250
260
|
print(f"Creating custom formatter for non UTF-8 environments due to {e}")
|
|
261
|
+
formatter = CustomFormatter("%(message)s")
|
|
251
262
|
|
|
252
|
-
|
|
253
|
-
def format(self, record):
|
|
254
|
-
"""Sets up logging with UTF-8 encoding and configurable verbosity."""
|
|
255
|
-
return emojis(super().format(record))
|
|
256
|
-
|
|
257
|
-
formatter = CustomFormatter("%(message)s") # Use CustomFormatter to eliminate UTF-8 output as last recourse
|
|
258
|
-
|
|
259
|
-
# Create and configure the StreamHandler
|
|
263
|
+
# Create and configure the StreamHandler with the appropriate formatter and level
|
|
260
264
|
stream_handler = logging.StreamHandler(sys.stdout)
|
|
261
265
|
stream_handler.setFormatter(formatter)
|
|
262
266
|
stream_handler.setLevel(level)
|
|
263
267
|
|
|
268
|
+
# Set up the logger
|
|
264
269
|
logger = logging.getLogger(name)
|
|
265
270
|
logger.setLevel(level)
|
|
266
271
|
logger.addHandler(stream_handler)
|
ultralytics/utils/plotting.py
CHANGED
|
@@ -363,6 +363,38 @@ class Annotator:
|
|
|
363
363
|
cv2.polylines(self.im, [points], isClosed=False, color=color, thickness=track_thickness)
|
|
364
364
|
cv2.circle(self.im, (int(track[-1][0]), int(track[-1][1])), track_thickness * 2, color, -1)
|
|
365
365
|
|
|
366
|
+
def queue_counts_display(self, label, points=None, region_color=(255, 255, 255), txt_color=(0, 0, 0), fontsize=0.7):
|
|
367
|
+
"""Displays queue counts on an image centered at the points with customizable font size and colors."""
|
|
368
|
+
x_values = [point[0] for point in points]
|
|
369
|
+
y_values = [point[1] for point in points]
|
|
370
|
+
center_x = sum(x_values) // len(points)
|
|
371
|
+
center_y = sum(y_values) // len(points)
|
|
372
|
+
|
|
373
|
+
text_size = cv2.getTextSize(label, cv2.FONT_HERSHEY_SIMPLEX, fontScale=fontsize, thickness=self.tf)[0]
|
|
374
|
+
text_width = text_size[0]
|
|
375
|
+
text_height = text_size[1]
|
|
376
|
+
|
|
377
|
+
rect_width = text_width + 20
|
|
378
|
+
rect_height = text_height + 20
|
|
379
|
+
rect_top_left = (center_x - rect_width // 2, center_y - rect_height // 2)
|
|
380
|
+
rect_bottom_right = (center_x + rect_width // 2, center_y + rect_height // 2)
|
|
381
|
+
cv2.rectangle(self.im, rect_top_left, rect_bottom_right, region_color, -1)
|
|
382
|
+
|
|
383
|
+
text_x = center_x - text_width // 2
|
|
384
|
+
text_y = center_y + text_height // 2
|
|
385
|
+
|
|
386
|
+
# Draw text
|
|
387
|
+
cv2.putText(
|
|
388
|
+
self.im,
|
|
389
|
+
label,
|
|
390
|
+
(text_x, text_y),
|
|
391
|
+
cv2.FONT_HERSHEY_SIMPLEX,
|
|
392
|
+
fontScale=fontsize,
|
|
393
|
+
color=txt_color,
|
|
394
|
+
thickness=self.tf,
|
|
395
|
+
lineType=cv2.LINE_AA,
|
|
396
|
+
)
|
|
397
|
+
|
|
366
398
|
def display_counts(
|
|
367
399
|
self, counts=None, tf=2, fontScale=0.6, line_color=(0, 0, 0), txt_color=(255, 255, 255), classwise_txtgap=55
|
|
368
400
|
):
|
ultralytics/utils/torch_utils.py
CHANGED
|
@@ -16,7 +16,7 @@ import torch.nn as nn
|
|
|
16
16
|
import torch.nn.functional as F
|
|
17
17
|
import torchvision
|
|
18
18
|
|
|
19
|
-
from ultralytics.utils import DEFAULT_CFG_DICT, DEFAULT_CFG_KEYS, LOGGER, __version__
|
|
19
|
+
from ultralytics.utils import DEFAULT_CFG_DICT, DEFAULT_CFG_KEYS, LOGGER, colorstr, __version__
|
|
20
20
|
from ultralytics.utils.checks import PYTHON_VERSION, check_version
|
|
21
21
|
|
|
22
22
|
try:
|
|
@@ -614,8 +614,9 @@ class EarlyStopping:
|
|
|
614
614
|
self.possible_stop = delta >= (self.patience - 1) # possible stop may occur next epoch
|
|
615
615
|
stop = delta >= self.patience # stop training if patience exceeded
|
|
616
616
|
if stop:
|
|
617
|
+
prefix = colorstr("EarlyStopping: ")
|
|
617
618
|
LOGGER.info(
|
|
618
|
-
f"
|
|
619
|
+
f"{prefix}Training stopped early as no improvement observed in last {self.patience} epochs. "
|
|
619
620
|
f"Best results observed at epoch {self.best_epoch}, best model saved as best.pt.\n"
|
|
620
621
|
f"To update EarlyStopping(patience={self.patience}) pass a new patience value, "
|
|
621
622
|
f"i.e. `patience=300` or use `patience=0` to disable EarlyStopping."
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ultralytics
|
|
3
|
-
Version: 8.1.
|
|
3
|
+
Version: 8.1.42
|
|
4
4
|
Summary: Ultralytics YOLOv8 for SOTA object detection, multi-object tracking, instance segmentation, pose estimation and image classification.
|
|
5
5
|
Author: Glenn Jocher, Ayush Chaurasia, Jing Qiu
|
|
6
6
|
Maintainer: Glenn Jocher, Ayush Chaurasia, Jing Qiu
|
|
@@ -63,6 +63,7 @@ Requires-Dist: streamlit ; extra == 'explorer'
|
|
|
63
63
|
Provides-Extra: export
|
|
64
64
|
Requires-Dist: onnx >=1.12.0 ; extra == 'export'
|
|
65
65
|
Requires-Dist: openvino >=2024.0.0 ; extra == 'export'
|
|
66
|
+
Requires-Dist: numpy ==1.23.5 ; (platform_machine == "aarch64") and extra == 'export'
|
|
66
67
|
Requires-Dist: coremltools >=7.0 ; (platform_system != "Windows" and python_version <= "3.11") and extra == 'export'
|
|
67
68
|
Requires-Dist: tensorflow <=2.13.1 ; (python_version <= "3.11") and extra == 'export'
|
|
68
69
|
Requires-Dist: tensorflowjs >=3.9.0 ; (python_version <= "3.11") and extra == 'export'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
ultralytics/__init__.py,sha256=
|
|
1
|
+
ultralytics/__init__.py,sha256=EPb0QNtYwzUrjlZwrq8Xr5ATiPKXHZv2VRZiKU4XPmA,625
|
|
2
2
|
ultralytics/assets/bus.jpg,sha256=wCAZxJecGR63Od3ZRERe9Aja1Weayrb9Ug751DS_vGM,137419
|
|
3
3
|
ultralytics/assets/zidane.jpg,sha256=Ftc4aeMmen1O0A3o6GCDO9FlfBslLpTAw0gnetx7bts,50427
|
|
4
4
|
ultralytics/cfg/__init__.py,sha256=ugSQqHCg31bAE9rwhVrnLMNzKLShr9JxDFcN6kBTbUk,21316
|
|
@@ -56,8 +56,10 @@ ultralytics/cfg/models/v8/yolov8-seg.yaml,sha256=fN85m_aDMCH4oTJ3z-ft98Pdh6dk0pZ
|
|
|
56
56
|
ultralytics/cfg/models/v8/yolov8-world.yaml,sha256=RXTp_tgix8dbnVHprapxiK2aax7M2qIfmuR-aAve4sU,2019
|
|
57
57
|
ultralytics/cfg/models/v8/yolov8-worldv2.yaml,sha256=fvGVUxvlBOjN6LUiiaiGsnjK5ZKjwYGWxgkJ49hGmMg,1956
|
|
58
58
|
ultralytics/cfg/models/v8/yolov8.yaml,sha256=VjSe_V2Gn9ZpJrwTtz0A6_6IMp6UuugNiR7aEShR5rc,1889
|
|
59
|
-
ultralytics/cfg/models/v9/yolov9c.yaml,sha256=
|
|
60
|
-
ultralytics/cfg/models/v9/
|
|
59
|
+
ultralytics/cfg/models/v9/yolov9c-seg.yaml,sha256=Q0FnO3-ff-JepwP9gY51dhXiN8CMiyJLWjeEIWNhiuQ,1270
|
|
60
|
+
ultralytics/cfg/models/v9/yolov9c.yaml,sha256=04C3zUJK56X727s3mKDtZCw4b4hM6Tcq8Qq_2w0pIBg,1257
|
|
61
|
+
ultralytics/cfg/models/v9/yolov9e-seg.yaml,sha256=J137yzM0OWtF0CV39IG7RaIWrlT44MT7KwfdnPKkBcU,2230
|
|
62
|
+
ultralytics/cfg/models/v9/yolov9e.yaml,sha256=glFAVjWU1iz440LjRTXLfoeq9O4mPfT0U6U67HN-KYU,2213
|
|
61
63
|
ultralytics/cfg/trackers/botsort.yaml,sha256=YrPmj18p1UU40kJH5NRdL_4S8f7knggkk_q2KYnVudo,883
|
|
62
64
|
ultralytics/cfg/trackers/bytetrack.yaml,sha256=QvHmtuwulK4X6j3T5VEqtCm0sbWWBUVmWPcCcM20qe0,688
|
|
63
65
|
ultralytics/data/__init__.py,sha256=bGJ8oEBheIj8tQ2q3d7JqiVJUT4Ft9lXkDXOvBUj6Q0,637
|
|
@@ -80,7 +82,7 @@ ultralytics/engine/exporter.py,sha256=ZQNF6SUj0NlgUCr9Tbj2TQJxLrgEJJPfdyo4LtL_WJ
|
|
|
80
82
|
ultralytics/engine/model.py,sha256=tCU9z_cQhdJTwUUce3a7rSeCWkUgJO4RfHNT29pB41E,39829
|
|
81
83
|
ultralytics/engine/predictor.py,sha256=wQRKdWGDTP5A6CS0gTC6U3RPDMhP3QkEzWSPm6eqCkU,17022
|
|
82
84
|
ultralytics/engine/results.py,sha256=MvrOBrBlRF7kbL-QwysMf9mIDy_lwQBTTYvy1x1FMME,30667
|
|
83
|
-
ultralytics/engine/trainer.py,sha256=
|
|
85
|
+
ultralytics/engine/trainer.py,sha256=GK3nxCrwdxhrfBdGfavCRirSPX8xrga90VwOBPzI4lQ,34919
|
|
84
86
|
ultralytics/engine/tuner.py,sha256=zttHrQkvXuUVTB7jmM4Z85GgIsQ2hjpW9YrMccrQ4wo,11829
|
|
85
87
|
ultralytics/engine/validator.py,sha256=p0irfLSZa3-0TtcuGheI8kNbzPUqs_UM3TMK4VRUGK4,14645
|
|
86
88
|
ultralytics/hub/__init__.py,sha256=U4j-2QPdwSDlxw6RgFYnnJXOoIzLtwke4TkY2A8q4ws,5068
|
|
@@ -156,6 +158,7 @@ ultralytics/solutions/ai_gym.py,sha256=IZHpvmNyEQT_aqMTrA5sIjCsl3_5Zl2WG31HxGT6K
|
|
|
156
158
|
ultralytics/solutions/distance_calculation.py,sha256=N1QB5uDG_6sp8jD5uSwp_NTPmyP4UCqJm9G2lNrgpr8,6334
|
|
157
159
|
ultralytics/solutions/heatmap.py,sha256=PjRI0PRhPwO1RE-NSDXlbvgCXTnGtD-HvI0HMKwUOkE,12902
|
|
158
160
|
ultralytics/solutions/object_counter.py,sha256=LOExuFduOKJcs94pWpv27jgLAZJxHDsmxouXKVBS10s,12058
|
|
161
|
+
ultralytics/solutions/queue_management.py,sha256=TBQ2dIKYtymBjhdw0Enxa22KHyH3IdXf2C-1Se21siA,6684
|
|
159
162
|
ultralytics/solutions/speed_estimation.py,sha256=lvaU-F8f3V4KFVKFaNS7isIdYtMSFjh_zF9gl0Mals8,6714
|
|
160
163
|
ultralytics/trackers/__init__.py,sha256=j72IgH2dZHQArMPK4YwcV5ieIw94fYvlGdQjB9cOQKw,227
|
|
161
164
|
ultralytics/trackers/basetrack.py,sha256=-vBDD-Q9lsxfTMK2w9kuqWGrYbRMmaBCCEbGGyR53gE,3675
|
|
@@ -166,7 +169,7 @@ ultralytics/trackers/utils/__init__.py,sha256=mHtJuK4hwF8cuV-VHDc7tp6u6D1gHz2Z7J
|
|
|
166
169
|
ultralytics/trackers/utils/gmc.py,sha256=vwcPA1n5zjPaBGhCDt8ItN7rq_6Sczsjn4gsXJfRylU,13688
|
|
167
170
|
ultralytics/trackers/utils/kalman_filter.py,sha256=JN1sAcfJZy8fTZxc8w3jUJnGQDKtgAL__p4nTR6RM2I,15168
|
|
168
171
|
ultralytics/trackers/utils/matching.py,sha256=c_pthBfu9sWeMVYe-dSecdWcQxUey-mQT2yMVsFH3VQ,5404
|
|
169
|
-
ultralytics/utils/__init__.py,sha256=
|
|
172
|
+
ultralytics/utils/__init__.py,sha256=8UoUCD7TM5EBFv2_fMsfYyYTc_2HBFGsMWcJ1CYRJHo,37843
|
|
170
173
|
ultralytics/utils/autobatch.py,sha256=ygZ3f2ByIkcujB89ENcTnGWWnAQw5Pbg6nBuShg-5t4,3863
|
|
171
174
|
ultralytics/utils/benchmarks.py,sha256=fpNWdrty1ULKP3jHFrRNln_o9gIT03F4KOE5xPuy0WI,18285
|
|
172
175
|
ultralytics/utils/checks.py,sha256=OtBD-U90qsiYGSti7xq2LlhjbtgKbye05fJ4cgCst7s,28030
|
|
@@ -179,9 +182,9 @@ ultralytics/utils/loss.py,sha256=lOFBx-lKn-aGHUIPTb1NQefXiNot07egNx7qKErChpU,327
|
|
|
179
182
|
ultralytics/utils/metrics.py,sha256=xKcQFjkrOpA5JtlC9K9F3BF40h09ejC8w0jKSbR3gCE,53473
|
|
180
183
|
ultralytics/utils/ops.py,sha256=GFe_tx8MVKT56xelbAuQjiJ28ohpzARpD6BzGyJ1yMk,33264
|
|
181
184
|
ultralytics/utils/patches.py,sha256=SgMqeMsq2K6JoBJP1NplXMl9C6rK0JeJUChjBrJOneo,2750
|
|
182
|
-
ultralytics/utils/plotting.py,sha256=
|
|
185
|
+
ultralytics/utils/plotting.py,sha256=pEhojZYbmonNSJBRKcbIKYSvxpz4TueKDBAx1nxQIbg,46391
|
|
183
186
|
ultralytics/utils/tal.py,sha256=xuIyryUjaaYHkHPG9GvBwh1xxN2Hq4y3hXOtuERehwY,16017
|
|
184
|
-
ultralytics/utils/torch_utils.py,sha256=
|
|
187
|
+
ultralytics/utils/torch_utils.py,sha256=15YL3IlZq4AevlK06zA-6FRIrRnxGtQo4Uh-GyGInm8,25825
|
|
185
188
|
ultralytics/utils/triton.py,sha256=gg1finxno_tY2Ge9PMhmu7PI9wvoFZoiicdT4Bhqv3w,3936
|
|
186
189
|
ultralytics/utils/tuner.py,sha256=JhvBp6haKA6eqpNPpGJzzjjCmPxBx5phk9kHmt_jppw,6171
|
|
187
190
|
ultralytics/utils/callbacks/__init__.py,sha256=YrWqC3BVVaTLob4iCPR6I36mUxIUOpPJW7B_LjT78Qw,214
|
|
@@ -195,9 +198,9 @@ ultralytics/utils/callbacks/neptune.py,sha256=5Z3ua5YBTUS56FH8VQKQG1aaIo9fH8GEyz
|
|
|
195
198
|
ultralytics/utils/callbacks/raytune.py,sha256=ODVYzy-CoM4Uge0zjkh3Hnh9nF2M0vhDrSenXnvcizw,705
|
|
196
199
|
ultralytics/utils/callbacks/tensorboard.py,sha256=hRmWjbqdA4RNaLuSZznuDcpOBW-_-_Ga0u-B8UU-7ZI,4134
|
|
197
200
|
ultralytics/utils/callbacks/wb.py,sha256=4QI81nHdzgwhXHlmTiRxLqunvkKakLXYUhHTUY1ZeHA,6635
|
|
198
|
-
ultralytics-8.1.
|
|
199
|
-
ultralytics-8.1.
|
|
200
|
-
ultralytics-8.1.
|
|
201
|
-
ultralytics-8.1.
|
|
202
|
-
ultralytics-8.1.
|
|
203
|
-
ultralytics-8.1.
|
|
201
|
+
ultralytics-8.1.42.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
|
|
202
|
+
ultralytics-8.1.42.dist-info/METADATA,sha256=NGLjPKhGssa9W0-gEQyo9lBmQNq54fImPzIy_YTtos8,40416
|
|
203
|
+
ultralytics-8.1.42.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
204
|
+
ultralytics-8.1.42.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
|
|
205
|
+
ultralytics-8.1.42.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
|
|
206
|
+
ultralytics-8.1.42.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|