From 39e03c4247004b577bb77df9a45bb997f81b5985 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Fri, 18 Apr 2025 00:43:42 +0200 Subject: [PATCH] Default `tensorboard=False` for speed (#20213) Signed-off-by: Glenn Jocher Co-authored-by: UltralyticsAssistant --- examples/tutorial.ipynb | 49 ++++++++++++++++++++--------------- tests/test_integrations.py | 8 ++++++ ultralytics/data/augment.py | 3 +++ ultralytics/nn/autobackend.py | 27 ++++++++++--------- ultralytics/utils/__init__.py | 2 +- 5 files changed, 53 insertions(+), 36 deletions(-) diff --git a/examples/tutorial.ipynb b/examples/tutorial.ipynb index 5fa6e149..f122b60b 100644 --- a/examples/tutorial.ipynb +++ b/examples/tutorial.ipynb @@ -21,9 +21,9 @@ }, "source": [ "
\n", - "\n", " \n", - " \n", + " \n", + " \n", "\n", " [中文](https://docs.ultralytics.com/zh/) | [한국어](https://docs.ultralytics.com/ko/) | [日本語](https://docs.ultralytics.com/ja/) | [Русский](https://docs.ultralytics.com/ru/) | [Deutsch](https://docs.ultralytics.com/de/) | [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/ar/)\n", "\n", @@ -35,20 +35,27 @@ " \"Discord\"\n", " \"Ultralytics\n", " \"Ultralytics\n", + "
\n", "\n", - "Welcome to the Ultralytics YOLO11 🚀 notebook! YOLO11 is the latest version of the YOLO (You Only Look Once) AI models developed by Ultralytics. This notebook serves as the starting point for exploring the various resources available to help you get started with YOLO11 and understand its features and capabilities.\n", + "This **Ultralytics Colab Notebook** is the easiest way to get started with [YOLO models](https://www.ultralytics.com/yolo)—no installation needed. Built by [Ultralytics](https://www.ultralytics.com/), the creators of YOLO, this notebook walks you through running **state-of-the-art** models directly in your browser.\n", "\n", - "YOLO11 models are fast, accurate, and easy to use, making them ideal for various object detection and image segmentation tasks. They can be trained on large datasets and run on diverse hardware platforms, from CPUs to GPUs.\n", + "Ultralytics models are constantly updated for performance and flexibility. They're **fast**, **accurate**, and **easy to use**, and they excel at [object detection](https://docs.ultralytics.com/tasks/detect/), [tracking](https://docs.ultralytics.com/modes/track/), [instance segmentation](https://docs.ultralytics.com/tasks/segment/), [image classification](https://docs.ultralytics.com/tasks/classify/), and [pose estimation](https://docs.ultralytics.com/tasks/pose/).\n", "\n", - "We hope that the resources in this notebook will help you get the most out of YOLO11. Please browse the YOLO11 Docs for details, raise an issue on GitHub for support, and join our Discord community for questions and discussions!\n", + "Find detailed documentation in the [Ultralytics Docs](https://docs.ultralytics.com/). Get support via [GitHub Issues](https://github.com/ultralytics/ultralytics/issues/new/choose). Join discussions on [Discord](https://discord.com/invite/ultralytics), [Reddit](https://www.reddit.com/r/ultralytics/), and the [Ultralytics Community Forums](https://community.ultralytics.com/)!\n", "\n", + "Request an Enterprise License for commercial use at [Ultralytics Licensing](https://www.ultralytics.com/license).\n", + "\n", + "
\n", + "
\n", " \n", - " \"Ultralytics\n", - " \n", + " \"Ultralytics\n", + " \n", + "\n", "

\n", " Watch: How to Train\n", - " Ultralytics\n", - " YOLO11 Model on Custom Dataset using Google Colab Notebook 🚀

\n", + " Ultralytics\n", + " YOLO11 Model on Custom Dataset using Google Colab Notebook 🚀\n", + "

\n", "
" ] }, @@ -79,7 +86,7 @@ "import ultralytics\n", "ultralytics.checks()" ], - "execution_count": 1, + "execution_count": null, "outputs": [ { "output_type": "stream", @@ -115,7 +122,7 @@ "# Run inference on an image with YOLO11n\n", "!yolo predict model=yolo11n.pt source='https://ultralytics.com/images/zidane.jpg'" ], - "execution_count": 2, + "execution_count": null, "outputs": [ { "output_type": "stream", @@ -183,7 +190,7 @@ "# Validate YOLO11n on COCO8 val\n", "!yolo val model=yolo11n.pt data=coco8.yaml" ], - "execution_count": 3, + "execution_count": null, "outputs": [ { "output_type": "stream", @@ -234,14 +241,14 @@ "cell_type": "code", "source": [ "#@title Select YOLO11 🚀 logger {run: 'auto'}\n", - "logger = 'Comet' #@param ['Comet', 'TensorBoard']\n", + "logger = 'TensorBoard' #@param ['TensorBoard', 'Weights & Biases']\n", "\n", - "if logger == 'Comet':\n", - " %pip install -q comet_ml\n", - " import comet_ml; comet_ml.init()\n", - "elif logger == 'TensorBoard':\n", + "if logger == 'TensorBoard':\n", + " !yolo settings tensorboard=True\n", " %load_ext tensorboard\n", - " %tensorboard --logdir ." + " %tensorboard --logdir .\n", + "elif logger == 'Weights & Biases':\n", + " !yolo settings wandb=True" ], "metadata": { "id": "ktegpM42AooT" @@ -262,7 +269,7 @@ "# Train YOLO11n on COCO8 for 3 epochs\n", "!yolo train model=yolo11n.pt data=coco8.yaml epochs=3 imgsz=640" ], - "execution_count": 4, + "execution_count": null, "outputs": [ { "output_type": "stream", @@ -401,7 +408,7 @@ "id": "CYIjW4igCjqD", "outputId": "54c9a0c0-7b49-4b4b-a990-c1f898d10093" }, - "execution_count": 5, + "execution_count": null, "outputs": [ { "output_type": "stream", @@ -631,7 +638,7 @@ { "cell_type": "code", "source": [ - "# Git clone and run tests on updates branch\n", + "# Git clone and run tests on 'main' branch\n", "!git clone https://github.com/ultralytics/ultralytics -b main\n", "%pip install -qe ultralytics" ], diff --git a/tests/test_integrations.py b/tests/test_integrations.py index c6ffaf04..807fcd56 100644 --- a/tests/test_integrations.py +++ b/tests/test_integrations.py @@ -14,6 +14,14 @@ from ultralytics.utils import DATASETS_DIR, SETTINGS from ultralytics.utils.checks import check_requirements +@pytest.mark.slow +def test_tensorboard(): + """Test training with MLflow tracking enabled (see https://mlflow.org/ for details).""" + SETTINGS["tensorboard"] = True + YOLO("yolo11n-cls.yaml").train(data="imagenet10", imgsz=32, epochs=3, plots=False, device="cpu") + SETTINGS["tensorboard"] = False + + @pytest.mark.skipif(not check_requirements("ray", install=False), reason="ray[tune] not installed") def test_model_ray_tune(): """Tune YOLO model using Ray for hyperparameter optimization.""" diff --git a/ultralytics/data/augment.py b/ultralytics/data/augment.py index 964e8bd4..2bd6cf1c 100644 --- a/ultralytics/data/augment.py +++ b/ultralytics/data/augment.py @@ -1796,6 +1796,9 @@ class Albumentations: prefix = colorstr("albumentations: ") try: + import os + + os.environ["NO_ALBUMENTATIONS_UPDATE"] = "1" # suppress Albumentations upgrade message import albumentations as A check_version(A.__version__, "1.0.3", hard=True) # version requirement diff --git a/ultralytics/nn/autobackend.py b/ultralytics/nn/autobackend.py index f8aa2eb6..8415f2ad 100644 --- a/ultralytics/nn/autobackend.py +++ b/ultralytics/nn/autobackend.py @@ -110,14 +110,14 @@ class AutoBackend(nn.Module): Initialize the AutoBackend for inference. Args: - weights (str | torch.nn.Module): Path to the model weights file or a module instance. Defaults to 'yolo11n.pt'. - device (torch.device): Device to run the model on. Defaults to CPU. - dnn (bool): Use OpenCV DNN module for ONNX inference. Defaults to False. + weights (str | List[str] | torch.nn.Module): Path to the model weights file or a module instance. + device (torch.device): Device to run the model on. + dnn (bool): Use OpenCV DNN module for ONNX inference. data (str | Path | optional): Path to the additional data.yaml file containing class names. - fp16 (bool): Enable half-precision inference. Supported only on specific backends. Defaults to False. + fp16 (bool): Enable half-precision inference. Supported only on specific backends. batch (int): Batch-size to assume for inference. - fuse (bool): Fuse Conv2D + BatchNorm layers for optimization. Defaults to True. - verbose (bool): Enable verbose logging. Defaults to True. + fuse (bool): Fuse Conv2D + BatchNorm layers for optimization. + verbose (bool): Enable verbose logging. """ super().__init__() w = str(weights[0] if isinstance(weights, list) else weights) @@ -288,8 +288,8 @@ class AutoBackend(nn.Module): # fix error: `np.bool` was a deprecated alias for the builtin `bool` for JetPack 4 with Python <= 3.8.0 check_requirements("numpy==1.23.5") - try: - import tensorrt as trt # noqa https://developer.nvidia.com/nvidia-tensorrt-download + try: # https://developer.nvidia.com/nvidia-tensorrt-download + import tensorrt as trt # noqa except ImportError: if LINUX: check_requirements("tensorrt>7.0.0,!=10.1.0") @@ -562,9 +562,9 @@ class AutoBackend(nn.Module): Args: im (torch.Tensor): The image tensor to perform inference on. - augment (bool): Whether to perform data augmentation during inference. Defaults to False. - visualize (bool): Whether to visualize the output predictions. Defaults to False. - embed (list, optional): A list of feature vectors/embeddings to return. + augment (bool): Whether to perform data augmentation during inference. + visualize (bool): Whether to visualize the output predictions. + embed (list | None): A list of feature vectors/embeddings to return. **kwargs (Any): Additional keyword arguments for model configuration. Returns: @@ -799,11 +799,10 @@ class AutoBackend(nn.Module): @staticmethod def _model_type(p="path/to/model.pt"): """ - Takes a path to a model file and returns the model type. Possibles types are pt, jit, onnx, xml, engine, coreml, - saved_model, pb, tflite, edgetpu, tfjs, ncnn, mnn, imx or paddle. + Takes a path to a model file and returns the model type. Args: - p (str): Path to the model file. Defaults to path/to/model.pt + p (str): Path to the model file. Returns: (List[bool]): List of booleans indicating the model type. diff --git a/ultralytics/utils/__init__.py b/ultralytics/utils/__init__.py index c8b86391..4498064c 100644 --- a/ultralytics/utils/__init__.py +++ b/ultralytics/utils/__init__.py @@ -1243,7 +1243,7 @@ class SettingsManager(JSONDict): "mlflow": True, # MLflow integration "neptune": True, # Neptune integration "raytune": True, # Ray Tune integration - "tensorboard": True, # TensorBoard logging + "tensorboard": False, # TensorBoard logging "wandb": False, # Weights & Biases logging "vscode_msg": True, # VSCode messaging }