dgenerate-ultralytics-headless 8.3.237__py3-none-any.whl → 8.3.240__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 (106) hide show
  1. {dgenerate_ultralytics_headless-8.3.237.dist-info → dgenerate_ultralytics_headless-8.3.240.dist-info}/METADATA +2 -1
  2. {dgenerate_ultralytics_headless-8.3.237.dist-info → dgenerate_ultralytics_headless-8.3.240.dist-info}/RECORD +105 -106
  3. tests/test_exports.py +3 -1
  4. tests/test_python.py +2 -2
  5. tests/test_solutions.py +6 -6
  6. ultralytics/__init__.py +1 -1
  7. ultralytics/cfg/__init__.py +4 -4
  8. ultralytics/cfg/datasets/Argoverse.yaml +7 -6
  9. ultralytics/cfg/datasets/DOTAv1.5.yaml +1 -1
  10. ultralytics/cfg/datasets/DOTAv1.yaml +1 -1
  11. ultralytics/cfg/datasets/VOC.yaml +15 -16
  12. ultralytics/cfg/datasets/african-wildlife.yaml +1 -1
  13. ultralytics/cfg/datasets/coco128-seg.yaml +1 -1
  14. ultralytics/cfg/datasets/dota8-multispectral.yaml +1 -1
  15. ultralytics/cfg/datasets/dota8.yaml +2 -2
  16. ultralytics/cfg/datasets/kitti.yaml +1 -1
  17. ultralytics/cfg/datasets/xView.yaml +16 -16
  18. ultralytics/cfg/models/11/yolo11-pose.yaml +1 -1
  19. ultralytics/cfg/models/11/yoloe-11-seg.yaml +2 -2
  20. ultralytics/cfg/models/11/yoloe-11.yaml +2 -2
  21. ultralytics/cfg/models/v8/yoloe-v8-seg.yaml +9 -6
  22. ultralytics/cfg/models/v8/yoloe-v8.yaml +9 -6
  23. ultralytics/cfg/models/v8/yolov8-cls-resnet101.yaml +1 -1
  24. ultralytics/cfg/models/v8/yolov8-cls-resnet50.yaml +1 -1
  25. ultralytics/cfg/models/v8/yolov8-ghost-p2.yaml +2 -2
  26. ultralytics/cfg/models/v8/yolov8-ghost-p6.yaml +2 -2
  27. ultralytics/cfg/models/v8/yolov8-ghost.yaml +2 -2
  28. ultralytics/cfg/models/v8/yolov8-obb.yaml +1 -1
  29. ultralytics/cfg/models/v8/yolov8-p2.yaml +1 -1
  30. ultralytics/cfg/models/v8/yolov8-pose-p6.yaml +1 -1
  31. ultralytics/cfg/models/v8/yolov8-rtdetr.yaml +1 -1
  32. ultralytics/cfg/models/v8/yolov8-world.yaml +1 -1
  33. ultralytics/cfg/models/v8/yolov8-worldv2.yaml +6 -6
  34. ultralytics/data/augment.py +1 -1
  35. ultralytics/data/base.py +4 -2
  36. ultralytics/data/build.py +4 -4
  37. ultralytics/data/loaders.py +17 -12
  38. ultralytics/data/utils.py +4 -4
  39. ultralytics/engine/exporter.py +24 -16
  40. ultralytics/engine/predictor.py +5 -4
  41. ultralytics/engine/results.py +12 -13
  42. ultralytics/engine/trainer.py +2 -2
  43. ultralytics/engine/tuner.py +2 -3
  44. ultralytics/engine/validator.py +2 -2
  45. ultralytics/models/fastsam/model.py +2 -2
  46. ultralytics/models/fastsam/predict.py +2 -3
  47. ultralytics/models/fastsam/val.py +4 -4
  48. ultralytics/models/rtdetr/predict.py +2 -3
  49. ultralytics/models/rtdetr/val.py +5 -4
  50. ultralytics/models/sam/build.py +5 -5
  51. ultralytics/models/sam/build_sam3.py +9 -6
  52. ultralytics/models/sam/model.py +1 -1
  53. ultralytics/models/sam/modules/sam.py +10 -5
  54. ultralytics/models/sam/modules/utils.py +8 -3
  55. ultralytics/models/sam/predict.py +53 -62
  56. ultralytics/models/sam/sam3/encoder.py +4 -4
  57. ultralytics/models/sam/sam3/geometry_encoders.py +3 -3
  58. ultralytics/models/sam/sam3/necks.py +17 -17
  59. ultralytics/models/sam/sam3/sam3_image.py +3 -21
  60. ultralytics/models/sam/sam3/vl_combiner.py +1 -6
  61. ultralytics/models/yolo/classify/val.py +1 -1
  62. ultralytics/models/yolo/detect/train.py +1 -1
  63. ultralytics/models/yolo/detect/val.py +7 -7
  64. ultralytics/models/yolo/obb/val.py +1 -1
  65. ultralytics/models/yolo/pose/val.py +1 -1
  66. ultralytics/models/yolo/segment/val.py +1 -1
  67. ultralytics/nn/autobackend.py +9 -9
  68. ultralytics/nn/modules/block.py +1 -1
  69. ultralytics/nn/tasks.py +3 -3
  70. ultralytics/nn/text_model.py +2 -7
  71. ultralytics/solutions/ai_gym.py +1 -1
  72. ultralytics/solutions/analytics.py +6 -6
  73. ultralytics/solutions/config.py +1 -1
  74. ultralytics/solutions/distance_calculation.py +1 -1
  75. ultralytics/solutions/object_counter.py +1 -1
  76. ultralytics/solutions/object_cropper.py +3 -6
  77. ultralytics/solutions/parking_management.py +21 -17
  78. ultralytics/solutions/queue_management.py +5 -5
  79. ultralytics/solutions/region_counter.py +2 -2
  80. ultralytics/solutions/security_alarm.py +1 -1
  81. ultralytics/solutions/solutions.py +45 -22
  82. ultralytics/solutions/speed_estimation.py +1 -1
  83. ultralytics/trackers/basetrack.py +1 -1
  84. ultralytics/trackers/bot_sort.py +4 -3
  85. ultralytics/trackers/byte_tracker.py +4 -4
  86. ultralytics/trackers/utils/gmc.py +6 -7
  87. ultralytics/trackers/utils/kalman_filter.py +2 -1
  88. ultralytics/trackers/utils/matching.py +4 -3
  89. ultralytics/utils/__init__.py +12 -3
  90. ultralytics/utils/benchmarks.py +2 -2
  91. ultralytics/utils/callbacks/tensorboard.py +19 -25
  92. ultralytics/utils/checks.py +2 -1
  93. ultralytics/utils/downloads.py +1 -1
  94. ultralytics/utils/export/tensorflow.py +16 -2
  95. ultralytics/utils/files.py +13 -12
  96. ultralytics/utils/logger.py +62 -27
  97. ultralytics/utils/metrics.py +1 -1
  98. ultralytics/utils/ops.py +6 -6
  99. ultralytics/utils/patches.py +3 -3
  100. ultralytics/utils/plotting.py +18 -23
  101. ultralytics/utils/tuner.py +1 -1
  102. ultralytics/models/sam/sam3/tokenizer_ve.py +0 -242
  103. {dgenerate_ultralytics_headless-8.3.237.dist-info → dgenerate_ultralytics_headless-8.3.240.dist-info}/WHEEL +0 -0
  104. {dgenerate_ultralytics_headless-8.3.237.dist-info → dgenerate_ultralytics_headless-8.3.240.dist-info}/entry_points.txt +0 -0
  105. {dgenerate_ultralytics_headless-8.3.237.dist-info → dgenerate_ultralytics_headless-8.3.240.dist-info}/licenses/LICENSE +0 -0
  106. {dgenerate_ultralytics_headless-8.3.237.dist-info → dgenerate_ultralytics_headless-8.3.240.dist-info}/top_level.txt +0 -0
@@ -1,242 +0,0 @@
1
- # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
-
3
- # Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved
4
-
5
- """
6
- Text Tokenizer.
7
-
8
- Copied and lightly adapted from VE repo, which in turn copied
9
- from open_clip and openAI CLIP.
10
- """
11
-
12
- from __future__ import annotations
13
-
14
- import gzip
15
- import html
16
- import io
17
- import os
18
- import string
19
- from functools import lru_cache
20
-
21
- import ftfy
22
- import regex as re
23
- import torch
24
- from iopath.common.file_io import g_pathmgr
25
-
26
-
27
- @lru_cache
28
- def bytes_to_unicode():
29
- """Returns list of utf-8 byte and a corresponding list of unicode strings. The reversible bpe codes work on unicode
30
- strings. This means you need a large # of unicode characters in your vocab if you want to avoid UNKs. When
31
- you're at something like a 10B token dataset you end up needing around 5K for decent coverage. This is a
32
- significant percentage of your normal, say, 32K bpe vocab. To avoid that, we want lookup tables between utf-8
33
- bytes and unicode strings. And avoids mapping to whitespace/control characters the bpe code barfs on.
34
- """
35
- bs = list(range(ord("!"), ord("~") + 1)) + list(range(ord("¡"), ord("¬") + 1)) + list(range(ord("®"), ord("ÿ") + 1))
36
- cs = bs[:]
37
- n = 0
38
- for b in range(2**8):
39
- if b not in bs:
40
- bs.append(b)
41
- cs.append(2**8 + n)
42
- n += 1
43
- cs = [chr(n) for n in cs]
44
- return dict(zip(bs, cs))
45
-
46
-
47
- def get_pairs(word):
48
- """Return set of symbol pairs in a word. Word is represented as tuple of symbols (symbols being variable-length
49
- strings).
50
- """
51
- pairs = set()
52
- prev_char = word[0]
53
- for char in word[1:]:
54
- pairs.add((prev_char, char))
55
- prev_char = char
56
- return pairs
57
-
58
-
59
- def basic_clean(text):
60
- """Basic text cleaning: fix unicode and unescape HTML entities."""
61
- text = ftfy.fix_text(text)
62
- text = html.unescape(html.unescape(text))
63
- return text.strip()
64
-
65
-
66
- def whitespace_clean(text):
67
- """Remove redundant whitespace."""
68
- text = re.sub(r"\s+", " ", text)
69
- text = text.strip()
70
- return text
71
-
72
-
73
- def _clean_canonicalize(x):
74
- """Clean text and canonicalize it."""
75
- # basic, remove whitespace, remove punctuation, lower case
76
- return canonicalize_text(basic_clean(x))
77
-
78
-
79
- def _clean_lower(x):
80
- """Clean text and return lowercase."""
81
- # basic, remove whitespace, lower case
82
- return whitespace_clean(basic_clean(x)).lower()
83
-
84
-
85
- def _clean_whitespace(x):
86
- """Clean text and remove redundant whitespace."""
87
- # basic, remove whitespace
88
- return whitespace_clean(basic_clean(x))
89
-
90
-
91
- def get_clean_fn(type: str):
92
- """Get text cleaning function by name."""
93
- if type == "canonicalize":
94
- return _clean_canonicalize
95
- elif type == "lower":
96
- return _clean_lower
97
- elif type == "whitespace":
98
- return _clean_whitespace
99
- else:
100
- assert False, f"Invalid clean function ({type})."
101
-
102
-
103
- def canonicalize_text(text, *, keep_punctuation_exact_string=None):
104
- """Returns canonicalized `text` (lowercase and punctuation removed). From:
105
- https://github.com/google-research/big_vision/blob/53f18caf27a9419231bbf08d3388b07671616d3d/big_vision/evaluators/proj/image_text/prompt_engineering.py#L94.
106
-
107
- Args:
108
- text: string to be canonicalized.
109
- keep_punctuation_exact_string: If provided, then this exact string kept. For example providing '{}' will keep
110
- any occurrences of '{}' (but will still remove '{' and '}' that appear separately).
111
- """
112
- text = text.replace("_", " ")
113
- if keep_punctuation_exact_string:
114
- text = keep_punctuation_exact_string.join(
115
- part.translate(str.maketrans("", "", string.punctuation))
116
- for part in text.split(keep_punctuation_exact_string)
117
- )
118
- else:
119
- text = text.translate(str.maketrans("", "", string.punctuation))
120
- text = text.lower()
121
- text = re.sub(r"\s+", " ", text)
122
- return text.strip()
123
-
124
-
125
- class SimpleTokenizer:
126
- """A simple tokenizer for text inputs."""
127
-
128
- def __init__(
129
- self,
130
- bpe_path: str | os.PathLike,
131
- additional_special_tokens: list[str] | None = None,
132
- context_length: int = 77,
133
- clean: str = "lower",
134
- ):
135
- """The tokenizer for text inputs."""
136
- self.byte_encoder = bytes_to_unicode()
137
- self.byte_decoder = {v: k for k, v in self.byte_encoder.items()}
138
- with g_pathmgr.open(bpe_path, "rb") as fh:
139
- bpe_bytes = io.BytesIO(fh.read())
140
- merges = gzip.open(bpe_bytes).read().decode("utf-8").split("\n")
141
- # merges = gzip.open(bpe_path).read().decode("utf-8").split("\n")
142
- merges = merges[1 : 49152 - 256 - 2 + 1]
143
- merges = [tuple(merge.split()) for merge in merges]
144
- vocab = list(bytes_to_unicode().values())
145
- vocab = vocab + [v + "</w>" for v in vocab]
146
- for merge in merges:
147
- vocab.append("".join(merge))
148
- special_tokens = ["<start_of_text>", "<end_of_text>"]
149
- if additional_special_tokens:
150
- special_tokens += additional_special_tokens
151
- vocab.extend(special_tokens)
152
- self.encoder = dict(zip(vocab, range(len(vocab))))
153
- self.decoder = {v: k for k, v in self.encoder.items()}
154
- self.bpe_ranks = dict(zip(merges, range(len(merges))))
155
- self.cache = {t: t for t in special_tokens}
156
- special = "|".join(special_tokens)
157
- self.pat = re.compile(
158
- special + r"""|'s|'t|'re|'ve|'m|'ll|'d|[\p{L}]+|[\p{N}]|[^\s\p{L}\p{N}]+""",
159
- re.IGNORECASE,
160
- )
161
- self.vocab_size = len(self.encoder)
162
- self.all_special_ids = [self.encoder[t] for t in special_tokens]
163
- self.sot_token_id = self.all_special_ids[0]
164
- self.eot_token_id = self.all_special_ids[1]
165
- self.context_length = context_length
166
- self.clean_fn = get_clean_fn(clean)
167
-
168
- def bpe(self, token):
169
- """Byte Pair Encoding."""
170
- if token in self.cache:
171
- return self.cache[token]
172
- word = (*tuple(token[:-1]), token[-1] + "</w>")
173
- pairs = get_pairs(word)
174
- if not pairs:
175
- return token + "</w>"
176
- while True:
177
- bigram = min(pairs, key=lambda pair: self.bpe_ranks.get(pair, float("inf")))
178
- if bigram not in self.bpe_ranks:
179
- break
180
- first, second = bigram
181
- new_word = []
182
- i = 0
183
- while i < len(word):
184
- try:
185
- j = word.index(first, i)
186
- new_word.extend(word[i:j])
187
- i = j
188
- except Exception:
189
- new_word.extend(word[i:])
190
- break
191
- if word[i] == first and i < len(word) - 1 and word[i + 1] == second:
192
- new_word.append(first + second)
193
- i += 2
194
- else:
195
- new_word.append(word[i])
196
- i += 1
197
- new_word = tuple(new_word)
198
- word = new_word
199
- if len(word) == 1:
200
- break
201
- else:
202
- pairs = get_pairs(word)
203
- word = " ".join(word)
204
- self.cache[token] = word
205
- return word
206
-
207
- def encode(self, text):
208
- """Encode text to a sequence of BPE tokens."""
209
- bpe_tokens = []
210
- text = self.clean_fn(text)
211
- for token in re.findall(self.pat, text):
212
- token = "".join(self.byte_encoder[b] for b in token.encode("utf-8"))
213
- bpe_tokens.extend(self.encoder[bpe_token] for bpe_token in self.bpe(token).split(" "))
214
- return bpe_tokens
215
-
216
- def decode(self, tokens):
217
- """Decodes a sequence of tokens back into a text string."""
218
- text = "".join([self.decoder[token] for token in tokens])
219
- text = bytearray([self.byte_decoder[c] for c in text]).decode("utf-8", errors="replace").replace("</w>", " ")
220
- return text
221
-
222
- def __call__(self, texts: str | list[str], context_length: int | None = None) -> torch.LongTensor:
223
- """Returns the tokenized representation of given input string(s) Parameters. ---------- texts : Union[str,
224
- list[str]] An input string or a list of input strings to tokenize context_length : int The context
225
- length to use; all CLIP models use 77 as the context length.
226
-
227
- Returns:
228
- -------: A two-dimensional tensor containing the resulting tokens, shape = [number of input strings,
229
- context_length]
230
- """
231
- if isinstance(texts, str):
232
- texts = [texts]
233
- context_length = context_length or self.context_length
234
- assert context_length, "Please set a valid context length"
235
- all_tokens = [[self.sot_token_id, *self.encode(text), self.eot_token_id] for text in texts]
236
- result = torch.zeros(len(all_tokens), context_length, dtype=torch.long)
237
- for i, tokens in enumerate(all_tokens):
238
- if len(tokens) > context_length:
239
- tokens = tokens[:context_length] # Truncate
240
- tokens[-1] = self.eot_token_id
241
- result[i, : len(tokens)] = torch.tensor(tokens)
242
- return result