dgenerate-ultralytics-headless 8.3.162__py3-none-any.whl → 8.3.165__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.
Files changed (49) hide show
  1. {dgenerate_ultralytics_headless-8.3.162.dist-info → dgenerate_ultralytics_headless-8.3.165.dist-info}/METADATA +1 -1
  2. {dgenerate_ultralytics_headless-8.3.162.dist-info → dgenerate_ultralytics_headless-8.3.165.dist-info}/RECORD +49 -49
  3. ultralytics/__init__.py +1 -1
  4. ultralytics/cfg/datasets/HomeObjects-3K.yaml +2 -3
  5. ultralytics/cfg/datasets/african-wildlife.yaml +3 -3
  6. ultralytics/cfg/datasets/brain-tumor.yaml +3 -4
  7. ultralytics/cfg/datasets/carparts-seg.yaml +4 -4
  8. ultralytics/cfg/datasets/crack-seg.yaml +4 -4
  9. ultralytics/cfg/datasets/dog-pose.yaml +2 -2
  10. ultralytics/cfg/datasets/hand-keypoints.yaml +2 -2
  11. ultralytics/cfg/datasets/medical-pills.yaml +2 -3
  12. ultralytics/cfg/datasets/package-seg.yaml +4 -4
  13. ultralytics/cfg/datasets/signature.yaml +3 -3
  14. ultralytics/cfg/datasets/tiger-pose.yaml +3 -3
  15. ultralytics/data/augment.py +182 -153
  16. ultralytics/data/build.py +23 -3
  17. ultralytics/data/dataset.py +6 -2
  18. ultralytics/data/loaders.py +2 -2
  19. ultralytics/data/utils.py +12 -9
  20. ultralytics/engine/exporter.py +9 -5
  21. ultralytics/engine/predictor.py +6 -6
  22. ultralytics/engine/results.py +42 -42
  23. ultralytics/models/fastsam/model.py +1 -1
  24. ultralytics/models/fastsam/predict.py +1 -1
  25. ultralytics/models/sam/model.py +4 -4
  26. ultralytics/models/sam/modules/blocks.py +5 -5
  27. ultralytics/models/sam/modules/memory_attention.py +19 -19
  28. ultralytics/models/sam/modules/transformer.py +24 -22
  29. ultralytics/models/yolo/detect/val.py +2 -2
  30. ultralytics/models/yolo/world/train_world.py +9 -1
  31. ultralytics/nn/tasks.py +2 -0
  32. ultralytics/solutions/distance_calculation.py +1 -1
  33. ultralytics/solutions/instance_segmentation.py +2 -2
  34. ultralytics/solutions/object_blurrer.py +2 -2
  35. ultralytics/solutions/object_counter.py +2 -2
  36. ultralytics/solutions/object_cropper.py +1 -1
  37. ultralytics/solutions/queue_management.py +1 -1
  38. ultralytics/solutions/region_counter.py +29 -32
  39. ultralytics/solutions/security_alarm.py +2 -2
  40. ultralytics/solutions/templates/similarity-search.html +0 -24
  41. ultralytics/solutions/vision_eye.py +1 -1
  42. ultralytics/utils/benchmarks.py +2 -2
  43. ultralytics/utils/export.py +0 -2
  44. ultralytics/utils/instance.py +32 -25
  45. ultralytics/utils/ops.py +8 -8
  46. {dgenerate_ultralytics_headless-8.3.162.dist-info → dgenerate_ultralytics_headless-8.3.165.dist-info}/WHEEL +0 -0
  47. {dgenerate_ultralytics_headless-8.3.162.dist-info → dgenerate_ultralytics_headless-8.3.165.dist-info}/entry_points.txt +0 -0
  48. {dgenerate_ultralytics_headless-8.3.162.dist-info → dgenerate_ultralytics_headless-8.3.165.dist-info}/licenses/LICENSE +0 -0
  49. {dgenerate_ultralytics_headless-8.3.162.dist-info → dgenerate_ultralytics_headless-8.3.165.dist-info}/top_level.txt +0 -0
@@ -3,7 +3,7 @@
3
3
  from collections import abc
4
4
  from itertools import repeat
5
5
  from numbers import Number
6
- from typing import List
6
+ from typing import List, Union
7
7
 
8
8
  import numpy as np
9
9
 
@@ -59,7 +59,7 @@ class Bboxes:
59
59
  This class does not handle normalization or denormalization of bounding boxes.
60
60
  """
61
61
 
62
- def __init__(self, bboxes, format="xyxy") -> None:
62
+ def __init__(self, bboxes: np.ndarray, format: str = "xyxy") -> None:
63
63
  """
64
64
  Initialize the Bboxes class with bounding box data in a specified format.
65
65
 
@@ -74,7 +74,7 @@ class Bboxes:
74
74
  self.bboxes = bboxes
75
75
  self.format = format
76
76
 
77
- def convert(self, format):
77
+ def convert(self, format: str) -> None:
78
78
  """
79
79
  Convert bounding box format from one type to another.
80
80
 
@@ -93,7 +93,7 @@ class Bboxes:
93
93
  self.bboxes = func(self.bboxes)
94
94
  self.format = format
95
95
 
96
- def areas(self):
96
+ def areas(self) -> np.ndarray:
97
97
  """Calculate the area of bounding boxes."""
98
98
  return (
99
99
  (self.bboxes[:, 2] - self.bboxes[:, 0]) * (self.bboxes[:, 3] - self.bboxes[:, 1]) # format xyxy
@@ -101,7 +101,7 @@ class Bboxes:
101
101
  else self.bboxes[:, 3] * self.bboxes[:, 2] # format xywh or ltwh
102
102
  )
103
103
 
104
- def mul(self, scale):
104
+ def mul(self, scale: Union[int, tuple, list]) -> None:
105
105
  """
106
106
  Multiply bounding box coordinates by scale factor(s).
107
107
 
@@ -118,7 +118,7 @@ class Bboxes:
118
118
  self.bboxes[:, 2] *= scale[2]
119
119
  self.bboxes[:, 3] *= scale[3]
120
120
 
121
- def add(self, offset):
121
+ def add(self, offset: Union[int, tuple, list]) -> None:
122
122
  """
123
123
  Add offset to bounding box coordinates.
124
124
 
@@ -135,12 +135,12 @@ class Bboxes:
135
135
  self.bboxes[:, 2] += offset[2]
136
136
  self.bboxes[:, 3] += offset[3]
137
137
 
138
- def __len__(self):
138
+ def __len__(self) -> int:
139
139
  """Return the number of bounding boxes."""
140
140
  return len(self.bboxes)
141
141
 
142
142
  @classmethod
143
- def concatenate(cls, boxes_list: List["Bboxes"], axis=0) -> "Bboxes":
143
+ def concatenate(cls, boxes_list: List["Bboxes"], axis: int = 0) -> "Bboxes":
144
144
  """
145
145
  Concatenate a list of Bboxes objects into a single Bboxes object.
146
146
 
@@ -163,7 +163,7 @@ class Bboxes:
163
163
  return boxes_list[0]
164
164
  return cls(np.concatenate([b.bboxes for b in boxes_list], axis=axis))
165
165
 
166
- def __getitem__(self, index) -> "Bboxes":
166
+ def __getitem__(self, index: Union[int, np.ndarray, slice]) -> "Bboxes":
167
167
  """
168
168
  Retrieve a specific bounding box or a set of bounding boxes using indexing.
169
169
 
@@ -220,13 +220,20 @@ class Instances:
220
220
  ... )
221
221
  """
222
222
 
223
- def __init__(self, bboxes, segments=None, keypoints=None, bbox_format="xywh", normalized=True) -> None:
223
+ def __init__(
224
+ self,
225
+ bboxes: np.ndarray,
226
+ segments: np.ndarray = None,
227
+ keypoints: np.ndarray = None,
228
+ bbox_format: str = "xywh",
229
+ normalized: bool = True,
230
+ ) -> None:
224
231
  """
225
232
  Initialize the Instances object with bounding boxes, segments, and keypoints.
226
233
 
227
234
  Args:
228
235
  bboxes (np.ndarray): Bounding boxes with shape (N, 4).
229
- segments (List | np.ndarray, optional): Segmentation masks.
236
+ segments (np.ndarray, optional): Segmentation masks.
230
237
  keypoints (np.ndarray, optional): Keypoints with shape (N, 17, 3) in format (x, y, visible).
231
238
  bbox_format (str): Format of bboxes.
232
239
  normalized (bool): Whether the coordinates are normalized.
@@ -236,7 +243,7 @@ class Instances:
236
243
  self.normalized = normalized
237
244
  self.segments = segments
238
245
 
239
- def convert_bbox(self, format):
246
+ def convert_bbox(self, format: str) -> None:
240
247
  """
241
248
  Convert bounding box format.
242
249
 
@@ -246,11 +253,11 @@ class Instances:
246
253
  self._bboxes.convert(format=format)
247
254
 
248
255
  @property
249
- def bbox_areas(self):
256
+ def bbox_areas(self) -> np.ndarray:
250
257
  """Calculate the area of bounding boxes."""
251
258
  return self._bboxes.areas()
252
259
 
253
- def scale(self, scale_w, scale_h, bbox_only=False):
260
+ def scale(self, scale_w: float, scale_h: float, bbox_only: bool = False):
254
261
  """
255
262
  Scale coordinates by given factors.
256
263
 
@@ -268,7 +275,7 @@ class Instances:
268
275
  self.keypoints[..., 0] *= scale_w
269
276
  self.keypoints[..., 1] *= scale_h
270
277
 
271
- def denormalize(self, w, h):
278
+ def denormalize(self, w: int, h: int) -> None:
272
279
  """
273
280
  Convert normalized coordinates to absolute coordinates.
274
281
 
@@ -286,7 +293,7 @@ class Instances:
286
293
  self.keypoints[..., 1] *= h
287
294
  self.normalized = False
288
295
 
289
- def normalize(self, w, h):
296
+ def normalize(self, w: int, h: int) -> None:
290
297
  """
291
298
  Convert absolute coordinates to normalized coordinates.
292
299
 
@@ -304,7 +311,7 @@ class Instances:
304
311
  self.keypoints[..., 1] /= h
305
312
  self.normalized = True
306
313
 
307
- def add_padding(self, padw, padh):
314
+ def add_padding(self, padw: int, padh: int) -> None:
308
315
  """
309
316
  Add padding to coordinates.
310
317
 
@@ -320,7 +327,7 @@ class Instances:
320
327
  self.keypoints[..., 0] += padw
321
328
  self.keypoints[..., 1] += padh
322
329
 
323
- def __getitem__(self, index) -> "Instances":
330
+ def __getitem__(self, index: Union[int, np.ndarray, slice]) -> "Instances":
324
331
  """
325
332
  Retrieve a specific instance or a set of instances using indexing.
326
333
 
@@ -346,7 +353,7 @@ class Instances:
346
353
  normalized=self.normalized,
347
354
  )
348
355
 
349
- def flipud(self, h):
356
+ def flipud(self, h: int) -> None:
350
357
  """
351
358
  Flip coordinates vertically.
352
359
 
@@ -364,7 +371,7 @@ class Instances:
364
371
  if self.keypoints is not None:
365
372
  self.keypoints[..., 1] = h - self.keypoints[..., 1]
366
373
 
367
- def fliplr(self, w):
374
+ def fliplr(self, w: int) -> None:
368
375
  """
369
376
  Flip coordinates horizontally.
370
377
 
@@ -382,7 +389,7 @@ class Instances:
382
389
  if self.keypoints is not None:
383
390
  self.keypoints[..., 0] = w - self.keypoints[..., 0]
384
391
 
385
- def clip(self, w, h):
392
+ def clip(self, w: int, h: int) -> None:
386
393
  """
387
394
  Clip coordinates to stay within image boundaries.
388
395
 
@@ -409,7 +416,7 @@ class Instances:
409
416
  self.keypoints[..., 0] = self.keypoints[..., 0].clip(0, w)
410
417
  self.keypoints[..., 1] = self.keypoints[..., 1].clip(0, h)
411
418
 
412
- def remove_zero_area_boxes(self):
419
+ def remove_zero_area_boxes(self) -> np.ndarray:
413
420
  """
414
421
  Remove zero-area boxes, i.e. after clipping some boxes may have zero width or height.
415
422
 
@@ -425,7 +432,7 @@ class Instances:
425
432
  self.keypoints = self.keypoints[good]
426
433
  return good
427
434
 
428
- def update(self, bboxes, segments=None, keypoints=None):
435
+ def update(self, bboxes: np.ndarray, segments: np.ndarray = None, keypoints: np.ndarray = None):
429
436
  """
430
437
  Update instance variables.
431
438
 
@@ -440,7 +447,7 @@ class Instances:
440
447
  if keypoints is not None:
441
448
  self.keypoints = keypoints
442
449
 
443
- def __len__(self):
450
+ def __len__(self) -> int:
444
451
  """Return the number of instances."""
445
452
  return len(self.bboxes)
446
453
 
@@ -492,6 +499,6 @@ class Instances:
492
499
  return cls(cat_boxes, cat_segments, cat_keypoints, bbox_format, normalized)
493
500
 
494
501
  @property
495
- def bboxes(self):
502
+ def bboxes(self) -> np.ndarray:
496
503
  """Return bounding boxes."""
497
504
  return self._bboxes.bboxes
ultralytics/utils/ops.py CHANGED
@@ -343,11 +343,11 @@ def clip_boxes(boxes, shape):
343
343
  Clip bounding boxes to image boundaries.
344
344
 
345
345
  Args:
346
- boxes (torch.Tensor | numpy.ndarray): Bounding boxes to clip.
346
+ boxes (torch.Tensor | np.ndarray): Bounding boxes to clip.
347
347
  shape (tuple): Image shape as (height, width).
348
348
 
349
349
  Returns:
350
- (torch.Tensor | numpy.ndarray): Clipped bounding boxes.
350
+ (torch.Tensor | np.ndarray): Clipped bounding boxes.
351
351
  """
352
352
  if isinstance(boxes, torch.Tensor): # faster individually (WARNING: inplace .clamp_() Apple MPS bug)
353
353
  boxes[..., 0] = boxes[..., 0].clamp(0, shape[1]) # x1
@@ -365,11 +365,11 @@ def clip_coords(coords, shape):
365
365
  Clip line coordinates to image boundaries.
366
366
 
367
367
  Args:
368
- coords (torch.Tensor | numpy.ndarray): Line coordinates to clip.
368
+ coords (torch.Tensor | np.ndarray): Line coordinates to clip.
369
369
  shape (tuple): Image shape as (height, width).
370
370
 
371
371
  Returns:
372
- (torch.Tensor | numpy.ndarray): Clipped coordinates.
372
+ (torch.Tensor | np.ndarray): Clipped coordinates.
373
373
  """
374
374
  if isinstance(coords, torch.Tensor): # faster individually (WARNING: inplace .clamp_() Apple MPS bug)
375
375
  coords[..., 0] = coords[..., 0].clamp(0, shape[1]) # x
@@ -564,10 +564,10 @@ def xyxyxyxy2xywhr(x):
564
564
  Convert batched Oriented Bounding Boxes (OBB) from [xy1, xy2, xy3, xy4] to [xywh, rotation] format.
565
565
 
566
566
  Args:
567
- x (numpy.ndarray | torch.Tensor): Input box corners with shape (N, 8) in [xy1, xy2, xy3, xy4] format.
567
+ x (np.ndarray | torch.Tensor): Input box corners with shape (N, 8) in [xy1, xy2, xy3, xy4] format.
568
568
 
569
569
  Returns:
570
- (numpy.ndarray | torch.Tensor): Converted data in [cx, cy, w, h, rotation] format with shape (N, 5).
570
+ (np.ndarray | torch.Tensor): Converted data in [cx, cy, w, h, rotation] format with shape (N, 5).
571
571
  Rotation values are in radians from 0 to pi/2.
572
572
  """
573
573
  is_torch = isinstance(x, torch.Tensor)
@@ -587,11 +587,11 @@ def xywhr2xyxyxyxy(x):
587
587
  Convert batched Oriented Bounding Boxes (OBB) from [xywh, rotation] to [xy1, xy2, xy3, xy4] format.
588
588
 
589
589
  Args:
590
- x (numpy.ndarray | torch.Tensor): Boxes in [cx, cy, w, h, rotation] format with shape (N, 5) or (B, N, 5).
590
+ x (np.ndarray | torch.Tensor): Boxes in [cx, cy, w, h, rotation] format with shape (N, 5) or (B, N, 5).
591
591
  Rotation values should be in radians from 0 to pi/2.
592
592
 
593
593
  Returns:
594
- (numpy.ndarray | torch.Tensor): Converted corner points with shape (N, 4, 2) or (B, N, 4, 2).
594
+ (np.ndarray | torch.Tensor): Converted corner points with shape (N, 4, 2) or (B, N, 4, 2).
595
595
  """
596
596
  cos, sin, cat, stack = (
597
597
  (torch.cos, torch.sin, torch.cat, torch.stack)