`ultralytics 8.0.72` faster Windows trainings and corrupt cache fix (#1912)

Co-authored-by: andreaswimmer <53872150+andreaswimmer@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
pull/1934/head v8.0.72
Glenn Jocher 2 years ago committed by GitHub
parent 48f1d269fb
commit 95f96dc5bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .github/workflows/greetings.yml
  2. 16
      README.md
  3. 362
      README.zh-CN.md
  4. 2
      docs/modes/train.md
  5. 16
      docs/tasks/pose.md
  6. 2
      docs/usage/cfg.md
  7. 2
      docs/yolov5/train_custom_data.md
  8. 262
      examples/tutorial.ipynb
  9. 2
      tests/test_python.py
  10. 2
      ultralytics/__init__.py
  11. 16
      ultralytics/models/README.md
  12. 38
      ultralytics/tracker/utils/gmc.py
  13. 2
      ultralytics/yolo/cfg/default.yaml
  14. 17
      ultralytics/yolo/data/build.py
  15. 1
      ultralytics/yolo/data/dataset.py
  16. 4
      ultralytics/yolo/engine/model.py
  17. 4
      ultralytics/yolo/engine/results.py
  18. 1
      ultralytics/yolo/utils/__init__.py

@ -30,7 +30,7 @@ jobs:
If this is a 🐛 Bug Report, please provide a [minimum reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) to help us debug it. If this is a 🐛 Bug Report, please provide a [minimum reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) to help us debug it.
If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our [Tips for Best Training Results](https://github.com/ultralytics/yolov5/wiki/Tips-for-Best-Training-Results). If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our [Tips for Best Training Results](https://docs.ultralytics.com/yolov5/tips_for_best_training_results/).
## Install ## Install

@ -181,14 +181,14 @@ See [Classification Docs](https://docs.ultralytics.com/tasks/classify/) for usag
See [Pose Docs](https://docs.ultralytics.com/tasks/) for usage examples with these models. See [Pose Docs](https://docs.ultralytics.com/tasks/) for usage examples with these models.
| Model | size<br><sup>(pixels) | mAP<sup>box<br>50-95 | mAP<sup>pose<br>50-95 | Speed<br><sup>CPU ONNX<br>(ms) | Speed<br><sup>A100 TensorRT<br>(ms) | params<br><sup>(M) | FLOPs<br><sup>(B) | | Model | size<br><sup>(pixels) | mAP<sup>pose<br>50-95 | mAP<sup>pose<br>50 | Speed<br><sup>CPU ONNX<br>(ms) | Speed<br><sup>A100 TensorRT<br>(ms) | params<br><sup>(M) | FLOPs<br><sup>(B) |
| ---------------------------------------------------------------------------------------------------- | --------------------- | -------------------- | --------------------- | ------------------------------ | ----------------------------------- | ------------------ | ----------------- | | ---------------------------------------------------------------------------------------------------- | --------------------- | --------------------- | ------------------ | ------------------------------ | ----------------------------------- | ------------------ | ----------------- |
| [YOLOv8n-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n-pose.pt) | 640 | - | 49.7 | 131.8 | 1.18 | 3.3 | 9.2 | | [YOLOv8n-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n-pose.pt) | 640 | 49.7 | 79.7 | 131.8 | 1.18 | 3.3 | 9.2 |
| [YOLOv8s-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8s-pose.pt) | 640 | - | 59.2 | 233.2 | 1.42 | 11.6 | 30.2 | | [YOLOv8s-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8s-pose.pt) | 640 | 59.2 | 85.8 | 233.2 | 1.42 | 11.6 | 30.2 |
| [YOLOv8m-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8m-pose.pt) | 640 | - | 63.6 | 456.3 | 2.00 | 26.4 | 81.0 | | [YOLOv8m-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8m-pose.pt) | 640 | 63.6 | 88.8 | 456.3 | 2.00 | 26.4 | 81.0 |
| [YOLOv8l-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8l-pose.pt) | 640 | - | 67.0 | 784.5 | 2.59 | 44.4 | 168.6 | | [YOLOv8l-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8l-pose.pt) | 640 | 67.0 | 89.9 | 784.5 | 2.59 | 44.4 | 168.6 |
| [YOLOv8x-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8x-pose.pt) | 640 | - | 68.9 | 1607.1 | 3.73 | 69.4 | 263.2 | | [YOLOv8x-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8x-pose.pt) | 640 | 68.9 | 90.4 | 1607.1 | 3.73 | 69.4 | 263.2 |
| [YOLOv8x-pose-p6](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8x-pose-p6.pt) | 1280 | - | 71.5 | 4088.7 | 10.04 | 99.1 | 1066.4 | | [YOLOv8x-pose-p6](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8x-pose-p6.pt) | 1280 | 71.5 | 91.3 | 4088.7 | 10.04 | 99.1 | 1066.4 |
- **mAP<sup>val</sup>** values are for single-model single-scale on [COCO Keypoints val2017](http://cocodataset.org) - **mAP<sup>val</sup>** values are for single-model single-scale on [COCO Keypoints val2017](http://cocodataset.org)
dataset. dataset.

@ -1,266 +1,170 @@
<div align="center"> # YOLOv8 Pose Models
<p>
<a href="https://ultralytics.com/yolov8" target="_blank">
<img width="850" src="https://raw.githubusercontent.com/ultralytics/assets/main/yolov8/banner-yolov8.png"></a>
</p>
[English](README.md) | [简体中文](README.zh-CN.md)
<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="YOLOv8 Citation"></a>
<a href="https://hub.docker.com/r/ultralytics/yolov5"><img src="https://img.shields.io/docker/pulls/ultralytics/yolov5?logo=docker" alt="Docker Pulls"></a>
<br>
<a href="https://console.paperspace.com/github/ultralytics/ultralytics"><img src="https://assets.paperspace.io/img/gradient-badge.svg" alt="Run 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 In Colab"></a>
<a href="https://www.kaggle.com/ultralytics/yolov8"><img src="https://kaggle.com/static/images/open-in-kaggle.svg" alt="Open In Kaggle"></a>
</div>
<br>
[Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics) 是由 [Ultralytics](https://ultralytics.com) 开发的一个前沿的
SOTA 模型。它在以前成功的 YOLO 版本基础上,引入了新的功能和改进,进一步提升了其性能和灵活性。YOLOv8
基于快速、准确和易于使用的设计理念,使其成为广泛的目标检测、图像分割和图像分类任务的绝佳选择。
如果要申请企业许可证,请填写 [Ultralytics 许可](https://ultralytics.com/license)。
<div align="center">
<a href="https://github.com/ultralytics" style="text-decoration:none;">
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-github.png" width="2%" alt="" /></a>
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%" alt="" />
<a href="https://www.linkedin.com/company/ultralytics" style="text-decoration:none;">
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-linkedin.png" width="2%" alt="" /></a>
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%" alt="" />
<a href="https://twitter.com/ultralytics" style="text-decoration:none;">
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-twitter.png" width="2%" alt="" /></a>
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%" alt="" />
<a href="https://youtube.com/ultralytics" style="text-decoration:none;">
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-youtube.png" width="2%" alt="" /></a>
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%" alt="" />
<a href="https://www.tiktok.com/@ultralytics" style="text-decoration:none;">
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-tiktok.png" width="2%" alt="" /></a>
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%" alt="" />
<a href="https://www.instagram.com/ultralytics/" style="text-decoration:none;">
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-instagram.png" width="2%" alt="" /></a>
</div>
</div>
## <div align="center">文档</div>
有关训练、测试和部署的完整文档见[YOLOv8 Docs](https://docs.ultralytics.com)。请参阅下面的快速入门示例。
<details open>
<summary>安装</summary>
Pip 安装包含所有 [requirements](https://github.com/ultralytics/ultralytics/blob/main/requirements.txt) 的
ultralytics 包,环境要求 [**Python>=3.7**](https://www.python.org/),且 [\*\*PyTorch>=1.7
\*\*](https://pytorch.org/get-started/locally/)。
```bash Pose estimation is a task that involves identifying the location of specific points in an image, usually referred
pip install ultralytics to as keypoints. The keypoints can represent various parts of the object such as joints, landmarks, or other distinctive
``` features. The locations of the keypoints are usually represented as a set of 2D `[x, y]` or 3D `[x, y, visible]`
coordinates.
</details> <img width="1024" src="https://user-images.githubusercontent.com/26833433/212094133-6bb8c21c-3d47-41df-a512-81c5931054ae.png">
<details open> The output of a pose estimation model is a set of points that represent the keypoints on an object in the image, usually
<summary>使用方法</summary> along with the confidence scores for each point. Pose estimation is a good choice when you need to identify specific
parts of an object in a scene, and their location in relation to each other.
YOLOv8 可以直接在命令行界面(CLI)中使用 `yolo` 命令运行: **Pro Tip:** YOLOv8 _pose_ models use the `-pose` suffix, i.e. `yolov8n-pose.pt`. These models are trained on the [COCO keypoints](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/coco-pose.yaml) dataset and are suitable for a variety of pose estimation tasks.
```bash ## [Models](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/models/v8)
yolo predict model=yolov8n.pt source='https://ultralytics.com/images/bus.jpg'
YOLOv8 pretrained Pose models are shown here. Detect, Segment and Pose models are pretrained on
the [COCO](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/coco.yaml) dataset, while Classify
models are pretrained on
the [ImageNet](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/ImageNet.yaml) dataset.
[Models](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/models) download automatically from the latest
Ultralytics [release](https://github.com/ultralytics/assets/releases) on first use.
| Model | size<br><sup>(pixels) | mAP<sup>pose<br>50-95 | mAP<sup>pose<br>50 | Speed<br><sup>CPU ONNX<br>(ms) | Speed<br><sup>A100 TensorRT<br>(ms) | params<br><sup>(M) | FLOPs<br><sup>(B) |
| ---------------------------------------------------------------------------------------------------- | --------------------- | --------------------- | ------------------ | ------------------------------ | ----------------------------------- | ------------------ | ----------------- |
| [YOLOv8n-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n-pose.pt) | 640 | 49.7 | 79.7 | 131.8 | 1.18 | 3.3 | 9.2 |
| [YOLOv8s-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8s-pose.pt) | 640 | 59.2 | 85.8 | 233.2 | 1.42 | 11.6 | 30.2 |
| [YOLOv8m-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8m-pose.pt) | 640 | 63.6 | 88.8 | 456.3 | 2.00 | 26.4 | 81.0 |
| [YOLOv8l-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8l-pose.pt) | 640 | 67.0 | 89.9 | 784.5 | 2.59 | 44.4 | 168.6 |
| [YOLOv8x-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8x-pose.pt) | 640 | 68.9 | 90.4 | 1607.1 | 3.73 | 69.4 | 263.2 |
| [YOLOv8x-pose-p6](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8x-pose-p6.pt) | 1280 | 71.5 | 91.3 | 4088.7 | 10.04 | 99.1 | 1066.4 |
- **mAP<sup>val</sup>** values are for single-model single-scale on [COCO Keypoints val2017](http://cocodataset.org)
dataset. Reproduce by `yolo val pose data=coco-pose.yaml device=0`
- **Speed** averaged over COCO val images using an [Amazon EC2 P4d](https://aws.amazon.com/ec2/instance-types/p4/)
instance. Reproduce by `yolo val pose data=coco8-pose.yaml batch=1 device=0|cpu`
## Train
Train a YOLOv8-pose model on the COCO128-pose dataset.
### Python
```python
from ultralytics import YOLO
# Load a model
model = YOLO("yolov8n-pose.yaml") # build a new model from YAML
model = YOLO("yolov8n-pose.pt") # load a pretrained model (recommended for training)
model = YOLO("yolov8n-pose.yaml").load(
"yolov8n-pose.pt"
) # build from YAML and transfer weights
# Train the model
model.train(data="coco8-pose.yaml", epochs=100, imgsz=640)
``` ```
`yolo`可以用于各种任务和模式,并接受额外的参数,例如 `imgsz=640`。参见 YOLOv8 [文档](https://docs.ultralytics.com) ### CLI
中可用`yolo`[参数](https://docs.ultralytics.com/usage/cfg/)的完整列表。
```bash ```bash
yolo task=detect mode=train model=yolov8n.pt args... # Build a new model from YAML and start training from scratch
classify predict yolov8n-cls.yaml args... yolo pose train data=coco8-pose.yaml model=yolov8n-pose.yaml epochs=100 imgsz=640
segment val yolov8n-seg.yaml args...
export yolov8n.pt format=onnx args... # Start training from a pretrained *.pt model
yolo pose train data=coco8-pose.yaml model=yolov8n-pose.pt epochs=100 imgsz=640
# Build a new model from YAML, transfer pretrained weights to it and start training
yolo pose train data=coco8-pose.yaml model=yolov8n-pose.yaml pretrained=yolov8n-pose.pt epochs=100 imgsz=640
``` ```
YOLOv8 也可以在 Python 环境中直接使用,并接受与上面 CLI 例子中相同的[参数](https://docs.ultralytics.com/usage/cfg/): ## Val
Validate trained YOLOv8n-pose model accuracy on the COCO128-pose dataset. No argument need to passed as the `model`
retains it's training `data` and arguments as model attributes.
### Python
```python ```python
from ultralytics import YOLO from ultralytics import YOLO
# 加载模型 # Load a model
model = YOLO("yolov8n.yaml") # 从头开始构建新模型 model = YOLO("yolov8n-pose.pt") # load an official model
model = YOLO("yolov8n.pt") # 加载预训练模型(推荐用于训练) model = YOLO("path/to/best.pt") # load a custom model
# Use the model # Validate the model
results = model.train(data="coco128.yaml", epochs=3) # 训练模型 metrics = model.val() # no arguments needed, dataset and settings remembered
results = model.val() # 在验证集上评估模型性能 metrics.box.map # map50-95
results = model("https://ultralytics.com/images/bus.jpg") # 预测图像 metrics.box.map50 # map50
success = model.export(format="onnx") # 将模型导出为 ONNX 格式 metrics.box.map75 # map75
metrics.box.maps # a list contains map50-95 of each category
``` ```
[模型](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/models) 会从 ### CLI
Ultralytics [发布页](https://github.com/ultralytics/ultralytics/releases) 自动下载。
</details> ```bash
yolo pose val model=yolov8n-pose.pt # val official model
## <div align="center">模型</div> yolo pose val model=path/to/best.pt # val custom model
```
所有 YOLOv8 的预训练模型都可以在这里找到。目标检测和分割模型是在 COCO 数据集上预训练的,而分类模型是在 ImageNet 数据集上预训练的。 ## Predict
第一次使用时,[模型](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/models) 会从 Use a trained YOLOv8n-pose model to run predictions on images.
Ultralytics [发布页](https://github.com/ultralytics/ultralytics/releases) 自动下载。
<details open><summary>目标检测</summary> ### Python
| 模型 | 尺寸<br><sup>(像素) | mAP<sup>val<br>50-95 | 推理速度<br><sup>CPU ONNX<br>(ms) | 推理速度<br><sup>A100 TensorRT<br>(ms) | 参数量<br><sup>(M) | FLOPs<br><sup>(B) | ```python
| ------------------------------------------------------------------------------------ | --------------- | -------------------- | ----------------------------- | ---------------------------------- | --------------- | ----------------- | from ultralytics import YOLO
| [YOLOv8n](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n.pt) | 640 | 37.3 | 80.4 | 0.99 | 3.2 | 8.7 |
| [YOLOv8s](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8s.pt) | 640 | 44.9 | 128.4 | 1.20 | 11.2 | 28.6 |
| [YOLOv8m](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8m.pt) | 640 | 50.2 | 234.7 | 1.83 | 25.9 | 78.9 |
| [YOLOv8l](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8l.pt) | 640 | 52.9 | 375.2 | 2.39 | 43.7 | 165.2 |
| [YOLOv8x](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8x.pt) | 640 | 53.9 | 479.1 | 3.53 | 68.2 | 257.8 |
- **mAP<sup>val</sup>** 结果都在 [COCO val2017](http://cocodataset.org) 数据集上,使用单模型单尺度测试得到。 # Load a model
<br>复现命令 `yolo val detect data=coco.yaml device=0` model = YOLO("yolov8n-pose.pt") # load an official model
- **推理速度**使用 COCO model = YOLO("path/to/best.pt") # load a custom model
验证集图片推理时间进行平均得到,测试环境使用 [Amazon EC2 P4d](https://aws.amazon.com/ec2/instance-types/p4/) 实例。
<br>复现命令 `yolo val detect data=coco128.yaml batch=1 device=0|cpu`
</details> # Predict with the model
results = model("https://ultralytics.com/images/bus.jpg") # predict on an image
```
<details><summary>实例分割</summary> ### CLI
| 模型 | 尺寸<br><sup>(像素) | mAP<sup>box<br>50-95 | mAP<sup>mask<br>50-95 | 推理速度<br><sup>CPU ONNX<br>(ms) | 推理速度<br><sup>A100 TensorRT<br>(ms) | 参数量<br><sup>(M) | FLOPs<br><sup>(B) | ```bash
| -------------------------------------------------------------------------------------------- | --------------- | -------------------- | --------------------- | ----------------------------- | ---------------------------------- | --------------- | ----------------- | yolo pose predict model=yolov8n-pose.pt source='https://ultralytics.com/images/bus.jpg' # predict with official model
| [YOLOv8n-seg](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n-seg.pt) | 640 | 36.7 | 30.5 | 96.1 | 1.21 | 3.4 | 12.6 | yolo pose predict model=path/to/best.pt source='https://ultralytics.com/images/bus.jpg' # predict with custom model
| [YOLOv8s-seg](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8s-seg.pt) | 640 | 44.6 | 36.8 | 155.7 | 1.47 | 11.8 | 42.6 | ```
| [YOLOv8m-seg](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8m-seg.pt) | 640 | 49.9 | 40.8 | 317.0 | 2.18 | 27.3 | 110.2 |
| [YOLOv8l-seg](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8l-seg.pt) | 640 | 52.3 | 42.6 | 572.4 | 2.79 | 46.0 | 220.5 |
| [YOLOv8x-seg](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8x-seg.pt) | 640 | 53.4 | 43.4 | 712.1 | 4.02 | 71.8 | 344.1 |
- **mAP<sup>val</sup>** 结果都在 [COCO val2017](http://cocodataset.org) 数据集上,使用单模型单尺度测试得到。 See full `predict` mode details in the [Predict](https://docs.ultralytics.com/modes/predict/) page.
<br>复现命令 `yolo val segment data=coco.yaml device=0`
- **推理速度**使用 COCO
验证集图片推理时间进行平均得到,测试环境使用 [Amazon EC2 P4d](https://aws.amazon.com/ec2/instance-types/p4/) 实例。
<br>复现命令 `yolo val segment data=coco128-seg.yaml batch=1 device=0|cpu`
</details> ## Export
<details><summary>分类</summary> Export a YOLOv8n Pose model to a different format like ONNX, CoreML, etc.
| 模型 | 尺寸<br><sup>(像素) | acc<br><sup>top1 | acc<br><sup>top5 | 推理速度<br><sup>CPU ONNX<br>(ms) | 推理速度<br><sup>A100 TensorRT<br>(ms) | 参数量<br><sup>(M) | FLOPs<br><sup>(B) at 640 | ### Python
| -------------------------------------------------------------------------------------------- | --------------- | ---------------- | ---------------- | ----------------------------- | ---------------------------------- | --------------- | ------------------------ |
| [YOLOv8n-cls](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n-cls.pt) | 224 | 66.6 | 87.0 | 12.9 | 0.31 | 2.7 | 4.3 |
| [YOLOv8s-cls](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8s-cls.pt) | 224 | 72.3 | 91.1 | 23.4 | 0.35 | 6.4 | 13.5 |
| [YOLOv8m-cls](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8m-cls.pt) | 224 | 76.4 | 93.2 | 85.4 | 0.62 | 17.0 | 42.7 |
| [YOLOv8l-cls](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8l-cls.pt) | 224 | 78.0 | 94.1 | 163.0 | 0.87 | 37.5 | 99.7 |
| [YOLOv8x-cls](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8x-cls.pt) | 224 | 78.4 | 94.3 | 232.0 | 1.01 | 57.4 | 154.8 |
- **acc** 都在 [ImageNet](https://www.image-net.org/) 数据集上,使用单模型单尺度测试得到。 ```python
<br>复现命令 `yolo val classify data=path/to/ImageNet device=0` from ultralytics import YOLO
- **推理速度**使用 ImageNet
验证集图片推理时间进行平均得到,测试环境使用 [Amazon EC2 P4d](https://aws.amazon.com/ec2/instance-types/p4/) 实例。
<br>复现命令 `yolo val classify data=path/to/ImageNet batch=1 device=0|cpu`
</details> # Load a model
model = YOLO("yolov8n-pose.pt") # load an official model
model = YOLO("path/to/best.pt") # load a custom trained
<details><summary>Pose</summary> # Export the model
model.export(format="onnx")
```
See [Pose Docs](https://docs.ultralytics.com/tasks/) for usage examples with these models. ### CLI
| Model | size<br><sup>(pixels) | mAP<sup>box<br>50-95 | mAP<sup>pose<br>50-95 | Speed<br><sup>CPU ONNX<br>(ms) | Speed<br><sup>A100 TensorRT<br>(ms) | params<br><sup>(M) | FLOPs<br><sup>(B) | ```bash
| ---------------------------------------------------------------------------------------------------- | --------------------- | -------------------- | --------------------- | ------------------------------ | ----------------------------------- | ------------------ | ----------------- | yolo export model=yolov8n-pose.pt format=onnx # export official model
| [YOLOv8n-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n-pose.pt) | 640 | - | 49.7 | 131.8 | 1.18 | 3.3 | 9.2 | yolo export model=path/to/best.pt format=onnx # export custom trained model
| [YOLOv8s-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8s-pose.pt) | 640 | - | 59.2 | 233.2 | 1.42 | 11.6 | 30.2 | ```
| [YOLOv8m-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8m-pose.pt) | 640 | - | 63.6 | 456.3 | 2.00 | 26.4 | 81.0 |
| [YOLOv8l-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8l-pose.pt) | 640 | - | 67.0 | 784.5 | 2.59 | 44.4 | 168.6 |
| [YOLOv8x-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8x-pose.pt) | 640 | - | 68.9 | 1607.1 | 3.73 | 69.4 | 263.2 |
| [YOLOv8x-pose-p6](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8x-pose-p6.pt) | 1280 | - | 71.5 | 4088.7 | 10.04 | 99.1 | 1066.4 |
- **mAP<sup>val</sup>** values are for single-model single-scale on [COCO Keypoints val2017](http://cocodataset.org) Available YOLOv8-pose export formats are in the table below. You can predict or validate directly on exported models,
dataset. i.e. `yolo predict model=yolov8n-pose.onnx`. Usage examples are shown for your model after export completes.
<br>Reproduce by `yolo val pose data=coco-pose.yaml device=0`
- **Speed** averaged over COCO val images using an [Amazon EC2 P4d](https://aws.amazon.com/ec2/instance-types/p4/) | Format | `format` Argument | Model | Metadata |
instance. | ------------------------------------------------------------------ | ----------------- | ------------------------------ | -------- |
<br>Reproduce by `yolo val pose data=coco8-pose.yaml batch=1 device=0|cpu` | [PyTorch](https://pytorch.org/) | - | `yolov8n-pose.pt` | ✅ |
| [TorchScript](https://pytorch.org/docs/stable/jit.html) | `torchscript` | `yolov8n-pose.torchscript` | ✅ |
</details> | [ONNX](https://onnx.ai/) | `onnx` | `yolov8n-pose.onnx` | ✅ |
| [OpenVINO](https://docs.openvino.ai/latest/index.html) | `openvino` | `yolov8n-pose_openvino_model/` | ✅ |
## <div align="center">模块集成</div> | [TensorRT](https://developer.nvidia.com/tensorrt) | `engine` | `yolov8n-pose.engine` | ✅ |
| [CoreML](https://github.com/apple/coremltools) | `coreml` | `yolov8n-pose.mlmodel` | ✅ |
<br> | [TF SavedModel](https://www.tensorflow.org/guide/saved_model) | `saved_model` | `yolov8n-pose_saved_model/` | ✅ |
<a href="https://bit.ly/ultralytics_hub" target="_blank"> | [TF GraphDef](https://www.tensorflow.org/api_docs/python/tf/Graph) | `pb` | `yolov8n-pose.pb` | ❌ |
<img width="100%" src="https://github.com/ultralytics/assets/raw/main/yolov8/banner-integrations.png"></a> | [TF Lite](https://www.tensorflow.org/lite) | `tflite` | `yolov8n-pose.tflite` | ✅ |
<br> | [TF Edge TPU](https://coral.ai/docs/edgetpu/models-intro/) | `edgetpu` | `yolov8n-pose_edgetpu.tflite` | ✅ |
<br> | [TF.js](https://www.tensorflow.org/js) | `tfjs` | `yolov8n-pose_web_model/` | ✅ |
| [PaddlePaddle](https://github.com/PaddlePaddle) | `paddle` | `yolov8n-pose_paddle_model/` | ✅ |
<div align="center">
<a href="https://roboflow.com/?ref=ultralytics"> See full `export` details in the [Export](https://docs.ultralytics.com/modes/export/) page.
<img src="https://github.com/ultralytics/assets/raw/main/partners/logo-roboflow.png" width="10%" /></a>
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="15%" height="0" alt="" />
<a href="https://cutt.ly/yolov5-readme-clearml">
<img src="https://github.com/ultralytics/assets/raw/main/partners/logo-clearml.png" width="10%" /></a>
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="15%" height="0" alt="" />
<a href="https://bit.ly/yolov8-readme-comet">
<img src="https://github.com/ultralytics/assets/raw/main/partners/logo-comet.png" width="10%" /></a>
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="15%" height="0" alt="" />
<a href="https://bit.ly/yolov5-neuralmagic">
<img src="https://github.com/ultralytics/assets/raw/main/partners/logo-neuralmagic.png" width="10%" /></a>
</div>
| Roboflow | ClearML ⭐ 新 | Comet ⭐ 新 | Neural Magic ⭐ 新 |
| :--------------------------------------------------------------------------------: | :-------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------: |
| 将您的自定义数据集进行标注并直接导出到 YOLOv8 以进行训练 [Roboflow](https://roboflow.com/?ref=ultralytics) | 自动跟踪、可视化甚至远程训练 YOLOv8 [ClearML](https://cutt.ly/yolov5-readme-clearml)(开源!) | 永远免费,[Comet](https://bit.ly/yolov8-readme-comet)可让您保存 YOLOv8 模型、恢复训练以及交互式可视化和调试预测 | 使用 [Neural Magic DeepSparse](https://bit.ly/yolov5-neuralmagic),运行 YOLOv8 推理的速度最高可提高6倍 |
## <div align="center">Ultralytics HUB</div>
[Ultralytics HUB](https://bit.ly/ultralytics_hub) 是我们⭐ **新**的无代码解决方案,用于可视化数据集,训练 YOLOv8🚀
模型,并以无缝体验方式部署到现实世界。现在开始**免费**!
还可以通过下载 [Ultralytics App](https://ultralytics.com/app_install) 在你的 iOS 或 Android 设备上运行 YOLOv8 模型!
<a href="https://bit.ly/ultralytics_hub" target="_blank">
<img width="100%" src="https://github.com/ultralytics/assets/raw/main/im/ultralytics-hub.png"></a>
## <div align="center">贡献</div>
我们喜欢您的意见或建议!我们希望尽可能简单和透明地为 YOLOv8 做出贡献。请看我们的 [贡献指南](CONTRIBUTING.md)
,并填写 [调查问卷](https://ultralytics.com/survey?utm_source=github&utm_medium=social&utm_campaign=Survey)
向我们发送您的体验反馈。感谢我们所有的贡献者!
<!-- SVG image from https://opencollective.com/ultralytics/contributors.svg?width=990 -->
<a href="https://github.com/ultralytics/yolov5/graphs/contributors">
<img width="100%" src="https://github.com/ultralytics/assets/raw/main/im/image-contributors.png"></a>
## <div align="center">License</div>
YOLOv8 在两种不同的 License 下可用:
- **GPL-3.0 License**: 查看 [License](https://github.com/ultralytics/ultralytics/blob/main/LICENSE) 文件的详细信息。
- **企业License**:在没有 GPL-3.0 开源要求的情况下为商业产品开发提供更大的灵活性。典型用例是将 Ultralytics 软件和 AI
模型嵌入到商业产品和应用程序中。在以下位置申请企业许可证 [Ultralytics 许可](https://ultralytics.com/license) 。
## <div align="center">联系我们</div>
请访问 [GitHub Issues](https://github.com/ultralytics/ultralytics/issues)
或 [Ultralytics Community Forum](https://community.ultralytics.com) 以报告 YOLOv8 错误和请求功能。
<br>
<div align="center">
<a href="https://github.com/ultralytics" style="text-decoration:none;">
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-github.png" width="3%" alt="" /></a>
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="" />
<a href="https://www.linkedin.com/company/ultralytics" style="text-decoration:none;">
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-linkedin.png" width="3%" alt="" /></a>
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="" />
<a href="https://twitter.com/ultralytics" style="text-decoration:none;">
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-twitter.png" width="3%" alt="" /></a>
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="" />
<a href="https://youtube.com/ultralytics" style="text-decoration:none;">
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-youtube.png" width="3%" alt="" /></a>
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="" />
<a href="https://www.tiktok.com/@ultralytics" style="text-decoration:none;">
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-tiktok.png" width="3%" alt="" /></a>
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="" />
<a href="https://www.instagram.com/ultralytics/" style="text-decoration:none;">
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-instagram.png" width="3%" alt="" /></a>
</div>

@ -75,7 +75,7 @@ task.
| `image_weights` | `False` | use weighted image selection for training | | `image_weights` | `False` | use weighted image selection for training |
| `rect` | `False` | rectangular training with each batch collated for minimum padding | | `rect` | `False` | rectangular training with each batch collated for minimum padding |
| `cos_lr` | `False` | use cosine learning rate scheduler | | `cos_lr` | `False` | use cosine learning rate scheduler |
| `close_mosaic` | `10` | disable mosaic augmentation for final 10 epochs | | `close_mosaic` | `0` | (int) disable mosaic augmentation for final epochs |
| `resume` | `False` | resume training from last checkpoint | | `resume` | `False` | resume training from last checkpoint |
| `amp` | `True` | Automatic Mixed Precision (AMP) training, choices=[True, False] | | `amp` | `True` | Automatic Mixed Precision (AMP) training, choices=[True, False] |
| `lr0` | `0.01` | initial learning rate (i.e. SGD=1E-2, Adam=1E-3) | | `lr0` | `0.01` | initial learning rate (i.e. SGD=1E-2, Adam=1E-3) |

@ -23,14 +23,14 @@ the [ImageNet](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/
[Models](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/models) download automatically from the latest [Models](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/models) download automatically from the latest
Ultralytics [release](https://github.com/ultralytics/assets/releases) on first use. Ultralytics [release](https://github.com/ultralytics/assets/releases) on first use.
| Model | size<br><sup>(pixels) | mAP<sup>box<br>50-95 | mAP<sup>pose<br>50-95 | Speed<br><sup>CPU ONNX<br>(ms) | Speed<br><sup>A100 TensorRT<br>(ms) | params<br><sup>(M) | FLOPs<br><sup>(B) | | Model | size<br><sup>(pixels) | mAP<sup>pose<br>50-95 | mAP<sup>pose<br>50 | Speed<br><sup>CPU ONNX<br>(ms) | Speed<br><sup>A100 TensorRT<br>(ms) | params<br><sup>(M) | FLOPs<br><sup>(B) |
|------------------------------------------------------------------------------------------------------|-----------------------|----------------------|-----------------------|--------------------------------|-------------------------------------|--------------------|-------------------| | ---------------------------------------------------------------------------------------------------- | --------------------- | -------------------- | ------------------ | ------------------------------ | ----------------------------------- | ------------------ | ----------------- |
| [YOLOv8n-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n-pose.pt) | 640 | - | 49.7 | 131.8 | 1.18 | 3.3 | 9.2 | | [YOLOv8n-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n-pose.pt) | 640 | 49.7 | 79.7 | 131.8 | 1.18 | 3.3 | 9.2 |
| [YOLOv8s-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8s-pose.pt) | 640 | - | 59.2 | 233.2 | 1.42 | 11.6 | 30.2 | | [YOLOv8s-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8s-pose.pt) | 640 | 59.2 | 85.8 | 233.2 | 1.42 | 11.6 | 30.2 |
| [YOLOv8m-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8m-pose.pt) | 640 | - | 63.6 | 456.3 | 2.00 | 26.4 | 81.0 | | [YOLOv8m-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8m-pose.pt) | 640 | 63.6 | 88.8 | 456.3 | 2.00 | 26.4 | 81.0 |
| [YOLOv8l-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8l-pose.pt) | 640 | - | 67.0 | 784.5 | 2.59 | 44.4 | 168.6 | | [YOLOv8l-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8l-pose.pt) | 640 | 67.0 | 89.9 | 784.5 | 2.59 | 44.4 | 168.6 |
| [YOLOv8x-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8x-pose.pt) | 640 | - | 68.9 | 1607.1 | 3.73 | 69.4 | 263.2 | | [YOLOv8x-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8x-pose.pt) | 640 | 68.9 | 90.4 | 1607.1 | 3.73 | 69.4 | 263.2 |
| [YOLOv8x-pose-p6](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8x-pose-p6.pt) | 1280 | - | 71.5 | 4088.7 | 10.04 | 99.1 | 1066.4 | | [YOLOv8x-pose-p6](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8x-pose-p6.pt) | 1280 | 71.5 | 91.3 | 4088.7 | 10.04 | 99.1 | 1066.4 |
- **mAP<sup>val</sup>** values are for single-model single-scale on [COCO Keypoints val2017](http://cocodataset.org) - **mAP<sup>val</sup>** values are for single-model single-scale on [COCO Keypoints val2017](http://cocodataset.org)
dataset. dataset.

@ -97,7 +97,7 @@ The training settings for YOLO models encompass various hyperparameters and conf
| `image_weights` | `False` | use weighted image selection for training | | `image_weights` | `False` | use weighted image selection for training |
| `rect` | `False` | rectangular training with each batch collated for minimum padding | | `rect` | `False` | rectangular training with each batch collated for minimum padding |
| `cos_lr` | `False` | use cosine learning rate scheduler | | `cos_lr` | `False` | use cosine learning rate scheduler |
| `close_mosaic` | `10` | disable mosaic augmentation for final 10 epochs | | `close_mosaic` | `0` | (int) disable mosaic augmentation for final epochs |
| `resume` | `False` | resume training from last checkpoint | | `resume` | `False` | resume training from last checkpoint |
| `amp` | `True` | Automatic Mixed Precision (AMP) training, choices=[True, False] | | `amp` | `True` | Automatic Mixed Precision (AMP) training, choices=[True, False] |
| `lr0` | `0.01` | initial learning rate (i.e. SGD=1E-2, Adam=1E-3) | | `lr0` | `0.01` | initial learning rate (i.e. SGD=1E-2, Adam=1E-3) |

@ -25,7 +25,7 @@ Creating a custom model to detect your objects is an iterative process of collec
YOLOv5 models must be trained on labelled data in order to learn classes of objects in that data. There are two options for creating your dataset before you start training: YOLOv5 models must be trained on labelled data in order to learn classes of objects in that data. There are two options for creating your dataset before you start training:
<details markdown> <details markdown>
<summary>Use Roboflow to manage your dataset in YOLO format</summary> <summary>Use <a href="https://roboflow.com/?ref=ultralytics">Roboflow</a> to create your dataset in YOLO format</summary>
### 1.1 Collect Images ### 1.1 Collect Images

@ -59,21 +59,21 @@
"colab": { "colab": {
"base_uri": "https://localhost:8080/" "base_uri": "https://localhost:8080/"
}, },
"outputId": "ea235da2-8fb5-4094-9dc2-8523d0800a22" "outputId": "2ea6e0b9-1a62-4355-c246-5e8b7b1dafff"
}, },
"source": [ "source": [
"%pip install ultralytics\n", "%pip install ultralytics\n",
"import ultralytics\n", "import ultralytics\n",
"ultralytics.checks()" "ultralytics.checks()"
], ],
"execution_count": null, "execution_count": 1,
"outputs": [ "outputs": [
{ {
"output_type": "stream", "output_type": "stream",
"name": "stderr", "name": "stderr",
"text": [ "text": [
"Ultralytics YOLOv8.0.57 🚀 Python-3.9.16 torch-1.13.1+cu116 CUDA:0 (Tesla T4, 15102MiB)\n", "Ultralytics YOLOv8.0.71 🚀 Python-3.9.16 torch-2.0.0+cu118 CUDA:0 (Tesla T4, 15102MiB)\n",
"Setup complete ✅ (2 CPUs, 12.7 GB RAM, 25.9/166.8 GB disk)\n" "Setup complete ✅ (2 CPUs, 12.7 GB RAM, 23.3/166.8 GB disk)\n"
] ]
} }
] ]
@ -96,24 +96,28 @@
"colab": { "colab": {
"base_uri": "https://localhost:8080/" "base_uri": "https://localhost:8080/"
}, },
"outputId": "fe0a5a26-3bcc-4c1f-e688-cae00ee5b958" "outputId": "c578afbd-47cd-4d11-beec-8b5c31fcfba8"
}, },
"source": [ "source": [
"# Run inference on an image with YOLOv8n\n", "# Run inference on an image with YOLOv8n\n",
"!yolo predict model=yolov8n.pt source='https://ultralytics.com/images/zidane.jpg'" "!yolo predict model=yolov8n.pt source='https://ultralytics.com/images/zidane.jpg'"
], ],
"execution_count": null, "execution_count": 2,
"outputs": [ "outputs": [
{ {
"output_type": "stream", "output_type": "stream",
"name": "stdout", "name": "stdout",
"text": [ "text": [
"Ultralytics YOLOv8.0.57 🚀 Python-3.9.16 torch-1.13.1+cu116 CUDA:0 (Tesla T4, 15102MiB)\n", "Downloading https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n.pt to yolov8n.pt...\n",
"100% 6.23M/6.23M [00:00<00:00, 195MB/s]\n",
"Ultralytics YOLOv8.0.71 🚀 Python-3.9.16 torch-2.0.0+cu118 CUDA:0 (Tesla T4, 15102MiB)\n",
"YOLOv8n summary (fused): 168 layers, 3151904 parameters, 0 gradients, 8.7 GFLOPs\n", "YOLOv8n summary (fused): 168 layers, 3151904 parameters, 0 gradients, 8.7 GFLOPs\n",
"\n", "\n",
"Found https://ultralytics.com/images/zidane.jpg locally at zidane.jpg\n", "Downloading https://ultralytics.com/images/zidane.jpg to zidane.jpg...\n",
"image 1/1 /content/zidane.jpg: 384x640 2 persons, 1 tie, 14.3ms\n", "100% 165k/165k [00:00<00:00, 51.7MB/s]\n",
"Speed: 0.5ms preprocess, 14.3ms inference, 1.8ms postprocess per image at shape (1, 3, 640, 640)\n" "image 1/1 /content/zidane.jpg: 384x640 2 persons, 1 tie, 60.9ms\n",
"Speed: 0.6ms preprocess, 60.9ms inference, 301.3ms postprocess per image at shape (1, 3, 640, 640)\n",
"Results saved to \u001b[1mruns/detect/predict\u001b[0m\n"
] ]
} }
] ]
@ -156,7 +160,7 @@
"cell_type": "code", "cell_type": "code",
"metadata": { "metadata": {
"id": "X58w8JLpMnjH", "id": "X58w8JLpMnjH",
"outputId": "ae2040df-0f95-4701-c680-8bbb7be92bcd", "outputId": "3e5a9c48-8eba-45eb-d92f-8456cf94b60e",
"colab": { "colab": {
"base_uri": "https://localhost:8080/" "base_uri": "https://localhost:8080/"
} }
@ -165,26 +169,26 @@
"# Validate YOLOv8n on COCO128 val\n", "# Validate YOLOv8n on COCO128 val\n",
"!yolo val model=yolov8n.pt data=coco128.yaml" "!yolo val model=yolov8n.pt data=coco128.yaml"
], ],
"execution_count": null, "execution_count": 3,
"outputs": [ "outputs": [
{ {
"output_type": "stream", "output_type": "stream",
"name": "stdout", "name": "stdout",
"text": [ "text": [
"Ultralytics YOLOv8.0.57 🚀 Python-3.9.16 torch-1.13.1+cu116 CUDA:0 (Tesla T4, 15102MiB)\n", "Ultralytics YOLOv8.0.71 🚀 Python-3.9.16 torch-2.0.0+cu118 CUDA:0 (Tesla T4, 15102MiB)\n",
"YOLOv8n summary (fused): 168 layers, 3151904 parameters, 0 gradients, 8.7 GFLOPs\n", "YOLOv8n summary (fused): 168 layers, 3151904 parameters, 0 gradients, 8.7 GFLOPs\n",
"\n", "\n",
"Dataset 'coco128.yaml' images not found ⚠, missing paths ['/content/datasets/coco128/images/train2017']\n", "Dataset 'coco128.yaml' images not found ⚠, missing paths ['/content/datasets/coco128/images/train2017']\n",
"Downloading https://ultralytics.com/assets/coco128.zip to /content/datasets/coco128.zip...\n", "Downloading https://ultralytics.com/assets/coco128.zip to /content/datasets/coco128.zip...\n",
"100% 6.66M/6.66M [00:00<00:00, 87.2MB/s]\n", "100% 6.66M/6.66M [00:01<00:00, 6.80MB/s]\n",
"Unzipping /content/datasets/coco128.zip to /content/datasets...\n", "Unzipping /content/datasets/coco128.zip to /content/datasets...\n",
"Dataset download success ✅ (0.4s), saved to \u001b[1m/content/datasets\u001b[0m\n", "Dataset download success ✅ (2.2s), saved to \u001b[1m/content/datasets\u001b[0m\n",
"\n", "\n",
"Downloading https://ultralytics.com/assets/Arial.ttf to /root/.config/Ultralytics/Arial.ttf...\n", "Downloading https://ultralytics.com/assets/Arial.ttf to /root/.config/Ultralytics/Arial.ttf...\n",
"100% 755k/755k [00:00<00:00, 16.9MB/s]\n", "100% 755k/755k [00:00<00:00, 107MB/s]\n",
"\u001b[34m\u001b[1mval: \u001b[0mScanning /content/datasets/coco128/labels/train2017... 126 images, 2 backgrounds, 0 corrupt: 100% 128/128 [00:00<00:00, 2007.12it/s]\n", "\u001b[34m\u001b[1mval: \u001b[0mScanning /content/datasets/coco128/labels/train2017... 126 images, 2 backgrounds, 80 corrupt: 100% 128/128 [00:00<00:00, 1183.28it/s]\n",
"\u001b[34m\u001b[1mval: \u001b[0mNew cache created: /content/datasets/coco128/labels/train2017.cache\n", "\u001b[34m\u001b[1mval: \u001b[0mNew cache created: /content/datasets/coco128/labels/train2017.cache\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% 8/8 [00:08<00:00, 1.04s/it]\n", " Class Images Instances Box(P R mAP50 mAP50-95): 100% 8/8 [00:12<00:00, 1.54s/it]\n",
" all 128 929 0.64 0.537 0.605 0.446\n", " all 128 929 0.64 0.537 0.605 0.446\n",
" person 128 254 0.797 0.677 0.764 0.538\n", " person 128 254 0.797 0.677 0.764 0.538\n",
" bicycle 128 6 0.514 0.333 0.315 0.264\n", " bicycle 128 6 0.514 0.333 0.315 0.264\n",
@ -257,7 +261,7 @@
" scissors 128 1 1 0 0.249 0.0746\n", " scissors 128 1 1 0 0.249 0.0746\n",
" teddy bear 128 21 0.877 0.333 0.591 0.394\n", " teddy bear 128 21 0.877 0.333 0.591 0.394\n",
" toothbrush 128 5 0.743 0.6 0.638 0.374\n", " toothbrush 128 5 0.743 0.6 0.638 0.374\n",
"Speed: 2.9ms preprocess, 6.2ms inference, 0.0ms loss, 5.1ms postprocess per image\n", "Speed: 5.3ms preprocess, 20.1ms inference, 0.0ms loss, 11.7ms postprocess per image\n",
"Results saved to \u001b[1mruns/detect/val\u001b[0m\n" "Results saved to \u001b[1mruns/detect/val\u001b[0m\n"
] ]
} }
@ -271,7 +275,7 @@
"source": [ "source": [
"# 3. Train\n", "# 3. Train\n",
"\n", "\n",
"<p align=\"\"><a href=\"https://roboflow.com/?ref=ultralytics\"><img width=\"1000\" src=\"https://github.com/ultralytics/assets/raw/main/yolov8/banner-integrations.png\"/></a></p>\n", "<p align=\"\"><a href=\"https://bit.ly/ultralytics_hub\"><img width=\"1000\" src=\"https://github.com/ultralytics/assets/raw/main/yolov8/banner-integrations.png\"/></a></p>\n",
"\n", "\n",
"Train YOLOv8 on [Detect](https://docs.ultralytics.com/tasks/detect/), [Segment](https://docs.ultralytics.com/tasks/segment/), [Classify](https://docs.ultralytics.com/tasks/classify/) and [Pose](https://docs.ultralytics.com/tasks/pose/) datasets. See [YOLOv8 Train Docs](https://docs.ultralytics.com/modes/train/) for more information." "Train YOLOv8 on [Detect](https://docs.ultralytics.com/tasks/detect/), [Segment](https://docs.ultralytics.com/tasks/segment/), [Classify](https://docs.ultralytics.com/tasks/classify/) and [Pose](https://docs.ultralytics.com/tasks/pose/) datasets. See [YOLOv8 Train Docs](https://docs.ultralytics.com/modes/train/) for more information."
] ]
@ -280,7 +284,7 @@
"cell_type": "code", "cell_type": "code",
"metadata": { "metadata": {
"id": "1NcFxRcFdJ_O", "id": "1NcFxRcFdJ_O",
"outputId": "fcb5e3da-3766-4c72-97e1-73c1bd2ccbef", "outputId": "b60a1f74-8035-4f9e-b4b0-604f9cf76231",
"colab": { "colab": {
"base_uri": "https://localhost:8080/" "base_uri": "https://localhost:8080/"
} }
@ -289,14 +293,14 @@
"# Train YOLOv8n on COCO128 for 3 epochs\n", "# Train YOLOv8n on COCO128 for 3 epochs\n",
"!yolo train model=yolov8n.pt data=coco128.yaml epochs=3 imgsz=640" "!yolo train model=yolov8n.pt data=coco128.yaml epochs=3 imgsz=640"
], ],
"execution_count": null, "execution_count": 4,
"outputs": [ "outputs": [
{ {
"output_type": "stream", "output_type": "stream",
"name": "stdout", "name": "stdout",
"text": [ "text": [
"Ultralytics YOLOv8.0.57 🚀 Python-3.9.16 torch-1.13.1+cu116 CUDA:0 (Tesla T4, 15102MiB)\n", "Ultralytics YOLOv8.0.71 🚀 Python-3.9.16 torch-2.0.0+cu118 CUDA:0 (Tesla T4, 15102MiB)\n",
"\u001b[34m\u001b[1myolo/engine/trainer: \u001b[0mtask=detect, mode=train, model=yolov8n.pt, data=coco128.yaml, epochs=3, patience=50, batch=16, imgsz=640, save=True, save_period=-1, cache=False, device=None, workers=8, project=None, name=None, exist_ok=False, pretrained=False, optimizer=SGD, verbose=True, seed=0, deterministic=True, single_cls=False, image_weights=False, rect=False, cos_lr=False, close_mosaic=10, resume=False, amp=True, overlap_mask=True, mask_ratio=4, dropout=0.0, val=True, split=val, save_json=False, save_hybrid=False, conf=None, iou=0.7, max_det=300, half=False, dnn=False, plots=True, source=None, show=False, save_txt=False, save_conf=False, save_crop=False, hide_labels=False, hide_conf=False, vid_stride=1, line_thickness=3, visualize=False, augment=False, agnostic_nms=False, classes=None, retina_masks=False, boxes=True, format=torchscript, keras=False, optimize=False, int8=False, dynamic=False, simplify=False, opset=None, workspace=4, nms=False, lr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=7.5, cls=0.5, dfl=1.5, label_smoothing=0.0, nbs=64, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0, cfg=None, v5loader=False, tracker=botsort.yaml, save_dir=runs/detect/train\n", "\u001b[34m\u001b[1myolo/engine/trainer: \u001b[0mtask=detect, mode=train, model=yolov8n.pt, data=coco128.yaml, epochs=3, patience=50, batch=16, imgsz=640, save=True, save_period=-1, cache=False, device=None, workers=8, project=None, name=None, exist_ok=False, pretrained=False, optimizer=SGD, verbose=True, seed=0, deterministic=True, single_cls=False, image_weights=False, rect=False, cos_lr=False, close_mosaic=0, resume=False, amp=True, overlap_mask=True, mask_ratio=4, dropout=0.0, val=True, split=val, save_json=False, save_hybrid=False, conf=None, iou=0.7, max_det=300, half=False, dnn=False, plots=True, source=None, show=False, save_txt=False, save_conf=False, save_crop=False, show_labels=True, show_conf=True, vid_stride=1, line_thickness=3, visualize=False, augment=False, agnostic_nms=False, classes=None, retina_masks=False, boxes=True, format=torchscript, keras=False, optimize=False, int8=False, dynamic=False, simplify=False, opset=None, workspace=4, nms=False, lr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=7.5, cls=0.5, dfl=1.5, pose=12.0, kobj=1.0, label_smoothing=0.0, nbs=64, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0, cfg=None, v5loader=False, tracker=botsort.yaml, save_dir=runs/detect/train\n",
"\n", "\n",
" from n params module arguments \n", " from n params module arguments \n",
" 0 -1 1 464 ultralytics.nn.modules.Conv [3, 16, 3, 2] \n", " 0 -1 1 464 ultralytics.nn.modules.Conv [3, 16, 3, 2] \n",
@ -325,18 +329,13 @@
"Model summary: 225 layers, 3157200 parameters, 3157184 gradients, 8.9 GFLOPs\n", "Model summary: 225 layers, 3157200 parameters, 3157184 gradients, 8.9 GFLOPs\n",
"\n", "\n",
"Transferred 355/355 items from pretrained weights\n", "Transferred 355/355 items from pretrained weights\n",
"2023-03-26 14:57:47.224672: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA\n",
"To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.\n",
"2023-03-26 14:57:48.209047: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/lib/python3.9/dist-packages/cv2/../../lib64:/usr/local/lib/python3.9/dist-packages/cv2/../../lib64:/usr/lib64-nvidia\n",
"2023-03-26 14:57:48.209179: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7'; dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/lib/python3.9/dist-packages/cv2/../../lib64:/usr/local/lib/python3.9/dist-packages/cv2/../../lib64:/usr/lib64-nvidia\n",
"2023-03-26 14:57:48.209199: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.\n",
"\u001b[34m\u001b[1mTensorBoard: \u001b[0mStart with 'tensorboard --logdir runs/detect/train', view at http://localhost:6006/\n", "\u001b[34m\u001b[1mTensorBoard: \u001b[0mStart with 'tensorboard --logdir runs/detect/train', view at http://localhost:6006/\n",
"\u001b[34m\u001b[1mAMP: \u001b[0mrunning Automatic Mixed Precision (AMP) checks with YOLOv8n...\n", "\u001b[34m\u001b[1mAMP: \u001b[0mrunning Automatic Mixed Precision (AMP) checks with YOLOv8n...\n",
"\u001b[34m\u001b[1mAMP: \u001b[0mchecks passed ✅\n", "\u001b[34m\u001b[1mAMP: \u001b[0mchecks passed ✅\n",
"\u001b[34m\u001b[1moptimizer:\u001b[0m SGD(lr=0.01) with parameter groups 57 weight(decay=0.0), 64 weight(decay=0.0005), 63 bias\n", "\u001b[34m\u001b[1moptimizer:\u001b[0m SGD(lr=0.01) with parameter groups 57 weight(decay=0.0), 64 weight(decay=0.0005), 63 bias\n",
"\u001b[34m\u001b[1mtrain: \u001b[0mScanning /content/datasets/coco128/labels/train2017.cache... 126 images, 2 backgrounds, 0 corrupt: 100% 128/128 [00:00<?, ?it/s]\n", "\u001b[34m\u001b[1mtrain: \u001b[0mScanning /content/datasets/coco128/labels/train2017.cache... 126 images, 2 backgrounds, 80 corrupt: 100% 128/128 [00:00<?, ?it/s]\n",
"\u001b[34m\u001b[1malbumentations: \u001b[0mBlur(p=0.01, blur_limit=(3, 7)), MedianBlur(p=0.01, blur_limit=(3, 7)), ToGray(p=0.01), CLAHE(p=0.01, clip_limit=(1, 4.0), tile_grid_size=(8, 8))\n", "\u001b[34m\u001b[1malbumentations: \u001b[0mBlur(p=0.01, blur_limit=(3, 7)), MedianBlur(p=0.01, blur_limit=(3, 7)), ToGray(p=0.01), CLAHE(p=0.01, clip_limit=(1, 4.0), tile_grid_size=(8, 8))\n",
"\u001b[34m\u001b[1mval: \u001b[0mScanning /content/datasets/coco128/labels/train2017.cache... 126 images, 2 backgrounds, 0 corrupt: 100% 128/128 [00:00<?, ?it/s]\n", "\u001b[34m\u001b[1mval: \u001b[0mScanning /content/datasets/coco128/labels/train2017.cache... 126 images, 2 backgrounds, 80 corrupt: 100% 128/128 [00:00<?, ?it/s]\n",
"Plotting labels to runs/detect/train/labels.jpg... \n", "Plotting labels to runs/detect/train/labels.jpg... \n",
"Image sizes 640 train, 640 val\n", "Image sizes 640 train, 640 val\n",
"Using 2 dataloader workers\n", "Using 2 dataloader workers\n",
@ -344,101 +343,101 @@
"Starting training for 3 epochs...\n", "Starting training for 3 epochs...\n",
"\n", "\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n", " Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 1/3 2.77G 1.221 1.429 1.241 196 640: 100% 8/8 [00:10<00:00, 1.34s/it]\n", " 1/3 2.78G 1.177 1.338 1.25 230 640: 100% 8/8 [00:06<00:00, 1.21it/s]\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% 4/4 [00:02<00:00, 1.70it/s]\n", " Class Images Instances Box(P R mAP50 mAP50-95): 100% 4/4 [00:04<00:00, 1.21s/it]\n",
" all 128 929 0.674 0.517 0.616 0.456\n", " all 128 929 0.631 0.549 0.614 0.455\n",
"\n", "\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n", " Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 2/3 3.61G 1.186 1.306 1.255 287 640: 100% 8/8 [00:05<00:00, 1.58it/s]\n", " 2/3 2.69G 1.131 1.405 1.24 179 640: 100% 8/8 [00:02<00:00, 3.13it/s]\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% 4/4 [00:02<00:00, 1.83it/s]\n", " Class Images Instances Box(P R mAP50 mAP50-95): 100% 4/4 [00:02<00:00, 1.51it/s]\n",
" all 128 929 0.644 0.599 0.638 0.473\n", " all 128 929 0.669 0.569 0.634 0.478\n",
"\n", "\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n", " Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 3/3 3.61G 1.169 1.405 1.266 189 640: 100% 8/8 [00:04<00:00, 1.65it/s]\n", " 3/3 2.84G 1.151 1.281 1.212 214 640: 100% 8/8 [00:02<00:00, 3.27it/s]\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% 4/4 [00:06<00:00, 1.59s/it]\n", " Class Images Instances Box(P R mAP50 mAP50-95): 100% 4/4 [00:09<00:00, 2.42s/it]\n",
" all 128 929 0.63 0.607 0.641 0.48\n", " all 128 929 0.687 0.58 0.65 0.488\n",
"\n", "\n",
"3 epochs completed in 0.011 hours.\n", "3 epochs completed in 0.010 hours.\n",
"Optimizer stripped from runs/detect/train/weights/last.pt, 6.5MB\n", "Optimizer stripped from runs/detect/train/weights/last.pt, 6.5MB\n",
"Optimizer stripped from runs/detect/train/weights/best.pt, 6.5MB\n", "Optimizer stripped from runs/detect/train/weights/best.pt, 6.5MB\n",
"\n", "\n",
"Validating runs/detect/train/weights/best.pt...\n", "Validating runs/detect/train/weights/best.pt...\n",
"Ultralytics YOLOv8.0.57 🚀 Python-3.9.16 torch-1.13.1+cu116 CUDA:0 (Tesla T4, 15102MiB)\n", "Ultralytics YOLOv8.0.71 🚀 Python-3.9.16 torch-2.0.0+cu118 CUDA:0 (Tesla T4, 15102MiB)\n",
"Model summary (fused): 168 layers, 3151904 parameters, 0 gradients, 8.7 GFLOPs\n", "Model summary (fused): 168 layers, 3151904 parameters, 0 gradients, 8.7 GFLOPs\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% 4/4 [00:06<00:00, 1.66s/it]\n", " Class Images Instances Box(P R mAP50 mAP50-95): 100% 4/4 [00:06<00:00, 1.63s/it]\n",
" all 128 929 0.632 0.597 0.639 0.479\n", " all 128 929 0.689 0.578 0.65 0.486\n",
" person 128 254 0.708 0.693 0.766 0.55\n", " person 128 254 0.763 0.673 0.769 0.544\n",
" bicycle 128 6 0.458 0.333 0.323 0.254\n", " bicycle 128 6 1 0.328 0.379 0.332\n",
" car 128 46 0.763 0.217 0.287 0.181\n", " car 128 46 0.84 0.217 0.292 0.18\n",
" motorcycle 128 5 0.542 0.8 0.895 0.727\n", " motorcycle 128 5 0.612 0.8 0.872 0.709\n",
" airplane 128 6 0.744 0.833 0.903 0.695\n", " airplane 128 6 0.766 0.833 0.894 0.694\n",
" bus 128 7 0.699 0.714 0.724 0.64\n", " bus 128 7 0.748 0.714 0.721 0.675\n",
" train 128 3 0.73 0.919 0.913 0.797\n", " train 128 3 0.686 1 0.913 0.83\n",
" truck 128 12 0.747 0.5 0.497 0.324\n", " truck 128 12 0.889 0.5 0.529 0.342\n",
" boat 128 6 0.365 0.333 0.393 0.291\n", " boat 128 6 0.393 0.333 0.44 0.216\n",
" traffic light 128 14 0.708 0.214 0.202 0.139\n", " traffic light 128 14 1 0.21 0.224 0.142\n",
" stop sign 128 2 1 0.953 0.995 0.666\n", " stop sign 128 2 1 0.977 0.995 0.697\n",
" bench 128 9 0.754 0.556 0.606 0.412\n", " bench 128 9 0.795 0.434 0.658 0.418\n",
" bird 128 16 0.929 0.819 0.948 0.643\n", " bird 128 16 0.933 0.868 0.955 0.656\n",
" cat 128 4 0.864 1 0.995 0.778\n", " cat 128 4 0.796 1 0.995 0.786\n",
" dog 128 9 0.598 0.828 0.834 0.627\n", " dog 128 9 0.713 0.889 0.823 0.608\n",
" horse 128 2 0.679 1 0.995 0.547\n", " horse 128 2 0.576 1 0.995 0.547\n",
" elephant 128 17 0.757 0.882 0.929 0.722\n", " elephant 128 17 0.786 0.824 0.911 0.719\n",
" bear 128 1 0.593 1 0.995 0.995\n", " bear 128 1 0.432 1 0.995 0.895\n",
" zebra 128 4 0.851 1 0.995 0.966\n", " zebra 128 4 0.86 1 0.995 0.935\n",
" giraffe 128 9 0.838 1 0.984 0.681\n", " giraffe 128 9 0.966 1 0.995 0.727\n",
" backpack 128 6 0.473 0.333 0.342 0.217\n", " backpack 128 6 0.534 0.333 0.399 0.227\n",
" umbrella 128 18 0.569 0.667 0.708 0.454\n", " umbrella 128 18 0.757 0.519 0.665 0.447\n",
" handbag 128 19 0.649 0.105 0.233 0.137\n", " handbag 128 19 0.939 0.105 0.25 0.14\n",
" tie 128 7 0.608 0.714 0.614 0.428\n", " tie 128 7 0.677 0.602 0.682 0.505\n",
" suitcase 128 4 0.471 1 0.745 0.54\n", " suitcase 128 4 0.636 1 0.995 0.646\n",
" frisbee 128 5 0.629 0.8 0.732 0.64\n", " frisbee 128 5 1 0.789 0.799 0.689\n",
" skis 128 1 0.699 1 0.995 0.522\n", " skis 128 1 0.794 1 0.995 0.497\n",
" snowboard 128 7 0.654 0.714 0.758 0.497\n", " snowboard 128 7 0.575 0.714 0.762 0.48\n",
" sports ball 128 6 0.707 0.415 0.515 0.288\n", " sports ball 128 6 0.703 0.407 0.514 0.288\n",
" kite 128 10 0.687 0.4 0.561 0.207\n", " kite 128 10 0.645 0.4 0.506 0.206\n",
" baseball bat 128 4 0.439 0.409 0.263 0.114\n", " baseball bat 128 4 0.436 0.404 0.253 0.125\n",
" baseball glove 128 7 0.679 0.429 0.43 0.317\n", " baseball glove 128 7 0.786 0.429 0.43 0.303\n",
" skateboard 128 5 0.738 0.6 0.599 0.386\n", " skateboard 128 5 0.752 0.6 0.6 0.433\n",
" tennis racket 128 7 0.738 0.408 0.493 0.371\n", " tennis racket 128 7 0.707 0.286 0.508 0.313\n",
" bottle 128 18 0.44 0.333 0.377 0.247\n", " bottle 128 18 0.484 0.389 0.43 0.271\n",
" wine glass 128 16 0.545 0.5 0.596 0.358\n", " wine glass 128 16 0.471 0.562 0.584 0.327\n",
" cup 128 36 0.651 0.278 0.412 0.297\n", " cup 128 36 0.569 0.278 0.404 0.286\n",
" fork 128 6 0.568 0.167 0.229 0.202\n", " fork 128 6 0.529 0.167 0.207 0.192\n",
" knife 128 16 0.557 0.562 0.628 0.399\n", " knife 128 16 0.697 0.562 0.594 0.377\n",
" spoon 128 22 0.471 0.318 0.369 0.214\n", " spoon 128 22 0.68 0.182 0.376 0.213\n",
" bowl 128 28 0.611 0.679 0.671 0.547\n", " bowl 128 28 0.623 0.679 0.653 0.536\n",
" banana 128 1 0.0573 0.286 0.199 0.0522\n", " banana 128 1 0 0 0.142 0.0363\n",
" sandwich 128 2 0.377 0.5 0.745 0.745\n", " sandwich 128 2 1 0 0.745 0.745\n",
" orange 128 4 0.743 0.729 0.895 0.595\n", " orange 128 4 1 0.457 0.849 0.56\n",
" broccoli 128 11 0.491 0.265 0.281 0.233\n", " broccoli 128 11 0.465 0.273 0.284 0.246\n",
" carrot 128 24 0.548 0.667 0.694 0.465\n", " carrot 128 24 0.581 0.751 0.745 0.489\n",
" hot dog 128 2 0.586 1 0.828 0.796\n", " hot dog 128 2 0.654 0.961 0.828 0.763\n",
" pizza 128 5 0.873 1 0.995 0.798\n", " pizza 128 5 0.631 1 0.995 0.854\n",
" donut 128 14 0.554 1 0.891 0.786\n", " donut 128 14 0.583 1 0.933 0.84\n",
" cake 128 4 0.806 1 0.995 0.904\n", " cake 128 4 0.643 1 0.995 0.88\n",
" chair 128 35 0.408 0.514 0.469 0.267\n", " chair 128 35 0.5 0.543 0.459 0.272\n",
" couch 128 6 0.517 0.5 0.655 0.463\n", " couch 128 6 0.488 0.5 0.624 0.47\n",
" potted plant 128 14 0.564 0.643 0.673 0.467\n", " potted plant 128 14 0.645 0.714 0.747 0.542\n",
" bed 128 3 0.72 1 0.995 0.734\n", " bed 128 3 0.718 1 0.995 0.798\n",
" dining table 128 13 0.433 0.692 0.58 0.48\n", " dining table 128 13 0.448 0.615 0.538 0.437\n",
" toilet 128 2 0.508 0.5 0.745 0.721\n", " toilet 128 2 1 0.884 0.995 0.946\n",
" tv 128 2 0.563 0.689 0.828 0.762\n", " tv 128 2 0.548 0.644 0.828 0.762\n",
" laptop 128 3 1 0.455 0.747 0.657\n", " laptop 128 3 1 0.563 0.72 0.639\n",
" mouse 128 2 1 0 0.0405 0.0081\n", " mouse 128 2 1 0 0.0623 0.0125\n",
" remote 128 8 0.832 0.5 0.574 0.445\n", " remote 128 8 0.697 0.5 0.578 0.496\n",
" cell phone 128 8 0 0 0.0724 0.0315\n", " cell phone 128 8 0 0 0.102 0.0471\n",
" microwave 128 3 0.496 0.667 0.806 0.685\n", " microwave 128 3 0.651 0.667 0.863 0.738\n",
" oven 128 5 0.501 0.4 0.345 0.273\n", " oven 128 5 0.471 0.4 0.415 0.309\n",
" sink 128 6 0.379 0.212 0.366 0.21\n", " sink 128 6 0.45 0.284 0.268 0.159\n",
" refrigerator 128 5 0.612 0.4 0.77 0.608\n", " refrigerator 128 5 0.679 0.4 0.695 0.537\n",
" book 128 29 0.553 0.207 0.387 0.2\n", " book 128 29 0.656 0.133 0.424 0.227\n",
" clock 128 9 0.88 0.889 0.907 0.772\n", " clock 128 9 0.878 0.778 0.898 0.759\n",
" vase 128 2 0.508 1 0.828 0.745\n", " vase 128 2 0.413 1 0.828 0.745\n",
" scissors 128 1 1 0 0.142 0.0426\n", " scissors 128 1 1 0 0.199 0.0597\n",
" teddy bear 128 21 0.662 0.476 0.603 0.442\n", " teddy bear 128 21 0.553 0.472 0.669 0.447\n",
" toothbrush 128 5 0.792 0.768 0.898 0.574\n", " toothbrush 128 5 1 0.518 0.8 0.521\n",
"Speed: 1.1ms preprocess, 5.4ms inference, 0.0ms loss, 2.9ms postprocess per image\n", "Speed: 2.7ms preprocess, 3.5ms inference, 0.0ms loss, 3.2ms postprocess per image\n",
"Results saved to \u001b[1mruns/detect/train\u001b[0m\n" "Results saved to \u001b[1mruns/detect/train\u001b[0m\n"
] ]
} }
@ -485,23 +484,23 @@
"base_uri": "https://localhost:8080/" "base_uri": "https://localhost:8080/"
}, },
"id": "CYIjW4igCjqD", "id": "CYIjW4igCjqD",
"outputId": "49b5bb9d-2c16-415b-c3e7-ec95c15a9e62" "outputId": "fc41bf7a-0ea2-41a6-9ec5-dd0455af43bc"
}, },
"execution_count": null, "execution_count": 5,
"outputs": [ "outputs": [
{ {
"output_type": "stream", "output_type": "stream",
"name": "stdout", "name": "stdout",
"text": [ "text": [
"Ultralytics YOLOv8.0.57 🚀 Python-3.9.16 torch-1.13.1+cu116 CPU\n", "Ultralytics YOLOv8.0.71 🚀 Python-3.9.16 torch-2.0.0+cu118 CPU\n",
"YOLOv8n summary (fused): 168 layers, 3151904 parameters, 0 gradients, 8.7 GFLOPs\n", "YOLOv8n summary (fused): 168 layers, 3151904 parameters, 0 gradients, 8.7 GFLOPs\n",
"\n", "\n",
"\u001b[34m\u001b[1mPyTorch:\u001b[0m starting from yolov8n.pt with input shape (1, 3, 640, 640) BCHW and output shape(s) (1, 84, 8400) (6.2 MB)\n", "\u001b[34m\u001b[1mPyTorch:\u001b[0m starting from yolov8n.pt with input shape (1, 3, 640, 640) BCHW and output shape(s) (1, 84, 8400) (6.2 MB)\n",
"\n", "\n",
"\u001b[34m\u001b[1mTorchScript:\u001b[0m starting export with torch 1.13.1+cu116...\n", "\u001b[34m\u001b[1mTorchScript:\u001b[0m starting export with torch 2.0.0+cu118...\n",
"\u001b[34m\u001b[1mTorchScript:\u001b[0m export success ✅ 1.9s, saved as yolov8n.torchscript (12.4 MB)\n", "\u001b[34m\u001b[1mTorchScript:\u001b[0m export success ✅ 2.3s, saved as yolov8n.torchscript (12.4 MB)\n",
"\n", "\n",
"Export complete (2.6s)\n", "Export complete (3.1s)\n",
"Results saved to \u001b[1m/content\u001b[0m\n", "Results saved to \u001b[1m/content\u001b[0m\n",
"Predict: yolo predict task=detect model=yolov8n.torchscript imgsz=640 \n", "Predict: yolo predict task=detect model=yolov8n.torchscript imgsz=640 \n",
"Validate: yolo val task=detect model=yolov8n.torchscript imgsz=640 data=coco.yaml \n", "Validate: yolo val task=detect model=yolov8n.torchscript imgsz=640 data=coco.yaml \n",
@ -677,9 +676,10 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# Git clone install (for development)\n", "# Git clone and run tests on updates branch\n",
"!git clone https://github.com/ultralytics/ultralytics -b main\n", "!git clone https://github.com/ultralytics/ultralytics -b updates\n",
"%pip install -qe ultralytics" "%pip install -qe ultralytics\n",
"!pytest ultralytics/tests"
], ],
"metadata": { "metadata": {
"id": "uRKlwxSJdhd1" "id": "uRKlwxSJdhd1"
@ -687,18 +687,6 @@
"execution_count": null, "execution_count": null,
"outputs": [] "outputs": []
}, },
{
"cell_type": "code",
"metadata": {
"id": "GMusP4OAxFu6"
},
"source": [
"# Run YOLOv8 tests (git clone install only)\n",
"!pytest ultralytics/tests"
],
"execution_count": null,
"outputs": []
},
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [

@ -207,7 +207,6 @@ def test_predict_callback_and_setup():
def test_result(): def test_result():
model = YOLO('yolov8n-pose.pt') model = YOLO('yolov8n-pose.pt')
res = model([SOURCE, SOURCE]) res = model([SOURCE, SOURCE])
res[0].plot(show_conf=False) # raises warning
res[0].plot(conf=True, boxes=False) res[0].plot(conf=True, boxes=False)
res[0].plot(pil=True) res[0].plot(pil=True)
res[0] = res[0].cpu().numpy() res[0] = res[0].cpu().numpy()
@ -215,7 +214,6 @@ def test_result():
model = YOLO('yolov8n-seg.pt') model = YOLO('yolov8n-seg.pt')
res = model([SOURCE, SOURCE]) res = model([SOURCE, SOURCE])
res[0].plot(show_conf=False) # raises warning
res[0].plot(conf=True, boxes=False, masks=True) res[0].plot(conf=True, boxes=False, masks=True)
res[0].plot(pil=True) res[0].plot(pil=True)
res[0] = res[0].cpu().numpy() res[0] = res[0].cpu().numpy()

@ -1,6 +1,6 @@
# Ultralytics YOLO 🚀, GPL-3.0 license # Ultralytics YOLO 🚀, GPL-3.0 license
__version__ = '8.0.71' __version__ = '8.0.72'
from ultralytics.hub import start from ultralytics.hub import start
from ultralytics.yolo.engine.model import YOLO from ultralytics.yolo.engine.model import YOLO

@ -87,14 +87,14 @@ Available Models:
### Pose ### Pose
| Model | size<br><sup>(pixels) | mAP<sup>box<br>50-95 | mAP<sup>pose<br>50-95 | Speed<br><sup>CPU ONNX<br>(ms) | Speed<br><sup>A100 TensorRT<br>(ms) | params<br><sup>(M) | FLOPs<br><sup>(B) | | Model | size<br><sup>(pixels) | mAP<sup>pose<br>50-95 | mAP<sup>pose<br>50 | Speed<br><sup>CPU ONNX<br>(ms) | Speed<br><sup>A100 TensorRT<br>(ms) | params<br><sup>(M) | FLOPs<br><sup>(B) |
| ---------------------------------------------------------------------------------------------------- | --------------------- | -------------------- | --------------------- | ------------------------------ | ----------------------------------- | ------------------ | ----------------- | | ---------------------------------------------------------------------------------------------------- | --------------------- | --------------------- | ------------------ | ------------------------------ | ----------------------------------- | ------------------ | ----------------- |
| [YOLOv8n-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n-pose.pt) | 640 | - | 49.7 | 131.8 | 1.18 | 3.3 | 9.2 | | [YOLOv8n-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n-pose.pt) | 640 | 49.7 | 79.7 | 131.8 | 1.18 | 3.3 | 9.2 |
| [YOLOv8s-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8s-pose.pt) | 640 | - | 59.2 | 233.2 | 1.42 | 11.6 | 30.2 | | [YOLOv8s-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8s-pose.pt) | 640 | 59.2 | 85.8 | 233.2 | 1.42 | 11.6 | 30.2 |
| [YOLOv8m-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8m-pose.pt) | 640 | - | 63.6 | 456.3 | 2.00 | 26.4 | 81.0 | | [YOLOv8m-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8m-pose.pt) | 640 | 63.6 | 88.8 | 456.3 | 2.00 | 26.4 | 81.0 |
| [YOLOv8l-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8l-pose.pt) | 640 | - | 67.0 | 784.5 | 2.59 | 44.4 | 168.6 | | [YOLOv8l-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8l-pose.pt) | 640 | 67.0 | 89.9 | 784.5 | 2.59 | 44.4 | 168.6 |
| [YOLOv8x-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8x-pose.pt) | 640 | - | 68.9 | 1607.1 | 3.73 | 69.4 | 263.2 | | [YOLOv8x-pose](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8x-pose.pt) | 640 | 68.9 | 90.4 | 1607.1 | 3.73 | 69.4 | 263.2 |
| [YOLOv8x-pose-p6](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8x-pose-p6.pt) | 1280 | - | 71.5 | 4088.7 | 10.04 | 99.1 | 1066.4 | | [YOLOv8x-pose-p6](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8x-pose-p6.pt) | 1280 | 71.5 | 91.3 | 4088.7 | 10.04 | 99.1 | 1066.4 |
</details> </details>

@ -3,7 +3,6 @@
import copy import copy
import cv2 import cv2
import matplotlib.pyplot as plt
import numpy as np import numpy as np
from ultralytics.yolo.utils import LOGGER from ultralytics.yolo.utils import LOGGER
@ -205,24 +204,25 @@ class GMC:
currPoints = np.array(currPoints) currPoints = np.array(currPoints)
# Draw the keypoint matches on the output image # Draw the keypoint matches on the output image
if 0: # if False:
matches_img = np.hstack((self.prevFrame, frame)) # import matplotlib.pyplot as plt
matches_img = cv2.cvtColor(matches_img, cv2.COLOR_GRAY2BGR) # matches_img = np.hstack((self.prevFrame, frame))
W = np.size(self.prevFrame, 1) # matches_img = cv2.cvtColor(matches_img, cv2.COLOR_GRAY2BGR)
for m in goodMatches: # W = np.size(self.prevFrame, 1)
prev_pt = np.array(self.prevKeyPoints[m.queryIdx].pt, dtype=np.int_) # for m in goodMatches:
curr_pt = np.array(keypoints[m.trainIdx].pt, dtype=np.int_) # prev_pt = np.array(self.prevKeyPoints[m.queryIdx].pt, dtype=np.int_)
curr_pt[0] += W # curr_pt = np.array(keypoints[m.trainIdx].pt, dtype=np.int_)
color = np.random.randint(0, 255, 3) # curr_pt[0] += W
color = (int(color[0]), int(color[1]), int(color[2])) # color = np.random.randint(0, 255, 3)
# color = (int(color[0]), int(color[1]), int(color[2]))
matches_img = cv2.line(matches_img, prev_pt, curr_pt, tuple(color), 1, cv2.LINE_AA) #
matches_img = cv2.circle(matches_img, prev_pt, 2, tuple(color), -1) # matches_img = cv2.line(matches_img, prev_pt, curr_pt, tuple(color), 1, cv2.LINE_AA)
matches_img = cv2.circle(matches_img, curr_pt, 2, tuple(color), -1) # matches_img = cv2.circle(matches_img, prev_pt, 2, tuple(color), -1)
# matches_img = cv2.circle(matches_img, curr_pt, 2, tuple(color), -1)
plt.figure() #
plt.imshow(matches_img) # plt.figure()
plt.show() # plt.imshow(matches_img)
# plt.show()
# Find rigid matrix # Find rigid matrix
if (np.size(prevPoints, 0) > 4) and (np.size(prevPoints, 0) == np.size(prevPoints, 0)): if (np.size(prevPoints, 0) > 4) and (np.size(prevPoints, 0) == np.size(prevPoints, 0)):

@ -28,7 +28,7 @@ single_cls: False # train multi-class data as single-class
image_weights: False # use weighted image selection for training image_weights: False # use weighted image selection for training
rect: False # rectangular training if mode='train' or rectangular validation if mode='val' rect: False # rectangular training if mode='train' or rectangular validation if mode='val'
cos_lr: False # use cosine learning rate scheduler cos_lr: False # use cosine learning rate scheduler
close_mosaic: 10 # disable mosaic augmentation for final 10 epochs close_mosaic: 0 # (int) disable mosaic augmentation for final epochs
resume: False # resume training from last checkpoint resume: False # resume training from last checkpoint
amp: True # Automatic Mixed Precision (AMP) training, choices=[True, False], True runs AMP check amp: True # Automatic Mixed Precision (AMP) training, choices=[True, False], True runs AMP check
# Segmentation # Segmentation

@ -162,7 +162,18 @@ def check_source(source):
def load_inference_source(source=None, transforms=None, imgsz=640, vid_stride=1, stride=32, auto=True): def load_inference_source(source=None, transforms=None, imgsz=640, vid_stride=1, stride=32, auto=True):
""" """
TODO: docs Loads an inference source for object detection and applies necessary transformations.
Args:
source (str, Path, Tensor, PIL.Image, np.ndarray): The input source for inference.
transforms (callable, optional): Custom transformations to be applied to the input source.
imgsz (int, optional): The size of the image for inference. Default is 640.
vid_stride (int, optional): The frame interval for video sources. Default is 1.
stride (int, optional): The model stride. Default is 32.
auto (bool, optional): Automatically apply pre-processing. Default is True.
Returns:
dataset: A dataset object for the specified input source.
""" """
source, webcam, screenshot, from_img, in_memory, tensor = check_source(source) source, webcam, screenshot, from_img, in_memory, tensor = check_source(source)
source_type = source.source_type if in_memory else SourceTypes(webcam, screenshot, from_img, tensor) source_type = source.source_type if in_memory else SourceTypes(webcam, screenshot, from_img, tensor)
@ -179,7 +190,6 @@ def load_inference_source(source=None, transforms=None, imgsz=640, vid_stride=1,
auto=auto, auto=auto,
transforms=transforms, transforms=transforms,
vid_stride=vid_stride) vid_stride=vid_stride)
elif screenshot: elif screenshot:
dataset = LoadScreenshots(source, imgsz=imgsz, stride=stride, auto=auto, transforms=transforms) dataset = LoadScreenshots(source, imgsz=imgsz, stride=stride, auto=auto, transforms=transforms)
elif from_img: elif from_img:
@ -192,6 +202,7 @@ def load_inference_source(source=None, transforms=None, imgsz=640, vid_stride=1,
transforms=transforms, transforms=transforms,
vid_stride=vid_stride) vid_stride=vid_stride)
setattr(dataset, 'source_type', source_type) # attach source types # Attach source types to the dataset
setattr(dataset, 'source_type', source_type)
return dataset return dataset

@ -77,7 +77,6 @@ class YOLODataset(BaseDataset):
nm, nf, ne, nc, msgs = 0, 0, 0, 0, [] # number missing, found, empty, corrupt, messages nm, nf, ne, nc, msgs = 0, 0, 0, 0, [] # number missing, found, empty, corrupt, messages
desc = f'{self.prefix}Scanning {path.parent / path.stem}...' desc = f'{self.prefix}Scanning {path.parent / path.stem}...'
total = len(self.im_files) total = len(self.im_files)
nc = len(self.data['names'])
nkpt, ndim = self.data.get('kpt_shape', (0, 0)) nkpt, ndim = self.data.get('kpt_shape', (0, 0))
if self.use_keypoints and (nkpt <= 0 or ndim not in (2, 3)): if self.use_keypoints and (nkpt <= 0 or ndim not in (2, 3)):
raise ValueError("'kpt_shape' in data.yaml missing or incorrect. Should be a list with [number of " raise ValueError("'kpt_shape' in data.yaml missing or incorrect. Should be a list with [number of "

@ -253,10 +253,10 @@ class YOLO:
source (str, optional): The input source for object tracking. Can be a file path or a video stream. source (str, optional): The input source for object tracking. Can be a file path or a video stream.
stream (bool, optional): Whether the input source is a video stream. Defaults to False. stream (bool, optional): Whether the input source is a video stream. Defaults to False.
persist (bool, optional): Whether to persist the trackers if they already exist. Defaults to False. persist (bool, optional): Whether to persist the trackers if they already exist. Defaults to False.
**kwargs: Additional keyword arguments for the tracking process. **kwargs (optional): Additional keyword arguments for the tracking process.
Returns: Returns:
object: The tracking results. (List[ultralytics.yolo.engine.results.Results]): The tracking results.
""" """
if not hasattr(self.predictor, 'trackers'): if not hasattr(self.predictor, 'trackers'):

@ -244,8 +244,7 @@ class Boxes(BaseTensor):
orig_shape (tuple): Original image size, in the format (height, width). orig_shape (tuple): Original image size, in the format (height, width).
Attributes: Attributes:
boxes (torch.Tensor) or (numpy.ndarray): A tensor or numpy array containing the detection boxes, boxes (torch.Tensor) or (numpy.ndarray): The detection boxes with shape (num_boxes, 6).
with shape (num_boxes, 6).
orig_shape (torch.Tensor) or (numpy.ndarray): Original image size, in the format (height, width). orig_shape (torch.Tensor) or (numpy.ndarray): Original image size, in the format (height, width).
is_track (bool): True if the boxes also include track IDs, False otherwise. is_track (bool): True if the boxes also include track IDs, False otherwise.
@ -272,7 +271,6 @@ class Boxes(BaseTensor):
boxes = boxes[None, :] boxes = boxes[None, :]
n = boxes.shape[-1] n = boxes.shape[-1]
assert n in (6, 7), f'expected `n` in [6, 7], but got {n}' # xyxy, (track_id), conf, cls assert n in (6, 7), f'expected `n` in [6, 7], but got {n}' # xyxy, (track_id), conf, cls
# TODO
self.is_track = n == 7 self.is_track = n == 7
self.boxes = boxes self.boxes = boxes
self.orig_shape = torch.as_tensor(orig_shape, device=boxes.device) if isinstance(boxes, torch.Tensor) \ self.orig_shape = torch.as_tensor(orig_shape, device=boxes.device) if isinstance(boxes, torch.Tensor) \

@ -102,6 +102,7 @@ np.set_printoptions(linewidth=320, formatter={'float_kind': '{:11.5g}'.format})
cv2.setNumThreads(0) # prevent OpenCV from multithreading (incompatible with PyTorch DataLoader) cv2.setNumThreads(0) # prevent OpenCV from multithreading (incompatible with PyTorch DataLoader)
os.environ['NUMEXPR_MAX_THREADS'] = str(NUM_THREADS) # NumExpr max threads os.environ['NUMEXPR_MAX_THREADS'] = str(NUM_THREADS) # NumExpr max threads
os.environ['CUBLAS_WORKSPACE_CONFIG'] = ':4096:8' # for deterministic training os.environ['CUBLAS_WORKSPACE_CONFIG'] = ':4096:8' # for deterministic training
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # suppress verbose TF compiler warnings in Colab
class SimpleClass: class SimpleClass:

Loading…
Cancel
Save