dgenerate-ultralytics-headless 8.3.143__py3-none-any.whl → 8.3.144__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.
- {dgenerate_ultralytics_headless-8.3.143.dist-info → dgenerate_ultralytics_headless-8.3.144.dist-info}/METADATA +1 -1
- dgenerate_ultralytics_headless-8.3.144.dist-info/RECORD +272 -0
- tests/conftest.py +7 -24
- tests/test_cli.py +1 -1
- tests/test_cuda.py +7 -2
- tests/test_engine.py +7 -8
- tests/test_exports.py +16 -16
- tests/test_integrations.py +1 -1
- tests/test_solutions.py +11 -11
- ultralytics/__init__.py +1 -1
- ultralytics/cfg/__init__.py +16 -13
- ultralytics/data/annotator.py +6 -5
- ultralytics/data/augment.py +127 -126
- ultralytics/data/base.py +54 -51
- ultralytics/data/build.py +47 -23
- ultralytics/data/converter.py +47 -43
- ultralytics/data/dataset.py +51 -50
- ultralytics/data/loaders.py +77 -44
- ultralytics/data/split.py +22 -9
- ultralytics/data/split_dota.py +63 -39
- ultralytics/data/utils.py +59 -39
- ultralytics/engine/exporter.py +79 -27
- ultralytics/engine/model.py +39 -39
- ultralytics/engine/predictor.py +37 -28
- ultralytics/engine/results.py +187 -157
- ultralytics/engine/trainer.py +36 -19
- ultralytics/engine/tuner.py +12 -9
- ultralytics/engine/validator.py +7 -9
- ultralytics/hub/__init__.py +11 -13
- ultralytics/hub/auth.py +22 -2
- ultralytics/hub/google/__init__.py +19 -19
- ultralytics/hub/session.py +37 -51
- ultralytics/hub/utils.py +19 -5
- ultralytics/models/fastsam/model.py +30 -12
- ultralytics/models/fastsam/predict.py +5 -6
- ultralytics/models/fastsam/utils.py +3 -3
- ultralytics/models/fastsam/val.py +10 -6
- ultralytics/models/nas/model.py +9 -5
- ultralytics/models/nas/predict.py +6 -6
- ultralytics/models/nas/val.py +3 -3
- ultralytics/models/rtdetr/model.py +7 -6
- ultralytics/models/rtdetr/predict.py +14 -7
- ultralytics/models/rtdetr/train.py +10 -4
- ultralytics/models/rtdetr/val.py +36 -9
- ultralytics/models/sam/amg.py +30 -12
- ultralytics/models/sam/build.py +22 -22
- ultralytics/models/sam/model.py +10 -9
- ultralytics/models/sam/modules/blocks.py +76 -80
- ultralytics/models/sam/modules/decoders.py +6 -8
- ultralytics/models/sam/modules/encoders.py +23 -26
- ultralytics/models/sam/modules/memory_attention.py +13 -1
- ultralytics/models/sam/modules/sam.py +57 -26
- ultralytics/models/sam/modules/tiny_encoder.py +232 -237
- ultralytics/models/sam/modules/transformer.py +13 -13
- ultralytics/models/sam/modules/utils.py +11 -19
- ultralytics/models/sam/predict.py +114 -101
- ultralytics/models/utils/loss.py +98 -77
- ultralytics/models/utils/ops.py +116 -67
- ultralytics/models/yolo/classify/predict.py +5 -5
- ultralytics/models/yolo/classify/train.py +32 -28
- ultralytics/models/yolo/classify/val.py +7 -8
- ultralytics/models/yolo/detect/predict.py +1 -0
- ultralytics/models/yolo/detect/train.py +15 -14
- ultralytics/models/yolo/detect/val.py +37 -36
- ultralytics/models/yolo/model.py +106 -23
- ultralytics/models/yolo/obb/predict.py +3 -4
- ultralytics/models/yolo/obb/train.py +14 -6
- ultralytics/models/yolo/obb/val.py +29 -23
- ultralytics/models/yolo/pose/predict.py +9 -8
- ultralytics/models/yolo/pose/train.py +24 -16
- ultralytics/models/yolo/pose/val.py +44 -26
- ultralytics/models/yolo/segment/predict.py +5 -5
- ultralytics/models/yolo/segment/train.py +11 -7
- ultralytics/models/yolo/segment/val.py +2 -2
- ultralytics/models/yolo/world/train.py +33 -23
- ultralytics/models/yolo/world/train_world.py +11 -3
- ultralytics/models/yolo/yoloe/predict.py +11 -11
- ultralytics/models/yolo/yoloe/train.py +73 -21
- ultralytics/models/yolo/yoloe/train_seg.py +10 -7
- ultralytics/models/yolo/yoloe/val.py +42 -18
- ultralytics/nn/autobackend.py +59 -15
- ultralytics/nn/modules/__init__.py +4 -4
- ultralytics/nn/modules/activation.py +4 -1
- ultralytics/nn/modules/block.py +178 -111
- ultralytics/nn/modules/conv.py +6 -5
- ultralytics/nn/modules/head.py +469 -121
- ultralytics/nn/modules/transformer.py +147 -58
- ultralytics/nn/tasks.py +227 -20
- ultralytics/nn/text_model.py +30 -33
- ultralytics/solutions/ai_gym.py +1 -1
- ultralytics/solutions/analytics.py +7 -4
- ultralytics/solutions/config.py +10 -10
- ultralytics/solutions/distance_calculation.py +11 -10
- ultralytics/solutions/heatmap.py +1 -1
- ultralytics/solutions/instance_segmentation.py +6 -3
- ultralytics/solutions/object_blurrer.py +3 -3
- ultralytics/solutions/object_counter.py +15 -7
- ultralytics/solutions/object_cropper.py +3 -2
- ultralytics/solutions/parking_management.py +29 -28
- ultralytics/solutions/queue_management.py +6 -6
- ultralytics/solutions/region_counter.py +10 -3
- ultralytics/solutions/security_alarm.py +3 -3
- ultralytics/solutions/similarity_search.py +85 -24
- ultralytics/solutions/solutions.py +184 -75
- ultralytics/solutions/speed_estimation.py +28 -22
- ultralytics/solutions/streamlit_inference.py +17 -12
- ultralytics/solutions/trackzone.py +4 -4
- ultralytics/trackers/basetrack.py +16 -23
- ultralytics/trackers/bot_sort.py +30 -20
- ultralytics/trackers/byte_tracker.py +70 -64
- ultralytics/trackers/track.py +4 -8
- ultralytics/trackers/utils/gmc.py +31 -58
- ultralytics/trackers/utils/kalman_filter.py +37 -37
- ultralytics/trackers/utils/matching.py +1 -1
- ultralytics/utils/__init__.py +105 -89
- ultralytics/utils/autobatch.py +16 -3
- ultralytics/utils/autodevice.py +54 -24
- ultralytics/utils/benchmarks.py +42 -28
- ultralytics/utils/callbacks/base.py +3 -3
- ultralytics/utils/callbacks/clearml.py +9 -9
- ultralytics/utils/callbacks/comet.py +67 -25
- ultralytics/utils/callbacks/dvc.py +7 -10
- ultralytics/utils/callbacks/mlflow.py +2 -5
- ultralytics/utils/callbacks/neptune.py +7 -13
- ultralytics/utils/callbacks/raytune.py +1 -1
- ultralytics/utils/callbacks/tensorboard.py +5 -6
- ultralytics/utils/callbacks/wb.py +14 -14
- ultralytics/utils/checks.py +14 -13
- ultralytics/utils/dist.py +5 -5
- ultralytics/utils/downloads.py +94 -67
- ultralytics/utils/errors.py +5 -5
- ultralytics/utils/export.py +61 -47
- ultralytics/utils/files.py +23 -22
- ultralytics/utils/instance.py +48 -52
- ultralytics/utils/loss.py +78 -40
- ultralytics/utils/metrics.py +186 -130
- ultralytics/utils/ops.py +186 -190
- ultralytics/utils/patches.py +15 -17
- ultralytics/utils/plotting.py +71 -27
- ultralytics/utils/tal.py +21 -15
- ultralytics/utils/torch_utils.py +53 -50
- ultralytics/utils/triton.py +5 -4
- ultralytics/utils/tuner.py +5 -5
- dgenerate_ultralytics_headless-8.3.143.dist-info/RECORD +0 -272
- {dgenerate_ultralytics_headless-8.3.143.dist-info → dgenerate_ultralytics_headless-8.3.144.dist-info}/WHEEL +0 -0
- {dgenerate_ultralytics_headless-8.3.143.dist-info → dgenerate_ultralytics_headless-8.3.144.dist-info}/entry_points.txt +0 -0
- {dgenerate_ultralytics_headless-8.3.143.dist-info → dgenerate_ultralytics_headless-8.3.144.dist-info}/licenses/LICENSE +0 -0
- {dgenerate_ultralytics_headless-8.3.143.dist-info → dgenerate_ultralytics_headless-8.3.144.dist-info}/top_level.txt +0 -0
tests/test_solutions.py
CHANGED
@@ -156,14 +156,14 @@ SOLUTIONS = [
|
|
156
156
|
"StreamlitInference",
|
157
157
|
solutions.Inference,
|
158
158
|
False,
|
159
|
-
None, # streamlit application
|
160
|
-
{}, # streamlit application
|
159
|
+
None, # streamlit application doesn't require video file
|
160
|
+
{}, # streamlit application doesn't accept arguments
|
161
161
|
),
|
162
162
|
]
|
163
163
|
|
164
164
|
|
165
|
-
def process_video(solution, video_path, needs_frame_count=False):
|
166
|
-
"""Process video with solution, feeding frames and optional frame count."""
|
165
|
+
def process_video(solution, video_path: str, needs_frame_count: bool = False):
|
166
|
+
"""Process video with solution, feeding frames and optional frame count to the solution instance."""
|
167
167
|
cap = cv2.VideoCapture(video_path)
|
168
168
|
assert cap.isOpened(), f"Error reading video file {video_path}"
|
169
169
|
|
@@ -183,7 +183,7 @@ def process_video(solution, video_path, needs_frame_count=False):
|
|
183
183
|
@pytest.mark.skipif(IS_RASPBERRYPI, reason="Disabled for testing due to --slow test errors after YOLOE PR.")
|
184
184
|
@pytest.mark.parametrize("name, solution_class, needs_frame_count, video, kwargs", SOLUTIONS)
|
185
185
|
def test_solution(name, solution_class, needs_frame_count, video, kwargs):
|
186
|
-
"""Test individual Ultralytics solution."""
|
186
|
+
"""Test individual Ultralytics solution with video processing and parameter validation."""
|
187
187
|
if video:
|
188
188
|
if name != "ObjectCounterVertical":
|
189
189
|
safe_download(url=f"{ASSETS_URL}/{video}", dir=TMP)
|
@@ -208,14 +208,14 @@ def test_solution(name, solution_class, needs_frame_count, video, kwargs):
|
|
208
208
|
@pytest.mark.skipif(checks.IS_PYTHON_3_8, reason="Disabled due to unsupported CLIP dependencies.")
|
209
209
|
@pytest.mark.skipif(IS_RASPBERRYPI, reason="Disabled due to slow performance on Raspberry Pi.")
|
210
210
|
def test_similarity_search():
|
211
|
-
"""Test similarity search solution."""
|
212
|
-
safe_download(f"{ASSETS_URL}/4-imgs-similaritysearch.zip", dir=TMP) # 4 dog images for testing in a zip file
|
211
|
+
"""Test similarity search solution with sample images and text query."""
|
212
|
+
safe_download(f"{ASSETS_URL}/4-imgs-similaritysearch.zip", dir=TMP) # 4 dog images for testing in a zip file
|
213
213
|
searcher = solutions.VisualAISearch(data=str(TMP / "4-imgs-similaritysearch"))
|
214
214
|
_ = searcher("a dog sitting on a bench") # Returns the results in format "- img name | similarity score"
|
215
215
|
|
216
216
|
|
217
217
|
def test_left_click_selection():
|
218
|
-
"""Test distance calculation left click."""
|
218
|
+
"""Test distance calculation left click selection functionality."""
|
219
219
|
dc = solutions.DistanceCalculation()
|
220
220
|
dc.boxes, dc.track_ids = [[10, 10, 50, 50]], [1]
|
221
221
|
dc.mouse_event_for_distance(cv2.EVENT_LBUTTONDOWN, 30, 30, None, None)
|
@@ -223,7 +223,7 @@ def test_left_click_selection():
|
|
223
223
|
|
224
224
|
|
225
225
|
def test_right_click_reset():
|
226
|
-
"""Test distance calculation right click."""
|
226
|
+
"""Test distance calculation right click reset functionality."""
|
227
227
|
dc = solutions.DistanceCalculation()
|
228
228
|
dc.selected_boxes, dc.left_mouse_count = {1: [10, 10, 50, 50]}, 1
|
229
229
|
dc.mouse_event_for_distance(cv2.EVENT_RBUTTONDOWN, 0, 0, None, None)
|
@@ -232,7 +232,7 @@ def test_right_click_reset():
|
|
232
232
|
|
233
233
|
|
234
234
|
def test_parking_json_none():
|
235
|
-
"""Test that ParkingManagement
|
235
|
+
"""Test that ParkingManagement handles missing JSON gracefully."""
|
236
236
|
im0 = np.zeros((640, 480, 3), dtype=np.uint8)
|
237
237
|
try:
|
238
238
|
parkingmanager = solutions.ParkingManagement(json_path=None)
|
@@ -266,7 +266,7 @@ def test_config_update_method_with_invalid_argument():
|
|
266
266
|
obj.update(invalid_key=123)
|
267
267
|
assert False, "Expected ValueError for invalid update argument"
|
268
268
|
except ValueError as e:
|
269
|
-
assert "
|
269
|
+
assert "is not a valid solution argument" in str(e)
|
270
270
|
|
271
271
|
|
272
272
|
def test_plot_with_no_masks():
|
ultralytics/__init__.py
CHANGED
ultralytics/cfg/__init__.py
CHANGED
@@ -70,7 +70,7 @@ TASK2METRIC = {
|
|
70
70
|
"pose": "metrics/mAP50-95(P)",
|
71
71
|
"obb": "metrics/mAP50-95(B)",
|
72
72
|
}
|
73
|
-
MODELS = frozenset(
|
73
|
+
MODELS = frozenset(TASK2MODEL[task] for task in TASKS)
|
74
74
|
|
75
75
|
ARGV = sys.argv or ["", ""] # sometimes sys.argv = []
|
76
76
|
SOLUTIONS_HELP_MSG = f"""
|
@@ -240,7 +240,7 @@ CFG_BOOL_KEYS = frozenset(
|
|
240
240
|
|
241
241
|
def cfg2dict(cfg: Union[str, Path, Dict, SimpleNamespace]) -> Dict:
|
242
242
|
"""
|
243
|
-
|
243
|
+
Convert a configuration object to a dictionary.
|
244
244
|
|
245
245
|
Args:
|
246
246
|
cfg (str | Path | Dict | SimpleNamespace): Configuration object to be converted. Can be a file path,
|
@@ -323,7 +323,7 @@ def get_cfg(cfg: Union[str, Path, Dict, SimpleNamespace] = DEFAULT_CFG_DICT, ove
|
|
323
323
|
|
324
324
|
def check_cfg(cfg: Dict, hard: bool = True) -> None:
|
325
325
|
"""
|
326
|
-
|
326
|
+
Check configuration argument types and values for the Ultralytics library.
|
327
327
|
|
328
328
|
This function validates the types and values of configuration arguments, ensuring correctness and converting
|
329
329
|
them if necessary. It checks for specific key types defined in global variables such as `CFG_FLOAT_KEYS`,
|
@@ -385,7 +385,7 @@ def check_cfg(cfg: Dict, hard: bool = True) -> None:
|
|
385
385
|
|
386
386
|
def get_save_dir(args: SimpleNamespace, name: str = None) -> Path:
|
387
387
|
"""
|
388
|
-
|
388
|
+
Return the directory path for saving outputs, derived from arguments or default settings.
|
389
389
|
|
390
390
|
Args:
|
391
391
|
args (SimpleNamespace): Namespace object containing configurations such as 'project', 'name', 'task',
|
@@ -417,11 +417,14 @@ def get_save_dir(args: SimpleNamespace, name: str = None) -> Path:
|
|
417
417
|
|
418
418
|
def _handle_deprecation(custom: Dict) -> Dict:
|
419
419
|
"""
|
420
|
-
|
420
|
+
Handle deprecated configuration keys by mapping them to current equivalents with deprecation warnings.
|
421
421
|
|
422
422
|
Args:
|
423
423
|
custom (dict): Configuration dictionary potentially containing deprecated keys.
|
424
424
|
|
425
|
+
Returns:
|
426
|
+
(dict): Updated configuration dictionary with deprecated keys replaced.
|
427
|
+
|
425
428
|
Examples:
|
426
429
|
>>> custom_config = {"boxes": True, "hide_labels": "False", "line_thickness": 2}
|
427
430
|
>>> _handle_deprecation(custom_config)
|
@@ -458,7 +461,7 @@ def _handle_deprecation(custom: Dict) -> Dict:
|
|
458
461
|
|
459
462
|
def check_dict_alignment(base: Dict, custom: Dict, e: Exception = None) -> None:
|
460
463
|
"""
|
461
|
-
|
464
|
+
Check alignment between custom and base configuration dictionaries, handling deprecated keys and providing error
|
462
465
|
messages for mismatched keys.
|
463
466
|
|
464
467
|
Args:
|
@@ -498,7 +501,7 @@ def check_dict_alignment(base: Dict, custom: Dict, e: Exception = None) -> None:
|
|
498
501
|
|
499
502
|
def merge_equals_args(args: List[str]) -> List[str]:
|
500
503
|
"""
|
501
|
-
|
504
|
+
Merge arguments around isolated '=' in a list of strings and join fragments with brackets.
|
502
505
|
|
503
506
|
This function handles the following cases:
|
504
507
|
1. ['arg', '=', 'val'] becomes ['arg=val']
|
@@ -557,7 +560,7 @@ def merge_equals_args(args: List[str]) -> List[str]:
|
|
557
560
|
|
558
561
|
def handle_yolo_hub(args: List[str]) -> None:
|
559
562
|
"""
|
560
|
-
|
563
|
+
Handle Ultralytics HUB command-line interface (CLI) commands for authentication.
|
561
564
|
|
562
565
|
This function processes Ultralytics HUB CLI commands such as login and logout. It should be called when executing a
|
563
566
|
script with arguments related to HUB authentication.
|
@@ -587,7 +590,7 @@ def handle_yolo_hub(args: List[str]) -> None:
|
|
587
590
|
|
588
591
|
def handle_yolo_settings(args: List[str]) -> None:
|
589
592
|
"""
|
590
|
-
|
593
|
+
Handle YOLO settings command-line interface (CLI) commands.
|
591
594
|
|
592
595
|
This function processes YOLO settings CLI commands such as reset and updating individual settings. It should be
|
593
596
|
called when executing a script with arguments related to YOLO settings management.
|
@@ -628,7 +631,7 @@ def handle_yolo_settings(args: List[str]) -> None:
|
|
628
631
|
|
629
632
|
def handle_yolo_solutions(args: List[str]) -> None:
|
630
633
|
"""
|
631
|
-
|
634
|
+
Process YOLO solutions arguments and run the specified computer vision solutions pipeline.
|
632
635
|
|
633
636
|
Args:
|
634
637
|
args (List[str]): Command-line arguments for configuring and running the Ultralytics YOLO
|
@@ -740,7 +743,7 @@ def handle_yolo_solutions(args: List[str]) -> None:
|
|
740
743
|
|
741
744
|
def parse_key_value_pair(pair: str = "key=value") -> tuple:
|
742
745
|
"""
|
743
|
-
|
746
|
+
Parse a key-value pair string into separate key and value components.
|
744
747
|
|
745
748
|
Args:
|
746
749
|
pair (str): A string containing a key-value pair in the format "key=value".
|
@@ -774,7 +777,7 @@ def parse_key_value_pair(pair: str = "key=value") -> tuple:
|
|
774
777
|
|
775
778
|
def smart_value(v: str) -> Any:
|
776
779
|
"""
|
777
|
-
|
780
|
+
Convert a string representation of a value to its appropriate Python type.
|
778
781
|
|
779
782
|
This function attempts to convert a given string into a Python object of the most appropriate type. It handles
|
780
783
|
conversions to None, bool, int, float, and other types that can be evaluated safely.
|
@@ -991,7 +994,7 @@ def entrypoint(debug: str = "") -> None:
|
|
991
994
|
# Special modes --------------------------------------------------------------------------------------------------------
|
992
995
|
def copy_default_cfg() -> None:
|
993
996
|
"""
|
994
|
-
|
997
|
+
Copy the default configuration file and create a new one with '_copy' appended to its name.
|
995
998
|
|
996
999
|
This function duplicates the existing default configuration file (DEFAULT_CFG_PATH) and saves it
|
997
1000
|
with '_copy' appended to its name in the current working directory. It provides a convenient way
|
ultralytics/data/annotator.py
CHANGED
@@ -22,19 +22,20 @@ def auto_annotate(
|
|
22
22
|
Automatically annotate images using a YOLO object detection model and a SAM segmentation model.
|
23
23
|
|
24
24
|
This function processes images in a specified directory, detects objects using a YOLO model, and then generates
|
25
|
-
segmentation masks using a SAM model. The resulting annotations are saved as text files.
|
25
|
+
segmentation masks using a SAM model. The resulting annotations are saved as text files in YOLO format.
|
26
26
|
|
27
27
|
Args:
|
28
28
|
data (str | Path): Path to a folder containing images to be annotated.
|
29
29
|
det_model (str): Path or name of the pre-trained YOLO detection model.
|
30
30
|
sam_model (str): Path or name of the pre-trained SAM segmentation model.
|
31
|
-
device (str): Device to run the models on (e.g., 'cpu', 'cuda', '0').
|
31
|
+
device (str): Device to run the models on (e.g., 'cpu', 'cuda', '0'). Empty string for auto-selection.
|
32
32
|
conf (float): Confidence threshold for detection model.
|
33
33
|
iou (float): IoU threshold for filtering overlapping boxes in detection results.
|
34
34
|
imgsz (int): Input image resize dimension.
|
35
35
|
max_det (int): Maximum number of detections per image.
|
36
|
-
classes (List[int]
|
37
|
-
output_dir (str | Path
|
36
|
+
classes (List[int], optional): Filter predictions to specified class IDs, returning only relevant detections.
|
37
|
+
output_dir (str | Path, optional): Directory to save the annotated results. If None, creates a default
|
38
|
+
directory based on the input data path.
|
38
39
|
|
39
40
|
Examples:
|
40
41
|
>>> from ultralytics.data.annotator import auto_annotate
|
@@ -53,7 +54,7 @@ def auto_annotate(
|
|
53
54
|
)
|
54
55
|
|
55
56
|
for result in det_results:
|
56
|
-
class_ids = result.boxes.cls.int().tolist() #
|
57
|
+
class_ids = result.boxes.cls.int().tolist() # Extract class IDs from detection results
|
57
58
|
if class_ids:
|
58
59
|
boxes = result.boxes.xyxy # Boxes object for bbox outputs
|
59
60
|
sam_results = sam_model(result.orig_img, bboxes=boxes, verbose=False, save=False, device=device)
|