From 9a7b344fd0f11a7aeccff5d93804eb32b7653c46 Mon Sep 17 00:00:00 2001 From: Laughing <61612323+Laughing-q@users.noreply.github.com> Date: Fri, 8 Nov 2024 02:02:29 +0800 Subject: [PATCH 01/15] Fix duplicated annotations by `yolo_bbox2segment` (#17401) Co-authored-by: Burhan <62214284+Burhan-Q@users.noreply.github.com> --- ultralytics/data/converter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ultralytics/data/converter.py b/ultralytics/data/converter.py index fa5821418a..6b87f4e833 100644 --- a/ultralytics/data/converter.py +++ b/ultralytics/data/converter.py @@ -636,8 +636,8 @@ def yolo_bbox2segment(im_dir, save_dir=None, sam_model="sam_b.pt"): continue line = (int(cls[i]), *s.reshape(-1)) texts.append(("%g " * len(line)).rstrip() % line) - with open(txt_file, "a") as f: - f.writelines(text + "\n" for text in texts) + with open(txt_file, "a") as f: + f.writelines(text + "\n" for text in texts) LOGGER.info(f"Generated segment labels saved in {save_dir}") From b0aef79d367ed37d203728c9fc8752adbe9d8829 Mon Sep 17 00:00:00 2001 From: Laughing <61612323+Laughing-q@users.noreply.github.com> Date: Fri, 8 Nov 2024 17:16:27 +0800 Subject: [PATCH 02/15] Add device selection for `yolo_bbox2segment` (#17409) --- ultralytics/data/converter.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ultralytics/data/converter.py b/ultralytics/data/converter.py index 6b87f4e833..e854c60de9 100644 --- a/ultralytics/data/converter.py +++ b/ultralytics/data/converter.py @@ -577,7 +577,7 @@ def merge_multi_segment(segments): return s -def yolo_bbox2segment(im_dir, save_dir=None, sam_model="sam_b.pt"): +def yolo_bbox2segment(im_dir, save_dir=None, sam_model="sam_b.pt", device=None): """ Converts existing object detection dataset (bounding boxes) to segmentation dataset or oriented bounding box (OBB) in YOLO format. Generates segmentation data using SAM auto-annotator as needed. @@ -587,6 +587,7 @@ def yolo_bbox2segment(im_dir, save_dir=None, sam_model="sam_b.pt"): save_dir (str | Path): Path to save the generated labels, labels will be saved into `labels-segment` in the same directory level of `im_dir` if save_dir is None. Default: None. sam_model (str): Segmentation model to use for intermediate segmentation data; optional. + device (int | str): The specific device to run SAM models. Default: None. Notes: The input directory structure assumed for dataset: @@ -621,7 +622,7 @@ def yolo_bbox2segment(im_dir, save_dir=None, sam_model="sam_b.pt"): boxes[:, [0, 2]] *= w boxes[:, [1, 3]] *= h im = cv2.imread(label["im_file"]) - sam_results = sam_model(im, bboxes=xywh2xyxy(boxes), verbose=False, save=False) + sam_results = sam_model(im, bboxes=xywh2xyxy(boxes), verbose=False, save=False, device=device) label["segments"] = sam_results[0].masks.xyn save_dir = Path(save_dir) if save_dir else Path(im_dir).parent / "labels-segment" From f2f81aa5e8bc41d8d43d233c9d79f3a922c5e0f0 Mon Sep 17 00:00:00 2001 From: Mohammed Yasin <32206511+Y-T-G@users.noreply.github.com> Date: Fri, 8 Nov 2024 17:19:17 +0800 Subject: [PATCH 03/15] Update validation-args.md (#17411) Co-authored-by: UltralyticsAssistant Co-authored-by: Glenn Jocher --- docs/en/macros/validation-args.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/macros/validation-args.md b/docs/en/macros/validation-args.md index 5eeea81f49..c28a8e473a 100644 --- a/docs/en/macros/validation-args.md +++ b/docs/en/macros/validation-args.md @@ -12,7 +12,7 @@ | `device` | `str` | `None` | Specifies the device for validation (`cpu`, `cuda:0`, etc.). Allows flexibility in utilizing CPU or GPU resources. | | `dnn` | `bool` | `False` | If `True`, uses the [OpenCV](https://www.ultralytics.com/glossary/opencv) DNN module for ONNX model inference, offering an alternative to [PyTorch](https://www.ultralytics.com/glossary/pytorch) inference methods. | | `plots` | `bool` | `False` | When set to `True`, generates and saves plots of predictions versus ground truth for visual evaluation of the model's performance. | -| `rect` | `bool` | `False` | If `True`, uses rectangular inference for batching, reducing padding and potentially increasing speed and efficiency. | +| `rect` | `bool` | `True` | If `True`, uses rectangular inference for batching, reducing padding and potentially increasing speed and efficiency. | | `split` | `str` | `val` | Determines the dataset split to use for validation (`val`, `test`, or `train`). Allows flexibility in choosing the data segment for performance evaluation. | | `project` | `str` | `None` | Name of the project directory where validation outputs are saved. | | `name` | `str` | `None` | Name of the validation run. Used for creating a subdirectory within the project folder, where valdiation logs and outputs are stored. | From 84bfe3c2e4fd5881c33d0f1264b94c6e62edeb43 Mon Sep 17 00:00:00 2001 From: Paula Derrenger <107626595+pderrenger@users.noreply.github.com> Date: Fri, 8 Nov 2024 12:31:42 +0100 Subject: [PATCH 04/15] Use new Ultralytics Retry action (#17419) Co-authored-by: UltralyticsAssistant Co-authored-by: Glenn Jocher --- .github/workflows/docker.yaml | 8 ++++---- .github/workflows/links.yml | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 38f30bb1b6..8682340a33 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -134,12 +134,12 @@ jobs: - name: Build Image if: github.event_name == 'push' || github.event.inputs[matrix.dockerfile] == 'true' - uses: nick-invision/retry@v3 + uses: ultralytics/actions/retry@main with: timeout_minutes: 120 - retry_wait_seconds: 60 - max_attempts: 3 # retry twice - command: | + retry_delay_seconds: 60 + retries: 2 + run: | docker build \ --platform ${{ matrix.platforms }} \ -f docker/${{ matrix.dockerfile }} \ diff --git a/.github/workflows/links.yml b/.github/workflows/links.yml index 4dd8aa38b0..1a0b3ca15c 100644 --- a/.github/workflows/links.yml +++ b/.github/workflows/links.yml @@ -29,12 +29,12 @@ jobs: sudo mv lychee /usr/local/bin - name: Test Markdown and HTML links with retry - uses: nick-invision/retry@v3 + uses: ultralytics/actions/retry@main with: - timeout_minutes: 5 - retry_wait_seconds: 60 - max_attempts: 3 - command: | + timeout_minutes: 60 + retry_delay_seconds: 300 + retries: 2 + run: | lychee \ --scheme https \ --timeout 60 \ @@ -59,12 +59,12 @@ jobs: - name: Test Markdown, HTML, YAML, Python and Notebook links with retry if: github.event_name == 'workflow_dispatch' - uses: nick-invision/retry@v3 + uses: ultralytics/actions/retry@main with: - timeout_minutes: 5 - retry_wait_seconds: 60 - max_attempts: 3 - command: | + timeout_minutes: 60 + retry_delay_seconds: 300 + retries: 2 + run: | lychee \ --scheme https \ --timeout 60 \ From 95368cbe54ba0767e7fd8504e417f5be8e87b544 Mon Sep 17 00:00:00 2001 From: Kilian Schnelle <57074573+KiSchnelle@users.noreply.github.com> Date: Fri, 8 Nov 2024 16:19:46 +0100 Subject: [PATCH 05/15] Changed model.names return type hint from list to dict[int, str] (#17402) --- ultralytics/engine/model.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ultralytics/engine/model.py b/ultralytics/engine/model.py index c5b63eed83..718176726f 100644 --- a/ultralytics/engine/model.py +++ b/ultralytics/engine/model.py @@ -2,7 +2,7 @@ import inspect from pathlib import Path -from typing import List, Union +from typing import Dict, List, Union import numpy as np import torch @@ -881,7 +881,7 @@ class Model(nn.Module): return self @property - def names(self) -> list: + def names(self) -> Dict[int, str]: """ Retrieves the class names associated with the loaded model. From cc81b0667993df97fee963bf6de4ce41318597ae Mon Sep 17 00:00:00 2001 From: Burhan <62214284+Burhan-Q@users.noreply.github.com> Date: Fri, 8 Nov 2024 11:49:11 -0500 Subject: [PATCH 06/15] Match Docs caption to video thumbnail text (#17424) --- docs/en/guides/object-counting.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/guides/object-counting.md b/docs/en/guides/object-counting.md index 144555793d..796d1533aa 100644 --- a/docs/en/guides/object-counting.md +++ b/docs/en/guides/object-counting.md @@ -19,7 +19,7 @@ Object counting with [Ultralytics YOLO11](https://github.com/ultralytics/ultraly allowfullscreen>
- Watch: Object Counting using Ultralytics YOLO11 + Watch: Object Counting using Ultralytics YOLOv8