From 627453c26ab960212d72a273ae45195ed6cfc094 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 25 May 2024 21:25:51 +0200 Subject: [PATCH] Auto-update Docs Reference section action (#13127) Signed-off-by: Glenn Jocher Co-authored-by: UltralyticsAssistant --- .github/workflows/ci.yaml | 17 +++++++ docs/build_reference.py | 16 ++++-- docs/en/guides/parking-management.md | 1 + docs/en/index.md | 50 ++++++++++++------- docs/en/reference/models/yolo/world/train.md | 5 ++ .../models/yolo/world/train_world.md | 5 ++ docs/en/reference/solutions/analytics.md | 16 ++++++ docs/mkdocs_github_authors.yaml | 2 +- examples/heatmaps.ipynb | 4 +- examples/hub.ipynb | 4 +- examples/object_counting.ipynb | 6 ++- examples/object_tracking.ipynb | 6 ++- examples/tutorial.ipynb | 14 +++--- mkdocs.yml | 3 ++ ultralytics/solutions/analytics.py | 4 +- 15 files changed, 116 insertions(+), 37 deletions(-) create mode 100644 docs/en/reference/solutions/analytics.md diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c0f0448b..81ff3f2b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -43,6 +43,9 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref || github.ref }} + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v5 with: @@ -50,6 +53,20 @@ jobs: cache: "pip" # caching pip dependencies - name: Install Dependencies run: pip install tqdm mkdocs-material "mkdocstrings[python]" mkdocs-jupyter mkdocs-redirects mkdocs-ultralytics-plugin + - name: Update Docs Reference Section + run: python docs/build_reference.py + - name: Commit and Push Changes + run: | + git add . + git reset HEAD -- .github/workflows/ # workflow changes are not permitted with default token + if ! git diff --staged --quiet; then + git config --global user.name "UltralyticsAssistant" + git config --global user.email "web@ultralytics.com" + git commit -m "Auto-update Ultralytics Docs by https://ultralytics.com/actions" + git push + else + echo "No changes to commit" + fi - name: Build Docs and Check for Warnings run: python docs/build_docs.py diff --git a/docs/build_reference.py b/docs/build_reference.py index 7b2b4094..f15e1b1c 100644 --- a/docs/build_reference.py +++ b/docs/build_reference.py @@ -7,13 +7,13 @@ Note: Must be run from repository root directory. Do not run from docs directory """ import re +import subprocess from collections import defaultdict from pathlib import Path -# Get package root i.e. /Users/glennjocher/PycharmProjects/ultralytics/ultralytics -from ultralytics.utils import ROOT as PACKAGE_DIR - # Constants +FILE = Path(__file__).resolve() +PACKAGE_DIR = FILE.parents[1] / "ultralytics" # i.e. /Users/glennjocher/PycharmProjects/ultralytics/ultralytics REFERENCE_DIR = PACKAGE_DIR.parent / "docs/en/reference" GITHUB_REPO = "ultralytics/ultralytics" @@ -33,15 +33,18 @@ def extract_classes_and_functions(filepath: Path) -> tuple: def create_markdown(py_filepath: Path, module_path: str, classes: list, functions: list): """Creates a Markdown file containing the API reference for the given Python module.""" md_filepath = py_filepath.with_suffix(".md") + exists = md_filepath.exists() # Read existing content and keep header content between first two --- header_content = "" - if md_filepath.exists(): + if exists: existing_content = md_filepath.read_text() header_parts = existing_content.split("---") for part in header_parts: if "description:" in part or "comments:" in part: header_content += f"---{part}---\n\n" + if not any(header_content): + header_content = "---\ndescription: TODO ADD DESCRIPTION\nkeywords: TODO ADD KEYWORDS\n---\n\n" module_name = module_path.replace(".__init__", "") module_path = module_path.replace(".", "/") @@ -62,6 +65,11 @@ def create_markdown(py_filepath: Path, module_path: str, classes: list, function md_filepath.parent.mkdir(parents=True, exist_ok=True) md_filepath.write_text(md_content) + if not exists: + # Add new markdown file to the git staging area + print(f"Created new file '{md_filepath}'") + subprocess.run(["git", "add", "-f", str(md_filepath)], check=True) + return md_filepath.relative_to(PACKAGE_DIR.parent) diff --git a/docs/en/guides/parking-management.md b/docs/en/guides/parking-management.md index dfc61359..803df0f0 100644 --- a/docs/en/guides/parking-management.md +++ b/docs/en/guides/parking-management.md @@ -44,6 +44,7 @@ Parking management with [Ultralytics YOLOv8](https://github.com/ultralytics/ultr ```python from ultralytics import solutions + solutions.ParkingPtsSelection() ``` diff --git a/docs/en/index.md b/docs/en/index.md index be3b80fe..9f638cd4 100644 --- a/docs/en/index.md +++ b/docs/en/index.md @@ -5,10 +5,38 @@ keywords: Ultralytics, YOLOv8, object detection, image segmentation, machine lea ---
-

- - Ultralytics YOLO banner -

+Ultralytics YOLO banner +中文 | +한국어 | +日本語 | +Русский | +Deutsch | +Français | +Español | +Português | +Türkçe | +Tiếng Việt | +हिन्दी | +العربية +
+
+Ultralytics CI +Ultralytics Code Coverage +YOLOv8 Citation +Docker Pulls +Discord +
+Run on Gradient +Open In Colab +Open In Kaggle +
+ +Introducing [Ultralytics](https://ultralytics.com) [YOLOv8](https://github.com/ultralytics/ultralytics), the latest version of the acclaimed real-time object detection and image segmentation model. YOLOv8 is built on cutting-edge advancements in deep learning and computer vision, offering unparalleled performance in terms of speed and accuracy. Its streamlined design makes it suitable for various applications and easily adaptable to different hardware platforms, from edge devices to cloud APIs. + +Explore the YOLOv8 Docs, a comprehensive resource designed to help you understand and utilize its features and capabilities. Whether you are a seasoned machine learning practitioner or new to the field, this hub aims to maximize YOLOv8's potential in your projects + +
+
Ultralytics GitHub space Ultralytics LinkedIn @@ -22,22 +50,8 @@ keywords: Ultralytics, YOLOv8, object detection, image segmentation, machine lea Ultralytics Instagram space Ultralytics Discord -
-
- Ultralytics CI - Ultralytics Code Coverage - YOLOv8 Citation - Docker Pulls - Discord -
- Run on Gradient - Open In Colab - Open In Kaggle
-Introducing [Ultralytics](https://ultralytics.com) [YOLOv8](https://github.com/ultralytics/ultralytics), the latest version of the acclaimed real-time object detection and image segmentation model. YOLOv8 is built on cutting-edge advancements in deep learning and computer vision, offering unparalleled performance in terms of speed and accuracy. Its streamlined design makes it suitable for various applications and easily adaptable to different hardware platforms, from edge devices to cloud APIs. - -Explore the YOLOv8 Docs, a comprehensive resource designed to help you understand and utilize its features and capabilities. Whether you are a seasoned machine learning practitioner or new to the field, this hub aims to maximize YOLOv8's potential in your projects ## Where to Start diff --git a/docs/en/reference/models/yolo/world/train.md b/docs/en/reference/models/yolo/world/train.md index 113a443e..fd542057 100644 --- a/docs/en/reference/models/yolo/world/train.md +++ b/docs/en/reference/models/yolo/world/train.md @@ -1,3 +1,8 @@ +--- +description: Detailed guide on the Ultralytics YOLO WorldTrainer class, including methods for fine-tuning world models and dataset building. +keywords: Ultralytics, YOLO, WorldTrainer, WorldModel, training, dataset, machine learning, AI, deep learning, computer vision, ViT-B/32, clip +--- + # Reference for `ultralytics/models/yolo/world/train.py` !!! Note diff --git a/docs/en/reference/models/yolo/world/train_world.md b/docs/en/reference/models/yolo/world/train_world.md index e9a72a73..4b35eca6 100644 --- a/docs/en/reference/models/yolo/world/train_world.md +++ b/docs/en/reference/models/yolo/world/train_world.md @@ -1,3 +1,8 @@ +--- +description: Comprehensive guide on the WorldTrainerFromScratch class for training YOLO world models from scratch on open-set datasets. +keywords: YOLO, WorldTrainerFromScratch, Ultralytics, YOLO world models, open-set datasets, deep learning, machine learning, computer vision, dataset building, ViT-B/32, CLIP, training +--- + # Reference for `ultralytics/models/yolo/world/train_world.py` !!! Note diff --git a/docs/en/reference/solutions/analytics.md b/docs/en/reference/solutions/analytics.md new file mode 100644 index 00000000..cb65b2d4 --- /dev/null +++ b/docs/en/reference/solutions/analytics.md @@ -0,0 +1,16 @@ +--- +description: This script integrates Ultralytics YOLO with OpenCV and Matplotlib to create and update line, bar, and pie charts for real-time data visualization in video processing. +keywords: Ultralytics, YOLO, data visualization, OpenCV, Matplotlib, line chart, bar chart, pie chart, real-time analytics, video processing, machine learning, computer vision, AGPL-3.0 +--- + +# Reference for `ultralytics/solutions/analytics.py` + +!!! Note + + This file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/solutions/analytics.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/solutions/analytics.py). If you spot a problem please help fix it by [contributing](/help/contributing.md) a [Pull Request](https://github.com/ultralytics/ultralytics/edit/main/ultralytics/solutions/analytics.py) 🛠️. Thank you 🙏! + +

+ +## ::: ultralytics.solutions.analytics.Analytics + +

diff --git a/docs/mkdocs_github_authors.yaml b/docs/mkdocs_github_authors.yaml index c37c8910..1584fc99 100644 --- a/docs/mkdocs_github_authors.yaml +++ b/docs/mkdocs_github_authors.yaml @@ -16,6 +16,7 @@ 78843978+Skillnoob@users.noreply.github.com: Skillnoob 79740115+0xSynapse@users.noreply.github.com: 0xSynapse abirami.vina@gmail.com: abirami-vina +andrei.kochin@intel.com: andrei-kochin ayush.chaurarsia@gmail.com: AyushExel chr043416@gmail.com: RizwanMunawar glenn.jocher@ultralytics.com: glenn-jocher @@ -28,4 +29,3 @@ priytosh.revolution@live.com: priytosh-tripathi shuizhuyuanluo@126.com: null stormsson@users.noreply.github.com: stormsson xinwang614@gmail.com: GreatV -andrei.kochin@intel.com: andrei-kochin diff --git a/examples/heatmaps.ipynb b/examples/heatmaps.ipynb index b73c90d6..fc80a1c8 100644 --- a/examples/heatmaps.ipynb +++ b/examples/heatmaps.ipynb @@ -50,7 +50,9 @@ "source": [ "# Setup\n", "\n", - "Pip install `ultralytics` and [dependencies](https://github.com/ultralytics/ultralytics/blob/main/pyproject.toml) and check software and hardware." + "Pip install `ultralytics` and [dependencies](https://github.com/ultralytics/ultralytics/blob/main/pyproject.toml) and check software and hardware.\n", + "\n", + "[![PyPI - Version](https://img.shields.io/pypi/v/ultralytics?logo=pypi&logoColor=white)](https://pypi.org/project/ultralytics/) [![Downloads](https://static.pepy.tech/badge/ultralytics)](https://pepy.tech/project/ultralytics) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ultralytics?logo=python&logoColor=gold)](https://pypi.org/project/ultralytics/)" ], "metadata": { "id": "o68Sg1oOeZm2" diff --git a/examples/hub.ipynb b/examples/hub.ipynb index db2b4fb3..707b6692 100644 --- a/examples/hub.ipynb +++ b/examples/hub.ipynb @@ -49,7 +49,9 @@ "source": [ "# Setup\n", "\n", - "Pip install `ultralytics` and [dependencies](https://github.com/ultralytics/ultralytics/blob/main/pyproject.toml) and check software and hardware." + "Pip install `ultralytics` and [dependencies](https://github.com/ultralytics/ultralytics/blob/main/pyproject.toml) and check software and hardware.\n", + "\n", + "[![PyPI - Version](https://img.shields.io/pypi/v/ultralytics?logo=pypi&logoColor=white)](https://pypi.org/project/ultralytics/) [![Downloads](https://static.pepy.tech/badge/ultralytics)](https://pepy.tech/project/ultralytics) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ultralytics?logo=python&logoColor=gold)](https://pypi.org/project/ultralytics/)" ] }, { diff --git a/examples/object_counting.ipynb b/examples/object_counting.ipynb index 3a610d0a..4dc197ca 100644 --- a/examples/object_counting.ipynb +++ b/examples/object_counting.ipynb @@ -49,7 +49,9 @@ "source": [ "# Setup\n", "\n", - "Pip install `ultralytics` and [dependencies](https://github.com/ultralytics/ultralytics/blob/main/pyproject.toml) and check software and hardware." + "Pip install `ultralytics` and [dependencies](https://github.com/ultralytics/ultralytics/blob/main/pyproject.toml) and check software and hardware.\n", + "\n", + "[![PyPI - Version](https://img.shields.io/pypi/v/ultralytics?logo=pypi&logoColor=white)](https://pypi.org/project/ultralytics/) [![Downloads](https://static.pepy.tech/badge/ultralytics)](https://pepy.tech/project/ultralytics) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ultralytics?logo=python&logoColor=gold)](https://pypi.org/project/ultralytics/)" ], "metadata": { "id": "o68Sg1oOeZm2" @@ -203,4 +205,4 @@ } } ] -} \ No newline at end of file +} diff --git a/examples/object_tracking.ipynb b/examples/object_tracking.ipynb index e576922a..5aedab5a 100644 --- a/examples/object_tracking.ipynb +++ b/examples/object_tracking.ipynb @@ -49,7 +49,9 @@ "source": [ "# Setup\n", "\n", - "Pip install `ultralytics` and [dependencies](https://github.com/ultralytics/ultralytics/blob/main/pyproject.toml) and check software and hardware." + "Pip install `ultralytics` and [dependencies](https://github.com/ultralytics/ultralytics/blob/main/pyproject.toml) and check software and hardware.\n", + "\n", + "[![PyPI - Version](https://img.shields.io/pypi/v/ultralytics?logo=pypi&logoColor=white)](https://pypi.org/project/ultralytics/) [![Downloads](https://static.pepy.tech/badge/ultralytics)](https://pepy.tech/project/ultralytics) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ultralytics?logo=python&logoColor=gold)](https://pypi.org/project/ultralytics/)" ], "metadata": { "id": "o68Sg1oOeZm2" @@ -238,4 +240,4 @@ } } ] -} \ No newline at end of file +} diff --git a/examples/tutorial.ipynb b/examples/tutorial.ipynb index 14c58d2d..7dec6f44 100644 --- a/examples/tutorial.ipynb +++ b/examples/tutorial.ipynb @@ -50,7 +50,9 @@ "source": [ "# Setup\n", "\n", - "Pip install `ultralytics` and [dependencies](https://github.com/ultralytics/ultralytics/blob/main/pyproject.toml) and check software and hardware." + "Pip install `ultralytics` and [dependencies](https://github.com/ultralytics/ultralytics/blob/main/pyproject.toml) and check software and hardware.\n", + "\n", + "[![PyPI - Version](https://img.shields.io/pypi/v/ultralytics?logo=pypi&logoColor=white)](https://pypi.org/project/ultralytics/) [![Downloads](https://static.pepy.tech/badge/ultralytics)](https://pepy.tech/project/ultralytics) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ultralytics?logo=python&logoColor=gold)](https://pypi.org/project/ultralytics/)" ] }, { @@ -67,7 +69,7 @@ "import ultralytics\n", "ultralytics.checks()" ], - "execution_count": 1, + "execution_count": null, "outputs": [ { "output_type": "stream", @@ -103,7 +105,7 @@ "# Run inference on an image with YOLOv8n\n", "!yolo predict model=yolov8n.pt source='https://ultralytics.com/images/zidane.jpg'" ], - "execution_count": 2, + "execution_count": null, "outputs": [ { "output_type": "stream", @@ -171,7 +173,7 @@ "# Validate YOLOv8n on COCO8 val\n", "!yolo val model=yolov8n.pt data=coco8.yaml" ], - "execution_count": 3, + "execution_count": null, "outputs": [ { "output_type": "stream", @@ -250,7 +252,7 @@ "# Train YOLOv8n on COCO8 for 3 epochs\n", "!yolo train model=yolov8n.pt data=coco8.yaml epochs=3 imgsz=640" ], - "execution_count": 4, + "execution_count": null, "outputs": [ { "output_type": "stream", @@ -384,7 +386,7 @@ "id": "CYIjW4igCjqD", "outputId": "947e65cc-79c8-4713-bfd4-3139903ac05a" }, - "execution_count": 5, + "execution_count": null, "outputs": [ { "output_type": "stream", diff --git a/mkdocs.yml b/mkdocs.yml index 9869fde6..a51b12a4 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -171,6 +171,8 @@ nav: - 🇫🇷  Français: https://docs.ultralytics.com/fr/ - 🇪🇸  Español: https://docs.ultralytics.com/es/ - 🇵🇹  Português: https://docs.ultralytics.com/pt/ + - 🇹🇷  Türkçe: https://docs.ultralytics.com/tr/ + - 🇻🇳  Tiếng Việt: https://docs.ultralytics.com/vi/ - 🇮🇳  हिन्दी: https://docs.ultralytics.com/hi/ - 🇸🇦  العربية: https://docs.ultralytics.com/ar/ - Quickstart: @@ -499,6 +501,7 @@ nav: - tasks: reference/nn/tasks.md - solutions: - ai_gym: reference/solutions/ai_gym.md + - analytics: reference/solutions/analytics.md - distance_calculation: reference/solutions/distance_calculation.md - heatmap: reference/solutions/heatmap.md - object_counter: reference/solutions/object_counter.md diff --git a/ultralytics/solutions/analytics.py b/ultralytics/solutions/analytics.py index 356386cd..bbae23f1 100644 --- a/ultralytics/solutions/analytics.py +++ b/ultralytics/solutions/analytics.py @@ -33,7 +33,7 @@ class Analytics: Args: type (str): Type of chart to initialize ('line', 'bar', or 'pie'). - writer: Video writer object to save the frames. + writer (object): Video writer object to save the frames. im0_shape (tuple): Shape of the input image (width, height). title (str): Title of the chart. x_label (str): Label for the x-axis. @@ -64,7 +64,7 @@ class Analytics: self.ax = fig.add_subplot(111, facecolor=self.bg_color) (self.line,) = self.ax.plot([], [], color=line_color, linewidth=line_width) - elif type == "bar" or type == "pie": + elif type in {"bar", "pie"}: # Initialize bar or pie plot self.fig, self.ax = plt.subplots(figsize=figsize, facecolor=self.bg_color) self.ax.set_facecolor(self.bg_color)