Merge branch 'main' into stale-actions

stale-actions
Ultralytics Assistant 2 months ago committed by GitHub
commit 46f34824e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 10
      .github/workflows/docs.yml
  2. 2
      docs/en/datasets/classify/fashion-mnist.md
  3. 616
      docs/en/datasets/explorer/explorer.ipynb
  4. 286
      docs/en/datasets/explorer/explorer.md
  5. 2
      docs/en/guides/coral-edge-tpu-on-raspberry-pi.md
  6. 87
      docs/en/guides/deepstream-nvidia-jetson.md
  7. 4
      docs/en/guides/index.md
  8. 2
      docs/en/guides/model-evaluation-insights.md
  9. 2
      docs/en/guides/model-monitoring-and-maintenance.md
  10. 19
      docs/en/guides/nvidia-jetson.md
  11. 22
      docs/en/help/FAQ.md
  12. 4
      docs/en/integrations/ibm-watsonx.md
  13. 4
      docs/en/integrations/kaggle.md
  14. 2
      docs/en/integrations/ncnn.md
  15. 2
      docs/en/integrations/sony-imx500.md
  16. 24
      docs/en/integrations/weights-biases.md
  17. 16
      docs/en/models/yolov6.md
  18. 8
      docs/en/models/yolov9.md
  19. 10
      docs/en/usage/simple-utilities.md
  20. 8
      examples/YOLOv8-CPP-Inference/README.md
  21. 2
      examples/YOLOv8-LibTorch-CPP-Inference/README.md
  22. 2
      examples/YOLOv8-OpenVINO-CPP-Inference/README.md
  23. 3
      mkdocs.yml
  24. 1
      pyproject.toml
  25. 21
      tests/test_solutions.py
  26. 2
      ultralytics/__init__.py
  27. 2
      ultralytics/cfg/__init__.py
  28. 2
      ultralytics/data/converter.py
  29. 3
      ultralytics/data/dataset.py
  30. 7
      ultralytics/engine/exporter.py
  31. 14
      ultralytics/models/sam/predict.py
  32. 2
      ultralytics/nn/autobackend.py
  33. 2
      ultralytics/utils/plotting.py

@ -33,29 +33,29 @@ jobs:
env:
GITHUB_REF: ${{ github.head_ref || github.ref }}
steps:
- name: Git config
run: |
git config --global user.name "UltralyticsAssistant"
git config --global user.email "web@ultralytics.com"
- name: Checkout Repository
uses: actions/checkout@v4
with:
# Fetch depth 0 required to capture full docs author history
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
token: ${{ secrets._GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
ref: ${{ env.GITHUB_REF }}
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- uses: astral-sh/setup-uv@v5
- name: Install Dependencies
run: uv pip install --system ruff black tqdm mkdocs-material "mkdocstrings[python]" mkdocs-jupyter mkdocs-redirects mkdocs-ultralytics-plugin mkdocs-macros-plugin
run: uv pip install --system ruff black tqdm mkdocs-material "mkdocstrings[python]" mkdocs-redirects mkdocs-ultralytics-plugin mkdocs-macros-plugin
- name: Ruff fixes
continue-on-error: true
run: ruff check --fix --unsafe-fixes --select D --ignore=D100,D104,D203,D205,D212,D213,D401,D406,D407,D413 .
- name: Update Docs Reference Section and Push Changes
continue-on-error: true
run: |
git config --global user.name "UltralyticsAssistant"
git config --global user.email "web@ultralytics.com"
python docs/build_reference.py
git pull origin "$GITHUB_REF"
git add .

@ -37,6 +37,7 @@ The Fashion-MNIST dataset is split into two subsets:
Each training and test example is assigned to one of the following labels:
```
0. T-shirt/top
1. Trouser
2. Pullover
@ -47,6 +48,7 @@ Each training and test example is assigned to one of the following labels:
7. Sneaker
8. Bag
9. Ankle boot
```
## Applications

@ -1,616 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "aa923c26-81c8-4565-9277-1cb686e3702e",
"metadata": {
"id": "aa923c26-81c8-4565-9277-1cb686e3702e"
},
"source": [
"# VOC Exploration Example\n",
"<div align=\"center\">\n",
"\n",
" <a href=\"https://ultralytics.com/yolo\" target=\"_blank\">\n",
" <img width=\"1024\", src=\"https://raw.githubusercontent.com/ultralytics/assets/main/yolov8/banner-yolov8.png\"></a>\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",
" <a href=\"https://console.paperspace.com/github/ultralytics/ultralytics\"><img src=\"https://assets.paperspace.io/img/gradient-badge.svg\" alt=\"Run on Gradient\"/></a>\n",
" <a href=\"https://colab.research.google.com/github/ultralytics/ultralytics/blob/main/examples/tutorial.ipynb\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"></a>\n",
" <a href=\"https://www.kaggle.com/models/ultralytics/yolo11\"><img src=\"https://kaggle.com/static/images/open-in-kaggle.svg\" alt=\"Open In Kaggle\"></a>\n",
"\n",
"Welcome to the Ultralytics Explorer API notebook! This notebook serves as the starting point for exploring the various resources available to help you get started with using Ultralytics to explore your datasets using with the power of semantic search. You can utilities out of the box that allow you to examine specific types of labels using vector search or even SQL queries.\n",
"\n",
"We hope that the resources in this notebook will help you get the most out of Ultralytics. Please browse the Explorer <a href=\"https://docs.ultralytics.com/\">Docs</a> for details, raise an issue on <a href=\"https://github.com/ultralytics/ultralytics\">GitHub</a> for support, and join our <a href=\"https://ultralytics.com/discord\">Discord</a> community for questions and discussions!\n",
"\n",
"Try `yolo explorer` powered by Exlorer API\n",
"\n",
"Simply `pip install ultralytics` and run `yolo explorer` in your terminal to run custom queries and semantic search on your datasets right inside your browser!\n",
"\n",
"</div>"
]
},
{
"cell_type": "markdown",
"source": [
"## Ultralytics Explorer support deprecated ⚠\n",
"\n",
"As of **`ultralytics>=8.3.10`**, Ultralytics explorer support has been deprecated. But don’t worry! You can now access similar and even enhanced functionality through [Ultralytics HUB](https://hub.ultralytics.com/), our intuitive no-code platform designed to streamline your workflow. With Ultralytics HUB, you can continue exploring, visualizing, and managing your data effortlessly, all without writing a single line of code. Make sure to check it out and take advantage of its powerful features!🚀"
],
"metadata": {
"id": "RHe1PX5c7uK2"
},
"id": "RHe1PX5c7uK2"
},
{
"cell_type": "markdown",
"id": "2454d9ba-9db4-4b37-98e8-201ba285c92f",
"metadata": {
"id": "2454d9ba-9db4-4b37-98e8-201ba285c92f"
},
"source": [
"## Setup\n",
"Pip install `ultralytics` and [dependencies](https://github.com/ultralytics/ultralytics/blob/main/pyproject.toml) and check software and hardware."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "433f3a4d-a914-42cb-b0b6-be84a84e5e41",
"metadata": {
"id": "433f3a4d-a914-42cb-b0b6-be84a84e5e41"
},
"outputs": [],
"source": [
"%pip install ultralytics[explorer] openai\n",
"import ultralytics\n",
"\n",
"ultralytics.checks()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ae602549-3419-4909-9f82-35cba515483f",
"metadata": {
"id": "ae602549-3419-4909-9f82-35cba515483f"
},
"outputs": [],
"source": [
"from ultralytics import Explorer"
]
},
{
"cell_type": "markdown",
"id": "d8c06350-be8e-45cf-b3a6-b5017bbd943c",
"metadata": {
"id": "d8c06350-be8e-45cf-b3a6-b5017bbd943c"
},
"source": [
"## Similarity search\n",
"Utilize the power of vector similarity search to find the similar data points in your dataset along with their distance in the embedding space. Simply create an embeddings table for the given dataset-model pair. It is only needed once and it is reused automatically.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "334619da-6deb-4b32-9fe0-74e0a79cee20",
"metadata": {
"id": "334619da-6deb-4b32-9fe0-74e0a79cee20"
},
"outputs": [],
"source": [
"exp = Explorer(\"VOC.yaml\", model=\"yolo11n.pt\")\n",
"exp.create_embeddings_table()"
]
},
{
"cell_type": "markdown",
"id": "b6c5e42d-bc7e-4b4c-bde0-643072a2165d",
"metadata": {
"id": "b6c5e42d-bc7e-4b4c-bde0-643072a2165d"
},
"source": [
"One the embeddings table is built, you can get run semantic search in any of the following ways:\n",
"- On a given index / list of indices in the dataset like - `exp.get_similar(idx=[1,10], limit=10)`\n",
"- On any image/ list of images not in the dataset - `exp.get_similar(img=[\"path/to/img1\", \"path/to/img2\"], limit=10)`\n",
"In case of multiple inputs, the aggregade of their embeddings is used.\n",
"\n",
"You get a pandas dataframe with the `limit` number of most similar data points to the input, along with their distance in the embedding space. You can use this dataset to perform further filtering\n",
"<img width=\"1120\" alt=\"Screenshot 2024-01-06 at 9 45 42PM\" src=\"https://github.com/AyushExel/assets/assets/15766192/7742ac57-e22a-4cea-a0f9-2b2a257483c5\">\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b485f05b-d92d-42bc-8da7-5e361667b341",
"metadata": {
"id": "b485f05b-d92d-42bc-8da7-5e361667b341"
},
"outputs": [],
"source": [
"similar = exp.get_similar(idx=1, limit=10)\n",
"similar.head()"
]
},
{
"cell_type": "markdown",
"id": "acf4b489-2161-4176-a1fe-d1d067d8083d",
"metadata": {
"id": "acf4b489-2161-4176-a1fe-d1d067d8083d"
},
"source": [
"You can use the also plot the similar samples directly using the `plot_similar` util\n",
"<p>\n",
"\n",
" <img src=\"https://github.com/AyushExel/assets/assets/15766192/a3c9247b-9271-47df-aaa5-36d96c5034b1\" />\n",
"</p>\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9dbfe7d0-8613-4529-adb6-6e0632d7cce7",
"metadata": {
"id": "9dbfe7d0-8613-4529-adb6-6e0632d7cce7"
},
"outputs": [],
"source": [
"exp.plot_similar(idx=6500, limit=20)\n",
"# exp.plot_similar(idx=[100,101], limit=10) # Can also pass list of idxs or imgs"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "260e09bf-4960-4089-a676-cb0e76ff3c0d",
"metadata": {
"id": "260e09bf-4960-4089-a676-cb0e76ff3c0d"
},
"outputs": [],
"source": [
"exp.plot_similar(\n",
" img=\"https://ultralytics.com/images/bus.jpg\", limit=10, labels=False\n",
") # Can also pass any external images"
]
},
{
"cell_type": "markdown",
"id": "faa0b7a7-6318-40e4-b0f4-45a8113bdc3a",
"metadata": {
"id": "faa0b7a7-6318-40e4-b0f4-45a8113bdc3a"
},
"source": [
"<p>\n",
"<img src=\"https://github.com/AyushExel/assets/assets/15766192/8e011195-b0da-43ef-b3cd-5fb6f383037e\">\n",
"\n",
"</p>"
]
},
{
"cell_type": "markdown",
"id": "0cea63f1-71f1-46da-af2b-b1b7d8f73553",
"metadata": {
"id": "0cea63f1-71f1-46da-af2b-b1b7d8f73553"
},
"source": [
"## 2. Ask AI: Search or filter with Natural Language\n",
"You can prompt the Explorer object with the kind of data points you want to see and it'll try to return a dataframe with those. Because it is powered by LLMs, it doesn't always get it right. In that case, it'll return None.\n",
"<p>\n",
"<img width=\"1131\" alt=\"Screenshot 2024-01-07 at 2 34 53PM\" src=\"https://github.com/AyushExel/assets/assets/15766192/c4a69fd9-e54f-4d6a-aba5-dc9cfae1bc04\">\n",
"\n",
"</p>\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "92fb92ac-7f76-465a-a9ba-ea7492498d9c",
"metadata": {
"id": "92fb92ac-7f76-465a-a9ba-ea7492498d9c"
},
"outputs": [],
"source": [
"df = exp.ask_ai(\"show me images containing more than 10 objects with at least 2 persons\")\n",
"df.head(5)"
]
},
{
"cell_type": "markdown",
"id": "f2a7d26e-0ce5-4578-ad1a-b1253805280f",
"metadata": {
"id": "f2a7d26e-0ce5-4578-ad1a-b1253805280f"
},
"source": [
"for plotting these results you can use `plot_query_result` util\n",
"Example:\n",
"```\n",
"plt = plot_query_result(exp.ask_ai(\"show me 10 images containing exactly 2 persons\"))\n",
"Image.fromarray(plt)\n",
"```\n",
"<p>\n",
" <img src=\"https://github.com/AyushExel/assets/assets/15766192/2cb780de-d05b-4412-a526-7f7f0f10e669\">\n",
"\n",
"</p>"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b1cfab84-9835-4da0-8e9a-42b30cf84511",
"metadata": {
"id": "b1cfab84-9835-4da0-8e9a-42b30cf84511"
},
"outputs": [],
"source": [
"# plot\n",
"from PIL import Image\n",
"\n",
"from ultralytics.data.explorer import plot_query_result\n",
"\n",
"plt = plot_query_result(exp.ask_ai(\"show me 10 images containing exactly 2 persons\"))\n",
"Image.fromarray(plt)"
]
},
{
"cell_type": "markdown",
"id": "35315ae6-d827-40e4-8813-279f97a83b34",
"metadata": {
"id": "35315ae6-d827-40e4-8813-279f97a83b34"
},
"source": [
"## 3. Run SQL queries on your Dataset!\n",
"Sometimes you might want to investigate a certain type of entries in your dataset. For this Explorer allows you to execute SQL queries.\n",
"It accepts either of the formats:\n",
"- Queries beginning with \"WHERE\" will automatically select all columns. This can be thought of as a short-hand query\n",
"- You can also write full queries where you can specify which columns to select\n",
"\n",
"This can be used to investigate model performance and specific data points. For example:\n",
"- let's say your model struggles on images that have humans and dogs. You can write a query like this to select the points that have at least 2 humans AND at least one dog.\n",
"\n",
"You can combine SQL query and semantic search to filter down to specific type of results\n",
"<img width=\"994\" alt=\"Screenshot 2024-01-06 at 9 47 30PM\" src=\"https://github.com/AyushExel/assets/assets/15766192/92bc3178-c151-4cd5-8007-c76178deb113\">\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8cd1072f-3100-4331-a0e3-4e2f6b1005bf",
"metadata": {
"id": "8cd1072f-3100-4331-a0e3-4e2f6b1005bf"
},
"outputs": [],
"source": [
"table = exp.sql_query(\"WHERE labels LIKE '%person, person%' AND labels LIKE '%dog%' LIMIT 10\")\n",
"table"
]
},
{
"cell_type": "markdown",
"id": "debf8a00-c9f6-448b-bd3b-454cf62f39ab",
"metadata": {
"id": "debf8a00-c9f6-448b-bd3b-454cf62f39ab"
},
"source": [
"Just like similarity search, you also get a util to directly plot the sql queries using `exp.plot_sql_query`\n",
"<img src=\"https://github.com/AyushExel/assets/assets/15766192/f8b66629-8dd0-419e-8f44-9837969ba678\">\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "18b977e7-d048-4b22-b8c4-084a03b04f23",
"metadata": {
"id": "18b977e7-d048-4b22-b8c4-084a03b04f23"
},
"outputs": [],
"source": [
"exp.plot_sql_query(\"WHERE labels LIKE '%person, person%' AND labels LIKE '%dog%' LIMIT 10\", labels=True)"
]
},
{
"cell_type": "markdown",
"id": "f26804c5-840b-4fd1-987f-e362f29e3e06",
"metadata": {
"id": "f26804c5-840b-4fd1-987f-e362f29e3e06"
},
"source": [
"## 3. Working with embeddings Table (Advanced)\n",
"Explorer works on [LanceDB](https://lancedb.github.io/lancedb/) tables internally. You can access this table directly, using `Explorer.table` object and run raw queries, push down pre and post filters, etc."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ea69260a-3407-40c9-9f42-8b34a6e6af7a",
"metadata": {
"id": "ea69260a-3407-40c9-9f42-8b34a6e6af7a"
},
"outputs": [],
"source": [
"table = exp.table\n",
"table.schema"
]
},
{
"cell_type": "markdown",
"id": "238db292-8610-40b3-9af7-dfd6be174892",
"metadata": {
"id": "238db292-8610-40b3-9af7-dfd6be174892"
},
"source": [
"### Run raw queries\n",
"Vector Search finds the nearest vectors from the database. In a recommendation system or search engine, you can find similar products from the one you searched. In LLM and other AI applications, each data point can be presented by the embeddings generated from some models, it returns the most relevant features.\n",
"\n",
"A search in high-dimensional vector space, is to find K-Nearest-Neighbors (KNN) of the query vector.\n",
"\n",
"Metric\n",
"In LanceDB, a Metric is the way to describe the distance between a pair of vectors. Currently, it supports the following metrics:\n",
"- L2\n",
"- Cosine\n",
"- Dot\n",
"Explorer's similarity search uses L2 by default. You can run queries on tables directly, or use the lance format to build custom utilities to manage datasets. More details on available LanceDB table ops in the [docs](https://lancedb.github.io/lancedb/)\n",
"\n",
"<img width=\"1015\" alt=\"Screenshot 2024-01-06 at 9 48 35PM\" src=\"https://github.com/AyushExel/assets/assets/15766192/a2ccdaf3-8877-4f70-bf47-8a9bd2bb20c0\">\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d74430fe-5aee-45a1-8863-3f2c31338792",
"metadata": {
"id": "d74430fe-5aee-45a1-8863-3f2c31338792"
},
"outputs": [],
"source": [
"dummy_img_embedding = [i for i in range(256)]\n",
"table.search(dummy_img_embedding).limit(5).to_pandas()"
]
},
{
"cell_type": "markdown",
"id": "587486b4-0d19-4214-b994-f032fb2e8eb5",
"metadata": {
"id": "587486b4-0d19-4214-b994-f032fb2e8eb5"
},
"source": [
"### Inter-conversion to popular data formats"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bb2876ea-999b-4eba-96bc-c196ba02c41c",
"metadata": {
"id": "bb2876ea-999b-4eba-96bc-c196ba02c41c"
},
"outputs": [],
"source": [
"df = table.to_pandas()\n",
"pa_table = table.to_arrow()"
]
},
{
"cell_type": "markdown",
"id": "42659d63-ad76-49d6-8dfc-78d77278db72",
"metadata": {
"id": "42659d63-ad76-49d6-8dfc-78d77278db72"
},
"source": [
"### Work with Embeddings\n",
"You can access the raw embedding from lancedb Table and analyse it. The image embeddings are stored in column `vector`"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "66d69e9b-046e-41c8-80d7-c0ee40be3bca",
"metadata": {
"id": "66d69e9b-046e-41c8-80d7-c0ee40be3bca"
},
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"embeddings = table.to_pandas()[\"vector\"].tolist()\n",
"embeddings = np.array(embeddings)"
]
},
{
"cell_type": "markdown",
"id": "e8df0a49-9596-4399-954b-b8ae1fd7a602",
"metadata": {
"id": "e8df0a49-9596-4399-954b-b8ae1fd7a602"
},
"source": [
"### Scatterplot\n",
"One of the preliminary steps in analysing embeddings is by plotting them in 2D space via dimensionality reduction. Let's try an example\n",
"\n",
"<img width=\"646\" alt=\"Screenshot 2024-01-06 at 9 48 58PM\" src=\"https://github.com/AyushExel/assets/assets/15766192/9e1da25c-face-4426-abc0-2f64a4e4952c\">\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d9a150e8-8092-41b3-82f8-2247f8187fc8",
"metadata": {
"id": "d9a150e8-8092-41b3-82f8-2247f8187fc8"
},
"outputs": [],
"source": [
"!pip install scikit-learn --q"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "196079c3-45a9-4325-81ab-af79a881e37a",
"metadata": {
"id": "196079c3-45a9-4325-81ab-af79a881e37a"
},
"outputs": [],
"source": [
"%matplotlib inline\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"from sklearn.decomposition import PCA\n",
"\n",
"# Reduce dimensions using PCA to 3 components for visualization in 3D\n",
"pca = PCA(n_components=3)\n",
"reduced_data = pca.fit_transform(embeddings)\n",
"\n",
"# Create a 3D scatter plot using Matplotlib's Axes3D\n",
"fig = plt.figure(figsize=(8, 6))\n",
"ax = fig.add_subplot(111, projection=\"3d\")\n",
"\n",
"# Scatter plot\n",
"ax.scatter(reduced_data[:, 0], reduced_data[:, 1], reduced_data[:, 2], alpha=0.5)\n",
"ax.set_title(\"3D Scatter Plot of Reduced 256-Dimensional Data (PCA)\")\n",
"ax.set_xlabel(\"Component 1\")\n",
"ax.set_ylabel(\"Component 2\")\n",
"ax.set_zlabel(\"Component 3\")\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "1c843c23-e3f2-490e-8d6c-212fa038a149",
"metadata": {
"id": "1c843c23-e3f2-490e-8d6c-212fa038a149"
},
"source": [
"## 4. Similarity Index\n",
"Here's a simple example of an operation powered by the embeddings table. Explorer comes with a `similarity_index` operation-\n",
"* It tries to estimate how similar each data point is with the rest of the dataset.\n",
"* It does that by counting how many image embeddings lie closer than `max_dist` to the current image in the generated embedding space, considering `top_k` similar images at a time.\n",
"\n",
"For a given dataset, model, `max_dist` & `top_k` the similarity index once generated will be reused. In case, your dataset has changed, or you simply need to regenerate the similarity index, you can pass `force=True`.\n",
"Similar to vector and SQL search, this also comes with a util to directly plot it. Let's look at the plot first\n",
"<img width=\"633\" alt=\"Screenshot 2024-01-06 at 9 49 36PM\" src=\"https://github.com/AyushExel/assets/assets/15766192/96a9d984-4a72-4784-ace1-428676ee2bdd\">\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "953c2a5f-1b61-4acf-a8e4-ed08547dbafc",
"metadata": {
"id": "953c2a5f-1b61-4acf-a8e4-ed08547dbafc"
},
"outputs": [],
"source": [
"exp.plot_similarity_index(max_dist=0.2, top_k=0.01)"
]
},
{
"cell_type": "markdown",
"id": "28228a9a-b727-45b5-8ca7-8db662c0b937",
"metadata": {
"id": "28228a9a-b727-45b5-8ca7-8db662c0b937"
},
"source": [
"Now let's look at the output of the operation"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f4161aaa-20e6-4df0-8e87-d2293ee0530a",
"metadata": {
"id": "f4161aaa-20e6-4df0-8e87-d2293ee0530a"
},
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"sim_idx = exp.similarity_index(max_dist=0.2, top_k=0.01, force=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b01d5b1a-9adb-4c3c-a873-217c71527c8d",
"metadata": {
"id": "b01d5b1a-9adb-4c3c-a873-217c71527c8d"
},
"outputs": [],
"source": [
"sim_idx"
]
},
{
"cell_type": "markdown",
"id": "22b28e54-4fbb-400e-ad8c-7068cbba11c4",
"metadata": {
"id": "22b28e54-4fbb-400e-ad8c-7068cbba11c4"
},
"source": [
"Let's create a query to see what data points have similarity count of more than 30 and plot images similar to them."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "58d2557b-d401-43cf-937d-4f554c7bc808",
"metadata": {
"id": "58d2557b-d401-43cf-937d-4f554c7bc808"
},
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"sim_count = np.array(sim_idx[\"count\"])\n",
"sim_idx[\"im_file\"][sim_count > 30]"
]
},
{
"cell_type": "markdown",
"id": "a5ec8d76-271a-41ab-ac74-cf8c0084ba5e",
"metadata": {
"id": "a5ec8d76-271a-41ab-ac74-cf8c0084ba5e"
},
"source": [
"You should see something like this\n",
"<img src=\"https://github.com/AyushExel/assets/assets/15766192/649bc366-ca2d-46ea-bfd9-3097cf575584\">\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3a7b2ee3-9f35-48a2-9c38-38379516f4d2",
"metadata": {
"id": "3a7b2ee3-9f35-48a2-9c38-38379516f4d2"
},
"outputs": [],
"source": [
"exp.plot_similar(idx=[7146, 14035]) # Using avg embeddings of 2 images"
]
}
],
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

@ -0,0 +1,286 @@
---
comments: true
description: Dive into advanced data exploration with Ultralytics Explorer. Perform semantic searches, execute SQL queries, and leverage AI-powered natural language insights for seamless data analysis.
keywords: Ultralytics Explorer, data exploration, semantic search, vector similarity, SQL queries, AI, natural language queries, machine learning, OpenAI, LLMs, Ultralytics HUB
---
# VOC Exploration Example
<div align="center">
<a href="https://www.ultralytics.com/events/yolovision" target="_blank"><img width="1024%" src="https://github.com/ultralytics/docs/releases/download/0/ultralytics-yolov8-banner.avif" alt="Ultralytics YOLO banner"></a>
<a href="https://docs.ultralytics.com/zh">中文</a> |
<a href="https://docs.ultralytics.com/ko">한국어</a> |
<a href="https://docs.ultralytics.com/ja">日本語</a> |
<a href="https://docs.ultralytics.com/ru">Русский</a> |
<a href="https://docs.ultralytics.com/de">Deutsch</a> |
<a href="https://docs.ultralytics.com/fr">Français</a> |
<a href="https://docs.ultralytics.com/es/">Español</a> |
<a href="https://docs.ultralytics.com/pt">Português</a> |
<a href="https://docs.ultralytics.com/tr">Türkçe</a> |
<a href="https://docs.ultralytics.com/vi">Tiếng Việt</a> |
<a href="https://docs.ultralytics.com/ar">العربية</a>
<br>
<br>
<a href="https://github.com/ultralytics/ultralytics/actions/workflows/ci.yaml"><img src="https://github.com/ultralytics/ultralytics/actions/workflows/ci.yaml/badge.svg" alt="Ultralytics CI"></a>
<a href="https://pepy.tech/projects/ultralytics"><img src="https://static.pepy.tech/badge/ultralytics" alt="Ultralytics Downloads"></a>
<a href="https://zenodo.org/badge/latestdoi/264818686"><img src="https://zenodo.org/badge/264818686.svg" alt="Ultralytics YOLO Citation"></a>
<a href="https://discord.com/invite/ultralytics"><img alt="Ultralytics Discord" src="https://img.shields.io/discord/1089800235347353640?logo=discord&logoColor=white&label=Discord&color=blue"></a>
<a href="https://community.ultralytics.com/"><img alt="Ultralytics Forums" src="https://img.shields.io/discourse/users?server=https%3A%2F%2Fcommunity.ultralytics.com&logo=discourse&label=Forums&color=blue"></a>
<a href="https://reddit.com/r/ultralytics"><img alt="Ultralytics Reddit" src="https://img.shields.io/reddit/subreddit-subscribers/ultralytics?style=flat&logo=reddit&logoColor=white&label=Reddit&color=blue"></a>
<br>
<a href="https://console.paperspace.com/github/ultralytics/ultralytics"><img src="https://assets.paperspace.io/img/gradient-badge.svg" alt="Run Ultralytics on Gradient"></a>
<a href="https://colab.research.google.com/github/ultralytics/ultralytics/blob/main/examples/tutorial.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open Ultralytics In Colab"></a>
<a href="https://www.kaggle.com/models/ultralytics/yolo11"><img src="https://kaggle.com/static/images/open-in-kaggle.svg" alt="Open Ultralytics In Kaggle"></a>
<a href="https://mybinder.org/v2/gh/ultralytics/ultralytics/HEAD?labpath=examples%2Ftutorial.ipynb"><img src="https://mybinder.org/badge_logo.svg" alt="Open Ultralytics In Binder"></a>
<br>
</div>
Welcome to the Ultralytics Explorer API notebook! This notebook serves as the starting point for exploring the various resources available to help you get started with using Ultralytics to explore your datasets using with the power of semantic search. You can utilities out of the box that allow you to examine specific types of labels using vector search or even SQL queries.
Try `yolo explorer` powered by Explorer API
Simply `pip install ultralytics` and run `yolo explorer` in your terminal to run custom queries and semantic search on your datasets right inside your browser!
## Ultralytics Explorer support deprecated ⚠
As of **`ultralytics>=8.3.10`**, Ultralytics explorer support has been deprecated. But don't worry! You can now access similar and even enhanced functionality through [Ultralytics HUB](https://hub.ultralytics.com/), our intuitive no-code platform designed to streamline your workflow. With Ultralytics HUB, you can continue exploring, visualizing, and managing your data effortlessly, all without writing a single line of code. Make sure to check it out and take advantage of its powerful features!🚀
## Setup
Pip install `ultralytics` and [dependencies](https://github.com/ultralytics/ultralytics/blob/main/pyproject.toml) and check software and hardware.
```bash
%pip install ultralytics[explorer] openai
import ultralytics
ultralytics.checks()
```
## Similarity Search
Utilize the power of vector similarity search to find the similar data points in your dataset along with their distance in the embedding space. Simply create an embeddings table for the given dataset-model pair. It is only needed once, and it is reused automatically.
```python
exp = Explorer("VOC.yaml", model="yolo11n.pt")
exp.create_embeddings_table()
```
One the embeddings table is built, you can get run semantic search in any of the following ways:
- On a given index / list of indices in the dataset like - exp.get_similar(idx=[1,10], limit=10)
- On any image/ list of images not in the dataset - exp.get_similar(img=["path/to/img1", "path/to/img2"], limit=10) In case of multiple inputs, the aggregate of their embeddings is used.
You get a pandas dataframe with the limit number of most similar data points to the input, along with their distance in the embedding space. You can use this dataset to perform further filtering
![Similarity search table](https://github.com/ultralytics/docs/releases/download/0/similarity-search-table.avif)
```python
# Search dataset by index
similar = exp.get_similar(idx=1, limit=10)
similar.head()
```
You can use the also plot the similar samples directly using the `plot_similar` util
![Similarity search image 1](https://github.com/ultralytics/docs/releases/download/0/similarity-search-image-1.avif)
```python
exp.plot_similar(idx=6500, limit=20)
# exp.plot_similar(idx=[100,101], limit=10) # Can also pass list of idxs or imgs
exp.plot_similar(
img="https://ultralytics.com/images/bus.jpg", limit=10, labels=False
) # Can also pass any external images
```
![Similarity search image 2](https://github.com/ultralytics/docs/releases/download/0/similarity-search-image-2.avif)
## Ask AI: Search or filter with Natural Language
You can prompt the Explorer object with the kind of data points you want to see, and it'll try to return a dataframe with those. Because it is powered by LLMs, it doesn't always get it right. In that case, it'll return None.
![Ask ai table](https://github.com/ultralytics/docs/releases/download/0/ask-ai-nlp-table.avif)
```python
df = exp.ask_ai("show me images containing more than 10 objects with at least 2 persons")
df.head(5)
```
for plotting these results you can use `plot_query_result` util Example:
```python
plt = plot_query_result(exp.ask_ai("show me 10 images containing exactly 2 persons"))
Image.fromarray(plt)
```
![Ask ai image 1](https://github.com/ultralytics/docs/releases/download/0/ask-ai-nlp-image-1.avif)
```python
# plot
from PIL import Image
from ultralytics.data.explorer import plot_query_result
plt = plot_query_result(exp.ask_ai("show me 10 images containing exactly 2 persons"))
Image.fromarray(plt)
```
## Run SQL queries on your Dataset
Sometimes you might want to investigate a certain type of entries in your dataset. For this Explorer allows you to execute SQL queries. It accepts either of the formats:
- Queries beginning with "WHERE" will automatically select all columns. This can be thought of as a shorthand query
- You can also write full queries where you can specify which columns to select
This can be used to investigate model performance and specific data points. For example:
- let's say your model struggles on images that have humans and dogs. You can write a query like this to select the points that have at least 2 humans AND at least one dog.
You can combine SQL query and semantic search to filter down to specific type of results
```python
table = exp.sql_query("WHERE labels LIKE '%person, person%' AND labels LIKE '%dog%' LIMIT 10")
exp.plot_sql_query("WHERE labels LIKE '%person, person%' AND labels LIKE '%dog%' LIMIT 10", labels=True)
```
![SQL queries table](https://github.com/ultralytics/docs/releases/download/0/sql-queries-table.avif)
```python
table = exp.sql_query("WHERE labels LIKE '%person, person%' AND labels LIKE '%dog%' LIMIT 10")
table
```
Just like similarity search, you also get a util to directly plot the sql queries using `exp.plot_sql_query`
![SQL queries image 1](https://github.com/ultralytics/docs/releases/download/0/sql-query-image-1.avif)
```python
exp.plot_sql_query("WHERE labels LIKE '%person, person%' AND labels LIKE '%dog%' LIMIT 10", labels=True)
```
## Working with embeddings Table (Advanced)
Explorer works on [LanceDB](https://lancedb.github.io/lancedb/) tables internally. You can access this table directly, using `Explorer.table` object and run raw queries, push down pre- and post-filters, etc.
```python
table = exp.table
table.schema
```
### Run raw queries¶
Vector Search finds the nearest vectors from the database. In a recommendation system or search engine, you can find similar products from the one you searched. In LLM and other AI applications, each data point can be presented by the embeddings generated from some models, it returns the most relevant features.
A search in high-dimensional vector space, is to find K-Nearest-Neighbors (KNN) of the query vector.
Metric In LanceDB, a Metric is the way to describe the distance between a pair of vectors. Currently, it supports the following metrics:
- L2
- Cosine
- Dot Explorer's similarity search uses L2 by default. You can run queries on tables directly, or use the lance format to build custom utilities to manage datasets. More details on available LanceDB table ops in the [docs](https://lancedb.github.io/lancedb/)
![Raw-queries-table](https://github.com/ultralytics/docs/releases/download/0/raw-queries-table.avif)
```python
dummy_img_embedding = [i for i in range(256)]
table.search(dummy_img_embedding).limit(5).to_pandas()
```
### Interconversion to popular data formats
```python
df = table.to_pandas()
pa_table = table.to_arrow()
```
### Work with Embeddings
You can access the raw embedding from lancedb Table and analyse it. The image embeddings are stored in column `vector`
```python
import numpy as np
embeddings = table.to_pandas()["vector"].tolist()
embeddings = np.array(embeddings)
```
### Scatterplot
One of the preliminary steps in analysing embeddings is by plotting them in 2D space via dimensionality reduction. Let's try an example
![Scatterplot Example](https://github.com/ultralytics/docs/releases/download/0/scatterplot-sql-queries.avif)
```python
pip install scikit-learn
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from sklearn.decomposition import PCA
# Reduce dimensions using PCA to 3 components for visualization in 3D
pca = PCA(n_components=3)
reduced_data = pca.fit_transform(embeddings)
# Create a 3D scatter plot using Matplotlib's Axes3D
fig = plt.figure(figsize=(8, 6))
ax = fig.add_subplot(111, projection="3d")
# Scatter plot
ax.scatter(reduced_data[:, 0], reduced_data[:, 1], reduced_data[:, 2], alpha=0.5)
ax.set_title("3D Scatter Plot of Reduced 256-Dimensional Data (PCA)")
ax.set_xlabel("Component 1")
ax.set_ylabel("Component 2")
ax.set_zlabel("Component 3")
plt.show()
```
### Similarity Index
Here's a simple example of an operation powered by the embeddings table. Explorer comes with a `similarity_index` operation-
- It tries to estimate how similar each data point is with the rest of the dataset.
- It does that by counting how many image embeddings lie closer than max_dist to the current image in the generated embedding space, considering top_k similar images at a time.
For a given dataset, model, `max_dist` & `top_k` the similarity index once generated will be reused. In case, your dataset has changed, or you simply need to regenerate the similarity index, you can pass `force=True`. Similar to vector and SQL search, this also comes with a util to directly plot it. Let's look
```python
sim_idx = exp.similarity_index(max_dist=0.2, top_k=0.01)
exp.plot_similarity_index(max_dist=0.2, top_k=0.01)
```
![Similarity Index](https://github.com/ultralytics/docs/releases/download/0/similarity-index.avif)
at the plot first
```python
exp.plot_similarity_index(max_dist=0.2, top_k=0.01)
```
Now let's look at the output of the operation
```python
sim_idx = exp.similarity_index(max_dist=0.2, top_k=0.01, force=False)
sim_idx
```
Let's create a query to see what data points have similarity count of more than 30 and plot images similar to them.
```python
import numpy as np
sim_count = np.array(sim_idx["count"])
sim_idx["im_file"][sim_count > 30]
```
You should see something like this
![similarity-index-image](https://github.com/ultralytics/docs/releases/download/0/similarity-index-image.avif)
```python
exp.plot_similar(idx=[7146, 14035]) # Using avg embeddings of 2 images
```

@ -209,7 +209,7 @@ Yes, you can export your Ultralytics YOLO11 model to be compatible with the Cora
For more information, refer to the [Export Mode](../modes/export.md) documentation.
### What should I do if TensorFlow is already installed on my Raspberry Pi but I want to use tflite-runtime instead?
### What should I do if TensorFlow is already installed on my Raspberry Pi, but I want to use tflite-runtime instead?
If you have TensorFlow installed on your Raspberry Pi and need to switch to `tflite-runtime`, you'll need to uninstall TensorFlow first using:

@ -23,7 +23,8 @@ This comprehensive guide provides a detailed walkthrough for deploying Ultralyti
!!! note
This guide has been tested with both [Seeed Studio reComputer J4012](https://www.seeedstudio.com/reComputer-J4012-p-5586.html) which is based on NVIDIA Jetson Orin NX 16GB running JetPack release of [JP5.1.3](https://developer.nvidia.com/embedded/jetpack-sdk-513) and [Seeed Studio reComputer J1020 v2](https://www.seeedstudio.com/reComputer-J1020-v2-p-5498.html) which is based on NVIDIA Jetson Nano 4GB running JetPack release of [JP4.6.4](https://developer.nvidia.com/jetpack-sdk-464). It is expected to work across all the NVIDIA Jetson hardware lineup including latest and legacy.
This guide has been tested with [NVIDIA Jetson Orin Nano Super Developer Kit](https://www.nvidia.com/en-us/autonomous-machines/embedded-systems/jetson-orin/nano-super-developer-kit) running the latest stable JetPack release of [JP6.1](https://developer.nvidia.com/embedded/jetpack-sdk-61),
[Seeed Studio reComputer J4012](https://www.seeedstudio.com/reComputer-J4012-p-5586.html) which is based on NVIDIA Jetson Orin NX 16GB running JetPack release of [JP5.1.3](https://developer.nvidia.com/embedded/jetpack-sdk-513) and [Seeed Studio reComputer J1020 v2](https://www.seeedstudio.com/reComputer-J1020-v2-p-5498.html) which is based on NVIDIA Jetson Nano 4GB running JetPack release of [JP4.6.4](https://developer.nvidia.com/jetpack-sdk-464). It is expected to work across all the NVIDIA Jetson hardware lineup including latest and legacy.
## What is NVIDIA DeepStream?
@ -38,6 +39,7 @@ Before you start to follow this guide:
- For JetPack 4.6.4, install [DeepStream 6.0.1](https://docs.nvidia.com/metropolis/deepstream/6.0.1/dev-guide/text/DS_Quickstart.html)
- For JetPack 5.1.3, install [DeepStream 6.3](https://docs.nvidia.com/metropolis/deepstream/6.3/dev-guide/text/DS_Quickstart.html)
- For JetPack 6.1, install [DeepStream 7.1](https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_Installation.html)
!!! tip
@ -47,34 +49,48 @@ Before you start to follow this guide:
Here we are using [marcoslucianops/DeepStream-Yolo](https://github.com/marcoslucianops/DeepStream-Yolo) GitHub repository which includes NVIDIA DeepStream SDK support for YOLO models. We appreciate the efforts of marcoslucianops for his contributions!
1. Install dependencies
1. Install Ultralytics with necessary dependencies
```bash
pip install cmake
pip install onnxsim
cd ~
pip install -U pip
git clone https://github.com/ultralytics/ultralytics
cd ultralytics
pip install -e ".[export]" onnxslim
```
2. Clone the following repository
2. Clone the DeepStream-Yolo repository
```bash
cd ~
git clone https://github.com/marcoslucianops/DeepStream-Yolo
cd DeepStream-Yolo
```
3. Download Ultralytics YOLO11 detection model (.pt) of your choice from [YOLO11 releases](https://github.com/ultralytics/assets/releases). Here we use [yolov8s.pt](https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8s.pt).
3. Copy the `export_yoloV8.py` file from `DeepStream-Yolo/utils` directory to the `ultralytics` folder
```bash
wget https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8s.pt
cp ~/DeepStream-Yolo/utils/export_yoloV8.py ~/ultralytics
cd ultralytics
```
!!! note
`export_yoloV8.py` works for both YOLOv8 and YOLO11 models.
4. Download Ultralytics YOLO11 detection model (.pt) of your choice from [YOLO11 releases](https://github.com/ultralytics/assets/releases). Here we use [yolo11s.pt](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11s.pt).
```bash
wget https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11s.pt
```
!!! note
You can also use a [custom trained YOLO11 model](https://docs.ultralytics.com/modes/train/).
4. Convert model to ONNX
5. Convert model to ONNX
```bash
python3 utils/export_yoloV8.py -w yolov8s.pt
python3 export_yoloV8.py -w yolo11s.pt
```
!!! note "Pass the below arguments to the above command"
@ -120,7 +136,14 @@ Here we are using [marcoslucianops/DeepStream-Yolo](https://github.com/marcosluc
--batch 4
```
5. Set the CUDA version according to the JetPack version installed
6. Copy the generated `.onnx` model file and `labels.txt` file to the `DeepStream-Yolo` folder
```bash
cp yolo11s.pt.onnx labels.txt ~/DeepStream-Yolo
cd ~/DeepStream-Yolo
```
7. Set the CUDA version according to the JetPack version installed
For JetPack 4.6.4:
@ -134,24 +157,30 @@ Here we are using [marcoslucianops/DeepStream-Yolo](https://github.com/marcosluc
export CUDA_VER=11.4
```
6. Compile the library
For Jetpack 6.1:
```bash
export CUDA_VER=12.6
```
8. Compile the library
```bash
make -C nvdsinfer_custom_impl_Yolo clean && make -C nvdsinfer_custom_impl_Yolo
```
7. Edit the `config_infer_primary_yoloV8.txt` file according to your model (for YOLOv8s with 80 classes)
9. Edit the `config_infer_primary_yoloV8.txt` file according to your model (for YOLO11s with 80 classes)
```bash
[property]
...
onnx-file=yolov8s.onnx
onnx-file=yolo11s.pt.onnx
...
num-detected-classes=80
...
```
8. Edit the `deepstream_app_config` file
10. Edit the `deepstream_app_config` file
```bash
...
@ -160,7 +189,7 @@ Here we are using [marcoslucianops/DeepStream-Yolo](https://github.com/marcosluc
config-file=config_infer_primary_yoloV8.txt
```
9. You can also change the video source in `deepstream_app_config` file. Here a default video file is loaded
11. You can also change the video source in `deepstream_app_config` file. Here a default video file is loaded
```bash
...
@ -183,12 +212,16 @@ deepstream-app -c deepstream_app_config.txt
!!! tip
If you want to convert the model to FP16 [precision](https://www.ultralytics.com/glossary/precision), simply set `model-engine-file=model_b1_gpu0_fp16.engine` and `network-mode=2` inside `config_infer_primary_yoloV8.txt`
If you want to convert the model to FP16 precision, simply set `model-engine-file=model_b1_gpu0_fp16.engine` and `network-mode=2` inside `config_infer_primary_yoloV8.txt`
## INT8 Calibration
If you want to use INT8 precision for inference, you need to follow the steps below
!!! note
Currently INT8 does not work with TensorRT 10.x. This section of the guide has been tested with TensorRT 8.x which is expected to work.
1. Set `OPENCV` environment variable
```bash
@ -303,13 +336,13 @@ deepstream-app -c deepstream_app_config.txt
## Benchmark Results
The following table summarizes how YOLOv8s models perform at different TensorRT precision levels with an input size of 640x640 on NVIDIA Jetson Orin NX 16GB.
The following table summarizes how YOLO11s models perform at different TensorRT precision levels with an input size of 640x640 on NVIDIA Jetson Orin NX 16GB.
| Model Name | Precision | Inference Time (ms/im) | FPS |
| ---------- | --------- | ---------------------- | --- |
| YOLOv8s | FP32 | 15.63 | 64 |
| | FP16 | 7.94 | 126 |
| | INT8 | 5.53 | 181 |
| Model Name | Precision | Inference Time (ms/im) | FPS |
| ---------- | --------- | ---------------------- | ---- |
| YOLO11s | FP32 | 14.6 | 68.5 |
| | FP16 | 7.94 | 126 |
| | INT8 | 5.95 | 168 |
### Acknowledgements
@ -336,17 +369,17 @@ To convert a YOLO11 model to ONNX format for deployment with DeepStream, use the
Here's an example command:
```bash
python3 utils/export_yoloV8.py -w yolov8s.pt --opset 12 --simplify
python3 utils/export_yoloV8.py -w yolo11s.pt --opset 12 --simplify
```
For more details on model conversion, check out our [model export section](../modes/export.md).
### What are the performance benchmarks for YOLO on NVIDIA Jetson Orin NX?
The performance of YOLO11 models on NVIDIA Jetson Orin NX 16GB varies based on TensorRT precision levels. For example, YOLOv8s models achieve:
The performance of YOLO11 models on NVIDIA Jetson Orin NX 16GB varies based on TensorRT precision levels. For example, YOLO11s models achieve:
- **FP32 Precision**: 15.63 ms/im, 64 FPS
- **FP32 Precision**: 14.6 ms/im, 68.5 FPS
- **FP16 Precision**: 7.94 ms/im, 126 FPS
- **INT8 Precision**: 5.53 ms/im, 181 FPS
- **INT8 Precision**: 5.95 ms/im, 168 FPS
These benchmarks underscore the efficiency and capability of using TensorRT-optimized YOLO11 models on NVIDIA Jetson hardware. For further details, see our [Benchmark Results](#benchmark-results) section.

@ -27,6 +27,7 @@ Here's a compilation of in-depth guides to help you master different aspects of
- [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](https://www.ultralytics.com/glossary/f1-score) used to evaluate the performance of your YOLO models. Includes practical examples and tips on how to improve detection accuracy and speed.
- [YOLO Thread-Safe Inference](yolo-thread-safe-inference.md) 🚀 NEW: Guidelines for performing inference with YOLO models in a thread-safe manner. Learn the importance of thread safety and best practices to prevent race conditions and ensure consistent predictions.
- [Model Deployment Options](model-deployment-options.md): Overview of YOLO [model deployment](https://www.ultralytics.com/glossary/model-deployment) formats like ONNX, OpenVINO, and TensorRT, with pros and cons for each to inform your deployment strategy.
- [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.
@ -38,11 +39,11 @@ Here's a compilation of in-depth guides to help you master different aspects of
- [NVIDIA Jetson](nvidia-jetson.md) 🚀 NEW: Quickstart guide for deploying YOLO models on NVIDIA Jetson devices.
- [DeepStream on NVIDIA Jetson](deepstream-nvidia-jetson.md) 🚀 NEW: Quickstart guide for deploying YOLO models on NVIDIA Jetson devices using DeepStream and TensorRT.
- [Triton Inference Server Integration](triton-inference-server.md) 🚀 NEW: Dive into the integration of Ultralytics YOLO11 with NVIDIA's Triton Inference Server for scalable and efficient deep learning inference deployments.
- [YOLO Thread-Safe Inference](yolo-thread-safe-inference.md) 🚀 NEW: Guidelines for performing inference with YOLO models in a thread-safe manner. Learn the importance of thread safety and best practices to prevent race conditions and ensure consistent predictions.
- [Isolating Segmentation Objects](isolating-segmentation-objects.md) 🚀 NEW: Step-by-step recipe and explanation on how to extract and/or isolate objects from images using Ultralytics Segmentation.
- [Edge TPU on Raspberry Pi](coral-edge-tpu-on-raspberry-pi.md): [Google Edge TPU](https://coral.ai/products/accelerator) accelerates YOLO inference on [Raspberry Pi](https://www.raspberrypi.com/).
- [View Inference Images in a Terminal](view-results-in-terminal.md): Use VSCode's integrated terminal to view inference results when using Remote Tunnel or SSH sessions.
- [OpenVINO Latency vs Throughput Modes](optimizing-openvino-latency-vs-throughput-modes.md) - Learn latency and throughput optimization techniques for peak YOLO inference performance.
- [ROS Quickstart](ros-quickstart.md) 🚀 NEW: Learn how to integrate YOLO with the Robot Operating System (ROS) for real-time object detection in robotics applications, including Point Cloud and Depth images.
- [Steps of a Computer Vision Project ](steps-of-a-cv-project.md) 🚀 NEW: Learn about the key steps involved in a computer vision project, including defining goals, selecting models, preparing data, and evaluating results.
- [Defining A Computer Vision Project's Goals](defining-project-goals.md) 🚀 NEW: Walk through how to effectively define clear and measurable goals for your computer vision project. Learn the importance of a well-defined problem statement and how it creates a roadmap for your project.
- [Data Collection and Annotation](data-collection-and-annotation.md) 🚀 NEW: Explore the tools, techniques, and best practices for collecting and annotating data to create high-quality inputs for your computer vision models.
@ -52,7 +53,6 @@ Here's a compilation of in-depth guides to help you master different aspects of
- [A Guide on Model Testing](model-testing.md) 🚀 NEW: A thorough guide on testing your computer vision models in realistic settings. Learn how to verify accuracy, reliability, and performance in line with project goals.
- [Best Practices for Model Deployment](model-deployment-practices.md) 🚀 NEW: Walk through tips and best practices for efficiently deploying models in computer vision projects, with a focus on optimization, troubleshooting, and security.
- [Maintaining Your Computer Vision Model](model-monitoring-and-maintenance.md) 🚀 NEW: Understand the key practices for monitoring, maintaining, and documenting computer vision models to guarantee accuracy, spot anomalies, and mitigate data drift.
- [ROS Quickstart](ros-quickstart.md) 🚀 NEW: Learn how to integrate YOLO with the Robot Operating System (ROS) for real-time object detection in robotics applications, including Point Cloud and Depth images.
## Contribute to Our Guides

@ -31,7 +31,7 @@ Evaluating how well a model performs helps us understand how effectively it work
The confidence score represents the model's certainty that a detected object belongs to a particular class. It ranges from 0 to 1, with higher scores indicating greater confidence. The confidence score helps filter predictions; only detections with confidence scores above a specified threshold are considered valid.
_Quick Tip:_ When running inferences, if you aren't seeing any predictions and you've checked everything else, try lowering the confidence score. Sometimes, the threshold is too high, causing the model to ignore valid predictions. Lowering the score allows the model to consider more possibilities. This might not meet your project goals, but it's a good way to see what the model can do and decide how to fine-tune it.
_Quick Tip:_ When running inferences, if you aren't seeing any predictions, and you've checked everything else, try lowering the confidence score. Sometimes, the threshold is too high, causing the model to ignore valid predictions. Lowering the score allows the model to consider more possibilities. This might not meet your project goals, but it's a good way to see what the model can do and decide how to fine-tune it.
### Intersection over Union

@ -23,7 +23,7 @@ Regular model monitoring helps developers track the [model's performance](./mode
Here are some best practices to keep in mind while monitoring your computer vision model in production:
- **Track Performance Regularly**: Continuously monitor the model's performance to detect changes over time.
- **Double Check the Data Quality**: Check for missing values or anomalies in the data.
- **Double-Check the Data Quality**: Check for missing values or anomalies in the data.
- **Use Diverse Data Sources**: Monitor data from various sources to get a comprehensive view of the model's performance.
- **Combine Monitoring Techniques**: Use a mix of drift detection algorithms and rule-based approaches to identify a wide range of issues.
- **Monitor Inputs and Outputs**: Keep an eye on both the data the model processes and the results it produces to make sure everything is functioning correctly.

@ -177,7 +177,7 @@ pip install https://github.com/ultralytics/assets/releases/download/v0.0.0/onnxr
`pip install numpy==1.23.5`
### Run on JetPack 5.x
### Run on JetPack 5.1.2
#### Install Ultralytics Package
@ -213,22 +213,11 @@ The above ultralytics installation will install Torch and Torchvision. However,
pip uninstall torch torchvision
```
2. Install PyTorch 2.1.0 according to JP5.1.3
2. Install `torch 2.1.0` and `torchvision 0.16.2` according to JP5.1.2
```bash
sudo apt-get install -y libopenblas-base libopenmpi-dev
wget https://developer.download.nvidia.com/compute/redist/jp/v512/pytorch/torch-2.1.0a0+41361538.nv23.06-cp38-cp38-linux_aarch64.whl -O torch-2.1.0a0+41361538.nv23.06-cp38-cp38-linux_aarch64.whl
pip install torch-2.1.0a0+41361538.nv23.06-cp38-cp38-linux_aarch64.whl
```
3. Install Torchvision v0.16.2 according to PyTorch v2.1.0
```bash
sudo apt install -y libjpeg-dev zlib1g-dev
git clone https://github.com/pytorch/vision torchvision
cd torchvision
git checkout v0.16.2
python3 setup.py install --user
pip install https://github.com/ultralytics/assets/releases/download/v0.0.0/torch-2.1.0a0+41361538.nv23.06-cp38-cp38-linux_aarch64.whl
pip install https://github.com/ultralytics/assets/releases/download/v0.0.0/torchvision-0.16.2+c6f3977-cp38-cp38-linux_aarch64.whl
```
!!! note

@ -195,22 +195,22 @@ Performing inference with a trained Ultralytics YOLO model is straightforward:
1. Load the Model:
```python
from ultralytics import YOLO
```python
from ultralytics import YOLO
model = YOLO("path/to/your/model.pt")
```
model = YOLO("path/to/your/model.pt")
```
2. Run Inference:
```python
results = model("path/to/image.jpg")
```python
results = model("path/to/image.jpg")
for r in results:
print(r.boxes) # print bounding box predictions
print(r.masks) # print mask predictions
print(r.probs) # print class probabilities
```
for r in results:
print(r.boxes) # print bounding box predictions
print(r.masks) # print mask predictions
print(r.probs) # print class probabilities
```
For advanced inference techniques, including batch processing, video inference, and custom preprocessing, refer to the detailed [prediction guide](https://docs.ultralytics.com/modes/predict/).

@ -12,7 +12,7 @@ You can train [Ultralytics YOLO11 models](https://github.com/ultralytics/ultraly
## What is IBM Watsonx?
[Watsonx](https://www.ibm.com/watsonx) is IBM's cloud-based platform designed for commercial [generative AI](https://www.ultralytics.com/glossary/generative-ai) and scientific data. IBM Watsonx's three components - watsonx.ai, watsonx.data, and watsonx.governance - come together to create an end-to-end, trustworthy AI platform that can accelerate AI projects aimed at solving business problems. It provides powerful tools for building, training, and [deploying machine learning models](../guides/model-deployment-options.md) and makes it easy to connect with various data sources.
[Watsonx](https://www.ibm.com/watsonx) is IBM's cloud-based platform designed for commercial [generative AI](https://www.ultralytics.com/glossary/generative-ai) and scientific data. IBM Watsonx's three components - `watsonx.ai`, `watsonx.data`, and `watsonx.governance` - come together to create an end-to-end, trustworthy AI platform that can accelerate AI projects aimed at solving business problems. It provides powerful tools for building, training, and [deploying machine learning models](../guides/model-deployment-options.md) and makes it easy to connect with various data sources.
<p align="center">
<img width="800" src="https://github.com/ultralytics/docs/releases/download/0/overview-of-ibm-watsonx.avif" alt="Overview of IBM Watsonx">
@ -22,7 +22,7 @@ Its user-friendly interface and collaborative capabilities streamline the develo
## Key Features of IBM Watsonx
IBM Watsonx is made of three main components: watsonx.ai, watsonx.data, and watsonx.governance. Each component offers features that cater to different aspects of AI and data management. Let's take a closer look at them.
IBM Watsonx is made of three main components: `watsonx.ai`, `watsonx.data`, and `watsonx.governance`. Each component offers features that cater to different aspects of AI and data management. Let's take a closer look at them.
### [Watsonx.ai](https://www.ibm.com/products/watsonx-ai)

@ -62,7 +62,7 @@ Next, let's understand the features Kaggle offers that make it an excellent plat
- **Datasets**: Kaggle hosts a massive collection of datasets on various topics. You can easily search and use these datasets in your projects, which is particularly handy for training and testing your YOLO11 models.
- **Competitions**: Known for its exciting competitions, Kaggle allows data scientists and machine learning enthusiasts to solve real-world problems. Competing helps you improve your skills, learn new techniques, and gain recognition in the community.
- **Free Access to TPUs**: Kaggle provides free access to powerful TPUs, which are essential for training complex machine learning models. This means you can speed up processing and boost the performance of your YOLO11 projects without incurring extra costs.
- **Integration with Github**: Kaggle allows you to easily connect your GitHub repository to upload notebooks and save your work. This integration makes it convenient to manage and access your files.
- **Integration with GitHub**: Kaggle allows you to easily connect your GitHub repository to upload notebooks and save your work. This integration makes it convenient to manage and access your files.
- **Community and Discussions**: Kaggle boasts a strong community of data scientists and machine learning practitioners. The discussion forums and shared notebooks are fantastic resources for learning and troubleshooting. You can easily find help, share your knowledge, and collaborate with others.
## Why Should You Use Kaggle for Your YOLO11 Projects?
@ -81,7 +81,7 @@ If you want to learn more about Kaggle, here are some helpful resources to guide
- [**Kaggle Learn**](https://www.kaggle.com/learn): Discover a variety of free, interactive tutorials on Kaggle Learn. These courses cover essential data science topics and provide hands-on experience to help you master new skills.
- [**Getting Started with Kaggle**](https://www.kaggle.com/code/alexisbcook/getting-started-with-kaggle): This comprehensive guide walks you through the basics of using Kaggle, from joining competitions to creating your first notebook. It's a great starting point for newcomers.
- [**Kaggle Medium Page**](https://medium.com/@kaggleteam): Explore tutorials, updates, and community contributions on Kaggle's Medium page. It's an excellent source for staying up-to-date with the latest trends and gaining deeper insights into data science.
- [**Kaggle Medium Page**](https://medium.com/@kaggleteam): Explore tutorials, updates, and community contributions to Kaggle's Medium page. It's an excellent source for staying up-to-date with the latest trends and gaining deeper insights into data science.
## Summary

@ -101,7 +101,7 @@ For more details about supported export options, visit the [Ultralytics document
## Deploying Exported YOLO11 NCNN Models
After successfully exporting your Ultralytics YOLO11 models to NCNN format, you can now deploy them. The primary and recommended first step for running a NCNN model is to utilize the YOLO("./model_ncnn_model") method, as outlined in the previous usage code snippet. However, for in-depth instructions on deploying your NCNN models in various other settings, take a look at the following resources:
After successfully exporting your Ultralytics YOLO11 models to NCNN format, you can now deploy them. The primary and recommended first step for running a NCNN model is to utilize the YOLO("yolo11n_ncnn_model/") method, as outlined in the previous usage code snippet. However, for in-depth instructions on deploying your NCNN models in various other settings, take a look at the following resources:
- **[Android](https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-android)**: This blog explains how to use NCNN models for performing tasks like [object detection](https://www.ultralytics.com/glossary/object-detection) through Android applications.

@ -41,7 +41,7 @@ Export an Ultralytics YOLOv8 model to IMX500 format and run inference with the e
!!! note
Here we perform inference just to make sure the model works as expected. However, for deployment and inference on the Raspberry Pi AI Camera, please jump to [Using IMX500 Export in Deployment](#using-imx500-export-in-deployment) section.
IMX export is currently only supported for the YOLOv8n model. Here we perform inference just to make sure the model works as expected. However, for deployment and inference on the Raspberry Pi AI Camera, please jump to [Using IMX500 Export in Deployment](#using-imx500-export-in-deployment) section.
!!! example

@ -168,26 +168,26 @@ To integrate Weights & Biases with Ultralytics YOLO11:
1. Install the required packages:
```bash
pip install -U ultralytics wandb
```
```bash
pip install -U ultralytics wandb
```
2. Log in to your Weights & Biases account:
```python
import wandb
```python
import wandb
wandb.login(key="<API_KEY>")
```
wandb.login(key="<API_KEY>")
```
3. Train your YOLO11 model with W&B logging enabled:
```python
from ultralytics import YOLO
```python
from ultralytics import YOLO
model = YOLO("yolo11n.pt")
model.train(data="coco8.yaml", epochs=5, project="ultralytics", name="yolo11n")
```
model = YOLO("yolo11n.pt")
model.train(data="coco8.yaml", epochs=5, project="ultralytics", name="yolo11n")
```
This will automatically log metrics, hyperparameters, and model artifacts to your W&B project.

@ -40,7 +40,7 @@ This example provides simple YOLOv6 training and inference examples. For full do
=== "Python"
[PyTorch](https://www.ultralytics.com/glossary/pytorch) pretrained `*.pt` models as well as configuration `*.yaml` files can be passed to the `YOLO()` class to create a model instance in python:
YOLOv6 `*.yaml` files can be passed to the `YOLO()` class to build the corresponding model in Python:
```python
from ultralytics import YOLO
@ -74,13 +74,13 @@ This example provides simple YOLOv6 training and inference examples. For full do
The YOLOv6 series offers a range of models, each optimized for high-performance [Object Detection](../tasks/detect.md). These models cater to varying computational needs and [accuracy](https://www.ultralytics.com/glossary/accuracy) requirements, making them versatile for a wide array of applications.
| Model Type | Pre-trained Weights | Tasks Supported | Inference | Validation | Training | Export |
| ---------- | ------------------- | -------------------------------------- | --------- | ---------- | -------- | ------ |
| YOLOv6-N | `yolov6-n.pt` | [Object Detection](../tasks/detect.md) | ✅ | ✅ | ✅ | ✅ |
| YOLOv6-S | `yolov6-s.pt` | [Object Detection](../tasks/detect.md) | ✅ | ✅ | ✅ | ✅ |
| YOLOv6-M | `yolov6-m.pt` | [Object Detection](../tasks/detect.md) | ✅ | ✅ | ✅ | ✅ |
| YOLOv6-L | `yolov6-l.pt` | [Object Detection](../tasks/detect.md) | ✅ | ✅ | ✅ | ✅ |
| YOLOv6-L6 | `yolov6-l6.pt` | [Object Detection](../tasks/detect.md) | ✅ | ✅ | ✅ | ✅ |
| Model | Filenames | Tasks | Inference | Validation | Training | Export |
| -------- | -------------- | -------------------------------------- | --------- | ---------- | -------- | ------ |
| YOLOv6-N | `yolov6n.yaml` | [Object Detection](../tasks/detect.md) | ✅ | ✅ | ✅ | ✅ |
| YOLOv6-S | `yolov6s.yaml` | [Object Detection](../tasks/detect.md) | ✅ | ✅ | ✅ | ✅ |
| YOLOv6-M | `yolov6m.yaml` | [Object Detection](../tasks/detect.md) | ✅ | ✅ | ✅ | ✅ |
| YOLOv6-L | `yolov6l.yaml` | [Object Detection](../tasks/detect.md) | ✅ | ✅ | ✅ | ✅ |
| YOLOv6-X | `yolov6x.yaml` | [Object Detection](../tasks/detect.md) | ✅ | ✅ | ✅ | ✅ |
This table provides a detailed overview of the YOLOv6 model variants, highlighting their capabilities in [object detection](https://www.ultralytics.com/glossary/object-detection) tasks and their compatibility with various operational modes such as [Inference](../modes/predict.md), [Validation](../modes/val.md), [Training](../modes/train.md), and [Export](../modes/export.md). This comprehensive support ensures that users can fully leverage the capabilities of YOLOv6 models in a broad range of object detection scenarios.

@ -169,10 +169,10 @@ This example provides simple YOLOv9 training and inference examples. For full do
The YOLOv9 series offers a range of models, each optimized for high-performance [Object Detection](../tasks/detect.md). These models cater to varying computational needs and accuracy requirements, making them versatile for a wide array of applications.
| Model | Filenames | Tasks | Inference | Validation | Training | Export |
| ---------- | ------------------------------------------------------- | -------------------------------------------- | --------- | ---------- | -------- | ------ |
| YOLOv9 | `yolov9t` `yolov9s` `yolov9m` `yolov9c.pt` `yolov9e.pt` | [Object Detection](../tasks/detect.md) | ✅ | ✅ | ✅ | ✅ |
| YOLOv9-seg | `yolov9c-seg.pt` `yolov9e-seg.pt` | [Instance Segmentation](../tasks/segment.md) | ✅ | ✅ | ✅ | ✅ |
| Model | Filenames | Tasks | Inference | Validation | Training | Export |
| ---------- | ---------------------------------------------------------------- | -------------------------------------------- | --------- | ---------- | -------- | ------ |
| YOLOv9 | `yolov9t.pt` `yolov9s.pt` `yolov9m.pt` `yolov9c.pt` `yolov9e.pt` | [Object Detection](../tasks/detect.md) | ✅ | ✅ | ✅ | ✅ |
| YOLOv9-seg | `yolov9c-seg.pt` `yolov9e-seg.pt` | [Instance Segmentation](../tasks/segment.md) | ✅ | ✅ | ✅ | ✅ |
This table provides a detailed overview of the YOLOv9 model variants, highlighting their capabilities in object detection tasks and their compatibility with various operational modes such as [Inference](../modes/predict.md), [Validation](../modes/val.md), [Training](../modes/train.md), and [Export](../modes/export.md). This comprehensive support ensures that users can fully leverage the capabilities of YOLOv9 models in a broad range of object detection scenarios.

@ -32,7 +32,7 @@ Dataset annotation is a very resource intensive and time-consuming process. If y
```{ .py .annotate }
from ultralytics.data.annotator import auto_annotate
auto_annotate( # (1)!
auto_annotate(
data="path/to/new/data",
det_model="yolo11n.pt",
sam_model="mobile_sam.pt",
@ -41,17 +41,16 @@ auto_annotate( # (1)!
)
```
1. Nothing returns from this function
This function does not return any value. For further details on how the function operates:
- [See the reference section for `annotator.auto_annotate`](../reference/data/annotator.md#ultralytics.data.annotator.auto_annotate) for more insight on how the function operates.
- Use in combination with the [function `segments2boxes`](#convert-segments-to-bounding-boxes) to generate object detection bounding boxes as well
### Convert Segmentation Masks into YOLO Format
![Segmentation Masks to YOLO Format](https://github.com/ultralytics/docs/releases/download/0/segmentation-masks-to-yolo-format.avif)
Use to convert a dataset of segmentation mask images to the `YOLO` segmentation format.
Use to convert a dataset of segmentation mask images to the [`YOLO`](../models/yolo11.md) segmentation format.
This function takes the directory containing the binary format mask images and converts them into YOLO segmentation format.
The converted masks will be saved in the specified output directory.
@ -59,7 +58,8 @@ The converted masks will be saved in the specified output directory.
```python
from ultralytics.data.converter import convert_segment_masks_to_yolo_seg
# The classes here is the total classes in the dataset, for COCO dataset we have 80 classes
# The classes here is the total classes in the dataset.
# for COCO dataset we have 80 classes.
convert_segment_masks_to_yolo_seg(masks_dir="path/to/masks_dir", output_dir="path/to/output_dir", classes=80)
```

@ -1,6 +1,6 @@
# YOLOv8/YOLOv5 Inference C++
This example demonstrates how to perform inference using YOLOv8 and YOLOv5 models in C++ with OpenCV's DNN API.
This example demonstrates how to perform inference using YOLOv8 and YOLOv5 models in C++ with OpenCV DNN API.
## Usage
@ -27,13 +27,13 @@ make
To export YOLOv8 models:
```commandline
```bash
yolo export model=yolov8s.pt imgsz=480,640 format=onnx opset=12
```
To export YOLOv5 models:
```commandline
```bash
python3 export.py --weights yolov5s.pt --img 480 640 --include onnx --opset 12
```
@ -45,6 +45,6 @@ yolov5s.onnx:
![image](https://user-images.githubusercontent.com/40023722/217357005-07464492-d1da-42e3-98a7-fc753f87d5e6.png)
This repository utilizes OpenCV's DNN API to run ONNX exported models of YOLOv5 and YOLOv8. In theory, it should work for YOLOv6 and YOLOv7 as well, but they have not been tested. Note that the example networks are exported with rectangular (640x480) resolutions, but any exported resolution will work. You may want to use the letterbox approach for square images, depending on your use case.
This repository utilizes OpenCV DNN API to run ONNX exported models of YOLOv5 and YOLOv8. In theory, it should work for YOLOv6 and YOLOv7 as well, but they have not been tested. Note that the example networks are exported with rectangular (640x480) resolutions, but any exported resolution will work. You may want to use the letterbox approach for square images, depending on your use case.
The **main** branch version uses Qt as a GUI wrapper. The primary focus here is the **Inference** class file, which demonstrates how to transpose YOLOv8 models to work as YOLOv5 models.

@ -30,6 +30,6 @@ make
To export YOLOv8 models:
```commandline
```bash
yolo export model=yolov8s.pt imgsz=640 format=torchscript
```

@ -50,7 +50,7 @@ Once built, you can run inference on an image using the following command:
To use your YOLOv8 model with OpenVINO, you need to export it first. Use the command below to export the model:
```commandline
```bash
yolo export model=yolov8s.pt imgsz=640 format=openvino
```

@ -365,7 +365,7 @@ nav:
- datasets/explorer/index.md
- Explorer API: datasets/explorer/api.md
- Explorer Dashboard Demo: datasets/explorer/dashboard.md
- VOC Exploration Example: datasets/explorer/explorer.ipynb
- VOC Exploration Example: datasets/explorer/explorer.md
- YOLOv5:
- yolov5/index.md
- Quickstart: yolov5/quickstart_tutorial.md
@ -661,7 +661,6 @@ plugins:
add_share_buttons: True
add_css: False
default_image: https://raw.githubusercontent.com/ultralytics/assets/main/yolov8/banner-yolov8.png
- mkdocs-jupyter
- redirects:
redirect_maps:
hi/index.md: index.md

@ -90,7 +90,6 @@ dev = [
"mkdocs>=1.6.0",
"mkdocs-material>=9.5.9",
"mkdocstrings[python]",
"mkdocs-jupyter", # notebooks
"mkdocs-redirects", # 301 redirects
"mkdocs-ultralytics-plugin>=0.1.8", # for meta descriptions and images, dates and authors
"mkdocs-macros-plugin>=1.0.5" # duplicating content (i.e. export tables) in multiple places

@ -14,46 +14,53 @@ POSE_VIDEO = "solution_ci_pose_demo.mp4"
@pytest.mark.slow
def test_major_solutions():
"""Test the object counting, heatmap, speed estimation and queue management solution."""
"""Test the object counting, heatmap, speed estimation, trackzone and queue management solution."""
safe_download(url=f"{ASSETS_URL}/{DEMO_VIDEO}", dir=TMP)
cap = cv2.VideoCapture(str(TMP / DEMO_VIDEO))
assert cap.isOpened(), "Error reading video file"
region_points = [(20, 400), (1080, 400), (1080, 360), (20, 360)]
counter = solutions.ObjectCounter(region=region_points, model="yolo11n.pt", show=False) # Test object counter
heatmap = solutions.Heatmap(colormap=cv2.COLORMAP_PARULA, model="yolo11n.pt", show=False) # Test heatmaps
heatmap_count = solutions.Heatmap(
colormap=cv2.COLORMAP_PARULA, model="yolo11n.pt", show=False, region=region_points
) # Test heatmaps with object counting
speed = solutions.SpeedEstimator(region=region_points, model="yolo11n.pt", show=False) # Test queue manager
queue = solutions.QueueManager(region=region_points, model="yolo11n.pt", show=False) # Test speed estimation
line_analytics = solutions.Analytics(analytics_type="line", model="yolo11n.pt", show=False) # line analytics
pie_analytics = solutions.Analytics(analytics_type="pie", model="yolo11n.pt", show=False) # line analytics
bar_analytics = solutions.Analytics(analytics_type="bar", model="yolo11n.pt", show=False) # line analytics
area_analytics = solutions.Analytics(analytics_type="area", model="yolo11n.pt", show=False) # line analytics
trackzone = solutions.TrackZone(region=region_points, model="yolo11n.pt", show=False) # Test trackzone
frame_count = 0 # Required for analytics
while cap.isOpened():
success, im0 = cap.read()
if not success:
break
frame_count += 1
original_im0 = im0.copy()
_ = counter.count(original_im0.copy())
_ = heatmap.generate_heatmap(original_im0.copy())
_ = heatmap_count.generate_heatmap(original_im0.copy())
_ = speed.estimate_speed(original_im0.copy())
_ = queue.process_queue(original_im0.copy())
_ = line_analytics.process_data(original_im0.copy(), frame_count)
_ = pie_analytics.process_data(original_im0.copy(), frame_count)
_ = bar_analytics.process_data(original_im0.copy(), frame_count)
_ = area_analytics.process_data(original_im0.copy(), frame_count)
_ = trackzone.trackzone(original_im0.copy())
cap.release()
# Test workouts monitoring
safe_download(url=f"{ASSETS_URL}/{POSE_VIDEO}", dir=TMP)
cap1 = cv2.VideoCapture(str(TMP / POSE_VIDEO))
assert cap1.isOpened(), "Error reading video file"
gym = solutions.AIGym(line_width=2, kpts=[5, 11, 13], show=False)
while cap1.isOpened():
success, im0 = cap1.read()
cap = cv2.VideoCapture(str(TMP / POSE_VIDEO))
assert cap.isOpened(), "Error reading video file"
gym = solutions.AIGym(kpts=[5, 11, 13], show=False)
while cap.isOpened():
success, im0 = cap.read()
if not success:
break
_ = gym.monitor(im0)
cap1.release()
cap.release()
@pytest.mark.slow

@ -1,6 +1,6 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license
__version__ = "8.3.55"
__version__ = "8.3.56"
import os

@ -303,7 +303,7 @@ def get_cfg(cfg: Union[str, Path, Dict, SimpleNamespace] = DEFAULT_CFG_DICT, ove
if k in cfg and isinstance(cfg[k], (int, float)):
cfg[k] = str(cfg[k])
if cfg.get("name") == "model": # assign model to 'name' arg
cfg["name"] = cfg.get("model", "").split(".")[0]
cfg["name"] = str(cfg.get("model", "")).split(".")[0]
LOGGER.warning(f"WARNING ⚠ 'name=model' automatically updated to 'name={cfg['name']}'.")
# Type and Value checks

@ -266,7 +266,7 @@ def convert_coco(
# since LVIS val set contains images from COCO 2017 train in addition to the COCO 2017 val split.
(fn / "train2017").mkdir(parents=True, exist_ok=True)
(fn / "val2017").mkdir(parents=True, exist_ok=True)
with open(json_file) as f:
with open(json_file, encoding="utf-8") as f:
data = json.load(f)
# Create image dict

@ -323,7 +323,8 @@ class GroundingDataset(YOLODataset):
if box[2] <= 0 or box[3] <= 0:
continue
cat_name = " ".join([img["caption"][t[0] : t[1]] for t in ann["tokens_positive"]])
caption = img["caption"]
cat_name = " ".join([caption[t[0] : t[1]] for t in ann["tokens_positive"]])
if cat_name not in cat2id:
cat2id[cat_name] = len(cat2id)
texts.append([cat_name])

@ -285,6 +285,7 @@ class Exporter:
"(torchscript, onnx, openvino, engine, coreml) formats. "
"See https://docs.ultralytics.com/models/yolo-world for details."
)
model.clip_model = None # openvino int8 export error: https://github.com/ultralytics/ultralytics/pull/18445
if self.args.int8 and not self.args.data:
self.args.data = DEFAULT_CFG.data or TASK2DATA[getattr(model, "task", "detect")] # assign default data
LOGGER.warning(
@ -602,7 +603,7 @@ class Exporter:
@try_export
def export_paddle(self, prefix=colorstr("PaddlePaddle:")):
"""YOLO Paddle export."""
check_requirements(("paddlepaddle", "x2paddle"))
check_requirements(("paddlepaddle-gpu" if torch.cuda.is_available() else "paddlepaddle", "x2paddle"))
import x2paddle # noqa
from x2paddle.convert import pytorch2paddle # noqa
@ -949,7 +950,7 @@ class Exporter:
"sng4onnx>=1.0.1", # required by 'onnx2tf' package
"onnx_graphsurgeon>=0.3.26", # required by 'onnx2tf' package
"onnx>=1.12.0",
"onnx2tf>1.17.5,<=1.22.3",
"onnx2tf>1.17.5,<=1.26.3",
"onnxslim>=0.1.31",
"tflite_support<=0.4.3" if IS_JETSON else "tflite_support", # fix ImportError 'GLIBCXX_3.4.29'
"flatbuffers>=23.5.26,<100", # update old 'flatbuffers' included inside tensorflow package
@ -1136,7 +1137,7 @@ class Exporter:
if getattr(self.model, "end2end", False):
raise ValueError("IMX export is not supported for end2end models.")
if "C2f" not in self.model.__str__():
raise ValueError("IMX export is only supported for YOLOv8 detection models")
raise ValueError("IMX export is only supported for YOLOv8n detection models")
check_requirements(("model-compression-toolkit==2.1.1", "sony-custom-layers==0.2.0", "tensorflow==2.12.0"))
check_requirements("imx500-converter[pt]==3.14.3") # Separate requirements for imx500-converter

@ -91,9 +91,9 @@ class Predictor(BasePredictor):
_callbacks (Dict | None): Dictionary of callback functions to customize behavior.
Examples:
>>> predictor = Predictor(cfg=DEFAULT_CFG)
>>> predictor = Predictor(overrides={"imgsz": 640})
>>> predictor = Predictor(_callbacks={"on_predict_start": custom_callback})
>>> predictor_example = Predictor(cfg=DEFAULT_CFG)
>>> predictor_example_with_imgsz = Predictor(overrides={"imgsz": 640})
>>> predictor_example_with_callback = Predictor(_callbacks={"on_predict_start": custom_callback})
"""
if overrides is None:
overrides = {}
@ -215,7 +215,7 @@ class Predictor(BasePredictor):
im (torch.Tensor): Preprocessed input image tensor with shape (N, C, H, W).
bboxes (np.ndarray | List | None): Bounding boxes in XYXY format with shape (N, 4).
points (np.ndarray | List | None): Points indicating object locations with shape (N, 2) or (N, num_points, 2), in pixels.
labels (np.ndarray | List | None): Point prompt labels with shape (N,) or (N, num_points). 1 for foreground, 0 for background.
labels (np.ndarray | List | None): Point prompt labels with shape (N) or (N, num_points). 1 for foreground, 0 for background.
masks (np.ndarray | None): Low-res masks from previous predictions with shape (N, H, W). For SAM, H=W=256.
multimask_output (bool): Flag to return multiple masks for ambiguous prompts.
@ -260,7 +260,7 @@ class Predictor(BasePredictor):
dst_shape (tuple): The target shape (height, width) for the prompts.
bboxes (np.ndarray | List | None): Bounding boxes in XYXY format with shape (N, 4).
points (np.ndarray | List | None): Points indicating object locations with shape (N, 2) or (N, num_points, 2), in pixels.
labels (np.ndarray | List | None): Point prompt labels with shape (N,) or (N, num_points). 1 for foreground, 0 for background.
labels (np.ndarray | List | None): Point prompt labels with shape (N) or (N, num_points). 1 for foreground, 0 for background.
masks (List | np.ndarray, Optional): Masks for the objects, where each mask is a 2D array.
Raises:
@ -853,8 +853,8 @@ class SAM2VideoPredictor(SAM2Predictor):
Examples:
>>> predictor = SAM2VideoPredictor(cfg=DEFAULT_CFG)
>>> predictor = SAM2VideoPredictor(overrides={"imgsz": 640})
>>> predictor = SAM2VideoPredictor(_callbacks={"on_predict_start": custom_callback})
>>> predictor_example_with_imgsz = SAM2VideoPredictor(overrides={"imgsz": 640})
>>> predictor_example_with_callback = SAM2VideoPredictor(_callbacks={"on_predict_start": custom_callback})
"""
super().__init__(cfg, overrides, _callbacks)
self.inference_state = {}

@ -133,7 +133,7 @@ class AutoBackend(nn.Module):
# Set device
cuda = torch.cuda.is_available() and device.type != "cpu" # use CUDA
if cuda and not any([nn_module, pt, jit, engine, onnx]): # GPU dataloader formats
if cuda and not any([nn_module, pt, jit, engine, onnx, paddle]): # GPU dataloader formats
device = torch.device("cpu")
cuda = False

@ -1269,7 +1269,7 @@ def plt_color_scatter(v, f, bins=20, cmap="viridis", alpha=0.8, edgecolors="none
def plot_tune_results(csv_file="tune_results.csv"):
"""
Plot the evolution results stored in an 'tune_results.csv' file. The function generates a scatter plot for each key
Plot the evolution results stored in a 'tune_results.csv' file. The function generates a scatter plot for each key
in the CSV, color-coded based on fitness scores. The best-performing configurations are highlighted on the plots.
Args:

Loading…
Cancel
Save