Home

Awesome

Adapting YOLO detection models with Infobatch

To make the infobatch adaption, we adapt the Detection model's V8DetectionLoss to a per-sample-based one. As in the original calculation, the bbox losses are summed for calculation, one should sum it to keep consistent with the original calculation. Then substitute the dataset in build_dataset and the sampler in build_dataloader. The collate_fn also needs to be adapted for index collection. Search "##InfoBatch" to find the adapted parts of code.

In the trainer part, we adapt the BaseTrainer._do_train function for the InfoBatch loss update step.

The major changes can be seen in commit 46a75c0ed752439f1f93e2d760d0c163a7d3641a.


<div align="center"> <p> <a href="https://www.ultralytics.com/events/yolovision" target="_blank"> <img width="100%" src="https://raw.githubusercontent.com/ultralytics/assets/main/yolov8/banner-yolov8.png" alt="YOLO Vision banner"></a> </p>

中文 | 한국어 | 日本語 | Русский | Deutsch | Français | Español | Português | Türkçe | Tiếng Việt | العربية <br>

<div> <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://zenodo.org/badge/latestdoi/264818686"><img src="https://zenodo.org/badge/264818686.svg" alt="Ultralytics YOLOv8 Citation"></a> <a href="https://hub.docker.com/r/ultralytics/ultralytics"><img src="https://img.shields.io/docker/pulls/ultralytics/ultralytics?logo=docker" alt="Ultralytics Docker Pulls"></a> <a href="https://ultralytics.com/discord"><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/ultralytics/yolov8"><img src="https://kaggle.com/static/images/open-in-kaggle.svg" alt="Open Ultralytics In Kaggle"></a> </div> <br>

Ultralytics YOLOv8 is a cutting-edge, state-of-the-art (SOTA) model that builds upon the success of previous YOLO versions and introduces new features and improvements to further boost performance and flexibility. YOLOv8 is designed to be fast, accurate, and easy to use, making it an excellent choice for a wide range of object detection and tracking, instance segmentation, image classification and pose estimation tasks.

We hope that the resources here will help you get the most out of YOLOv8. Please browse the YOLOv8 <a href="https://docs.ultralytics.com/">Docs</a> for details, raise an issue on <a href="https://github.com/ultralytics/ultralytics/issues/new/choose">GitHub</a> for support, questions, or discussions, become a member of the Ultralytics <a href="https://ultralytics.com/discord">Discord</a>, <a href="https://reddit.com/r/ultralytics">Reddit</a> and <a href="https://community.ultralytics.com">Forums</a>!

To request an Enterprise License please complete the form at Ultralytics Licensing.

<img width="100%" src="https://raw.githubusercontent.com/ultralytics/assets/main/yolov8/yolo-comparison-plots.png" alt="YOLOv8 performance plots"></a>

<div align="center"> <a href="https://github.com/ultralytics"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-github.png" width="2%" alt="Ultralytics GitHub"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%" alt="space"> <a href="https://www.linkedin.com/company/ultralytics/"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-linkedin.png" width="2%" alt="Ultralytics LinkedIn"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%" alt="space"> <a href="https://twitter.com/ultralytics"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-twitter.png" width="2%" alt="Ultralytics Twitter"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%" alt="space"> <a href="https://youtube.com/ultralytics?sub_confirmation=1"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-youtube.png" width="2%" alt="Ultralytics YouTube"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%" alt="space"> <a href="https://www.tiktok.com/@ultralytics"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-tiktok.png" width="2%" alt="Ultralytics TikTok"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%" alt="space"> <a href="https://ultralytics.com/bilibili"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-bilibili.png" width="2%" alt="Ultralytics BiliBili"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%" alt="space"> <a href="https://ultralytics.com/discord"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-discord.png" width="2%" alt="Ultralytics Discord"></a> </div> </div>

<div align="center">Documentation</div>

See below for a quickstart installation and usage example, and see the YOLOv8 Docs for full documentation on training, validation, prediction and deployment.

<details open> <summary>Install</summary>

Pip install the ultralytics package including all requirements in a Python>=3.8 environment with PyTorch>=1.8.

PyPI - Version Downloads PyPI - Python Version

pip install ultralytics

For alternative installation methods including Conda, Docker, and Git, please refer to the Quickstart Guide.

Conda Version Docker Image Version

</details> <details open> <summary>Usage</summary>

CLI

YOLOv8 may be used directly in the Command Line Interface (CLI) with a yolo command:

yolo predict model=yolov8n.pt source='https://ultralytics.com/images/bus.jpg'

yolo can be used for a variety of tasks and modes and accepts additional arguments, i.e. imgsz=640. See the YOLOv8 CLI Docs for examples.

Python

YOLOv8 may also be used directly in a Python environment, and accepts the same arguments as in the CLI example above:

from ultralytics import YOLO

# Load a model
model = YOLO("yolov8n.yaml")  # build a new model from scratch
model = YOLO("yolov8n.pt")  # load a pretrained model (recommended for training)

# Use the model
model.train(data="coco8.yaml", epochs=3)  # train the model
metrics = model.val()  # evaluate model performance on the validation set
results = model("https://ultralytics.com/images/bus.jpg")  # predict on an image
path = model.export(format="onnx")  # export the model to ONNX format

See YOLOv8 Python Docs for more examples.

</details>

Notebooks

Ultralytics provides interactive notebooks for YOLOv8, covering training, validation, tracking, and more. Each notebook is paired with a YouTube tutorial, making it easy to learn and implement advanced YOLOv8 features.

DocsNotebookYouTube
<a href="https://docs.ultralytics.com/modes/">YOLOv8 Train, Val, Predict and Export Modes</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 In Colab"></a><a href="https://youtu.be/j8uQc0qB91s"><center><img width=30% src="https://raw.githubusercontent.com/ultralytics/assets/main/social/logo-social-youtube-rect.png" alt="Ultralytics Youtube Video"></center></a>
<a href="https://docs.ultralytics.com/hub/quickstart/">Ultralytics HUB QuickStart</a><a href="https://colab.research.google.com/github/ultralytics/ultralytics/blob/main/examples/hub.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a><a href="https://youtu.be/lveF9iCMIzc"><center><img width=30% src="https://raw.githubusercontent.com/ultralytics/assets/main/social/logo-social-youtube-rect.png" alt="Ultralytics Youtube Video"></center></a>
<a href="https://docs.ultralytics.com/modes/track/">YOLOv8 Multi-Object Tracking in Videos</a><a href="https://colab.research.google.com/github/ultralytics/ultralytics/blob/main/examples/object_tracking.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a><a href="https://youtu.be/hHyHmOtmEgs"><center><img width=30% src="https://raw.githubusercontent.com/ultralytics/assets/main/social/logo-social-youtube-rect.png" alt="Ultralytics Youtube Video"></center></a>
<a href="https://docs.ultralytics.com/guides/object-counting/">YOLOv8 Object Counting in Videos</a><a href="https://colab.research.google.com/github/ultralytics/ultralytics/blob/main/examples/object_counting.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a><a href="https://youtu.be/Ag2e-5_NpS0"><center><img width=30% src="https://raw.githubusercontent.com/ultralytics/assets/main/social/logo-social-youtube-rect.png" alt="Ultralytics Youtube Video"></center></a>
<a href="https://docs.ultralytics.com/guides/heatmaps/">YOLOv8 Heatmaps in Videos</a><a href="https://colab.research.google.com/github/ultralytics/ultralytics/blob/main/examples/heatmaps.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a><a href="https://youtu.be/4ezde5-nZZw"><center><img width=30% src="https://raw.githubusercontent.com/ultralytics/assets/main/social/logo-social-youtube-rect.png" alt="Ultralytics Youtube Video"></center></a>
<a href="https://docs.ultralytics.com/datasets/explorer/">Ultralytics Datasets Explorer with SQL and OpenAI Integration 🚀 New</a><a href="https://colab.research.google.com/github/ultralytics/ultralytics/blob/main/docs/en/datasets/explorer/explorer.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a><a href="https://youtu.be/3VryynorQeo"><center><img width=30% src="https://raw.githubusercontent.com/ultralytics/assets/main/social/logo-social-youtube-rect.png" alt="Ultralytics Youtube Video"></center></a>

<div align="center">Models</div>

YOLOv8 Detect, Segment and Pose models pretrained on the COCO dataset are available here, as well as YOLOv8 Classify models pretrained on the ImageNet dataset. Track mode is available for all Detect, Segment and Pose models.

<img width="1024" src="https://raw.githubusercontent.com/ultralytics/assets/main/im/banner-tasks.png" alt="Ultralytics YOLO supported tasks">

All Models download automatically from the latest Ultralytics release on first use.

<details open><summary>Detection (COCO)</summary>

See Detection Docs for usage examples with these models trained on COCO, which include 80 pre-trained classes.

Modelsize<br><sup>(pixels)mAP<sup>val<br>50-95Speed<br><sup>CPU ONNX<br>(ms)Speed<br><sup>A100 TensorRT<br>(ms)params<br><sup>(M)FLOPs<br><sup>(B)
YOLOv8n64037.380.40.993.28.7
YOLOv8s64044.9128.41.2011.228.6
YOLOv8m64050.2234.71.8325.978.9
YOLOv8l64052.9375.22.3943.7165.2
YOLOv8x64053.9479.13.5368.2257.8
</details> <details><summary>Detection (Open Image V7)</summary>

See Detection Docs for usage examples with these models trained on Open Image V7, which include 600 pre-trained classes.

Modelsize<br><sup>(pixels)mAP<sup>val<br>50-95Speed<br><sup>CPU ONNX<br>(ms)Speed<br><sup>A100 TensorRT<br>(ms)params<br><sup>(M)FLOPs<br><sup>(B)
YOLOv8n64018.4142.41.213.510.5
YOLOv8s64027.7183.11.4011.429.7
YOLOv8m64033.6408.52.2626.280.6
YOLOv8l64034.9596.92.4344.1167.4
YOLOv8x64036.3860.63.5668.7260.6
</details> <details><summary>Segmentation (COCO)</summary>

See Segmentation Docs for usage examples with these models trained on COCO-Seg, which include 80 pre-trained classes.

Modelsize<br><sup>(pixels)mAP<sup>box<br>50-95mAP<sup>mask<br>50-95Speed<br><sup>CPU ONNX<br>(ms)Speed<br><sup>A100 TensorRT<br>(ms)params<br><sup>(M)FLOPs<br><sup>(B)
YOLOv8n-seg64036.730.596.11.213.412.6
YOLOv8s-seg64044.636.8155.71.4711.842.6
YOLOv8m-seg64049.940.8317.02.1827.3110.2
YOLOv8l-seg64052.342.6572.42.7946.0220.5
YOLOv8x-seg64053.443.4712.14.0271.8344.1
</details> <details><summary>Pose (COCO)</summary>

See Pose Docs for usage examples with these models trained on COCO-Pose, which include 1 pre-trained class, person.

Modelsize<br><sup>(pixels)mAP<sup>pose<br>50-95mAP<sup>pose<br>50Speed<br><sup>CPU ONNX<br>(ms)Speed<br><sup>A100 TensorRT<br>(ms)params<br><sup>(M)FLOPs<br><sup>(B)
YOLOv8n-pose64050.480.1131.81.183.39.2
YOLOv8s-pose64060.086.2233.21.4211.630.2
YOLOv8m-pose64065.088.8456.32.0026.481.0
YOLOv8l-pose64067.690.0784.52.5944.4168.6
YOLOv8x-pose64069.290.21607.13.7369.4263.2
YOLOv8x-pose-p6128071.691.24088.710.0499.11066.4
</details> <details><summary>OBB (DOTAv1)</summary>

See OBB Docs for usage examples with these models trained on DOTAv1, which include 15 pre-trained classes.

Modelsize<br><sup>(pixels)mAP<sup>test<br>50Speed<br><sup>CPU ONNX<br>(ms)Speed<br><sup>A100 TensorRT<br>(ms)params<br><sup>(M)FLOPs<br><sup>(B)
YOLOv8n-obb102478.0204.773.573.123.3
YOLOv8s-obb102479.5424.884.0711.476.3
YOLOv8m-obb102480.5763.487.6126.4208.6
YOLOv8l-obb102480.71278.4211.8344.5433.8
YOLOv8x-obb102481.361759.1013.2369.5676.7
</details> <details><summary>Classification (ImageNet)</summary>

See Classification Docs for usage examples with these models trained on ImageNet, which include 1000 pretrained classes.

Modelsize<br><sup>(pixels)acc<br><sup>top1acc<br><sup>top5Speed<br><sup>CPU ONNX<br>(ms)Speed<br><sup>A100 TensorRT<br>(ms)params<br><sup>(M)FLOPs<br><sup>(B) at 640
YOLOv8n-cls22469.088.312.90.312.74.3
YOLOv8s-cls22473.891.723.40.356.413.5
YOLOv8m-cls22476.893.585.40.6217.042.7
YOLOv8l-cls22478.394.2163.00.8737.599.7
YOLOv8x-cls22479.094.6232.01.0157.4154.8
</details>

<div align="center">Integrations</div>

Our key integrations with leading AI platforms extend the functionality of Ultralytics' offerings, enhancing tasks like dataset labeling, training, visualization, and model management. Discover how Ultralytics, in collaboration with Roboflow, ClearML, Comet, Neural Magic and OpenVINO, can optimize your AI workflow.

<br> <a href="https://ultralytics.com/hub" target="_blank"> <img width="100%" src="https://github.com/ultralytics/assets/raw/main/yolov8/banner-integrations.png" alt="Ultralytics active learning integrations"></a> <br> <br> <div align="center"> <a href="https://roboflow.com/?ref=ultralytics"> <img src="https://github.com/ultralytics/assets/raw/main/partners/logo-roboflow.png" width="10%" alt="Roboflow logo"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="15%" height="0" alt="space"> <a href="https://clear.ml/"> <img src="https://github.com/ultralytics/assets/raw/main/partners/logo-clearml.png" width="10%" alt="ClearML logo"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="15%" height="0" alt="space"> <a href="https://bit.ly/yolov8-readme-comet"> <img src="https://github.com/ultralytics/assets/raw/main/partners/logo-comet.png" width="10%" alt="Comet ML logo"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="15%" height="0" alt="space"> <a href="https://bit.ly/yolov5-neuralmagic"> <img src="https://github.com/ultralytics/assets/raw/main/partners/logo-neuralmagic.png" width="10%" alt="NeuralMagic logo"></a> </div>
RoboflowClearML ⭐ NEWComet ⭐ NEWNeural Magic ⭐ NEW
Label and export your custom datasets directly to YOLOv8 for training with RoboflowAutomatically track, visualize and even remotely train YOLOv8 using ClearML (open-source!)Free forever, Comet lets you save YOLOv8 models, resume training, and interactively visualize and debug predictionsRun YOLOv8 inference up to 6x faster with Neural Magic DeepSparse

<div align="center">Ultralytics HUB</div>

Experience seamless AI with Ultralytics HUB ⭐, the all-in-one solution for data visualization, YOLOv5 and YOLOv8 🚀 model training and deployment, without any coding. Transform images into actionable insights and bring your AI visions to life with ease using our cutting-edge platform and user-friendly Ultralytics App. Start your journey for Free now!

<a href="https://ultralytics.com/hub" target="_blank"> <img width="100%" src="https://github.com/ultralytics/assets/raw/main/im/ultralytics-hub.png" alt="Ultralytics HUB preview image"></a>

<div align="center">Contribute</div>

We love your input! YOLOv5 and YOLOv8 would not be possible without help from our community. Please see our Contributing Guide to get started, and fill out our Survey to send us feedback on your experience. Thank you 🙏 to all our contributors!

<!-- SVG image from https://opencollective.com/ultralytics/contributors.svg?width=990 --> <a href="https://github.com/ultralytics/ultralytics/graphs/contributors"> <img width="100%" src="https://github.com/ultralytics/assets/raw/main/im/image-contributors.png" alt="Ultralytics open-source contributors"></a>

<div align="center">License</div>

Ultralytics offers two licensing options to accommodate diverse use cases:

<div align="center">Contact</div>

For Ultralytics bug reports and feature requests please visit GitHub Issues. Become a member of the Ultralytics Discord, Reddit, or Forums for asking questions, sharing projects, learning discussions, or for help with all things Ultralytics!

<br> <div align="center"> <a href="https://github.com/ultralytics"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-github.png" width="3%" alt="Ultralytics GitHub"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space"> <a href="https://www.linkedin.com/company/ultralytics/"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-linkedin.png" width="3%" alt="Ultralytics LinkedIn"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space"> <a href="https://twitter.com/ultralytics"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-twitter.png" width="3%" alt="Ultralytics Twitter"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space"> <a href="https://youtube.com/ultralytics?sub_confirmation=1"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-youtube.png" width="3%" alt="Ultralytics YouTube"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space"> <a href="https://www.tiktok.com/@ultralytics"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-tiktok.png" width="3%" alt="Ultralytics TikTok"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space"> <a href="https://ultralytics.com/bilibili"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-bilibili.png" width="3%" alt="Ultralytics BiliBili"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space"> <a href="https://ultralytics.com/discord"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-discord.png" width="3%" alt="Ultralytics Discord"></a> </div>