diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 061d96c71d7..0e2eb907501 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,14 +2,17 @@ # Pre-commit hooks. For more information see https://github.com/pre-commit/pre-commit-hooks/blob/main/README.md # Optionally remove from local hooks with 'rm .git/hooks/pre-commit' -# exclude: 'docs/' # Define bot property if installed via https://github.com/marketplace/pre-commit-ci ci: autofix_prs: true autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions' autoupdate_schedule: monthly - # submodules: true + submodules: true + +# Exclude directories (optional) +# exclude: 'docs/' +# Define repos to run repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 diff --git a/docker/Dockerfile b/docker/Dockerfile index 5973417a6e7..30952700ce4 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -13,7 +13,6 @@ ADD https://ultralytics.com/assets/Arial.ttf https://ultralytics.com/assets/Aria # g++ required to build 'tflite_support' and 'lap' packages, libusb-1.0-0 required for 'tflite_support' package RUN apt update \ && apt install --no-install-recommends -y gcc git zip curl htop libgl1-mesa-glx libglib2.0-0 libpython3-dev gnupg g++ libusb-1.0-0 -# RUN alias python=python3 # Security updates # https://security.snyk.io/vuln/SNYK-UBUNTU1804-OPENSSL-3314796 diff --git a/docker/Dockerfile-arm64 b/docker/Dockerfile-arm64 index c31bbaa3e42..c83af47de3a 100644 --- a/docker/Dockerfile-arm64 +++ b/docker/Dockerfile-arm64 @@ -12,7 +12,6 @@ ADD https://ultralytics.com/assets/Arial.ttf https://ultralytics.com/assets/Aria # g++ required to build 'tflite_support' and 'lap' packages, libusb-1.0-0 required for 'tflite_support' package RUN apt update \ && apt install --no-install-recommends -y python3-pip git zip curl htop gcc libgl1-mesa-glx libglib2.0-0 libpython3-dev gnupg g++ libusb-1.0-0 -# RUN alias python=python3 # Create working directory WORKDIR /usr/src/ultralytics diff --git a/docker/Dockerfile-cpu b/docker/Dockerfile-cpu index cc528c86c20..847c44dccfe 100644 --- a/docker/Dockerfile-cpu +++ b/docker/Dockerfile-cpu @@ -12,7 +12,6 @@ ADD https://ultralytics.com/assets/Arial.ttf https://ultralytics.com/assets/Aria # g++ required to build 'tflite_support' and 'lap' packages, libusb-1.0-0 required for 'tflite_support' package RUN apt update \ && apt install --no-install-recommends -y python3-pip git zip curl htop libgl1-mesa-glx libglib2.0-0 libpython3-dev gnupg g++ libusb-1.0-0 -# RUN alias python=python3 # Create working directory WORKDIR /usr/src/ultralytics diff --git a/docker/Dockerfile-jetson b/docker/Dockerfile-jetson index a8bbc6427b5..569b7f5d47e 100644 --- a/docker/Dockerfile-jetson +++ b/docker/Dockerfile-jetson @@ -12,7 +12,6 @@ ADD https://ultralytics.com/assets/Arial.ttf https://ultralytics.com/assets/Aria # g++ required to build 'tflite_support' and 'lap' packages, libusb-1.0-0 required for 'tflite_support' package RUN apt update \ && apt install --no-install-recommends -y gcc git zip curl htop libgl1-mesa-glx libglib2.0-0 libpython3-dev gnupg g++ libusb-1.0-0 -# RUN alias python=python3 # Create working directory WORKDIR /usr/src/ultralytics diff --git a/docker/Dockerfile-python b/docker/Dockerfile-python index caef5933234..5163d0afdde 100644 --- a/docker/Dockerfile-python +++ b/docker/Dockerfile-python @@ -12,7 +12,6 @@ ADD https://ultralytics.com/assets/Arial.ttf https://ultralytics.com/assets/Aria # g++ required to build 'tflite_support' and 'lap' packages, libusb-1.0-0 required for 'tflite_support' package RUN apt update \ && apt install --no-install-recommends -y python3-pip git zip curl htop libgl1-mesa-glx libglib2.0-0 libpython3-dev gnupg g++ libusb-1.0-0 -# RUN alias python=python3 # Create working directory WORKDIR /usr/src/ultralytics diff --git a/docs/guides/index.md b/docs/guides/index.md index 7204d3f50ee..1bf8eb35fa4 100644 --- a/docs/guides/index.md +++ b/docs/guides/index.md @@ -15,6 +15,7 @@ Whether you're a beginner or an expert in deep learning, our tutorials offer val Here's a compilation of in-depth guides to help you master different aspects of Ultralytics YOLO. * [YOLO Common Issues](yolo-common-issues.md) ⭐ RECOMMENDED: Practical solutions and troubleshooting tips to the most frequently encountered issues when working with Ultralytics YOLO models. +* [YOLO Performance Metrics](yolo-performance-metrics.md) ⭐ ESSENTIAL: Understand the key metrics like mAP, IoU, and F1 score used to evaluate the performance of your YOLO models. Includes practical examples and tips on how to improve detection accuracy and speed. * [K-Fold Cross Validation](kfold-cross-validation.md) 🚀 NEW: Learn how to improve model generalization using K-Fold cross-validation technique. * [Hyperparameter Tuning](hyperparameter-tuning.md) 🚀 NEW: Discover how to optimize your YOLO models by fine-tuning hyperparameters using the Tuner class and genetic evolution algorithms. * [SAHI Tiled Inference](sahi-tiled-inference.md) 🚀 NEW: Comprehensive guide on leveraging SAHI's sliced inference capabilities with YOLOv8 for object detection in high-resolution images. diff --git a/docs/guides/performance-metrics.md b/docs/guides/yolo-performance-metrics.md similarity index 94% rename from docs/guides/performance-metrics.md rename to docs/guides/yolo-performance-metrics.md index f527c162f7a..d2355a204be 100644 --- a/docs/guides/performance-metrics.md +++ b/docs/guides/yolo-performance-metrics.md @@ -46,13 +46,13 @@ One of the sections of the output is the class-wise breakdown of performance met - **Box(P, R, mAP50, mAP50-95)**: This metric provides insights into the model's performance in detecting objects: - - **P (Precision)**: The accuracy of the detected objects, indicating how many detections were correct. + - **P (Precision)**: The accuracy of the detected objects, indicating how many detections were correct. - - **R (Recall)**: The ability of the model to identify all instances of objects in the images. + - **R (Recall)**: The ability of the model to identify all instances of objects in the images. - - **mAP50**: Mean average precision calculated at an intersection over union (IoU) threshold of 0.50. It's a measure of the model's accuracy considering only the "easy" detections. + - **mAP50**: Mean average precision calculated at an intersection over union (IoU) threshold of 0.50. It's a measure of the model's accuracy considering only the "easy" detections. - - **mAP50-95**: The average of the mean average precision calculated at varying IoU thresholds, ranging from 0.50 to 0.95. It gives a comprehensive view of the model's performance across different levels of detection difficulty. + - **mAP50-95**: The average of the mean average precision calculated at varying IoU thresholds, ranging from 0.50 to 0.95. It gives a comprehensive view of the model's performance across different levels of detection difficulty. #### Speed Metrics diff --git a/docs/help/CI.md b/docs/help/CI.md index 890665ac613..60cd01e3912 100644 --- a/docs/help/CI.md +++ b/docs/help/CI.md @@ -22,13 +22,13 @@ Here's a brief description of our CI actions: Below is the table showing the status of these CI tests for our main repositories: -| Repository | CI | Docker Deployment | Broken Links | CodeQL | PyPi and Docs Publishing | -|-----------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [yolov3](https://github.com/ultralytics/yolov3) | [![YOLOv3 CI](https://github.com/ultralytics/yolov3/actions/workflows/ci-testing.yml/badge.svg)](https://github.com/ultralytics/yolov3/actions/workflows/ci-testing.yml) | [![Publish Docker Images](https://github.com/ultralytics/yolov3/actions/workflows/docker.yml/badge.svg)](https://github.com/ultralytics/yolov3/actions/workflows/docker.yml) | [![Check Broken links](https://github.com/ultralytics/yolov3/actions/workflows/links.yml/badge.svg)](https://github.com/ultralytics/yolov3/actions/workflows/links.yml) | [![CodeQL](https://github.com/ultralytics/yolov3/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/ultralytics/yolov3/actions/workflows/codeql-analysis.yml) | | -| [yolov5](https://github.com/ultralytics/yolov5) | [![YOLOv5 CI](https://github.com/ultralytics/yolov5/actions/workflows/ci-testing.yml/badge.svg)](https://github.com/ultralytics/yolov5/actions/workflows/ci-testing.yml) | [![Publish Docker Images](https://github.com/ultralytics/yolov5/actions/workflows/docker.yml/badge.svg)](https://github.com/ultralytics/yolov5/actions/workflows/docker.yml) | [![Check Broken links](https://github.com/ultralytics/yolov5/actions/workflows/links.yml/badge.svg)](https://github.com/ultralytics/yolov5/actions/workflows/links.yml) | [![CodeQL](https://github.com/ultralytics/yolov5/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/ultralytics/yolov5/actions/workflows/codeql-analysis.yml) | | -| [ultralytics](https://github.com/ultralytics/ultralytics) | [![ultralytics CI](https://github.com/ultralytics/ultralytics/actions/workflows/ci.yaml/badge.svg)](https://github.com/ultralytics/ultralytics/actions/workflows/ci.yaml) | [![Publish Docker Images](https://github.com/ultralytics/ultralytics/actions/workflows/docker.yaml/badge.svg)](https://github.com/ultralytics/ultralytics/actions/workflows/docker.yaml) | [![Check Broken links](https://github.com/ultralytics/ultralytics/actions/workflows/links.yml/badge.svg)](https://github.com/ultralytics/ultralytics/actions/workflows/links.yml) | [![CodeQL](https://github.com/ultralytics/ultralytics/actions/workflows/codeql.yaml/badge.svg)](https://github.com/ultralytics/ultralytics/actions/workflows/codeql.yaml) | [![Publish to PyPI and Deploy Docs](https://github.com/ultralytics/ultralytics/actions/workflows/publish.yml/badge.svg)](https://github.com/ultralytics/ultralytics/actions/workflows/publish.yml) | -| [hub](https://github.com/ultralytics/hub) | [![HUB CI](https://github.com/ultralytics/hub/actions/workflows/ci.yaml/badge.svg)](https://github.com/ultralytics/hub/actions/workflows/ci.yaml) | | [![Check Broken links](https://github.com/ultralytics/hub/actions/workflows/links.yml/badge.svg)](https://github.com/ultralytics/hub/actions/workflows/links.yml) | | | -| [docs](https://github.com/ultralytics/docs) | | | | | [![pages-build-deployment](https://github.com/ultralytics/docs/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/ultralytics/docs/actions/workflows/pages/pages-build-deployment) [![Check Broken links](https://github.com/ultralytics/docs/actions/workflows/links.yml/badge.svg)](https://github.com/ultralytics/docs/actions/workflows/links.yml) | +| Repository | CI | Docker Deployment | Broken Links | CodeQL | PyPi and Docs Publishing | +|-----------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [yolov3](https://github.com/ultralytics/yolov3) | [![YOLOv3 CI](https://github.com/ultralytics/yolov3/actions/workflows/ci-testing.yml/badge.svg)](https://github.com/ultralytics/yolov3/actions/workflows/ci-testing.yml) | [![Publish Docker Images](https://github.com/ultralytics/yolov3/actions/workflows/docker.yml/badge.svg)](https://github.com/ultralytics/yolov3/actions/workflows/docker.yml) | [![Check Broken links](https://github.com/ultralytics/yolov3/actions/workflows/links.yml/badge.svg)](https://github.com/ultralytics/yolov3/actions/workflows/links.yml) | [![CodeQL](https://github.com/ultralytics/yolov3/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/ultralytics/yolov3/actions/workflows/codeql-analysis.yml) | | +| [yolov5](https://github.com/ultralytics/yolov5) | [![YOLOv5 CI](https://github.com/ultralytics/yolov5/actions/workflows/ci-testing.yml/badge.svg)](https://github.com/ultralytics/yolov5/actions/workflows/ci-testing.yml) | [![Publish Docker Images](https://github.com/ultralytics/yolov5/actions/workflows/docker.yml/badge.svg)](https://github.com/ultralytics/yolov5/actions/workflows/docker.yml) | [![Check Broken links](https://github.com/ultralytics/yolov5/actions/workflows/links.yml/badge.svg)](https://github.com/ultralytics/yolov5/actions/workflows/links.yml) | [![CodeQL](https://github.com/ultralytics/yolov5/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/ultralytics/yolov5/actions/workflows/codeql-analysis.yml) | | +| [ultralytics](https://github.com/ultralytics/ultralytics) | [![ultralytics CI](https://github.com/ultralytics/ultralytics/actions/workflows/ci.yaml/badge.svg)](https://github.com/ultralytics/ultralytics/actions/workflows/ci.yaml) | [![Publish Docker Images](https://github.com/ultralytics/ultralytics/actions/workflows/docker.yaml/badge.svg)](https://github.com/ultralytics/ultralytics/actions/workflows/docker.yaml) | [![Check Broken links](https://github.com/ultralytics/ultralytics/actions/workflows/links.yml/badge.svg)](https://github.com/ultralytics/ultralytics/actions/workflows/links.yml) | [![CodeQL](https://github.com/ultralytics/ultralytics/actions/workflows/codeql.yaml/badge.svg)](https://github.com/ultralytics/ultralytics/actions/workflows/codeql.yaml) | [![Publish to PyPI and Deploy Docs](https://github.com/ultralytics/ultralytics/actions/workflows/publish.yml/badge.svg)](https://github.com/ultralytics/ultralytics/actions/workflows/publish.yml) | +| [hub](https://github.com/ultralytics/hub) | [![HUB CI](https://github.com/ultralytics/hub/actions/workflows/ci.yaml/badge.svg)](https://github.com/ultralytics/hub/actions/workflows/ci.yaml) | | [![Check Broken links](https://github.com/ultralytics/hub/actions/workflows/links.yml/badge.svg)](https://github.com/ultralytics/hub/actions/workflows/links.yml) | | | +| [docs](https://github.com/ultralytics/docs) | | | [![Check Broken links](https://github.com/ultralytics/docs/actions/workflows/links.yml/badge.svg)](https://github.com/ultralytics/docs/actions/workflows/links.yml) | | [![pages-build-deployment](https://github.com/ultralytics/docs/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/ultralytics/docs/actions/workflows/pages/pages-build-deployment) | Each badge shows the status of the last run of the corresponding CI test on the `main` branch of the respective repository. If a test fails, the badge will display a "failing" status, and if it passes, it will display a "passing" status. diff --git a/docs/modes/train.md b/docs/modes/train.md index e3db6c30d3c..6b01c5d8cff 100644 --- a/docs/modes/train.md +++ b/docs/modes/train.md @@ -47,7 +47,7 @@ The following are some notable features of YOLOv8's Train mode: ## Usage Examples -Train YOLOv8n on the COCO128 dataset for 100 epochs at image size 640. See Arguments section below for a full list of training arguments. +Train YOLOv8n on the COCO128 dataset for 100 epochs at image size 640. The training device can be specified using the `device` argument. If no argument is passed GPU `device=0` will be used if available, otherwise `device=cpu` will be used. See Arguments section below for a full list of training arguments. !!! example "Single-GPU and CPU Training Example" @@ -82,10 +82,12 @@ Train YOLOv8n on the COCO128 dataset for 100 epochs at image size 640. See Argum ### Multi-GPU Training -The training device can be specified using the `device` argument. If no argument is passed GPU `device=0` will be used if available, otherwise `device=cpu` will be used. +Multi-GPU training allows for more efficient utilization of available hardware resources by distributing the training load across multiple GPUs. This feature is available through both the Python API and the command-line interface. To enable multi-GPU training, specify the GPU device IDs you wish to use. !!! example "Multi-GPU Training Example" + To train with 2 GPUs, CUDA devices 0 and 1 use the following commands. Expand to additional GPUs as required. + === "Python" ```python diff --git a/mkdocs.yml b/mkdocs.yml index fd360be96a3..9b8a875341c 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -215,6 +215,7 @@ nav: - Guides: - guides/index.md - YOLO Common Issues: guides/yolo-common-issues.md + - Performance Metrics: guides/yolo-performance-metrics.md - K-Fold Cross Validation: guides/kfold-cross-validation.md - Hyperparameter Tuning: guides/hyperparameter-tuning.md - SAHI Tiled Inference: guides/sahi-tiled-inference.md diff --git a/ultralytics/__init__.py b/ultralytics/__init__.py index a73c2b9e17d..19149c336bd 100644 --- a/ultralytics/__init__.py +++ b/ultralytics/__init__.py @@ -1,6 +1,6 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license -__version__ = '8.0.202' +__version__ = '8.0.203' from ultralytics.models import RTDETR, SAM, YOLO from ultralytics.models.fastsam import FastSAM diff --git a/ultralytics/trackers/bot_sort.py b/ultralytics/trackers/bot_sort.py index 543d75262f4..778786b83e0 100644 --- a/ultralytics/trackers/bot_sort.py +++ b/ultralytics/trackers/bot_sort.py @@ -192,3 +192,8 @@ def get_dists(self, tracks, detections): def multi_predict(self, tracks): """Predict and track multiple objects with YOLOv8 model.""" BOTrack.multi_predict(tracks) + + def reset(self): + """Reset tracker.""" + super().reset() + self.gmc.reset_params() diff --git a/ultralytics/trackers/byte_tracker.py b/ultralytics/trackers/byte_tracker.py index 40954c98b45..1a612f89524 100644 --- a/ultralytics/trackers/byte_tracker.py +++ b/ultralytics/trackers/byte_tracker.py @@ -374,6 +374,15 @@ def reset_id(self): """Resets the ID counter of STrack.""" STrack.reset_id() + def reset(self): + """Reset tracker.""" + self.tracked_stracks = [] # type: list[STrack] + self.lost_stracks = [] # type: list[STrack] + self.removed_stracks = [] # type: list[STrack] + self.frame_id = 0 + self.kalman_filter = self.get_kalmanfilter() + self.reset_id() + @staticmethod def joint_stracks(tlista, tlistb): """Combine two lists of stracks into a single one.""" diff --git a/ultralytics/trackers/track.py b/ultralytics/trackers/track.py index cf06c033cfc..5ec06dc532e 100644 --- a/ultralytics/trackers/track.py +++ b/ultralytics/trackers/track.py @@ -1,6 +1,7 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license from functools import partial +from pathlib import Path import torch @@ -40,8 +41,12 @@ def on_predict_start(predictor, persist=False): def on_predict_postprocess_end(predictor): """Postprocess detected boxes and update with object tracking.""" bs = predictor.dataset.bs - im0s = predictor.batch[1] + path, im0s = predictor.batch[:2] + for i in range(bs): + if predictor.vid_path[i] != str(predictor.save_dir / Path(path[i]).name): # new video + predictor.trackers[i].reset() + det = predictor.results[i].boxes.cpu().numpy() if len(det) == 0: continue diff --git a/ultralytics/trackers/utils/gmc.py b/ultralytics/trackers/utils/gmc.py index 24e4907d8ee..60c46a191a1 100644 --- a/ultralytics/trackers/utils/gmc.py +++ b/ultralytics/trackers/utils/gmc.py @@ -300,3 +300,10 @@ def applySparseOptFlow(self, raw_frame, detections=None): self.prevKeyPoints = copy.copy(keypoints) return H + + def reset_params(self): + """Reset parameters.""" + self.prevFrame = None + self.prevKeyPoints = None + self.prevDescriptors = None + self.initializedFirstFrame = False