{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "name": "YOLO11 Tutorial", "provenance": [], "toc_visible": true }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "accelerator": "GPU" }, "cells": [ { "cell_type": "markdown", "metadata": { "id": "t6MPjfT5NrKQ" }, "source": "
\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 \"Ultralytics\n \"Run\n \"Open\n \"Open\n\n \"Discord\"\n \"Ultralytics\n \"Ultralytics\n
\n\nThis **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\nUltralytics 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\nFind 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\nRequest an Enterprise License for commercial use at [Ultralytics Licensing](https://www.ultralytics.com/license).\n\n
\n
\n \n \"Ultralytics\n \n\n

\n Watch: How to Train\n Ultralytics\n YOLO26 Model on Custom Dataset using Google Colab Notebook 🚀\n

\n
" }, { "cell_type": "markdown", "metadata": { "id": "7mGmQbAO5pQb" }, "source": [ "# Setup\n", "\n", "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://clickpy.clickhouse.com/dashboard/ultralytics) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ultralytics?logo=python&logoColor=gold)](https://pypi.org/project/ultralytics/)" ] }, { "cell_type": "code", "metadata": { "id": "wbvMlHd_QwMG", "colab": { "base_uri": "https://localhost:8080/" }, "outputId": "4de5a5c9-d3b5-4e4e-a4e5-cd80f159e4ce" }, "source": [ "!uv pip install ultralytics\n", "import ultralytics\n", "ultralytics.checks()" ], "execution_count": 1, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Ultralytics 8.3.187 🚀 Python-3.12.11 torch-2.8.0+cu126 CUDA:0 (Tesla T4, 15095MiB)\n", "Setup complete ✅ (2 CPUs, 12.7 GB RAM, 39.0/112.6 GB disk)\n" ] } ] }, { "cell_type": "markdown", "metadata": { "id": "4JnkELT0cIJg" }, "source": "# 1. Predict\n\nYOLO26 may be used directly in the Command Line Interface (CLI) with a `yolo` command for a variety of tasks and modes and accepts additional arguments, i.e. `imgsz=640`. See a full list of available `yolo` [arguments](https://docs.ultralytics.com/usage/cfg/) and other details in the [YOLO26 Predict Docs](https://docs.ultralytics.com/modes/train/)." }, { "cell_type": "code", "metadata": { "id": "zR9ZbuQCH7FX", "colab": { "base_uri": "https://localhost:8080/" }, "outputId": "1d438406-032a-4ea9-9ad5-dd17078850d3" }, "source": "# Run inference on an image with YOLO26n\n!yolo predict model=yolo26n.pt source='https://ultralytics.com/images/zidane.jpg'", "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "metadata": { "id": "hkAzDWJ7cWTr" }, "source": [ "        \n", "" ] }, { "cell_type": "markdown", "metadata": { "id": "0eq1SMWl6Sfn" }, "source": "# 2. Val\nValidate a model's accuracy on the [COCO](https://docs.ultralytics.com/datasets/detect/coco/) dataset's `val` or `test` splits. The latest YOLO26 [models](https://github.com/ultralytics/ultralytics#models) are downloaded automatically the first time they are used. See [YOLO26 Val Docs](https://docs.ultralytics.com/modes/val/) for more information." }, { "cell_type": "code", "metadata": { "id": "WQPtK1QYVaD_" }, "source": [ "# Download COCO val\n", "from ultralytics.utils.downloads import download\n", "\n", "download('https://ultralytics.com/assets/coco2017val.zip', unzip=True, dir='datasets') # download (780MB - 5000 images)" ], "execution_count": null, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "X58w8JLpMnjH", "outputId": "27364fde-3aff-47ea-9458-18e4a044e27b", "colab": { "base_uri": "https://localhost:8080/" } }, "source": "# Validate YOLO26n on COCO8 val\n!yolo val model=yolo26n.pt data=coco8.yaml", "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "metadata": { "id": "ZY2VXXXu74w5" }, "source": "# 3. Train\n\n

\n\nTrain YOLO26 on [Detect](https://docs.ultralytics.com/tasks/detect/), [Segment](https://docs.ultralytics.com/tasks/segment/), [Classify](https://docs.ultralytics.com/tasks/classify/) and [Pose](https://docs.ultralytics.com/tasks/pose/) datasets. See [YOLO26 Train Docs](https://docs.ultralytics.com/modes/train/) for more information." }, { "cell_type": "code", "source": "#@title Select YOLO26 🚀 logger {run: 'auto'}\nlogger = 'TensorBoard' #@param ['TensorBoard', 'Weights & Biases']\n\nif logger == 'TensorBoard':\n !yolo settings tensorboard=True\n %load_ext tensorboard\n %tensorboard --logdir .\nelif logger == 'Weights & Biases':\n !yolo settings wandb=True", "metadata": { "id": "ktegpM42AooT" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "1NcFxRcFdJ_O", "outputId": "849c2875-cd29-4a93-a7c7-e464a9b84dc6", "colab": { "base_uri": "https://localhost:8080/" } }, "source": "# Train YOLO26n on COCO8 for 3 epochs\n!yolo train model=yolo26n.pt data=coco8.yaml epochs=3 imgsz=640", "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": "# 4. Export\n\nExport a YOLO model to any supported format below with the `format` argument, i.e. `format=onnx`. See [Export Docs](https://docs.ultralytics.com/modes/export/) for more information.\n\n- 💡 ProTip: Export to [ONNX](https://docs.ultralytics.com/integrations/onnx/) or [OpenVINO](https://docs.ultralytics.com/integrations/openvino/) for up to 3x CPU speedup.\n- 💡 ProTip: Export to [TensorRT](https://docs.ultralytics.com/integrations/tensorrt/) for up to 5x GPU speedup.\n\n| Format | `format` Argument | Model | Metadata | Arguments |\n|--------|-----------------|-------|----------|------------|\n| [PyTorch](https://pytorch.org/) | - | `yolo26n.pt` | ✅ | - |\n| [TorchScript](https://docs.ultralytics.com/integrations/torchscript) | `torchscript` | `yolo26n.torchscript` | ✅ | `imgsz`, `batch`, `dynamic`, `optimize`, `half`, `nms`, `device` |\n| [ONNX](https://docs.ultralytics.com/integrations/onnx) | `onnx` | `yolo26n.onnx` | ✅ | `imgsz`, `batch`, `dynamic`, `half`, `opset`, `simplify`, `nms`, `device` |\n| [OpenVINO](https://docs.ultralytics.com/integrations/openvino) | `openvino` | `yolo26n_openvino_model/` | ✅ | `imgsz`, `batch`, `dynamic`, `half`, `int8`, `nms`, `fraction`, `device`, `data` |\n| [TensorRT](https://docs.ultralytics.com/integrations/tensorrt) | `engine` | `yolo26n.engine` | ✅ | `imgsz`, `batch`, `dynamic`, `half`, `int8`, `simplify`, `nms`, `fraction`, `device`, `data`, `workspace` |\n| [CoreML](https://docs.ultralytics.com/integrations/coreml) | `coreml` | `yolo26n.mlpackage` | ✅ | `imgsz`, `batch`, `half`, `int8`, `nms`, `device` |\n| [TF SavedModel](https://docs.ultralytics.com/integrations/tf-savedmodel) | `saved_model` | `yolo26n_saved_model/` | ✅ | `imgsz`, `batch`, `int8`, `keras`, `nms`, `device` |\n| [TF GraphDef](https://docs.ultralytics.com/integrations/tf-graphdef) | `pb` | `yolo26n.pb` | ❌ | `imgsz`, `batch`, `device` |\n| [TF Lite](https://docs.ultralytics.com/integrations/tflite) | `tflite` | `yolo26n.tflite` | ✅ | `imgsz`, `batch`, `half`, `int8`, `nms`, `fraction`, `device`, `data` |\n| [TF Edge TPU](https://docs.ultralytics.com/integrations/edge-tpu) | `edgetpu` | `yolo26n_edgetpu.tflite` | ✅ | `imgsz`, `device` |\n| [TF.js](https://docs.ultralytics.com/integrations/tfjs) | `tfjs` | `yolo26n_web_model/` | ✅ | `imgsz`, `batch`, `half`, `int8`, `nms`, `device` |\n| [PaddlePaddle](https://docs.ultralytics.com/integrations/paddlepaddle) | `paddle` | `yolo26n_paddle_model/` | ✅ | `imgsz`, `batch`, `device` |\n| [MNN](https://docs.ultralytics.com/integrations/mnn) | `mnn` | `yolo26n.mnn` | ✅ | `imgsz`, `batch`, `half`, `int8`, `device` |\n| [NCNN](https://docs.ultralytics.com/integrations/ncnn) | `ncnn` | `yolo26n_ncnn_model/` | ✅ | `imgsz`, `batch`, `half`, `device` |\n| [IMX500](https://docs.ultralytics.com/integrations/sony-imx500) | `imx` | `yolo26n_imx_model/` | ✅ | `imgsz`, `int8`, `fraction`, `device`, `data` |\n| [RKNN](https://docs.ultralytics.com/integrations/rockchip-rknn) | `rknn` | `yolo26n_rknn_model/` | ✅ | `imgsz`, `batch`, `name`, `device` || [ExecuTorch](https://docs.ultralytics.com/integrations/executorch) | `executorch` | `executorch_model/` | ✅ | `imgsz`, `device` || [Axelera](https://docs.ultralytics.com/integrations/axelera) | `axelera` | `axelera_model/` | ✅ | `imgsz`, `int8`, `fraction`, `device`, `data` |", "metadata": { "id": "nPZZeNrLCQG6" } }, { "cell_type": "code", "source": "!yolo export model=yolo26n.pt format=torchscript", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "CYIjW4igCjqD", "outputId": "f06e7d97-01d9-45f4-b24b-e90b08291675" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": "# 5. Python Usage\n\nYOLO26 was reimagined using Python-first principles for the most seamless Python YOLO experience yet. YOLO26 models can be loaded from a trained checkpoint or created from scratch. Then methods are used to train, val, predict, and export the model. See detailed Python usage examples in the [YOLO26 Python Docs](https://docs.ultralytics.com/usage/python/).", "metadata": { "id": "kUMOQ0OeDBJG" } }, { "cell_type": "code", "source": "from ultralytics import YOLO\n\n# Load a model\nmodel = YOLO('yolo26n.yaml') # build a new model from scratch\nmodel = YOLO('yolo26n.pt') # load a pretrained model (recommended for training)\n\n# Use the model\nresults = model.train(data='coco8.yaml', epochs=3) # train the model\nresults = model.val() # evaluate model performance on the validation set\nresults = model('https://ultralytics.com/images/bus.jpg') # predict on an image\nresults = model.export(format='onnx') # export the model to ONNX format", "metadata": { "id": "bpF9-vS_DAaf" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": "# 6. Tasks\n\nYOLO26 can train, val, predict and export models for the most common tasks in vision AI: [Detect](https://docs.ultralytics.com/tasks/detect/), [Segment](https://docs.ultralytics.com/tasks/segment/), [Classify](https://docs.ultralytics.com/tasks/classify/) and [Pose](https://docs.ultralytics.com/tasks/pose/). See [YOLO26 Tasks Docs](https://docs.ultralytics.com/tasks/) for more information.\n\n
", "metadata": { "id": "Phm9ccmOKye5" } }, { "cell_type": "markdown", "source": "## 1. Detection\n\nYOLO26 _detection_ models have no suffix and are the default YOLO26 models, i.e. `yolo26n.pt` and are pretrained on COCO. See [Detection Docs](https://docs.ultralytics.com/tasks/detect/) for full details.", "metadata": { "id": "yq26lwpYK1lq" } }, { "cell_type": "code", "source": "# Load YOLO26n, train it on COCO128 for 3 epochs and predict an image with it\nfrom ultralytics import YOLO\n\nmodel = YOLO('yolo26n.pt') # load a pretrained YOLO detection model\nmodel.train(data='coco8.yaml', epochs=3) # train the model\nmodel('https://ultralytics.com/images/bus.jpg') # predict on an image", "metadata": { "id": "8Go5qqS9LbC5" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": "## 2. Segmentation\n\nYOLO26 _segmentation_ models use the `-seg` suffix, i.e. `yolo26n-seg.pt` and are pretrained on COCO. See [Segmentation Docs](https://docs.ultralytics.com/tasks/segment/) for full details.", "metadata": { "id": "7ZW58jUzK66B" } }, { "cell_type": "code", "source": "# Load YOLO26n-seg, train it on COCO128-seg for 3 epochs and predict an image with it\nfrom ultralytics import YOLO\n\nmodel = YOLO('yolo26n-seg.pt') # load a pretrained YOLO segmentation model\nmodel.train(data='coco8-seg.yaml', epochs=3) # train the model\nmodel('https://ultralytics.com/images/bus.jpg') # predict on an image", "metadata": { "id": "WFPJIQl_L5HT" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": "## 3. Classification\n\nYOLO26 _classification_ models use the `-cls` suffix, i.e. `yolo26n-cls.pt` and are pretrained on ImageNet. See [Classification Docs](https://docs.ultralytics.com/tasks/classify/) for full details.", "metadata": { "id": "ax3p94VNK9zR" } }, { "cell_type": "code", "source": "# Load YOLO26n-cls, train it on mnist160 for 3 epochs and predict an image with it\nfrom ultralytics import YOLO\n\nmodel = YOLO('yolo26n-cls.pt') # load a pretrained YOLO classification model\nmodel.train(data='mnist160', epochs=3) # train the model\nmodel('https://ultralytics.com/images/bus.jpg') # predict on an image", "metadata": { "id": "5q9Zu6zlL5rS" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": "## 4. Pose\n\nYOLO26 _pose_ models use the `-pose` suffix, i.e. `yolo26n-pose.pt` and are pretrained on COCO Keypoints. See [Pose Docs](https://docs.ultralytics.com/tasks/pose/) for full details.", "metadata": { "id": "SpIaFLiO11TG" } }, { "cell_type": "code", "source": "# Load YOLO26n-pose, train it on COCO8-pose for 3 epochs and predict an image with it\nfrom ultralytics import YOLO\n\nmodel = YOLO('yolo26n-pose.pt') # load a pretrained YOLO pose model\nmodel.train(data='coco8-pose.yaml', epochs=3) # train the model\nmodel('https://ultralytics.com/images/bus.jpg') # predict on an image", "metadata": { "id": "si4aKFNg19vX" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": "## 4. Oriented Bounding Boxes (OBB)\n\nYOLO26 _OBB_ models use the `-obb` suffix, i.e. `yolo26n-obb.pt` and are pretrained on the DOTA dataset. See [OBB Docs](https://docs.ultralytics.com/tasks/obb/) for full details.", "metadata": { "id": "cf5j_T9-B5F0" } }, { "cell_type": "code", "source": "# Load YOLO26n-obb, train it on DOTA8 for 3 epochs and predict an image with it\nfrom ultralytics import YOLO\n\nmodel = YOLO('yolo26n-obb.pt') # load a pretrained YOLO OBB model\nmodel.train(data='dota8.yaml', epochs=3) # train the model\nmodel('https://ultralytics.com/images/boats.jpg') # predict on an image", "metadata": { "id": "IJNKClOOB5YS" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "metadata": { "id": "IEijrePND_2I" }, "source": [ "# Appendix\n", "\n", "Additional content below." ] }, { "cell_type": "code", "source": [ "# Pip install from source\n", "!uv pip install git+https://github.com/ultralytics/ultralytics@main" ], "metadata": { "id": "pIdE6i8C3LYp" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "# Git clone and run tests on 'main' branch\n", "!git clone https://github.com/ultralytics/ultralytics -b main\n", "!uv pip install -qe ultralytics" ], "metadata": { "id": "uRKlwxSJdhd1" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "# Run tests (Git clone only)\n", "!pytest ultralytics/tests" ], "metadata": { "id": "GtPlh7mcCGZX" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": "# Validate multiple models\nfor x in 'nsmlx':\n !yolo val model=yolo26{x}.pt data=coco.yaml", "metadata": { "id": "Wdc6t_bfzDDk" }, "execution_count": null, "outputs": [] } ] }