From 1db8e912a394ce506c7aa51602d7ee64cae7b1b9 Mon Sep 17 00:00:00 2001 From: Abirami Vina Date: Fri, 1 Mar 2024 04:55:31 +0530 Subject: [PATCH 1/8] Add TorchScript Docs Integrations Page (#8501) Co-authored-by: UltralyticsAssistant --- docs/build_docs.py | 1 + docs/en/integrations/index.md | 2 + docs/en/integrations/torchscript.md | 132 ++++++++++++++++++++++++++ mkdocs.yml | 1 + ultralytics/data/explorer/gui/dash.py | 6 +- ultralytics/engine/exporter.py | 7 +- ultralytics/engine/predictor.py | 1 + ultralytics/engine/tuner.py | 1 + ultralytics/engine/validator.py | 1 + 9 files changed, 146 insertions(+), 6 deletions(-) create mode 100644 docs/en/integrations/torchscript.md diff --git a/docs/build_docs.py b/docs/build_docs.py index ddcbcc57c7..825df8033d 100644 --- a/docs/build_docs.py +++ b/docs/build_docs.py @@ -23,6 +23,7 @@ Usage: Note: - This script is built to be run in an environment where Python and MkDocs are installed and properly configured. """ + import os import re import shutil diff --git a/docs/en/integrations/index.md b/docs/en/integrations/index.md index 2559077c80..1a55648bba 100644 --- a/docs/en/integrations/index.md +++ b/docs/en/integrations/index.md @@ -50,6 +50,8 @@ Welcome to the Ultralytics Integrations page! This page provides an overview of - [CoreML](coreml.md): CoreML, developed by [Apple](https://www.apple.com/), is a framework designed for efficiently integrating machine learning models into applications across iOS, macOS, watchOS, and tvOS, using Apple's hardware for effective and secure model deployment. +- [TorchScript](torchscript.md): Developed as part of the [PyTorch](https://pytorch.org/) framework, TorchScript enables efficient execution and deployment of machine learning models in various production environments without the need for Python dependencies. + ### Export Formats We also support a variety of model export formats for deployment in different environments. Here are the available formats: diff --git a/docs/en/integrations/torchscript.md b/docs/en/integrations/torchscript.md new file mode 100644 index 0000000000..68950dbcd8 --- /dev/null +++ b/docs/en/integrations/torchscript.md @@ -0,0 +1,132 @@ +--- +comments: true +description: Learn to export your Ultralytics YOLOv8 models to TorchScript format for deployment through platforms like embedded systems, web browsers, and C++ applications. +keywords: Ultralytics, YOLOv8, Export to Torchscript, Model Optimization, Deployment, PyTorch, C++, Faster Inference +--- + +# YOLOv8 Model Export to TorchScript for Quick Deployment + +Deploying computer vision models across different environments, including embedded systems, web browsers, or platforms with limited Python support, requires a flexible and portable solution. TorchScript focuses on portability and the ability to run models in environments where the entire Python framework is unavailable. This makes it ideal for scenarios where you need to deploy your computer vision capabilities across various devices or platforms. + +Export to Torchscript to serialize your [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics) models for cross-platform compatibility and streamlined deployment. In this guide, we'll show you how to export your YOLOv8 models to the TorchScript format, making it easier for you to use them across a wider range of applications. + +## Why should you export to TorchScript? + +

+ TorchScript Overview +

+ +Developed by the creators of PyTorch, TorchScript is a powerful tool for optimizing and deploying PyTorch models across a variety of platforms. Exporting YOLOv8 models to [TorchScript](https://pytorch.org/docs/stable/jit.html) is crucial for moving from research to real-world applications. TorchScript, part of the PyTorch framework, helps make this transition smoother by allowing PyTorch models to be used in environments that don't support Python. + +The process involves two techniques: tracing and scripting. Tracing records operations during model execution, while scripting allows for the definition of models using a subset of Python. These techniques ensures that models like YOLOv8 can still work their magic even outside their usual Python environment. + +

+ TorchScript Script and Trace +

+ +TorchScript models can also be optimized through techniques such as operator fusion and refinements in memory usage, ensuring efficient execution. Another advantage of exporting to TorchScript is its potential to accelerate model execution across various hardware platforms. It creates a standalone, production-ready representation of your PyTorch model that can be integrated into C++ environments, embedded systems, or deployed in web or mobile applications. + +## Key Features of TorchScript Models + +TorchScript, a key part of the PyTorch ecosystem, provides powerful features for optimizing and deploying deep learning models. + +

+ TorchScript Features +

+ +Here are the key features that make TorchScript a valuable tool for developers: + +- **Static Graph Execution**: TorchScript uses a static graph representation of the model’s computation, which is different from PyTorch’s dynamic graph execution. In static graph execution, the computational graph is defined and compiled once before the actual execution, resulting in improved performance during inference. + + - **Model Serialization**: TorchScript allows you to serialize PyTorch models into a platform-independent format. Serialized models can be loaded without requiring the original Python code, enabling deployment in different runtime environments. + + - **JIT Compilation**: TorchScript uses Just-In-Time (JIT) compilation to convert PyTorch models into an optimized intermediate representation. JIT compiles the model’s computational graph, enabling efficient execution on target devices. + + - **Cross-Language Integration**: With TorchScript, you can export PyTorch models to other languages such as C++, Java, and JavaScript. This makes it easier to integrate PyTorch models into existing software systems written in different languages. + +- **Gradual Conversion**: TorchScript provides a gradual conversion approach, allowing you to incrementally convert parts of your PyTorch model into TorchScript. This flexibility is particularly useful when dealing with complex models or when you want to optimize specific portions of the code. + +## Deployment Options in TorchScript + +Before we look at the code for exporting YOLOv8 models to the TorchScript format, let’s understand where TorchScript models are normally used. + +TorchScript offers various deployment options for machine learning models, such as: + +- **C++ API**: The most common use case for TorchScript is its C++ API, which allows you to load and execute optimized TorchScript models directly within C++ applications. This is ideal for production environments where Python may not be suitable or available. The C++ API offers low-overhead and efficient execution of TorchScript models, maximizing performance potential. + +- **Mobile Deployment**: TorchScript offers tools for converting models into formats readily deployable on mobile devices. PyTorch Mobile provides a runtime for executing these models within iOS and Android apps. This enables low-latency, offline inference capabilities, enhancing user experience and data privacy. + +- **Cloud Deployment**: TorchScript models can be deployed to cloud-based servers using solutions like TorchServe. It provides features like model versioning, batching, and metrics monitoring for scalable deployment in production environments. Cloud deployment with TorchScript can make your models accessible via APIs or other web services. + +## Export to TorchScript: Converting Your YOLOv8 Model + +Exporting YOLOv8 models to TorchScript makes it easier to use them in different places and helps them run faster and more efficiently. This is great for anyone looking to use deep learning models more effectively in real-world applications. + +### Installation + +To install the required package, run: + +!!! Tip "Installation" + + === "CLI" + + ```bash + # Install the required package for YOLOv8 + pip install ultralytics + ``` + +For detailed instructions and best practices related to the installation process, check our [Ultralytics Installation guide](../quickstart.md). While installing the required packages for YOLOv8, if you encounter any difficulties, consult our [Common Issues guide](../guides/yolo-common-issues.md) for solutions and tips. + +### Usage + +Before diving into the usage instructions, it's important to note that while all [Ultralytics YOLOv8 models]((../models/index.md)) are available for exporting, you can ensure that the model you select supports export functionality [here](../modes/export.md). + +!!! Example "Usage" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load the YOLOv8 model + model = YOLO('yolov8n.pt') + + # Export the model to TorchScript format + model.export(format='torchscript') # creates 'yolov8n.torchscript' + + # Load the exported TorchScript model + torchscript_model = YOLO('yolov8n.torchscript') + + # Run inference + results = torchscript_model('https://ultralytics.com/images/bus.jpg') + ``` + + === "CLI" + + ```bash + # Export a YOLOv8n PyTorch model to TorchScript format + yolo export model=yolov8n.pt format=torchscript # creates 'yolov8n.torchscript' + + # Run inference with the exported model + yolo predict model=yolov8n.torchscript source='https://ultralytics.com/images/bus.jpg' + ``` + +For more details about the export process, visit the [Ultralytics documentation page on exporting](../modes/export.md). + +## Deploying Exported YOLOv8 TorchScript Models + +After successfully exporting your Ultralytics YOLOv8 models to TorchScript format, you can now deploy them. The primary and recommended first step for running a TorchScript model is to utilize the YOLO("model.torchscript") method, as outlined in the previous usage code snippet. However, for in-depth instructions on deploying your TorchScript models in various other settings, take a look at the following resources: + +- **[Explore Mobile Deployment](https://pytorch.org/mobile/home/)**: The PyTorch Mobile Documentation provides comprehensive guidelines for deploying models on mobile devices, ensuring your applications are efficient and responsive. + +- **[Master Server-Side Deployment](https://pytorch.org/serve/getting_started.html)**: Learn how to deploy models server-side with TorchServe, offering a step-by-step tutorial for scalable, efficient model serving. + +- **[Implement C++ Deployment](https://pytorch.org/tutorials/advanced/cpp_export.html)**: Dive into the Tutorial on Loading a TorchScript Model in C++, facilitating the integration of your TorchScript models into C++ applications for enhanced performance and versatility. + +## Summary + +In this guide, we explored the process of exporting Ultralytics YOLOv8 models to the TorchScript format. By following the provided instructions, you can optimize YOLOv8 models for performance and gain the flexibility to deploy them across various platforms and environments. + +For further details on usage, visit [TorchScript’s official documentation](https://pytorch.org/docs/stable/jit.html). + +Also, if you’d like to know more about other Ultralytics YOLOv8 integrations, visit our [integration guide page](../integrations/index.md). You'll find plenty of useful resources and insights there. diff --git a/mkdocs.yml b/mkdocs.yml index d20812239e..83f48bb06c 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -344,6 +344,7 @@ nav: - ONNX: integrations/onnx.md - TensorRT: integrations/tensorrt.md - CoreML: integrations/coreml.md + - TorchScript: integrations/torchscript.md - Ray Tune: integrations/ray-tune.md - Roboflow: integrations/roboflow.md - MLflow: integrations/mlflow.md diff --git a/ultralytics/data/explorer/gui/dash.py b/ultralytics/data/explorer/gui/dash.py index 36ab3c0dd8..b082d49517 100644 --- a/ultralytics/data/explorer/gui/dash.py +++ b/ultralytics/data/explorer/gui/dash.py @@ -144,9 +144,9 @@ def run_sql_query(): def run_ai_query(): """Execute SQL query and update session state with query results.""" if not SETTINGS["openai_api_key"]: - st.session_state[ - "error" - ] = 'OpenAI API key not found in settings. Please run yolo settings openai_api_key="..."' + st.session_state["error"] = ( + 'OpenAI API key not found in settings. Please run yolo settings openai_api_key="..."' + ) return st.session_state["error"] = None query = st.session_state.get("ai_query") diff --git a/ultralytics/engine/exporter.py b/ultralytics/engine/exporter.py index 75f7a0f98b..b68595f54a 100644 --- a/ultralytics/engine/exporter.py +++ b/ultralytics/engine/exporter.py @@ -48,6 +48,7 @@ TensorFlow.js: $ ln -s ../../yolov5/yolov8n_web_model public/yolov8n_web_model $ npm start """ + import json import os import shutil @@ -1079,9 +1080,9 @@ class Exporter: model = ct.models.MLModel(pipeline.spec, weights_dir=weights_dir) model.input_description["image"] = "Input image" model.input_description["iouThreshold"] = f"(optional) IOU threshold override (default: {nms.iouThreshold})" - model.input_description[ - "confidenceThreshold" - ] = f"(optional) Confidence threshold override (default: {nms.confidenceThreshold})" + model.input_description["confidenceThreshold"] = ( + f"(optional) Confidence threshold override (default: {nms.confidenceThreshold})" + ) model.output_description["confidence"] = 'Boxes × Class confidence (see user-defined metadata "classes")' model.output_description["coordinates"] = "Boxes × [x, y, width, height] (relative to image size)" LOGGER.info(f"{prefix} pipeline success") diff --git a/ultralytics/engine/predictor.py b/ultralytics/engine/predictor.py index 28b15c2f4f..38b9641a3f 100644 --- a/ultralytics/engine/predictor.py +++ b/ultralytics/engine/predictor.py @@ -27,6 +27,7 @@ Usage - formats: yolov8n_edgetpu.tflite # TensorFlow Edge TPU yolov8n_paddle_model # PaddlePaddle """ + import platform import threading from pathlib import Path diff --git a/ultralytics/engine/tuner.py b/ultralytics/engine/tuner.py index 80a554d432..de804fd0ee 100644 --- a/ultralytics/engine/tuner.py +++ b/ultralytics/engine/tuner.py @@ -16,6 +16,7 @@ Example: model.tune(data='coco8.yaml', epochs=10, iterations=300, optimizer='AdamW', plots=False, save=False, val=False) ``` """ + import random import shutil import subprocess diff --git a/ultralytics/engine/validator.py b/ultralytics/engine/validator.py index 94c89ebd5a..db9d07607d 100644 --- a/ultralytics/engine/validator.py +++ b/ultralytics/engine/validator.py @@ -18,6 +18,7 @@ Usage - formats: yolov8n_edgetpu.tflite # TensorFlow Edge TPU yolov8n_paddle_model # PaddlePaddle """ + import json import time from pathlib import Path From 55ce6faec86e28fd9ead2a29c92c275bcb1f1be1 Mon Sep 17 00:00:00 2001 From: Robin Brown Date: Thu, 29 Feb 2024 23:28:01 +0000 Subject: [PATCH 2/8] Do RTDETR file suffix check using pathlib instead of string manipulations (#8525) Co-authored-by: Glenn Jocher --- ultralytics/models/rtdetr/model.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ultralytics/models/rtdetr/model.py b/ultralytics/models/rtdetr/model.py index b8def48569..d1cb18df37 100644 --- a/ultralytics/models/rtdetr/model.py +++ b/ultralytics/models/rtdetr/model.py @@ -6,6 +6,7 @@ hybrid encoder and IoU-aware query selection for enhanced detection accuracy. For more information on RT-DETR, visit: https://arxiv.org/pdf/2304.08069.pdf """ +from pathlib import Path from ultralytics.engine.model import Model from ultralytics.nn.tasks import RTDETRDetectionModel @@ -34,7 +35,7 @@ class RTDETR(Model): Raises: NotImplementedError: If the model file extension is not 'pt', 'yaml', or 'yml'. """ - if model and model.split(".")[-1] not in ("pt", "yaml", "yml"): + if model and Path(model).suffix not in (".pt", ".yaml", ".yml"): raise NotImplementedError("RT-DETR only supports creating from *.pt, *.yaml, or *.yml files.") super().__init__(model=model, task="detect") From fcff64cc3cfa8de462240af508f9ae5ed7aa3944 Mon Sep 17 00:00:00 2001 From: UltralyticsAssistant Date: Thu, 29 Feb 2024 23:28:20 +0000 Subject: [PATCH 3/8] Auto-format by https://ultralytics.com/actions --- ultralytics/models/rtdetr/model.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ultralytics/models/rtdetr/model.py b/ultralytics/models/rtdetr/model.py index d1cb18df37..362edce041 100644 --- a/ultralytics/models/rtdetr/model.py +++ b/ultralytics/models/rtdetr/model.py @@ -6,6 +6,7 @@ hybrid encoder and IoU-aware query selection for enhanced detection accuracy. For more information on RT-DETR, visit: https://arxiv.org/pdf/2304.08069.pdf """ + from pathlib import Path from ultralytics.engine.model import Model From aa592efda5d8d3175700b094c4aa2b13dfee4cc3 Mon Sep 17 00:00:00 2001 From: Abirami Vina Date: Fri, 1 Mar 2024 05:07:06 +0530 Subject: [PATCH 4/8] Add TFLite Docs Integrations Page (#8522) Co-authored-by: UltralyticsAssistant Co-authored-by: Glenn Jocher --- docs/en/integrations/index.md | 2 + docs/en/integrations/tflite.md | 122 +++++++++++++++++++++++++++++++++ mkdocs.yml | 1 + 3 files changed, 125 insertions(+) create mode 100644 docs/en/integrations/tflite.md diff --git a/docs/en/integrations/index.md b/docs/en/integrations/index.md index 1a55648bba..2644bbd9d4 100644 --- a/docs/en/integrations/index.md +++ b/docs/en/integrations/index.md @@ -50,6 +50,8 @@ Welcome to the Ultralytics Integrations page! This page provides an overview of - [CoreML](coreml.md): CoreML, developed by [Apple](https://www.apple.com/), is a framework designed for efficiently integrating machine learning models into applications across iOS, macOS, watchOS, and tvOS, using Apple's hardware for effective and secure model deployment. +- [TFLite](tflite.md): Developed by [Google](https://www.google.com), TFLite is a lightweight framework for deploying machine learning models on mobile and edge devices, ensuring fast, efficient inference with minimal memory footprint. + - [TorchScript](torchscript.md): Developed as part of the [PyTorch](https://pytorch.org/) framework, TorchScript enables efficient execution and deployment of machine learning models in various production environments without the need for Python dependencies. ### Export Formats diff --git a/docs/en/integrations/tflite.md b/docs/en/integrations/tflite.md new file mode 100644 index 0000000000..805e8a338b --- /dev/null +++ b/docs/en/integrations/tflite.md @@ -0,0 +1,122 @@ +--- +comments: true +description: Explore how to improve your Ultralytics YOLOv8 model's performance and interoperability using the TFLite export format suitable for edge computing environments. +keywords: Ultralytics, YOLOv8, TFLite Export, Export YOLOv8, Model Deployment +--- + +# A Guide on YOLOv8 Model Export to TFLite for Deployment + +Deploying computer vision models on edge devices or embedded devices requires a format that can ensure seamless performance. + +The TensorFlow Lite or TFLite export format allows you to optimize your [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics) models for tasks like object detection and image classification in edge device-based applications. In this guide, we'll walk through the steps for converting your models to the TFLite format, making it easier for your models to perform well on various edge devices. + +## Why should you export to TFLite? + +

+ TFLite Logo +

+ +Introduced by Google in May 2017 as part of their TensorFlow framework, [TensorFlow Lite](https://www.tensorflow.org/lite/guide), or TFLite for short, is an open-source deep learning framework designed for on-device inference, also known as edge computing. It gives developers the necessary tools to execute their trained models on mobile, embedded, and IoT devices, as well as traditional computers. + +TensorFlow Lite is compatible with a wide range of platforms, including embedded Linux, Android, iOS, and MCU. Exporting your model to TFLite makes your applications faster, more reliable, and capable of running offline. + +## Key Features of TFLite Models + +TFLite models offer a wide range of key features that enable on-device machine learning by helping developers run their models on mobile, embedded, and edge devices: + +- **On-device Optimization**: TFLite optimizes for on-device ML, reducing latency by processing data locally, enhancing privacy by not transmitting personal data, and minimizing model size to save space. + +- **Multiple Platform Support**: TFLite offers extensive platform compatibility, supporting Android, iOS, embedded Linux, and microcontrollers. + +- **Diverse Language Support**: TFLite is compatible with various programming languages, including Java, Swift, Objective-C, C++, and Python. + +- **High Performance**: Achieves superior performance through hardware acceleration and model optimization. + +## Deployment Options in TFLite + +Before we look at the code for exporting YOLOv8 models to the TFLite format, let’s understand how TFLite models are normally used. + +TFLite offers various on-device deployment options for machine learning models, including: + + - **Deploying with Android and iOS**: Both Android and iOS applications with TFLite can analyze edge-based camera feeds and sensors to detect and identify objects. TFLite also offers native iOS libraries written in [Swift](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/swift) and [Objective-C](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/objc). The architecture diagram below shows the process of deploying a trained model onto Android and iOS platforms using TensorFlow Lite. + +

+ Architecture +

+ + - **Implementing with Embedded Linux**: If running inferences on a [Raspberry Pi](https://www.raspberrypi.org/) using the [Ultralytics Guide](../guides/raspberry-pi.md) does not meet the speed requirements for your use case, you can use an exported TFLite model to accelerate inference times. Additionally, it's possible to further improve performance by utilizing a [Coral Edge TPU device]((https://coral.withgoogle.com/)). + + - **Deploying with Microcontrollers**: TFLite models can also be deployed on microcontrollers and other devices with only a few kilobytes of memory. The core runtime just fits in 16 KB on an Arm Cortex M3 and can run many basic models. It doesn't require operating system support, any standard C or C++ libraries, or dynamic memory allocation. + +## Export to TFLite: Converting Your YOLOv8 Model + +You can improve on-device model execution efficiency and optimize performance by converting them to TFLite format. + +### Installation + +To install the required packages, run: + +!!! Tip "Installation" + + === "CLI" + + ```bash + # Install the required package for YOLOv8 + pip install ultralytics + ``` + +For detailed instructions and best practices related to the installation process, check our [Ultralytics Installation guide](../quickstart.md). While installing the required packages for YOLOv8, if you encounter any difficulties, consult our [Common Issues guide](../guides/yolo-common-issues.md) for solutions and tips. + +### Usage + +Before diving into the usage instructions, it's important to note that while all [Ultralytics YOLOv8 models]((../models/index.md)) are available for exporting, you can ensure that the model you select supports export functionality [here](../modes/export.md). + +!!! Example "Usage" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load the YOLOv8 model + model = YOLO('yolov8n.pt') + + # Export the model to TFLite format + model.export(format='tflite') # creates 'yolov8n_float32.tflite' + + # Load the exported TFLite model + tflite_model = YOLO('yolov8n_float32.tflite') + + # Run inference + results = tflite_model('https://ultralytics.com/images/bus.jpg') + ``` + + === "CLI" + + ```bash + # Export a YOLOv8n PyTorch model to TFLite format + yolo export model=yolov8n.pt format=tflite # creates 'yolov8n_float32.tflite' + + # Run inference with the exported model + yolo predict model='yolov8n_float32.tflite' source='https://ultralytics.com/images/bus.jpg' + ``` + +For more details about the export process, visit the [Ultralytics documentation page on exporting](../modes/export.md). + +## Deploying Exported YOLOv8 TFLite Models + +After successfully exporting your Ultralytics YOLOv8 models to TFLite format, you can now deploy them. The primary and recommended first step for running a TFLite model is to utilize the YOLO("model.tflite") method, as outlined in the previous usage code snippet. However, for in-depth instructions on deploying your TFLite models in various other settings, take a look at the following resources: + + - **[Android](https://www.tensorflow.org/lite/android/quickstart)**: A quick start guide for integrating TensorFlow Lite into Android applications, providing easy-to-follow steps for setting up and running machine learning models. + + - **[iOS](https://www.tensorflow.org/lite/guide/ios)**: Check out this detailed guide for developers on integrating and deploying TensorFlow Lite models in iOS applications, offering step-by-step instructions and resources. + + - **[End-To-End Examples](https://www.tensorflow.org/lite/examples)**: This page provides an overview of various TensorFlow Lite examples, showcasing practical applications and tutorials designed to help developers implement TensorFlow Lite in their machine learning projects on mobile and edge devices. + +## Summary + +In this guide, we focused on how to export to TFLite format. By converting your Ultralytics YOLOv8 models to TFLite model format, you can improve the efficiency and speed of YOLOv8 models, making them more effective and suitable for edge computing environments. + +For further details on usage, visit [TFLite’s official documentation](https://www.tensorflow.org/lite/guide). + +Also, if you're curious about other Ultralytics YOLOv8 integrations, make sure to check out our [integration guide page](../integrations/index.md). You'll find tons of helpful info and insights waiting for you there. diff --git a/mkdocs.yml b/mkdocs.yml index 83f48bb06c..586eecd9c3 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -344,6 +344,7 @@ nav: - ONNX: integrations/onnx.md - TensorRT: integrations/tensorrt.md - CoreML: integrations/coreml.md + - TFLite: integrations/tflite.md - TorchScript: integrations/torchscript.md - Ray Tune: integrations/ray-tune.md - Roboflow: integrations/roboflow.md From 6bdf8dfaa22b59492befd24a21a3bfe2dfc92d64 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Fri, 1 Mar 2024 00:53:17 +0100 Subject: [PATCH 5/8] =?UTF-8?q?Fix=20undefined=20=E2=80=98im=5Farray?= =?UTF-8?q?=E2=80=99=20bug=20in=20predict.md=20(#8565)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Glenn Jocher Co-authored-by: fang_chenfang <1217690899@qq.com> --- docs/en/guides/model-deployment-options.md | 6 +++--- docs/en/modes/benchmark.md | 2 +- docs/en/modes/export.md | 2 +- docs/en/modes/predict.md | 2 +- docs/en/tasks/classify.md | 2 +- docs/en/tasks/detect.md | 2 +- docs/en/tasks/obb.md | 2 +- docs/en/tasks/pose.md | 2 +- docs/en/tasks/segment.md | 2 +- docs/en/usage/cli.md | 2 +- ultralytics/engine/exporter.py | 10 +++++----- ultralytics/nn/autobackend.py | 10 +++++----- ultralytics/utils/benchmarks.py | 2 +- 13 files changed, 23 insertions(+), 23 deletions(-) diff --git a/docs/en/guides/model-deployment-options.md b/docs/en/guides/model-deployment-options.md index d0d7b32559..a487ea4d94 100644 --- a/docs/en/guides/model-deployment-options.md +++ b/docs/en/guides/model-deployment-options.md @@ -240,9 +240,9 @@ PaddlePaddle is an open-source deep learning framework developed by Baidu. It is - **Hardware Acceleration**: Supports various hardware accelerations, including Baidu's own Kunlun chips. -#### ncnn +#### NCNN -ncnn is a high-performance neural network inference framework optimized for the mobile platform. It stands out for its lightweight nature and efficiency, making it particularly well-suited for mobile and embedded devices where resources are limited. +NCNN is a high-performance neural network inference framework optimized for the mobile platform. It stands out for its lightweight nature and efficiency, making it particularly well-suited for mobile and embedded devices where resources are limited. - **Performance Benchmarks**: Highly optimized for mobile platforms, offering efficient inference on ARM-based devices. @@ -276,7 +276,7 @@ The following table provides a snapshot of the various deployment options availa | TF Edge TPU | Optimized for Google's Edge TPU hardware | Exclusive to Edge TPU devices | Growing with Google and third-party resources | IoT devices requiring real-time processing | Improvements for new Edge TPU hardware | Google's robust IoT security | Custom-designed for Google Coral | | TF.js | Reasonable in-browser performance | High with web technologies | Web and Node.js developers support | Interactive web applications | TensorFlow team and community contributions | Web platform security model | Enhanced with WebGL and other APIs | | PaddlePaddle | Competitive, easy to use and scalable | Baidu ecosystem, wide application support | Rapidly growing, especially in China | Chinese market and language processing | Focus on Chinese AI applications | Emphasizes data privacy and security | Including Baidu's Kunlun chips | -| ncnn | Optimized for mobile ARM-based devices | Mobile and embedded ARM systems | Niche but active mobile/embedded ML community | Android and ARM systems efficiency | High performance maintenance on ARM | On-device security advantages | ARM CPUs and GPUs optimizations | +| NCNN | Optimized for mobile ARM-based devices | Mobile and embedded ARM systems | Niche but active mobile/embedded ML community | Android and ARM systems efficiency | High performance maintenance on ARM | On-device security advantages | ARM CPUs and GPUs optimizations | This comparative analysis gives you a high-level overview. For deployment, it's essential to consider the specific requirements and constraints of your project, and consult the detailed documentation and resources available for each option. diff --git a/docs/en/modes/benchmark.md b/docs/en/modes/benchmark.md index 4f22ee8d67..7f8e4573d7 100644 --- a/docs/en/modes/benchmark.md +++ b/docs/en/modes/benchmark.md @@ -101,6 +101,6 @@ Benchmarks will attempt to run automatically on all possible export formats belo | [TF Edge TPU](https://coral.ai/docs/edgetpu/models-intro/) | `edgetpu` | `yolov8n_edgetpu.tflite` | ✅ | `imgsz` | | [TF.js](https://www.tensorflow.org/js) | `tfjs` | `yolov8n_web_model/` | ✅ | `imgsz`, `half`, `int8` | | [PaddlePaddle](https://github.com/PaddlePaddle) | `paddle` | `yolov8n_paddle_model/` | ✅ | `imgsz` | -| [ncnn](https://github.com/Tencent/ncnn) | `ncnn` | `yolov8n_ncnn_model/` | ✅ | `imgsz`, `half` | +| [NCNN](https://github.com/Tencent/ncnn) | `ncnn` | `yolov8n_ncnn_model/` | ✅ | `imgsz`, `half` | See full `export` details in the [Export](https://docs.ultralytics.com/modes/export/) page. diff --git a/docs/en/modes/export.md b/docs/en/modes/export.md index 61576cf9e0..5859b18b6a 100644 --- a/docs/en/modes/export.md +++ b/docs/en/modes/export.md @@ -108,4 +108,4 @@ Available YOLOv8 export formats are in the table below. You can export to any fo | [TF Edge TPU](https://coral.ai/docs/edgetpu/models-intro/) | `edgetpu` | `yolov8n_edgetpu.tflite` | ✅ | `imgsz` | | [TF.js](https://www.tensorflow.org/js) | `tfjs` | `yolov8n_web_model/` | ✅ | `imgsz`, `half`, `int8` | | [PaddlePaddle](https://github.com/PaddlePaddle) | `paddle` | `yolov8n_paddle_model/` | ✅ | `imgsz` | -| [ncnn](https://github.com/Tencent/ncnn) | `ncnn` | `yolov8n_ncnn_model/` | ✅ | `imgsz`, `half` | +| [NCNN](https://github.com/Tencent/ncnn) | `ncnn` | `yolov8n_ncnn_model/` | ✅ | `imgsz`, `half` | diff --git a/docs/en/modes/predict.md b/docs/en/modes/predict.md index 64a3aa42ba..d3a9d47de8 100644 --- a/docs/en/modes/predict.md +++ b/docs/en/modes/predict.md @@ -683,7 +683,7 @@ The `plot()` method in `Results` objects facilitates visualization of prediction for i, r in enumerate(results): # Plot results image im_bgr = r.plot() # BGR-order numpy array - im_rgb = Image.fromarray(im_array[..., ::-1]) # RGB-order PIL image + im_rgb = Image.fromarray(im_bgr[..., ::-1]) # RGB-order PIL image # Show results to screen (in supported environments) r.show() diff --git a/docs/en/tasks/classify.md b/docs/en/tasks/classify.md index 5608c9857a..02b9a4bc9e 100644 --- a/docs/en/tasks/classify.md +++ b/docs/en/tasks/classify.md @@ -176,6 +176,6 @@ Available YOLOv8-cls export formats are in the table below. You can predict or v | [TF Edge TPU](https://coral.ai/docs/edgetpu/models-intro/) | `edgetpu` | `yolov8n-cls_edgetpu.tflite` | ✅ | `imgsz` | | [TF.js](https://www.tensorflow.org/js) | `tfjs` | `yolov8n-cls_web_model/` | ✅ | `imgsz`, `half`, `int8` | | [PaddlePaddle](https://github.com/PaddlePaddle) | `paddle` | `yolov8n-cls_paddle_model/` | ✅ | `imgsz` | -| [ncnn](https://github.com/Tencent/ncnn) | `ncnn` | `yolov8n-cls_ncnn_model/` | ✅ | `imgsz`, `half` | +| [NCNN](https://github.com/Tencent/ncnn) | `ncnn` | `yolov8n-cls_ncnn_model/` | ✅ | `imgsz`, `half` | See full `export` details in the [Export](https://docs.ultralytics.com/modes/export/) page. diff --git a/docs/en/tasks/detect.md b/docs/en/tasks/detect.md index a53877d575..b5d2700924 100644 --- a/docs/en/tasks/detect.md +++ b/docs/en/tasks/detect.md @@ -177,6 +177,6 @@ Available YOLOv8 export formats are in the table below. You can predict or valid | [TF Edge TPU](https://coral.ai/docs/edgetpu/models-intro/) | `edgetpu` | `yolov8n_edgetpu.tflite` | ✅ | `imgsz` | | [TF.js](https://www.tensorflow.org/js) | `tfjs` | `yolov8n_web_model/` | ✅ | `imgsz`, `half`, `int8` | | [PaddlePaddle](https://github.com/PaddlePaddle) | `paddle` | `yolov8n_paddle_model/` | ✅ | `imgsz` | -| [ncnn](https://github.com/Tencent/ncnn) | `ncnn` | `yolov8n_ncnn_model/` | ✅ | `imgsz`, `half` | +| [NCNN](https://github.com/Tencent/ncnn) | `ncnn` | `yolov8n_ncnn_model/` | ✅ | `imgsz`, `half` | See full `export` details in the [Export](https://docs.ultralytics.com/modes/export/) page. diff --git a/docs/en/tasks/obb.md b/docs/en/tasks/obb.md index 47f713bc82..c91690981b 100644 --- a/docs/en/tasks/obb.md +++ b/docs/en/tasks/obb.md @@ -186,6 +186,6 @@ Available YOLOv8-obb export formats are in the table below. You can predict or v | [TF Edge TPU](https://coral.ai/docs/edgetpu/models-intro/) | `edgetpu` | `yolov8n-obb_edgetpu.tflite` | ✅ | `imgsz` | | [TF.js](https://www.tensorflow.org/js) | `tfjs` | `yolov8n-obb_web_model/` | ✅ | `imgsz`, `half`, `int8` | | [PaddlePaddle](https://github.com/PaddlePaddle) | `paddle` | `yolov8n-obb_paddle_model/` | ✅ | `imgsz` | -| [ncnn](https://github.com/Tencent/ncnn) | `ncnn` | `yolov8n-obb_ncnn_model/` | ✅ | `imgsz`, `half` | +| [NCNN](https://github.com/Tencent/ncnn) | `ncnn` | `yolov8n-obb_ncnn_model/` | ✅ | `imgsz`, `half` | See full `export` details in the [Export](https://docs.ultralytics.com/modes/export/) page. diff --git a/docs/en/tasks/pose.md b/docs/en/tasks/pose.md index 2c3584c4d5..431164b1bb 100644 --- a/docs/en/tasks/pose.md +++ b/docs/en/tasks/pose.md @@ -180,6 +180,6 @@ Available YOLOv8-pose export formats are in the table below. You can predict or | [TF Edge TPU](https://coral.ai/docs/edgetpu/models-intro/) | `edgetpu` | `yolov8n-pose_edgetpu.tflite` | ✅ | `imgsz` | | [TF.js](https://www.tensorflow.org/js) | `tfjs` | `yolov8n-pose_web_model/` | ✅ | `imgsz`, `half`, `int8` | | [PaddlePaddle](https://github.com/PaddlePaddle) | `paddle` | `yolov8n-pose_paddle_model/` | ✅ | `imgsz` | -| [ncnn](https://github.com/Tencent/ncnn) | `ncnn` | `yolov8n-pose_ncnn_model/` | ✅ | `imgsz`, `half` | +| [NCNN](https://github.com/Tencent/ncnn) | `ncnn` | `yolov8n-pose_ncnn_model/` | ✅ | `imgsz`, `half` | See full `export` details in the [Export](https://docs.ultralytics.com/modes/export/) page. diff --git a/docs/en/tasks/segment.md b/docs/en/tasks/segment.md index b06bc94f0c..921378a450 100644 --- a/docs/en/tasks/segment.md +++ b/docs/en/tasks/segment.md @@ -182,6 +182,6 @@ Available YOLOv8-seg export formats are in the table below. You can predict or v | [TF Edge TPU](https://coral.ai/docs/edgetpu/models-intro/) | `edgetpu` | `yolov8n-seg_edgetpu.tflite` | ✅ | `imgsz` | | [TF.js](https://www.tensorflow.org/js) | `tfjs` | `yolov8n-seg_web_model/` | ✅ | `imgsz`, `half`, `int8` | | [PaddlePaddle](https://github.com/PaddlePaddle) | `paddle` | `yolov8n-seg_paddle_model/` | ✅ | `imgsz` | -| [ncnn](https://github.com/Tencent/ncnn) | `ncnn` | `yolov8n-seg_ncnn_model/` | ✅ | `imgsz`, `half` | +| [NCNN](https://github.com/Tencent/ncnn) | `ncnn` | `yolov8n-seg_ncnn_model/` | ✅ | `imgsz`, `half` | See full `export` details in the [Export](https://docs.ultralytics.com/modes/export/) page. diff --git a/docs/en/usage/cli.md b/docs/en/usage/cli.md index 55d01e0fa2..c71d7d0662 100644 --- a/docs/en/usage/cli.md +++ b/docs/en/usage/cli.md @@ -184,7 +184,7 @@ Available YOLOv8 export formats are in the table below. You can export to any fo | [TF Edge TPU](https://coral.ai/docs/edgetpu/models-intro/) | `edgetpu` | `yolov8n_edgetpu.tflite` | ✅ | `imgsz` | | [TF.js](https://www.tensorflow.org/js) | `tfjs` | `yolov8n_web_model/` | ✅ | `imgsz`, `half`, `int8` | | [PaddlePaddle](https://github.com/PaddlePaddle) | `paddle` | `yolov8n_paddle_model/` | ✅ | `imgsz` | -| [ncnn](https://github.com/Tencent/ncnn) | `ncnn` | `yolov8n_ncnn_model/` | ✅ | `imgsz`, `half` | +| [NCNN](https://github.com/Tencent/ncnn) | `ncnn` | `yolov8n_ncnn_model/` | ✅ | `imgsz`, `half` | ## Overriding default arguments diff --git a/ultralytics/engine/exporter.py b/ultralytics/engine/exporter.py index b68595f54a..afe7d3e6c2 100644 --- a/ultralytics/engine/exporter.py +++ b/ultralytics/engine/exporter.py @@ -16,7 +16,7 @@ TensorFlow Lite | `tflite` | yolov8n.tflite TensorFlow Edge TPU | `edgetpu` | yolov8n_edgetpu.tflite TensorFlow.js | `tfjs` | yolov8n_web_model/ PaddlePaddle | `paddle` | yolov8n_paddle_model/ -ncnn | `ncnn` | yolov8n_ncnn_model/ +NCNN | `ncnn` | yolov8n_ncnn_model/ Requirements: $ pip install "ultralytics[export]" @@ -293,7 +293,7 @@ class Exporter: f[9], _ = self.export_tfjs() if paddle: # PaddlePaddle f[10], _ = self.export_paddle() - if ncnn: # ncnn + if ncnn: # NCNN f[11], _ = self.export_ncnn() # Finish @@ -496,14 +496,14 @@ class Exporter: return f, None @try_export - def export_ncnn(self, prefix=colorstr("ncnn:")): + def export_ncnn(self, prefix=colorstr("NCNN:")): """ - YOLOv8 ncnn export using PNNX https://github.com/pnnx/pnnx. + YOLOv8 NCNN export using PNNX https://github.com/pnnx/pnnx. """ check_requirements("ncnn") import ncnn # noqa - LOGGER.info(f"\n{prefix} starting export with ncnn {ncnn.__version__}...") + LOGGER.info(f"\n{prefix} starting export with NCNN {ncnn.__version__}...") f = Path(str(self.file).replace(self.file.suffix, f"_ncnn_model{os.sep}")) f_ts = self.file.with_suffix(".torchscript") diff --git a/ultralytics/nn/autobackend.py b/ultralytics/nn/autobackend.py index 3fafbbd9c0..4d8c69c578 100644 --- a/ultralytics/nn/autobackend.py +++ b/ultralytics/nn/autobackend.py @@ -72,7 +72,7 @@ class AutoBackend(nn.Module): | TensorFlow Lite | *.tflite | | TensorFlow Edge TPU | *_edgetpu.tflite | | PaddlePaddle | *_paddle_model | - | ncnn | *_ncnn_model | + | NCNN | *_ncnn_model | This class offers dynamic backend switching capabilities based on the input model format, making it easier to deploy models across various platforms. @@ -304,9 +304,9 @@ class AutoBackend(nn.Module): input_handle = predictor.get_input_handle(predictor.get_input_names()[0]) output_names = predictor.get_output_names() metadata = w.parents[1] / "metadata.yaml" - elif ncnn: # ncnn - LOGGER.info(f"Loading {w} for ncnn inference...") - check_requirements("git+https://github.com/Tencent/ncnn.git" if ARM64 else "ncnn") # requires ncnn + elif ncnn: # NCNN + LOGGER.info(f"Loading {w} for NCNN inference...") + check_requirements("git+https://github.com/Tencent/ncnn.git" if ARM64 else "ncnn") # requires NCNN import ncnn as pyncnn net = pyncnn.Net() @@ -431,7 +431,7 @@ class AutoBackend(nn.Module): self.input_handle.copy_from_cpu(im) self.predictor.run() y = [self.predictor.get_output_handle(x).copy_to_cpu() for x in self.output_names] - elif self.ncnn: # ncnn + elif self.ncnn: # NCNN mat_in = self.pyncnn.Mat(im[0].cpu().numpy()) ex = self.net.create_extractor() input_names, output_names = self.net.input_names(), self.net.output_names() diff --git a/ultralytics/utils/benchmarks.py b/ultralytics/utils/benchmarks.py index f925b2d403..b98448da56 100644 --- a/ultralytics/utils/benchmarks.py +++ b/ultralytics/utils/benchmarks.py @@ -21,7 +21,7 @@ TensorFlow Lite | `tflite` | yolov8n.tflite TensorFlow Edge TPU | `edgetpu` | yolov8n_edgetpu.tflite TensorFlow.js | `tfjs` | yolov8n_web_model/ PaddlePaddle | `paddle` | yolov8n_paddle_model/ -ncnn | `ncnn` | yolov8n_ncnn_model/ +NCNN | `ncnn` | yolov8n_ncnn_model/ """ import glob From 33fff69f3d61e7a353eedc7c8086d8a9d13aed11 Mon Sep 17 00:00:00 2001 From: Muhammad Rizwan Munawar Date: Fri, 1 Mar 2024 05:05:41 +0500 Subject: [PATCH 6/8] Add https://youtu.be/ie3vLUDNYZo and other YT videos in Docs (#8551) Co-authored-by: Glenn Jocher --- docs/en/guides/distance-calculation.md | 11 +++++++++++ docs/en/guides/instance-segmentation-and-tracking.md | 11 +++++++++++ docs/en/hub/app/android.md | 11 +++++++++++ docs/en/hub/app/ios.md | 11 +++++++++++ docs/en/hub/cloud-training.md | 11 +++++++++++ 5 files changed, 55 insertions(+) diff --git a/docs/en/guides/distance-calculation.md b/docs/en/guides/distance-calculation.md index 8cd064e46e..c479d5f6e2 100644 --- a/docs/en/guides/distance-calculation.md +++ b/docs/en/guides/distance-calculation.md @@ -10,6 +10,17 @@ keywords: Ultralytics, YOLOv8, Object Detection, Distance Calculation, Object Tr Measuring the gap between two objects is known as distance calculation within a specified space. In the case of [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics), the bounding box centroid is employed to calculate the distance for bounding boxes highlighted by the user. +

+
+ +
+ Watch: Distance Calculation using Ultralytics YOLOv8 +

+ ## Visuals | Distance Calculation using Ultralytics YOLOv8 | diff --git a/docs/en/guides/instance-segmentation-and-tracking.md b/docs/en/guides/instance-segmentation-and-tracking.md index 0339ab900d..ac31ac8721 100644 --- a/docs/en/guides/instance-segmentation-and-tracking.md +++ b/docs/en/guides/instance-segmentation-and-tracking.md @@ -16,6 +16,17 @@ There are two types of instance segmentation tracking available in the Ultralyti - **Instance Segmentation with Object Tracks:** Every track is represented by a distinct color, facilitating easy identification and tracking. +

+
+ +
+ Watch: Instance Segmentation with Object Tracking using Ultralytics YOLOv8 +

+ ## Samples | Instance Segmentation | Instance Segmentation + Object Tracking | diff --git a/docs/en/hub/app/android.md b/docs/en/hub/app/android.md index 0bff31c182..7a80474351 100644 --- a/docs/en/hub/app/android.md +++ b/docs/en/hub/app/android.md @@ -31,6 +31,17 @@ keywords: Ultralytics, Android App, real-time object detection, YOLO models, Ten The Ultralytics Android App is a powerful tool that allows you to run YOLO models directly on your Android device for real-time object detection. This app utilizes TensorFlow Lite for model optimization and various hardware delegates for acceleration, enabling fast and efficient object detection. +

+
+ +
+ Watch: Getting Started with the Ultralytics HUB App (IOS & Android) +

+ ## Quantization and Acceleration To achieve real-time performance on your Android device, YOLO models are quantized to either FP16 or INT8 precision. Quantization is a process that reduces the numerical precision of the model's weights and biases, thus reducing the model's size and the amount of computation required. This results in faster inference times without significantly affecting the model's accuracy. diff --git a/docs/en/hub/app/ios.md b/docs/en/hub/app/ios.md index ac939c901c..41e4b634aa 100644 --- a/docs/en/hub/app/ios.md +++ b/docs/en/hub/app/ios.md @@ -31,6 +31,17 @@ keywords: Ultralytics, iOS app, object detection, YOLO models, real time, Apple The Ultralytics iOS App is a powerful tool that allows you to run YOLO models directly on your iPhone or iPad for real-time object detection. This app utilizes the Apple Neural Engine and Core ML for model optimization and acceleration, enabling fast and efficient object detection. +

+
+ +
+ Watch: Getting Started with the Ultralytics HUB App (IOS & Android) +

+ ## Quantization and Acceleration To achieve real-time performance on your iOS device, YOLO models are quantized to either FP16 or INT8 precision. Quantization is a process that reduces the numerical precision of the model's weights and biases, thus reducing the model's size and the amount of computation required. This results in faster inference times without significantly affecting the model's accuracy. diff --git a/docs/en/hub/cloud-training.md b/docs/en/hub/cloud-training.md index 0fc850e19f..91178ea2dd 100644 --- a/docs/en/hub/cloud-training.md +++ b/docs/en/hub/cloud-training.md @@ -12,6 +12,17 @@ keywords: Ultralytics, HUB Models, AI model training, model creation, model trai Read more about creating and other details of a Model at our [HUB Models page](models.md) +

+
+ +
+ Watch: New Feature 🌟 Introducing Ultralytics HUB Cloud Training +

+ ## Selecting an Instance For details on picking a model and instances for it, please read our [Instances guide Page](models.md) From 31cf94e7f944fd7d62cbf5f9b0a2ab04e6687017 Mon Sep 17 00:00:00 2001 From: Hassaan Farooq <103611273+hassaanfarooq01@users.noreply.github.com> Date: Fri, 1 Mar 2024 05:08:29 +0500 Subject: [PATCH 7/8] Hold failed upload metrics and upload with next upload metrics (#8513) Co-authored-by: hassaanfarooq01 Co-authored-by: Glenn Jocher --- ultralytics/hub/session.py | 8 ++++++++ ultralytics/utils/callbacks/hub.py | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/ultralytics/hub/session.py b/ultralytics/hub/session.py index 2d26b5a9bb..ebc6692b70 100644 --- a/ultralytics/hub/session.py +++ b/ultralytics/hub/session.py @@ -52,6 +52,7 @@ class HUBTrainingSession: "heartbeat": 300.0, } # rate limits (seconds) self.metrics_queue = {} # holds metrics for each epoch until upload + self.metrics_upload_failed_queue = {} # holds metrics for each epoch if upload failed self.timers = {} # holds timers in ultralytics/utils/callbacks/hub.py # Parse input @@ -234,6 +235,9 @@ class HUBTrainingSession: self._show_upload_progress(progress_total, response) if HTTPStatus.OK <= response.status_code < HTTPStatus.MULTIPLE_CHOICES: + # if request related to metrics upload + if kwargs.get("metrics"): + self.metrics_upload_failed_queue = {} return response # Success, no need to retry if i == 0: @@ -249,6 +253,10 @@ class HUBTrainingSession: time.sleep(2**i) # Exponential backoff for retries + # if request related to metrics upload and exceed retries + if response is None and kwargs.get("metrics"): + self.metrics_upload_failed_queue.update(kwargs.get("metrics", None)) + return response if thread: diff --git a/ultralytics/utils/callbacks/hub.py b/ultralytics/utils/callbacks/hub.py index 587b45902e..cdb42b9bc9 100644 --- a/ultralytics/utils/callbacks/hub.py +++ b/ultralytics/utils/callbacks/hub.py @@ -33,6 +33,11 @@ def on_fit_epoch_end(trainer): all_plots = {**all_plots, **model_info_for_loggers(trainer)} session.metrics_queue[trainer.epoch] = json.dumps(all_plots) + + # If any metrics fail to upload, add them to the queue to attempt uploading again. + if session.metrics_upload_failed_queue: + session.metrics_queue.update(session.metrics_upload_failed_queue) + if time() - session.timers["metrics"] > session.rate_limits["metrics"]: session.upload_metrics() session.timers["metrics"] = time() # reset timer From 59ed47c4482a09d0261b8801791258a241e562d8 Mon Sep 17 00:00:00 2001 From: Laughing <61612323+Laughing-q@users.noreply.github.com> Date: Fri, 1 Mar 2024 08:10:38 +0800 Subject: [PATCH 8/8] `ultralytics 8.1.20` add YOLOv8x-World support (#8539) Co-authored-by: Glenn Jocher --- docs/en/models/yolo-world.md | 2 ++ ultralytics/__init__.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/en/models/yolo-world.md b/docs/en/models/yolo-world.md index 8037baec5c..954b5dd189 100644 --- a/docs/en/models/yolo-world.md +++ b/docs/en/models/yolo-world.md @@ -41,6 +41,7 @@ This section details the models available with their specific pre-trained weight | YOLOv8s-world | [yolov8s-world.pt](https://github.com/ultralytics/assets/releases/download/v8.1.0/yolov8s-world.pt) | [Object Detection](../tasks/detect.md) | ✅ | ✅ | ❌ | ❌ | | YOLOv8m-world | [yolov8m-world.pt](https://github.com/ultralytics/assets/releases/download/v8.1.0/yolov8m-world.pt) | [Object Detection](../tasks/detect.md) | ✅ | ✅ | ❌ | ❌ | | YOLOv8l-world | [yolov8l-world.pt](https://github.com/ultralytics/assets/releases/download/v8.1.0/yolov8l-world.pt) | [Object Detection](../tasks/detect.md) | ✅ | ✅ | ❌ | ❌ | +| YOLOv8x-world | [yolov8x-world.pt](https://github.com/ultralytics/assets/releases/download/v8.1.0/yolov8x-world.pt) | [Object Detection](../tasks/detect.md) | ✅ | ✅ | ❌ | ❌ | ## Zero-shot Transfer on COCO Dataset @@ -49,6 +50,7 @@ This section details the models available with their specific pre-trained weight | yolov8s-world | 37.4 | 52.0 | 40.6 | | yolov8m-world | 42.0 | 57.0 | 45.6 | | yolov8l-world | 45.7 | 61.3 | 49.8 | +| yolov8x-world | 47.0 | 63.0 | 51.2 | ## Usage Examples diff --git a/ultralytics/__init__.py b/ultralytics/__init__.py index 0d72f48e6d..666aea71fb 100644 --- a/ultralytics/__init__.py +++ b/ultralytics/__init__.py @@ -1,6 +1,6 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license -__version__ = "8.1.19" +__version__ = "8.1.20" from ultralytics.data.explorer.explorer import Explorer from ultralytics.models import RTDETR, SAM, YOLO, YOLOWorld