jiaqi9720 commited on
Commit
1f3b5f1
·
verified ·
1 Parent(s): 9779df5

Upload 788 files

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. ultralytics-main/.dockerignore +35 -0
  3. ultralytics-main/.github/ISSUE_TEMPLATE/bug-report.yml +98 -0
  4. ultralytics-main/.github/ISSUE_TEMPLATE/config.yml +16 -0
  5. ultralytics-main/.github/ISSUE_TEMPLATE/feature-request.yml +53 -0
  6. ultralytics-main/.github/ISSUE_TEMPLATE/question.yml +35 -0
  7. ultralytics-main/.github/dependabot.yml +24 -0
  8. ultralytics-main/.github/workflows/ci.yml +523 -0
  9. ultralytics-main/.github/workflows/cla.yml +45 -0
  10. ultralytics-main/.github/workflows/docker.yml +284 -0
  11. ultralytics-main/.github/workflows/docs.yml +125 -0
  12. ultralytics-main/.github/workflows/format.yml +68 -0
  13. ultralytics-main/.github/workflows/links.yml +104 -0
  14. ultralytics-main/.github/workflows/merge-main-into-prs.yml +91 -0
  15. ultralytics-main/.github/workflows/mirror.yml +46 -0
  16. ultralytics-main/.github/workflows/publish.yml +153 -0
  17. ultralytics-main/.github/workflows/stale.yml +55 -0
  18. ultralytics-main/.gitignore +200 -0
  19. ultralytics-main/CITATION.cff +26 -0
  20. ultralytics-main/CONTRIBUTING.md +241 -0
  21. ultralytics-main/LICENSE +661 -0
  22. ultralytics-main/README.md +285 -0
  23. ultralytics-main/README.zh-CN.md +285 -0
  24. ultralytics-main/docker/Dockerfile +81 -0
  25. ultralytics-main/docker/Dockerfile-arm64 +61 -0
  26. ultralytics-main/docker/Dockerfile-conda +46 -0
  27. ultralytics-main/docker/Dockerfile-cpu +24 -0
  28. ultralytics-main/docker/Dockerfile-export +16 -0
  29. ultralytics-main/docker/Dockerfile-jetson-jetpack4 +73 -0
  30. ultralytics-main/docker/Dockerfile-jetson-jetpack5 +60 -0
  31. ultralytics-main/docker/Dockerfile-jetson-jetpack6 +60 -0
  32. ultralytics-main/docker/Dockerfile-jupyter +32 -0
  33. ultralytics-main/docker/Dockerfile-python +54 -0
  34. ultralytics-main/docker/Dockerfile-python-export +43 -0
  35. ultralytics-main/docker/Dockerfile-runner +36 -0
  36. ultralytics-main/docs/README.md +145 -0
  37. ultralytics-main/docs/build_docs.py +691 -0
  38. ultralytics-main/docs/build_reference.py +1191 -0
  39. ultralytics-main/docs/coming_soon_template.md +34 -0
  40. ultralytics-main/docs/en/CNAME +1 -0
  41. ultralytics-main/docs/en/datasets/classify/caltech101.md +167 -0
  42. ultralytics-main/docs/en/datasets/classify/caltech256.md +148 -0
  43. ultralytics-main/docs/en/datasets/classify/cifar10.md +173 -0
  44. ultralytics-main/docs/en/datasets/classify/cifar100.md +141 -0
  45. ultralytics-main/docs/en/datasets/classify/fashion-mnist.md +141 -0
  46. ultralytics-main/docs/en/datasets/classify/imagenet.md +132 -0
  47. ultralytics-main/docs/en/datasets/classify/imagenet10.md +129 -0
  48. ultralytics-main/docs/en/datasets/classify/imagenette.md +193 -0
  49. ultralytics-main/docs/en/datasets/classify/imagewoof.md +153 -0
  50. ultralytics-main/docs/en/datasets/classify/index.md +210 -0
.gitattributes CHANGED
@@ -37,3 +37,4 @@ ultralytics/assets/bus.jpg filter=lfs diff=lfs merge=lfs -text
37
  ultralytics/data/__pycache__/augment.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
38
  ultralytics/data/__pycache__/augment.cpython-38.pyc filter=lfs diff=lfs merge=lfs -text
39
  ultralytics/data/__pycache__/augment.cpython-39.pyc filter=lfs diff=lfs merge=lfs -text
 
 
37
  ultralytics/data/__pycache__/augment.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
38
  ultralytics/data/__pycache__/augment.cpython-38.pyc filter=lfs diff=lfs merge=lfs -text
39
  ultralytics/data/__pycache__/augment.cpython-39.pyc filter=lfs diff=lfs merge=lfs -text
40
+ ultralytics-main/ultralytics/assets/bus.jpg filter=lfs diff=lfs merge=lfs -text
ultralytics-main/.dockerignore ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python
2
+ __pycache__
3
+ *.pyc
4
+ *.pyo
5
+ *.pyd
6
+ .Python
7
+ *.py[cod]
8
+ *$py.class
9
+ .pytest_cache
10
+ .coverage
11
+ coverage.xml
12
+ .ruff_cache
13
+ *.egg-info
14
+ dist
15
+ build
16
+
17
+ # Development
18
+ .env
19
+ .venv
20
+ env/
21
+ venv/
22
+ ENV/
23
+ .idea
24
+ .vscode
25
+ *.swp
26
+ *.swo
27
+ .DS_Store
28
+
29
+ # Project specific
30
+ *.log
31
+ benchmarks.log
32
+ runs/
33
+
34
+ # Dependencies
35
+ node_modules/
ultralytics-main/.github/ISSUE_TEMPLATE/bug-report.yml ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ name: 🐛 Bug Report
4
+ # title: " "
5
+ description: Problems with Ultralytics YOLO
6
+ labels: [bug, triage]
7
+ type: "bug"
8
+ body:
9
+ - type: markdown
10
+ attributes:
11
+ value: |
12
+ Thank you for submitting an Ultralytics YOLO 🐛 Bug Report!
13
+
14
+ - type: checkboxes
15
+ attributes:
16
+ label: Search before asking
17
+ description: >
18
+ Please search the Ultralytics [Docs](https://docs.ultralytics.com/) and [issues](https://github.com/ultralytics/ultralytics/issues) to see if a similar bug report already exists.
19
+ options:
20
+ - label: >
21
+ I have searched the Ultralytics YOLO [issues](https://github.com/ultralytics/ultralytics/issues) and found no similar bug report.
22
+ required: true
23
+
24
+ - type: dropdown
25
+ attributes:
26
+ label: Ultralytics YOLO Component
27
+ description: |
28
+ Please select the Ultralytics YOLO component where you found the bug.
29
+ multiple: true
30
+ options:
31
+ - "Install"
32
+ - "Train"
33
+ - "Val"
34
+ - "Predict"
35
+ - "Export"
36
+ - "Multi-GPU"
37
+ - "Augmentation"
38
+ - "Hyperparameter Tuning"
39
+ - "Integrations"
40
+ - "Other"
41
+ validations:
42
+ required: false
43
+
44
+ - type: textarea
45
+ attributes:
46
+ label: Bug
47
+ description: Please provide as much information as possible. Copy and paste console output and error messages including the _full_ traceback. Use [Markdown](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax) to format text, code and logs. If necessary, include screenshots for visual elements only. Providing detailed information will help us resolve the issue more efficiently.
48
+ placeholder: |
49
+ 💡 ProTip! Include as much information as possible (logs, tracebacks, screenshots, etc.) to receive the most helpful response.
50
+ validations:
51
+ required: true
52
+
53
+ - type: textarea
54
+ attributes:
55
+ label: Environment
56
+ description: Try the latest version (`pip install -U ultralytics`) before reporting a bug. If it's still present, please provide the output of `yolo checks` (CLI) or `ultralytics.utils.checks.collect_system_info()` (Python) command to help us diagnose the problem.
57
+ placeholder: |
58
+ Paste output of `yolo checks` (CLI) or `ultralytics.utils.checks.collect_system_info()` (Python) command, i.e.:
59
+ ```
60
+ Ultralytics 8.3.2 🚀 Python-3.11.2 torch-2.4.1 CPU (Apple M3)
61
+ Setup complete ✅ (8 CPUs, 16.0 GB RAM, 266.5/460.4 GB disk)
62
+
63
+ OS macOS-13.5.2
64
+ Environment Jupyter
65
+ Python 3.11.2
66
+ Install git
67
+ RAM 16.00 GB
68
+ CPU Apple M3
69
+ CUDA None
70
+ ```
71
+ validations:
72
+ required: true
73
+
74
+ - type: textarea
75
+ attributes:
76
+ label: Minimal Reproducible Example
77
+ description: >
78
+ When asking a question, people will be better able to provide help if you provide code that they can easily understand and use to **reproduce** the problem. This is referred to by community members as creating a [minimal reproducible example](https://docs.ultralytics.com/help/minimum-reproducible-example/).
79
+ placeholder: |
80
+ ```
81
+ # Code to reproduce your issue here
82
+ ```
83
+ validations:
84
+ required: true
85
+
86
+ - type: textarea
87
+ attributes:
88
+ label: Additional
89
+ description: Anything else you would like to share?
90
+
91
+ - type: checkboxes
92
+ attributes:
93
+ label: Are you willing to submit a PR?
94
+ description: >
95
+ (Optional) We encourage you to submit a [Pull Request](https://github.com/ultralytics/ultralytics/pulls) (PR) to help improve Ultralytics YOLO for everyone, especially if you have a good understanding of how to implement a fix or feature.
96
+ See the Ultralytics YOLO [Contributing Guide](https://docs.ultralytics.com/help/contributing/) to get started.
97
+ options:
98
+ - label: Yes I'd like to help by submitting a PR!
ultralytics-main/.github/ISSUE_TEMPLATE/config.yml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ blank_issues_enabled: true
4
+ contact_links:
5
+ - name: 📄 Docs
6
+ url: https://docs.ultralytics.com/
7
+ about: Full Ultralytics YOLO Documentation
8
+ - name: 💬 Forum
9
+ url: https://community.ultralytics.com/
10
+ about: Ask on Ultralytics Community Forum
11
+ - name: 🎧 Discord
12
+ url: https://ultralytics.com/discord
13
+ about: Ask on Ultralytics Discord
14
+ - name: ⌨️ Reddit
15
+ url: https://reddit.com/r/ultralytics
16
+ about: Ask on Ultralytics Subreddit
ultralytics-main/.github/ISSUE_TEMPLATE/feature-request.yml ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ name: 🚀 Feature Request
4
+ description: Suggest an Ultralytics YOLO idea
5
+ # title: " "
6
+ labels: [enhancement]
7
+ type: "feature"
8
+ body:
9
+ - type: markdown
10
+ attributes:
11
+ value: |
12
+ Thank you for submitting an Ultralytics 🚀 Feature Request!
13
+
14
+ - type: checkboxes
15
+ attributes:
16
+ label: Search before asking
17
+ description: >
18
+ Please search the Ultralytics [Docs](https://docs.ultralytics.com/) and [issues](https://github.com/ultralytics/ultralytics/issues) to see if a similar feature request already exists.
19
+ options:
20
+ - label: >
21
+ I have searched the Ultralytics [issues](https://github.com/ultralytics/ultralytics/issues) and found no similar feature requests.
22
+ required: true
23
+
24
+ - type: textarea
25
+ attributes:
26
+ label: Description
27
+ description: A short description of your feature.
28
+ placeholder: |
29
+ What new feature would you like to see in YOLO?
30
+ validations:
31
+ required: true
32
+
33
+ - type: textarea
34
+ attributes:
35
+ label: Use case
36
+ description: |
37
+ Describe the use case of your feature request. It will help us understand and prioritize the feature request.
38
+ placeholder: |
39
+ How would this feature be used, and who would use it?
40
+
41
+ - type: textarea
42
+ attributes:
43
+ label: Additional
44
+ description: Anything else you would like to share?
45
+
46
+ - type: checkboxes
47
+ attributes:
48
+ label: Are you willing to submit a PR?
49
+ description: >
50
+ (Optional) We encourage you to submit a [Pull Request](https://github.com/ultralytics/ultralytics/pulls) (PR) to help improve YOLO for everyone, especially if you have a good understanding of how to implement a fix or feature.
51
+ See the Ultralytics [Contributing Guide](https://docs.ultralytics.com/help/contributing/) to get started.
52
+ options:
53
+ - label: Yes I'd like to help by submitting a PR!
ultralytics-main/.github/ISSUE_TEMPLATE/question.yml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ name: ❓ Question
4
+ description: Ask an Ultralytics YOLO question
5
+ # title: " "
6
+ labels: [question]
7
+ body:
8
+ - type: markdown
9
+ attributes:
10
+ value: |
11
+ Thank you for asking an Ultralytics YOLO ❓ Question!
12
+
13
+ - type: checkboxes
14
+ attributes:
15
+ label: Search before asking
16
+ description: >
17
+ Please search the Ultralytics [Docs](https://docs.ultralytics.com/), [issues](https://github.com/ultralytics/ultralytics/issues) and [discussions](https://github.com/orgs/ultralytics/discussions) to see if a similar question already exists.
18
+ options:
19
+ - label: >
20
+ I have searched the Ultralytics YOLO [issues](https://github.com/ultralytics/ultralytics/issues) and [discussions](https://github.com/orgs/ultralytics/discussions) and found no similar questions.
21
+ required: true
22
+
23
+ - type: textarea
24
+ attributes:
25
+ label: Question
26
+ description: What is your question? Please provide as much information as possible. Include detailed code examples to reproduce the problem and describe the context in which the issue occurs. Format your text and code using [Markdown](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax) for clarity and readability. Following these guidelines will help us assist you more effectively.
27
+ placeholder: |
28
+ 💡 ProTip! Include as much information as possible (logs, tracebacks, screenshots etc.) to receive the most helpful response.
29
+ validations:
30
+ required: true
31
+
32
+ - type: textarea
33
+ attributes:
34
+ label: Additional
35
+ description: Anything else you would like to share?
ultralytics-main/.github/dependabot.yml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Dependabot for package version updates
4
+ # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: pip
9
+ directory: "/"
10
+ schedule:
11
+ interval: daily
12
+ time: "04:00"
13
+ open-pull-requests-limit: 10
14
+ labels:
15
+ - dependencies
16
+
17
+ - package-ecosystem: github-actions
18
+ directory: "/.github/workflows"
19
+ schedule:
20
+ interval: daily
21
+ time: "04:00"
22
+ open-pull-requests-limit: 5
23
+ labels:
24
+ - dependencies
ultralytics-main/.github/workflows/ci.yml ADDED
@@ -0,0 +1,523 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Ultralytics YOLO Continuous Integration (CI) GitHub Actions tests
4
+
5
+ name: CI
6
+
7
+ permissions:
8
+ contents: read
9
+
10
+ env:
11
+ PYTHONFAULTHANDLER: 1
12
+
13
+ on:
14
+ push:
15
+ branches: [main]
16
+ pull_request:
17
+ schedule:
18
+ - cron: "0 8 * * *" # runs at 08:00 UTC every day
19
+ workflow_dispatch:
20
+ inputs:
21
+ hub:
22
+ description: "Run HUB"
23
+ default: true
24
+ type: boolean
25
+ benchmarks:
26
+ description: "Run Benchmarks"
27
+ default: true
28
+ type: boolean
29
+ tests:
30
+ description: "Run Tests"
31
+ default: true
32
+ type: boolean
33
+ gpu:
34
+ description: "Run GPU"
35
+ default: true
36
+ type: boolean
37
+ raspberrypi:
38
+ description: "Run Raspberry Pi"
39
+ default: true
40
+ type: boolean
41
+ nvidia-jetson:
42
+ description: "Run NVIDIA Jetson"
43
+ default: true
44
+ type: boolean
45
+ conda:
46
+ description: "Run Conda"
47
+ default: true
48
+ type: boolean
49
+
50
+ jobs:
51
+ HUB:
52
+ if: github.repository == 'ultralytics/ultralytics' && (github.event_name == 'schedule' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.hub == 'true'))
53
+ runs-on: ${{ matrix.os }}
54
+ strategy:
55
+ fail-fast: false
56
+ matrix:
57
+ os: [ubuntu-latest]
58
+ python: ["3.12"]
59
+ steps:
60
+ - uses: actions/checkout@v6
61
+ - uses: actions/setup-python@v6
62
+ with:
63
+ python-version: ${{ matrix.python }}
64
+ - uses: astral-sh/setup-uv@v7
65
+ - name: Install requirements
66
+ shell: bash # for Windows compatibility
67
+ run: |
68
+ uv pip install --system . --extra-index-url https://download.pytorch.org/whl/cpu
69
+ - name: Check environment
70
+ run: |
71
+ yolo checks
72
+ uv pip list
73
+ - name: Test HUB training
74
+ shell: python
75
+ env:
76
+ API_KEY: ${{ secrets.ULTRALYTICS_HUB_API_KEY }}
77
+ MODEL_ID: ${{ secrets.ULTRALYTICS_HUB_MODEL_ID }}
78
+ run: |
79
+ import os
80
+ from ultralytics import YOLO, hub
81
+ api_key, model_id = os.environ['API_KEY'], os.environ['MODEL_ID']
82
+ hub.login(api_key)
83
+ hub.reset_model(model_id)
84
+ model = YOLO('https://hub.ultralytics.com/models/' + model_id)
85
+ model.train()
86
+ - name: Test HUB inference API
87
+ shell: python
88
+ env:
89
+ API_KEY: ${{ secrets.ULTRALYTICS_HUB_API_KEY }}
90
+ MODEL_ID: ${{ secrets.ULTRALYTICS_HUB_MODEL_ID }}
91
+ run: |
92
+ import os
93
+ import requests
94
+ import json
95
+ api_key, model_id = os.environ['API_KEY'], os.environ['MODEL_ID']
96
+ url = f"https://api.ultralytics.com/v1/predict/{model_id}"
97
+ headers = {"x-api-key": api_key}
98
+ data = {"size": 320, "confidence": 0.25, "iou": 0.45}
99
+ with open("ultralytics/assets/zidane.jpg", "rb") as f:
100
+ response = requests.post(url, headers=headers, data=data, files={"image": f})
101
+ assert response.status_code == 200, f'Status code {response.status_code}, Reason {response.reason}'
102
+ print(json.dumps(response.json(), indent=2))
103
+
104
+ Benchmarks:
105
+ if: github.event_name != 'workflow_dispatch' || github.event.inputs.benchmarks == 'true'
106
+ runs-on: ${{ matrix.os }}
107
+ strategy:
108
+ fail-fast: false
109
+ matrix:
110
+ # Temporarily disable windows-latest due to https://github.com/ultralytics/ultralytics/actions/runs/13020330819/job/36319338854?pr=18921
111
+ os: [ubuntu-latest, macos-26, ubuntu-24.04-arm]
112
+ python: ["3.12"]
113
+ model: [yolo11n]
114
+ steps:
115
+ - uses: actions/checkout@v6
116
+ - uses: actions/setup-python@v6
117
+ with:
118
+ python-version: ${{ matrix.python }}
119
+ - uses: astral-sh/setup-uv@v7
120
+ - name: Install requirements
121
+ shell: bash # for Windows compatibility
122
+ run: |
123
+ uv pip install --system -e ".[export]" "coverage[toml]" --extra-index-url https://download.pytorch.org/whl/cpu --index-strategy unsafe-best-match
124
+ - name: Check environment
125
+ run: |
126
+ yolo checks
127
+ uv pip list
128
+ - name: Benchmark DetectionModel
129
+ shell: bash
130
+ run: coverage run -a --source=ultralytics -m ultralytics.cfg.__init__ benchmark model='path with spaces/${{ matrix.model }}.pt' imgsz=160 verbose=0.309
131
+ - name: Benchmark ClassificationModel
132
+ shell: bash
133
+ run: coverage run -a --source=ultralytics -m ultralytics.cfg.__init__ benchmark model='path with spaces/${{ matrix.model }}-cls.pt' imgsz=160 verbose=0.249
134
+ - name: Benchmark YOLOWorld DetectionModel
135
+ shell: bash
136
+ run: coverage run -a --source=ultralytics -m ultralytics.cfg.__init__ benchmark model='path with spaces/yolov8s-worldv2.pt' imgsz=160 verbose=0.337
137
+ - name: Benchmark SegmentationModel
138
+ shell: bash
139
+ run: coverage run -a --source=ultralytics -m ultralytics.cfg.__init__ benchmark model='path with spaces/${{ matrix.model }}-seg.pt' imgsz=160 verbose=0.195
140
+ - name: Benchmark PoseModel
141
+ shell: bash
142
+ run: coverage run -a --source=ultralytics -m ultralytics.cfg.__init__ benchmark model='path with spaces/${{ matrix.model }}-pose.pt' imgsz=160 verbose=0.197
143
+ - name: Benchmark OBBModel
144
+ shell: bash
145
+ run: coverage run -a --source=ultralytics -m ultralytics.cfg.__init__ benchmark model='path with spaces/${{ matrix.model }}-obb.pt' imgsz=160 verbose=0.597
146
+ - name: Merge Coverage Reports
147
+ run: |
148
+ coverage xml -o coverage-benchmarks.xml
149
+ - name: Upload Coverage Reports to CodeCov
150
+ if: github.repository == 'ultralytics/ultralytics'
151
+ uses: codecov/codecov-action@v5
152
+ with:
153
+ flags: Benchmarks
154
+ env:
155
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
156
+ - name: Prune uv Cache
157
+ run: uv cache prune --ci
158
+ - name: Benchmark Summary
159
+ run: |
160
+ cat benchmarks.log
161
+ echo '```' >> $GITHUB_STEP_SUMMARY
162
+ cat benchmarks.log >> $GITHUB_STEP_SUMMARY
163
+ echo '```' >> $GITHUB_STEP_SUMMARY
164
+
165
+ Tests:
166
+ if: github.event_name == 'pull_request' || github.event_name == 'push'
167
+ timeout-minutes: 60
168
+ runs-on: ${{ matrix.os }}
169
+ strategy:
170
+ fail-fast: false
171
+ matrix:
172
+ os: [ubuntu-latest, macos-26, windows-latest, ubuntu-24.04-arm]
173
+ python: ["3.12"]
174
+ torch: [latest]
175
+ include:
176
+ - os: ubuntu-latest
177
+ python: "3.8" # torch 1.8.0 requires python >=3.6, <=3.9
178
+ torch: "1.8.0"
179
+ torchvision: "0.9.0"
180
+ steps:
181
+ - uses: actions/checkout@v6
182
+ - uses: actions/setup-python@v6
183
+ with:
184
+ python-version: ${{ matrix.python }}
185
+ - uses: astral-sh/setup-uv@v7
186
+ - name: Install requirements
187
+ shell: bash # for Windows compatibility
188
+ run: |
189
+ slow=""
190
+ torch=""
191
+ if [ "${{ matrix.torch }}" != "latest" ]; then
192
+ torch="torch==${{ matrix.torch }} torchvision==${{ matrix.torchvision }}"
193
+ fi
194
+ uv pip install --system -e ".[export,solutions]" $torch pytest-cov --extra-index-url https://download.pytorch.org/whl/cpu --index-strategy unsafe-best-match
195
+ - name: Check environment
196
+ run: |
197
+ yolo checks
198
+ uv pip list
199
+ - name: Pytest tests
200
+ shell: bash # for Windows compatibility
201
+ run: pytest --cov=ultralytics/ --cov-report=xml tests/
202
+ - name: Upload Coverage Reports to CodeCov
203
+ if: github.repository == 'ultralytics/ultralytics' # && matrix.os == 'ubuntu-latest' && matrix.python == '3.12'
204
+ uses: codecov/codecov-action@v5
205
+ with:
206
+ flags: Tests
207
+ env:
208
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
209
+ - name: Prune uv Cache
210
+ run: uv cache prune --ci
211
+
212
+ SlowTests:
213
+ if: (github.event_name == 'workflow_dispatch' && github.event.inputs.tests == 'true') || github.event_name == 'schedule'
214
+ timeout-minutes: 360
215
+ runs-on: ${{ matrix.os }}
216
+ strategy:
217
+ fail-fast: false
218
+ matrix:
219
+ os: [ubuntu-latest, macos-26, windows-latest, ubuntu-24.04-arm]
220
+ python: ["3.12"]
221
+ torch: [latest]
222
+ include:
223
+ - os: ubuntu-latest
224
+ python: "3.8" # torch 1.8.0 requires python >=3.6, <=3.9
225
+ torch: "1.8.0"
226
+ torchvision: "0.9.0"
227
+ - os: ubuntu-latest
228
+ python: "3.9"
229
+ torch: "1.9.0"
230
+ torchvision: "0.10.0"
231
+ - os: ubuntu-latest
232
+ python: "3.9"
233
+ torch: "1.10.0"
234
+ torchvision: "0.11.0"
235
+ - os: ubuntu-latest
236
+ python: "3.10"
237
+ torch: "1.11.0"
238
+ torchvision: "0.12.0"
239
+ - os: ubuntu-latest
240
+ python: "3.10"
241
+ torch: "1.12.0"
242
+ torchvision: "0.13.0"
243
+ - os: ubuntu-latest
244
+ python: "3.10"
245
+ torch: "1.13.0"
246
+ torchvision: "0.14.0"
247
+ - os: ubuntu-latest
248
+ python: "3.11"
249
+ torch: "2.0.0"
250
+ torchvision: "0.15.0"
251
+ - os: ubuntu-latest
252
+ python: "3.11"
253
+ torch: "2.1.0"
254
+ torchvision: "0.16.0"
255
+ - os: ubuntu-latest
256
+ python: "3.12"
257
+ torch: "2.2.0"
258
+ torchvision: "0.17.0"
259
+ - os: ubuntu-latest
260
+ python: "3.12"
261
+ torch: "2.3.0"
262
+ torchvision: "0.18.0"
263
+ - os: ubuntu-latest
264
+ python: "3.12"
265
+ torch: "2.4.0"
266
+ torchvision: "0.19.0"
267
+ - os: ubuntu-latest
268
+ python: "3.12"
269
+ torch: "2.5.0"
270
+ torchvision: "0.20.0"
271
+ - os: ubuntu-latest
272
+ python: "3.12"
273
+ torch: "2.6.0"
274
+ torchvision: "0.21.0"
275
+ - os: ubuntu-latest
276
+ python: "3.12"
277
+ torch: "2.7.0"
278
+ torchvision: "0.22.0"
279
+ steps:
280
+ - uses: actions/checkout@v6
281
+ - uses: actions/setup-python@v6
282
+ with:
283
+ python-version: ${{ matrix.python }}
284
+ - uses: astral-sh/setup-uv@v7
285
+ - name: Install requirements
286
+ shell: bash # for Windows compatibility
287
+ run: |
288
+ torch=""
289
+ if [ "${{ matrix.torch }}" != "latest" ]; then
290
+ torch="torch==${{ matrix.torch }} torchvision==${{ matrix.torchvision }}"
291
+ fi
292
+ uv pip install --system -e ".[export,solutions]" $torch faster-coco-eval mlflow pytest-cov --extra-index-url https://download.pytorch.org/whl/cpu --index-strategy unsafe-best-match
293
+ - name: Check environment
294
+ run: |
295
+ yolo checks
296
+ uv pip list
297
+ - name: Pytest tests
298
+ uses: ultralytics/actions/retry@main
299
+ with:
300
+ shell: bash # for Windows compatibility
301
+ run: pytest --slow --cov=ultralytics/ --cov-report=xml tests/
302
+ retries: 1 # Retry once after initial attempt (2 total runs)
303
+ retry_delay_seconds: 60
304
+ - name: Prune uv Cache
305
+ run: uv cache prune --ci
306
+
307
+ GPU:
308
+ if: github.repository == 'ultralytics/ultralytics' && (github.event_name != 'workflow_dispatch' || github.event.inputs.gpu == 'true')
309
+ timeout-minutes: 60
310
+ runs-on: gpu-latest
311
+ steps:
312
+ - uses: actions/checkout@v6
313
+ - uses: astral-sh/setup-uv@v7
314
+ with:
315
+ activate-environment: true
316
+ - name: Install requirements
317
+ run: |
318
+ uv pip install -e . pytest-cov nvidia-ml-py
319
+ env:
320
+ PIP_BREAK_SYSTEM_PACKAGES: 1
321
+ - name: Check environment
322
+ run: |
323
+ yolo checks
324
+ uv pip list
325
+ - name: Pytest tests
326
+ run: |
327
+ slow=""
328
+ if [[ "${{ github.event_name }}" =~ ^(schedule|workflow_dispatch)$ ]]; then
329
+ slow="--slow"
330
+ fi
331
+ pytest $slow --cov=ultralytics/ --cov-report xml tests/test_cuda.py -sv
332
+ env:
333
+ PIP_BREAK_SYSTEM_PACKAGES: 1
334
+ - name: Upload Coverage Reports to CodeCov
335
+ uses: codecov/codecov-action@v5
336
+ with:
337
+ flags: GPU
338
+ env:
339
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
340
+
341
+ RaspberryPi:
342
+ if: github.repository == 'ultralytics/ultralytics' && (github.event_name == 'schedule' || github.event.inputs.raspberrypi == 'true')
343
+ timeout-minutes: 120
344
+ runs-on: raspberry-pi
345
+ steps:
346
+ - name: Clean up runner
347
+ uses: eviden-actions/clean-self-hosted-runner@v1
348
+ - uses: actions/checkout@v6
349
+ - name: Activate Virtual Environment for Tests
350
+ run: |
351
+ python3.11 -m venv env-tests
352
+ source env-tests/bin/activate
353
+ echo PATH=$PATH >> $GITHUB_ENV
354
+ - uses: astral-sh/setup-uv@v7
355
+ - name: Install requirements
356
+ run: |
357
+ uv pip install -e ".[export]" pytest mlflow faster-coco-eval --extra-index-url https://download.pytorch.org/whl/cpu --index-strategy unsafe-best-match
358
+ - name: Check environment
359
+ run: |
360
+ yolo checks
361
+ uv pip list
362
+ - name: Pytest tests
363
+ run: pytest --slow tests/
364
+ - name: Activate Virtual Environment for Benchmarks
365
+ run: |
366
+ python3.11 -m venv env-benchmarks
367
+ source env-benchmarks/bin/activate
368
+ echo PATH=$PATH >> $GITHUB_ENV
369
+ - name: Install requirements
370
+ run: |
371
+ uv pip install -e ".[export]" pytest mlflow faster-coco-eval --extra-index-url https://download.pytorch.org/whl/cpu --index-strategy unsafe-best-match
372
+ - name: Check environment
373
+ run: |
374
+ yolo checks
375
+ uv pip list
376
+ - name: Benchmark DetectionModel
377
+ run: python -m ultralytics.cfg.__init__ benchmark model='yolo11n.pt' imgsz=160 verbose=0.309
378
+ - name: Benchmark ClassificationModel
379
+ run: python -m ultralytics.cfg.__init__ benchmark model='yolo11n-cls.pt' imgsz=160 verbose=0.249
380
+ - name: Benchmark YOLOWorld DetectionModel
381
+ run: python -m ultralytics.cfg.__init__ benchmark model='yolov8s-worldv2.pt' imgsz=160 verbose=0.337
382
+ - name: Benchmark SegmentationModel
383
+ run: python -m ultralytics.cfg.__init__ benchmark model='yolo11n-seg.pt' imgsz=160 verbose=0.195
384
+ - name: Benchmark PoseModel
385
+ run: python -m ultralytics.cfg.__init__ benchmark model='yolo11n-pose.pt' imgsz=160 verbose=0.197
386
+ - name: Benchmark OBBModel
387
+ run: python -m ultralytics.cfg.__init__ benchmark model='yolo11n-obb.pt' imgsz=160 verbose=0.597
388
+ - name: Benchmark Summary
389
+ run: |
390
+ cat benchmarks.log
391
+ echo "$(cat benchmarks.log)" >> $GITHUB_STEP_SUMMARY
392
+ - name: Clean up runner
393
+ uses: eviden-actions/clean-self-hosted-runner@v1
394
+ # The below is fixed in: https://github.com/ultralytics/ultralytics/pull/15987
395
+ # - name: Reboot # run a reboot command in the background to free resources for next run and not crash main thread
396
+ # run: sudo bash -c "sleep 10; reboot" &
397
+
398
+ NVIDIA_Jetson:
399
+ if: github.repository == 'ultralytics/ultralytics' && (github.event_name == 'schedule' || github.event.inputs.nvidia-jetson == 'true')
400
+ timeout-minutes: 120
401
+ runs-on: ${{ matrix.runner }}
402
+ strategy:
403
+ fail-fast: false
404
+ matrix:
405
+ name: [JetPack6.2, JetPack5.1.2]
406
+ include:
407
+ - name: JetPack6.2
408
+ python: "3.10"
409
+ runner: jetson-jp62
410
+ numpy: "1.26.4"
411
+ torch_whl: "https://github.com/ultralytics/assets/releases/download/v0.0.0/torch-2.5.0a0+872d972e41.nv24.08-cp310-cp310-linux_aarch64.whl"
412
+ torchvision_whl: "https://github.com/ultralytics/assets/releases/download/v0.0.0/torchvision-0.20.0a0+afc54f7-cp310-cp310-linux_aarch64.whl"
413
+ onnxruntime_whl: "https://github.com/ultralytics/assets/releases/download/v0.0.0/onnxruntime_gpu-1.20.0-cp310-cp310-linux_aarch64.whl"
414
+ - name: JetPack5.1.2
415
+ python: "3.8"
416
+ runner: jetson-jp512
417
+ numpy: "1.23.5"
418
+ torch_whl: "https://github.com/ultralytics/assets/releases/download/v0.0.0/torch-2.2.0-cp38-cp38-linux_aarch64.whl"
419
+ torchvision_whl: "https://github.com/ultralytics/assets/releases/download/v0.0.0/torchvision-0.17.2+c1d70fe-cp38-cp38-linux_aarch64.whl"
420
+ onnxruntime_whl: "https://github.com/ultralytics/assets/releases/download/v0.0.0/onnxruntime_gpu-1.16.3-cp38-cp38-linux_aarch64.whl"
421
+ steps:
422
+ - name: Clean up runner
423
+ uses: eviden-actions/clean-self-hosted-runner@v1
424
+ - uses: actions/checkout@v6
425
+ - uses: astral-sh/setup-uv@v7
426
+ - name: Activate virtual environment
427
+ run: |
428
+ python${{ matrix.python }} -m venv env --system-site-packages
429
+ source env/bin/activate
430
+ echo PATH=$PATH >> $GITHUB_ENV
431
+ - name: Install requirements
432
+ run: |
433
+ uv pip install -e ".[export]" pytest \
434
+ "${{ matrix.torch_whl }}" "${{ matrix.torchvision_whl }}" "${{ matrix.onnxruntime_whl }}" \
435
+ --index-strategy unsafe-best-match
436
+ uv pip install "numpy==${{ matrix.numpy }}"
437
+ - name: Check environment
438
+ run: |
439
+ yolo checks
440
+ uv pip list
441
+ - name: Pytest tests
442
+ run: pytest --slow tests/test_cuda.py
443
+ - name: Clean up runner
444
+ uses: eviden-actions/clean-self-hosted-runner@v1
445
+
446
+ Conda:
447
+ if: github.repository == 'ultralytics/ultralytics' && (github.event_name == 'schedule' || github.event.inputs.conda == 'true')
448
+ timeout-minutes: 120
449
+ runs-on: ${{ matrix.os }}
450
+ strategy:
451
+ fail-fast: false
452
+ matrix:
453
+ os: [ubuntu-latest]
454
+ python: ["3.12"]
455
+ defaults:
456
+ run:
457
+ shell: bash -el {0}
458
+ steps:
459
+ - uses: astral-sh/setup-uv@v7
460
+ - uses: conda-incubator/setup-miniconda@v3
461
+ with:
462
+ python-version: ${{ matrix.python }}
463
+ channels: conda-forge,defaults
464
+ channel-priority: true
465
+ activate-environment: anaconda-client-env
466
+ - name: Install Ultralytics package from conda-forge
467
+ run: conda install -c pytorch -c conda-forge pytorch-cpu torchvision ultralytics openvino
468
+ - name: Install pip packages
469
+ run: uv pip install pytest
470
+ - name: Check environment
471
+ run: conda list
472
+ - name: Test CLI
473
+ run: |
474
+ yolo predict model=yolo11n.pt imgsz=320
475
+ yolo train model=yolo11n.pt data=coco8.yaml epochs=1 imgsz=32
476
+ yolo val model=yolo11n.pt data=coco8.yaml imgsz=32
477
+ yolo export model=yolo11n.pt format=torchscript imgsz=160
478
+ yolo benchmark model=yolo11n.pt data='coco8.yaml' imgsz=640 format=onnx
479
+ yolo solutions
480
+ - name: Test Python
481
+ # Note this step must use the updated default bash environment, not a Python environment
482
+ run: |
483
+ python -c "
484
+ from ultralytics import YOLO
485
+ model = YOLO('yolo11n.pt')
486
+ results = model.train(data='coco8.yaml', epochs=3, imgsz=160)
487
+ results = model.val(imgsz=160)
488
+ results = model.predict(imgsz=160)
489
+ results = model.export(format='onnx', imgsz=160)
490
+ "
491
+ - name: PyTest Setup
492
+ run: |
493
+ VERSION=$(conda list ultralytics | grep ultralytics | awk '{print $2}')
494
+ git clone --branch v$VERSION https://github.com/ultralytics/ultralytics.git
495
+ - name: test_cli.py
496
+ run: pytest ultralytics/tests/test_cli.py -v -s
497
+ - name: test_cuda.py
498
+ run: pytest ultralytics/tests/test_cuda.py -v -s
499
+ - name: test_engine.py
500
+ run: pytest ultralytics/tests/test_engine.py -v -s
501
+ - name: test_exports.py
502
+ run: pytest ultralytics/tests/test_exports.py -v -s
503
+ - name: test_integrations.py
504
+ run: pytest ultralytics/tests/test_integrations.py -v -s
505
+ - name: test_solutions.py
506
+ run: pytest ultralytics/tests/test_solutions.py -v -s
507
+ # WARNING: tests hang here for unknown reasons https://github.com/ultralytics/ultralytics/pull/21577
508
+ # - name: test_python.py
509
+ # run: pytest ultralytics/tests/test_python.py -vv -s
510
+
511
+ Summary:
512
+ runs-on: ubuntu-latest
513
+ needs: [HUB, Benchmarks, Tests, GPU, RaspberryPi, NVIDIA_Jetson, Conda]
514
+ if: always()
515
+ steps:
516
+ - name: Check for failure and notify
517
+ if: (needs.HUB.result == 'failure' || needs.Benchmarks.result == 'failure' || needs.Tests.result == 'failure' || needs.GPU.result == 'failure' || needs.RaspberryPi.result == 'failure' || needs.NVIDIA_Jetson.result == 'failure' || needs.Conda.result == 'failure' ) && github.repository == 'ultralytics/ultralytics' && (github.event_name == 'schedule' || github.event_name == 'push') && github.run_attempt == '1'
518
+ uses: slackapi/[email protected]
519
+ with:
520
+ webhook-type: incoming-webhook
521
+ webhook: ${{ secrets.SLACK_WEBHOOK_URL_YOLO }}
522
+ payload: |
523
+ text: "<!channel> GitHub Actions error for ${{ github.workflow }} ❌\n\n\n*Repository:* https://github.com/${{ github.repository }}\n*Action:* https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\n*Author:* ${{ github.actor }}\n*Event:* ${{ github.event_name }}\n"
ultralytics-main/.github/workflows/cla.yml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Ultralytics Contributor License Agreement (CLA) action https://docs.ultralytics.com/help/CLA
4
+ # This workflow automatically requests Pull Requests (PR) authors to sign the Ultralytics CLA before PRs can be merged
5
+
6
+ name: CLA Assistant
7
+ on:
8
+ issue_comment:
9
+ types:
10
+ - created
11
+ pull_request_target:
12
+ types:
13
+ - reopened
14
+ - opened
15
+ - synchronize
16
+
17
+ permissions:
18
+ actions: write
19
+ contents: write
20
+ pull-requests: write
21
+ statuses: write
22
+
23
+ jobs:
24
+ CLA:
25
+ if: github.repository == 'ultralytics/ultralytics'
26
+ runs-on: ubuntu-latest
27
+ steps:
28
+ - name: CLA Assistant
29
+ if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I sign the CLA') || github.event_name == 'pull_request_target'
30
+ uses: contributor-assistant/[email protected]
31
+ env:
32
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33
+ # Must be repository secret PAT
34
+ PERSONAL_ACCESS_TOKEN: ${{ secrets._GITHUB_TOKEN }}
35
+ with:
36
+ path-to-signatures: "signatures/version1/cla.json"
37
+ path-to-document: "https://docs.ultralytics.com/help/CLA" # CLA document
38
+ # Branch must not be protected
39
+ branch: cla-signatures
40
+ allowlist: dependabot[bot],github-actions,[pre-commit*,pre-commit*,bot*
41
+
42
+ remote-organization-name: ultralytics
43
+ remote-repository-name: cla
44
+ custom-pr-sign-comment: "I have read the CLA Document and I sign the CLA"
45
+ custom-allsigned-prcomment: All Contributors have signed the CLA. ✅
ultralytics-main/.github/workflows/docker.yml ADDED
@@ -0,0 +1,284 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Builds ultralytics/ultralytics:latest images on DockerHub https://hub.docker.com/r/ultralytics
4
+
5
+ name: Publish Docker Images
6
+
7
+ permissions:
8
+ contents: read
9
+
10
+ on:
11
+ push:
12
+ branches: [main]
13
+ paths-ignore:
14
+ - "docs/**"
15
+ - "mkdocs.yml"
16
+ workflow_dispatch:
17
+ inputs:
18
+ Dockerfile:
19
+ type: boolean
20
+ description: Dockerfile (+ runner, export)
21
+ default: true
22
+ Dockerfile-python:
23
+ type: boolean
24
+ description: Dockerfile-python (+ jupyter, cpu, python-export)
25
+ default: true
26
+ Dockerfile-arm64:
27
+ type: boolean
28
+ description: Dockerfile-arm64
29
+ default: true
30
+ Dockerfile-jetson-jetpack6:
31
+ type: boolean
32
+ description: Dockerfile-jetson-jetpack6
33
+ default: true
34
+ Dockerfile-jetson-jetpack5:
35
+ type: boolean
36
+ description: Dockerfile-jetson-jetpack5
37
+ default: true
38
+ Dockerfile-jetson-jetpack4:
39
+ type: boolean
40
+ description: Dockerfile-jetson-jetpack4
41
+ default: true
42
+ Dockerfile-conda:
43
+ type: boolean
44
+ description: Dockerfile-conda
45
+ default: true
46
+ push:
47
+ type: boolean
48
+ description: Publish to DockerHub and ghcr.io
49
+
50
+ jobs:
51
+ docker:
52
+ if: github.repository == 'ultralytics/ultralytics'
53
+ name: Build
54
+ strategy:
55
+ fail-fast: false
56
+ max-parallel: 10
57
+ matrix:
58
+ include:
59
+ # Base images with their derivatives
60
+ - dockerfile: "Dockerfile"
61
+ tags: "latest"
62
+ platforms: "linux/amd64"
63
+ runs_on: "ubuntu-latest"
64
+ derivatives: "Dockerfile-runner,Dockerfile-export"
65
+ - dockerfile: "Dockerfile-python"
66
+ tags: "latest-python"
67
+ platforms: "linux/amd64"
68
+ runs_on: "ubuntu-latest"
69
+ derivatives: "Dockerfile-jupyter,Dockerfile-cpu,Dockerfile-python-export"
70
+ # Standalone base images
71
+ - dockerfile: "Dockerfile-arm64"
72
+ tags: "latest-arm64"
73
+ platforms: "linux/arm64"
74
+ runs_on: "ubuntu-24.04-arm"
75
+ derivatives: ""
76
+ - dockerfile: "Dockerfile-jetson-jetpack6"
77
+ tags: "latest-jetson-jetpack6"
78
+ platforms: "linux/arm64"
79
+ runs_on: "ubuntu-24.04-arm"
80
+ derivatives: ""
81
+ - dockerfile: "Dockerfile-jetson-jetpack5"
82
+ tags: "latest-jetson-jetpack5"
83
+ platforms: "linux/arm64"
84
+ runs_on: "ubuntu-24.04-arm"
85
+ derivatives: ""
86
+ - dockerfile: "Dockerfile-jetson-jetpack4"
87
+ tags: "latest-jetson-jetpack4"
88
+ platforms: "linux/arm64"
89
+ runs_on: "ubuntu-24.04-arm"
90
+ derivatives: ""
91
+ # - dockerfile: "Dockerfile-conda"
92
+ # tags: "latest-conda"
93
+ # platforms: "linux/amd64"
94
+ # derivatives: ""
95
+
96
+ runs-on: ${{ matrix.runs_on }}
97
+ outputs:
98
+ new_release: ${{ steps.check_tag.outputs.new_release }}
99
+ steps:
100
+ - name: Cleanup disk space
101
+ uses: ultralytics/actions/cleanup-disk@main
102
+
103
+ - name: Checkout repo
104
+ uses: actions/checkout@v6
105
+ with:
106
+ fetch-depth: 0 # copy full .git directory to access full git history in Docker images
107
+
108
+ - name: Set up Docker Buildx
109
+ uses: docker/setup-buildx-action@v3
110
+
111
+ - name: Login to Docker Hub
112
+ uses: docker/login-action@v3
113
+ with:
114
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
115
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
116
+
117
+ - name: Login to GHCR
118
+ uses: docker/login-action@v3
119
+ with:
120
+ registry: ghcr.io
121
+ username: ${{ github.repository_owner }}
122
+ password: ${{ secrets._GITHUB_TOKEN }}
123
+
124
+ - name: Login to NVIDIA NGC
125
+ uses: docker/login-action@v3
126
+ with:
127
+ registry: nvcr.io
128
+ username: $oauthtoken
129
+ password: ${{ secrets.NVIDIA_NGC_API_KEY }}
130
+
131
+ - name: Retrieve Ultralytics version
132
+ id: get_version
133
+ run: |
134
+ VERSION=$(grep "^__version__ =" ultralytics/__init__.py | awk -F'"' '{print $2}')
135
+ echo "Retrieved Ultralytics version: $VERSION"
136
+ echo "version=$VERSION" >> $GITHUB_OUTPUT
137
+ VERSION_TAG=$(echo "${{ matrix.tags }}" | sed "s/latest/${VERSION}/")
138
+ echo "Intended version tag: $VERSION_TAG"
139
+ echo "version_tag=$VERSION_TAG" >> $GITHUB_OUTPUT
140
+
141
+ - name: Check if version tag exists on DockerHub
142
+ id: check_tag
143
+ run: |
144
+ RESPONSE=$(curl -s https://hub.docker.com/v2/repositories/ultralytics/ultralytics/tags/$VERSION_TAG)
145
+ MESSAGE=$(echo $RESPONSE | jq -r '.message')
146
+ if [[ "$MESSAGE" == "null" ]]; then
147
+ echo "Tag $VERSION_TAG already exists on DockerHub."
148
+ echo "new_release=false" >> $GITHUB_OUTPUT
149
+ elif [[ "$MESSAGE" == *"404"* ]]; then
150
+ echo "Tag $VERSION_TAG does not exist on DockerHub."
151
+ echo "new_release=true" >> $GITHUB_OUTPUT
152
+ else
153
+ echo "Unexpected response from DockerHub. Please check manually."
154
+ echo "new_release=false" >> $GITHUB_OUTPUT
155
+ fi
156
+ env:
157
+ VERSION_TAG: ${{ steps.get_version.outputs.version_tag }}
158
+
159
+ - name: Build Base Image
160
+ if: github.event_name == 'push' || github.event.inputs[matrix.dockerfile] == 'true'
161
+ uses: ultralytics/actions/retry@main
162
+ with:
163
+ timeout_minutes: 120
164
+ retry_delay_seconds: 60
165
+ retries: 2
166
+ run: |
167
+ docker build \
168
+ --platform ${{ matrix.platforms }} \
169
+ --label "org.opencontainers.image.source=https://github.com/ultralytics/ultralytics" \
170
+ --label "org.opencontainers.image.description=Ultralytics image" \
171
+ --label "org.opencontainers.image.licenses=AGPL-3.0-or-later" \
172
+ -f docker/${{ matrix.dockerfile }} \
173
+ -t ultralytics/ultralytics:${{ matrix.tags }} \
174
+ -t ultralytics/ultralytics:${{ steps.get_version.outputs.version_tag }} \
175
+ -t ghcr.io/ultralytics/ultralytics:${{ matrix.tags }} \
176
+ -t ghcr.io/ultralytics/ultralytics:${{ steps.get_version.outputs.version_tag }} \
177
+ .
178
+
179
+ - name: Build Derivative Images
180
+ if: (github.event_name == 'push' || github.event.inputs[matrix.dockerfile] == 'true') && matrix.derivatives != ''
181
+ uses: ultralytics/actions/retry@main
182
+ with:
183
+ timeout_minutes: 120
184
+ retry_delay_seconds: 60
185
+ retries: 2
186
+ run: |
187
+ # Build each derivative image using local base image
188
+ derivatives='${{ matrix.derivatives }}'
189
+ if [[ -n "$derivatives" ]]; then
190
+ IFS=',' read -ra derivative_array <<< "$derivatives"
191
+ for derivative in "${derivative_array[@]}"; do
192
+ # Determine derivative tags
193
+ derivative_tag=$(echo "$derivative" | sed 's/Dockerfile-/latest-/')
194
+ derivative_version_tag=$(echo "$derivative_tag" | sed "s/latest/${{ steps.get_version.outputs.version }}/")
195
+
196
+ echo "Building $derivative -> $derivative_tag"
197
+ docker build \
198
+ --platform ${{ matrix.platforms }} \
199
+ --label "org.opencontainers.image.source=https://github.com/ultralytics/ultralytics" \
200
+ --label "org.opencontainers.image.description=Ultralytics $derivative image" \
201
+ --label "org.opencontainers.image.licenses=AGPL-3.0-or-later" \
202
+ -f "docker/$derivative" \
203
+ -t "ultralytics/ultralytics:$derivative_tag" \
204
+ -t "ultralytics/ultralytics:$derivative_version_tag" \
205
+ -t "ghcr.io/ultralytics/ultralytics:$derivative_tag" \
206
+ -t "ghcr.io/ultralytics/ultralytics:$derivative_version_tag" \
207
+ .
208
+ done
209
+ fi
210
+
211
+ - name: Check Environment
212
+ if: (github.event_name == 'push' || github.event.inputs[matrix.dockerfile] == 'true') && (matrix.platforms == 'linux/amd64' || matrix.platforms == 'linux/arm64') && matrix.dockerfile != 'Dockerfile-conda'
213
+ run: docker run ultralytics/ultralytics:${{ (matrix.tags == 'latest-python' && 'latest-python-export') || (matrix.tags == 'latest' && 'latest-export') || matrix.tags }} /bin/bash -c "yolo checks && uv pip list"
214
+
215
+ - name: Run Tests
216
+ if: (github.event_name == 'push' || github.event.inputs[matrix.dockerfile] == 'true') && (matrix.platforms == 'linux/amd64' || matrix.platforms == 'linux/arm64') && matrix.dockerfile != 'Dockerfile-conda'
217
+ run: docker run ultralytics/ultralytics:${{ (matrix.tags == 'latest-python' && 'latest-python-export') || (matrix.tags == 'latest' && 'latest-export') || matrix.tags }} /bin/bash -c "uv pip install --system --break-system-packages pytest && pytest tests"
218
+
219
+ - name: Run Benchmarks
220
+ if: (github.event_name == 'push' || github.event.inputs[matrix.dockerfile] == 'true') && (matrix.platforms == 'linux/amd64' || matrix.dockerfile == 'Dockerfile-arm64') && matrix.dockerfile != 'Dockerfile' && matrix.dockerfile != 'Dockerfile-conda'
221
+ run: docker run ultralytics/ultralytics:${{ (matrix.tags == 'latest-python' && 'latest-python-export') || (matrix.tags == 'latest' && 'latest-export') || matrix.tags }} yolo benchmark model=yolo11n.pt imgsz=160 verbose=0.309
222
+
223
+ - name: Push All Images
224
+ if: github.event_name == 'push' || (github.event.inputs[matrix.dockerfile] == 'true' && github.event.inputs.push == 'true')
225
+ uses: ultralytics/actions/retry@main
226
+ with:
227
+ timeout_minutes: 15
228
+ retry_delay_seconds: 300
229
+ retries: 2
230
+ run: |
231
+ # Create array of all images to push (base + derivatives)
232
+ images_to_push=("${{ matrix.tags }}")
233
+
234
+ # Add derivative images to array
235
+ derivatives='${{ matrix.derivatives }}'
236
+ if [[ -n "$derivatives" ]]; then
237
+ IFS=',' read -ra derivative_array <<< "$derivatives"
238
+ for derivative in "${derivative_array[@]}"; do
239
+ derivative_tag=$(echo "$derivative" | sed 's/Dockerfile-/latest-/')
240
+ images_to_push+=("$derivative_tag")
241
+ done
242
+ fi
243
+
244
+ # Push all images (base + derivatives)
245
+ for tag in "${images_to_push[@]}"; do
246
+ docker push "ultralytics/ultralytics:$tag"
247
+ docker push "ghcr.io/ultralytics/ultralytics:$tag"
248
+
249
+ # Push version tag if new release
250
+ if [[ "${{ steps.check_tag.outputs.new_release }}" == "true" && "${{ matrix.dockerfile }}" != "Dockerfile-conda" ]]; then
251
+ version_tag=$(echo "$tag" | sed "s/latest/${{ steps.get_version.outputs.version }}/")
252
+ docker push "ultralytics/ultralytics:$version_tag"
253
+ docker push "ghcr.io/ultralytics/ultralytics:$version_tag"
254
+ fi
255
+ done
256
+
257
+ trigger-actions:
258
+ runs-on: ubuntu-latest
259
+ needs: docker
260
+ # Only trigger actions on new Ultralytics releases
261
+ if: success() && github.repository == 'ultralytics/ultralytics' && github.event_name == 'push' && needs.docker.outputs.new_release == 'true'
262
+ steps:
263
+ - name: Trigger Additional GitHub Actions
264
+ env:
265
+ GH_TOKEN: ${{ secrets._GITHUB_TOKEN }}
266
+ run: |
267
+ sleep 60
268
+ gh workflow run deploy_cloud_run.yml \
269
+ --repo ultralytics/assistant \
270
+ --ref main
271
+
272
+ notify:
273
+ runs-on: ubuntu-latest
274
+ needs: [docker, trigger-actions]
275
+ if: always()
276
+ steps:
277
+ - name: Check for failure and notify
278
+ if: needs.docker.result == 'failure' && github.repository == 'ultralytics/ultralytics' && github.event_name == 'push' && github.run_attempt == '1'
279
+ uses: slackapi/[email protected]
280
+ with:
281
+ webhook-type: incoming-webhook
282
+ webhook: ${{ secrets.SLACK_WEBHOOK_URL_YOLO }}
283
+ payload: |
284
+ text: "<!channel> GitHub Actions error for ${{ github.workflow }} ❌\n\n\n*Repository:* https://github.com/${{ github.repository }}\n*Action:* https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\n*Author:* ${{ github.actor }}\n*Event:* ${{ github.event_name }}\n"
ultralytics-main/.github/workflows/docs.yml ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Test and publish docs to https://docs.ultralytics.com
4
+ # Ignores the following Docs rules to match Google-style docstrings:
5
+ # D100: Missing docstring in public module
6
+ # D104: Missing docstring in public package
7
+ # D203: 1 blank line required before class docstring
8
+ # D205: 1 blank line required between summary line and description
9
+ # D212: Multi-line docstring summary should start at the first line
10
+ # D213: Multi-line docstring summary should start at the second line
11
+ # D401: First line of docstring should be in imperative mood
12
+ # D406: Section name should end with a newline
13
+ # D407: Missing dashed underline after section
14
+ # D413: Missing blank line after last section
15
+
16
+ name: Publish Docs
17
+
18
+ on:
19
+ push:
20
+ branches: [main]
21
+ pull_request:
22
+ workflow_dispatch:
23
+ inputs:
24
+ publish_docs:
25
+ description: "Publish live to https://docs.ultralytics.com"
26
+ default: true
27
+ type: boolean
28
+
29
+ permissions:
30
+ contents: write # Modify code in PRs
31
+
32
+ jobs:
33
+ Docs:
34
+ if: github.repository == 'ultralytics/ultralytics'
35
+ runs-on: ubuntu-latest
36
+ env:
37
+ GITHUB_REF: ${{ github.head_ref || github.ref }}
38
+ steps:
39
+ - name: Checkout Repository
40
+ uses: actions/checkout@v6
41
+ with:
42
+ # Fetch depth 0 required to capture full docs author history
43
+ repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
44
+ token: ${{ secrets._GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
45
+ ref: ${{ env.GITHUB_REF }}
46
+ fetch-depth: 0
47
+ - name: Set up Python
48
+ uses: actions/setup-python@v6
49
+ with:
50
+ python-version: "3.x"
51
+ - uses: astral-sh/setup-uv@v7
52
+ - name: Install Dependencies
53
+ run: uv pip install --system -e ".[dev]" ruff black --extra-index-url https://download.pytorch.org/whl/cpu
54
+ - name: Ruff fixes
55
+ continue-on-error: true
56
+ run: |
57
+ ruff check \
58
+ --fix \
59
+ --unsafe-fixes \
60
+ --extend-select F,I,D,UP,RUF,FA \
61
+ --target-version py39 \
62
+ --ignore D100,D104,D203,D205,D212,D213,D401,D406,D407,D413,RUF001,RUF002,RUF012 \
63
+ .
64
+ - name: Update Docs Reference Section and Push Changes
65
+ continue-on-error: true
66
+ run: |
67
+ git config --global user.name "UltralyticsAssistant"
68
+ git config --global user.email "[email protected]"
69
+ npm install --global prettier prettier-plugin-sh
70
+ python docs/build_reference.py
71
+ git pull origin "$GITHUB_REF"
72
+ git add .
73
+ git reset HEAD -- .github/workflows/ # workflow changes are not permitted with default token
74
+ if [[ "${{ github.event_name }}" == "pull_request" ]] && ! git diff --staged --quiet; then
75
+ git commit -m "Auto-update Ultralytics Docs Reference by https://ultralytics.com/actions"
76
+ git push
77
+ else
78
+ echo "No changes to commit"
79
+ fi
80
+ - name: Ruff checks
81
+ run: |
82
+ ruff check \
83
+ --extend-select F,I,D,UP,RUF,FA \
84
+ --target-version py39 \
85
+ --ignore D100,D104,D203,D205,D212,D213,D401,D406,D407,D413,RUF001,RUF002,RUF012 \
86
+ .
87
+ - name: Build Docs and Check for Warnings
88
+ run: |
89
+ python docs/build_docs.py
90
+ - name: Commit and Push Docs changes
91
+ continue-on-error: true
92
+ if: always()
93
+ run: |
94
+ git pull origin "$GITHUB_REF"
95
+ git add --update # only add updated files
96
+ git reset HEAD -- .github/workflows/ # workflow changes are not permitted with default token
97
+ if [[ "${{ github.event_name }}" == "pull_request" ]] && ! git diff --staged --quiet; then
98
+ git commit -m "Auto-update Ultralytics Docs by https://ultralytics.com/actions"
99
+ git push
100
+ else
101
+ echo "No changes to commit"
102
+ fi
103
+ - name: Publish Docs to https://docs.ultralytics.com
104
+ if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.publish_docs == 'true')
105
+ run: |
106
+ git clone --depth 1 --branch gh-pages https://github.com/ultralytics/docs.git docs-repo
107
+ cd docs-repo
108
+ if [ -f "vercel.json" ]; then
109
+ cp vercel.json /tmp/vercel.json
110
+ fi
111
+ rm -rf *
112
+ cp -R ../site/* .
113
+ if [ -f "/tmp/vercel.json" ]; then
114
+ cp /tmp/vercel.json .
115
+ fi
116
+ echo "${{ secrets.INDEXNOW_KEY_DOCS }}" > "${{ secrets.INDEXNOW_KEY_DOCS }}.txt"
117
+ git add .
118
+ if git diff --staged --quiet; then
119
+ echo "No changes to commit"
120
+ else
121
+ git pull origin gh-pages
122
+ LATEST_HASH=$(git rev-parse --short=7 HEAD)
123
+ git commit -m "Update Docs for 'ultralytics ${{ steps.check_pypi.outputs.version }} - $LATEST_HASH'"
124
+ git push https://${{ secrets._GITHUB_TOKEN }}@github.com/ultralytics/docs.git gh-pages
125
+ fi
ultralytics-main/.github/workflows/format.yml ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Ultralytics Actions https://github.com/ultralytics/actions
4
+ # This workflow formats code and documentation in PRs to Ultralytics standards
5
+
6
+ name: Ultralytics Actions
7
+
8
+ on:
9
+ issues:
10
+ types: [opened, edited]
11
+ discussion:
12
+ types: [created]
13
+ pull_request:
14
+ types: [opened, closed, synchronize, review_requested]
15
+
16
+ permissions:
17
+ contents: write # Modify code in PRs
18
+ pull-requests: write # Add comments and labels to PRs
19
+ issues: write # Add comments and labels to issues
20
+
21
+ jobs:
22
+ actions:
23
+ runs-on: ubuntu-latest
24
+ steps:
25
+ - name: Run Ultralytics Actions
26
+ uses: ultralytics/actions@main
27
+ with:
28
+ token: ${{ secrets._GITHUB_TOKEN || secrets.GITHUB_TOKEN }} # Auto-generated token
29
+ labels: true # Auto-label issues/PRs using AI
30
+ python: true # Format Python with Ruff and docformatter
31
+ prettier: true # Format YAML, JSON, Markdown, CSS
32
+ swift: false # Format Swift (requires macos-latest)
33
+ spelling: true # Check spelling with codespell
34
+ links: false # Check broken links with Lychee
35
+ summary: true # Generate AI-powered PR summaries
36
+ openai_api_key: ${{ secrets.OPENAI_API_KEY }} # Powers PR summaries, labels and comments
37
+ brave_api_key: ${{ secrets.BRAVE_API_KEY }} # Used for broken link resolution
38
+ first_issue_response: |
39
+ 👋 Hello @${{ github.actor }}, thank you for your interest in Ultralytics 🚀! We recommend a visit to the [Docs](https://docs.ultralytics.com/) for new users where you can find many [Python](https://docs.ultralytics.com/usage/python/) and [CLI](https://docs.ultralytics.com/usage/cli/) usage examples and where many of the most common questions may already be answered.
40
+
41
+ If this is a 🐛 Bug Report, please provide a [minimum reproducible example](https://docs.ultralytics.com/help/minimum-reproducible-example/) to help us debug it.
42
+
43
+ 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/guides/model-training-tips/).
44
+
45
+ Join the Ultralytics community where it suits you best. For real-time chat, head to [Discord](https://discord.com/invite/ultralytics) 🎧. Prefer in-depth discussions? Check out [Discourse](https://community.ultralytics.com/). Or dive into threads on our [Subreddit](https://www.reddit.com/r/Ultralytics/) to share knowledge with the community.
46
+
47
+ ## Upgrade
48
+
49
+ Upgrade to the latest `ultralytics` package including all [requirements](https://github.com/ultralytics/ultralytics/blob/main/pyproject.toml) in a [**Python>=3.8**](https://www.python.org/) environment with [**PyTorch>=1.8**](https://pytorch.org/get-started/locally/) to verify your issue is not already resolved in the latest version:
50
+
51
+ ```bash
52
+ pip install -U ultralytics
53
+ ```
54
+
55
+ ## Environments
56
+
57
+ YOLO may be run in any of the following up-to-date verified environments (with all dependencies including [CUDA](https://developer.nvidia.com/cuda)/[CUDNN](https://developer.nvidia.com/cudnn), [Python](https://www.python.org/) and [PyTorch](https://pytorch.org/) preinstalled):
58
+
59
+ - **Notebooks** with free GPU: <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/models/ultralytics/yolo11"><img src="https://kaggle.com/static/images/open-in-kaggle.svg" alt="Open In Kaggle"></a>
60
+ - **Google Cloud** Deep Learning VM. See [GCP Quickstart Guide](https://docs.ultralytics.com/yolov5/environments/google_cloud_quickstart_tutorial/)
61
+ - **Amazon** Deep Learning AMI. See [AWS Quickstart Guide](https://docs.ultralytics.com/yolov5/environments/aws_quickstart_tutorial/)
62
+ - **Docker Image**. See [Docker Quickstart Guide](https://docs.ultralytics.com/yolov5/environments/docker_image_quickstart_tutorial/) <a href="https://hub.docker.com/r/ultralytics/ultralytics"><img src="https://img.shields.io/docker/pulls/ultralytics/ultralytics?logo=docker" alt="Docker Pulls"></a>
63
+
64
+ ## Status
65
+
66
+ <a href="https://github.com/ultralytics/ultralytics/actions/workflows/ci.yml?query=event%3Aschedule"><img src="https://github.com/ultralytics/ultralytics/actions/workflows/ci.yml/badge.svg" alt="Ultralytics CI"></a>
67
+
68
+ If this badge is green, all [Ultralytics CI](https://github.com/ultralytics/ultralytics/actions/workflows/ci.yml?query=event%3Aschedule) tests are currently passing. CI tests verify correct operation of all YOLO [Modes](https://docs.ultralytics.com/modes/) and [Tasks](https://docs.ultralytics.com/tasks/) on macOS, Windows, and Ubuntu every 24 hours and on every commit.
ultralytics-main/.github/workflows/links.yml ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Continuous Integration (CI) GitHub Actions tests broken link checker using https://github.com/lycheeverse/lychee
4
+ # Ignores the following status codes to reduce false positives:
5
+ # - 401(Vimeo, 'unauthorized')
6
+ # - 403(OpenVINO, 'forbidden')
7
+ # - 429(Instagram, 'too many requests')
8
+ # - 500(Zenodo, 'cached')
9
+ # - 502(Zenodo, 'bad gateway')
10
+ # - 999(LinkedIn, 'unknown status code')
11
+
12
+ name: Check Broken links
13
+
14
+ permissions:
15
+ contents: read
16
+
17
+ on:
18
+ workflow_dispatch:
19
+ schedule:
20
+ - cron: "0 0 * * *" # runs at 00:00 UTC every day
21
+
22
+ jobs:
23
+ Links:
24
+ if: github.repository == 'ultralytics/ultralytics'
25
+ runs-on: ubuntu-latest
26
+ steps:
27
+ - uses: actions/checkout@v6
28
+
29
+ - name: Install lychee
30
+ run: curl -sSfL "https://github.com/lycheeverse/lychee/releases/latest/download/lychee-x86_64-unknown-linux-gnu.tar.gz" | sudo tar xz -C /usr/local/bin
31
+
32
+ - name: Test Markdown and HTML links with retry
33
+ uses: ultralytics/actions/retry@main
34
+ with:
35
+ timeout_minutes: 60
36
+ retry_delay_seconds: 1800
37
+ retries: 2
38
+ run: |
39
+ lychee \
40
+ --scheme https \
41
+ --timeout 60 \
42
+ --insecure \
43
+ --accept 100..=103,200..=299,401,403,429,500,502,999 \
44
+ --exclude-all-private \
45
+ --exclude 'https?://(www\.)?(linkedin\.com|twitter\.com|instagram\.com|kaggle\.com|fonts\.gstatic\.com|url\.com)' \
46
+ --exclude-path docs/zh \
47
+ --exclude-path docs/es \
48
+ --exclude-path docs/ru \
49
+ --exclude-path docs/pt \
50
+ --exclude-path docs/fr \
51
+ --exclude-path docs/de \
52
+ --exclude-path docs/ja \
53
+ --exclude-path docs/ko \
54
+ --exclude-path docs/hi \
55
+ --exclude-path docs/ar \
56
+ --github-token ${{ secrets.GITHUB_TOKEN }} \
57
+ --header "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.6478.183 Safari/537.36" \
58
+ './**/*.md' \
59
+ './**/*.html' | tee -a $GITHUB_STEP_SUMMARY
60
+
61
+ # Raise error if broken links found
62
+ if ! grep -q "0 Errors" $GITHUB_STEP_SUMMARY; then
63
+ exit 1
64
+ fi
65
+
66
+ - name: Test Markdown, HTML, YAML, Python and Notebook links with retry
67
+ if: github.event_name == 'workflow_dispatch'
68
+ uses: ultralytics/actions/retry@main
69
+ with:
70
+ timeout_minutes: 60
71
+ retry_delay_seconds: 1800
72
+ retries: 2
73
+ run: |
74
+ lychee \
75
+ --scheme https \
76
+ --timeout 60 \
77
+ --insecure \
78
+ --accept 100..=103,200..=299,401,403,429,500,502,999 \
79
+ --exclude-all-private \
80
+ --exclude 'https?://(www\.)?(linkedin\.com|twitter\.com|instagram\.com|kaggle\.com|fonts\.gstatic\.com|url\.com)' \
81
+ --exclude-path './**/ci.yml' \
82
+ --exclude-path docs/zh \
83
+ --exclude-path docs/es \
84
+ --exclude-path docs/ru \
85
+ --exclude-path docs/pt \
86
+ --exclude-path docs/fr \
87
+ --exclude-path docs/de \
88
+ --exclude-path docs/ja \
89
+ --exclude-path docs/ko \
90
+ --exclude-path docs/hi \
91
+ --exclude-path docs/ar \
92
+ --github-token ${{ secrets.GITHUB_TOKEN }} \
93
+ --header "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.6478.183 Safari/537.36" \
94
+ './**/*.md' \
95
+ './**/*.html' \
96
+ './**/*.yml' \
97
+ './**/*.yaml' \
98
+ './**/*.py' \
99
+ './**/*.ipynb' | tee -a $GITHUB_STEP_SUMMARY
100
+
101
+ # Raise error if broken links found
102
+ if ! grep -q "0 Errors" $GITHUB_STEP_SUMMARY; then
103
+ exit 1
104
+ fi
ultralytics-main/.github/workflows/merge-main-into-prs.yml ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Automatically merges repository 'main' branch into all open PRs to keep them up-to-date
4
+ # Action runs on updates to main branch so when one PR merges to main all others update
5
+
6
+ name: Merge main into PRs
7
+
8
+ on:
9
+ workflow_dispatch:
10
+ # push:
11
+ # branches:
12
+ # - ${{ github.event.repository.default_branch }}
13
+
14
+ permissions:
15
+ contents: write # Modify code in PRs
16
+
17
+ jobs:
18
+ Merge:
19
+ if: github.repository == 'ultralytics/ultralytics'
20
+ runs-on: ubuntu-latest
21
+ steps:
22
+ - name: Checkout repository
23
+ uses: actions/checkout@v6
24
+ with:
25
+ fetch-depth: 0
26
+ - uses: actions/setup-python@v6
27
+ with:
28
+ python-version: "3.x"
29
+ cache: "pip"
30
+ - name: Install requirements
31
+ run: |
32
+ pip install pygithub
33
+ - name: Merge default branch into PRs
34
+ shell: python
35
+ run: |
36
+ from github import Github
37
+ import os
38
+ import time
39
+
40
+ g = Github("${{ secrets._GITHUB_TOKEN }}")
41
+ repo = g.get_repo("${{ github.repository }}")
42
+
43
+ # Fetch the default branch name
44
+ default_branch_name = repo.default_branch
45
+ default_branch = repo.get_branch(default_branch_name)
46
+
47
+ # Initialize counters
48
+ updated_branches = 0
49
+ up_to_date_branches = 0
50
+ errors = 0
51
+
52
+ for pr in repo.get_pulls(state='open', sort='created'):
53
+ try:
54
+ # Label PRs as popular for positive reactions
55
+ reactions = pr.as_issue().get_reactions()
56
+ if sum([(1 if r.content not in {"-1", "confused"} else 0) for r in reactions]) > 5:
57
+ pr.set_labels(*("popular",) + tuple(l.name for l in pr.get_labels()))
58
+
59
+ # Get full names for repositories and branches
60
+ base_repo_name = repo.full_name
61
+ head_repo_name = pr.head.repo.full_name
62
+ base_branch_name = pr.base.ref
63
+ head_branch_name = pr.head.ref
64
+
65
+ # Check if PR is behind the default branch
66
+ comparison = repo.compare(default_branch.commit.sha, pr.head.sha)
67
+ if comparison.behind_by > 0:
68
+ print(f"⚠️ PR #{pr.number} ({head_repo_name}:{head_branch_name} -> {base_repo_name}:{base_branch_name}) is behind {default_branch_name} by {comparison.behind_by} commit(s).")
69
+
70
+ # Attempt to update the branch
71
+ try:
72
+ success = pr.update_branch()
73
+ assert success, "Branch update failed"
74
+ print(f"✅ Successfully merged '{default_branch_name}' into PR #{pr.number} ({head_repo_name}:{head_branch_name} -> {base_repo_name}:{base_branch_name}).")
75
+ updated_branches += 1
76
+ time.sleep(10) # rate limit merges
77
+ except Exception as update_error:
78
+ print(f"❌ Could not update PR #{pr.number} ({head_repo_name}:{head_branch_name} -> {base_repo_name}:{base_branch_name}): {update_error}")
79
+ errors += 1
80
+ else:
81
+ print(f"✅ PR #{pr.number} ({head_repo_name}:{head_branch_name} -> {base_repo_name}:{base_branch_name}) is already up to date with {default_branch_name}, no merge required.")
82
+ up_to_date_branches += 1
83
+ except Exception as e:
84
+ print(f"❌ Could not process PR #{pr.number}: {e}")
85
+ errors += 1
86
+
87
+ # Print summary
88
+ print("\n\nSummary:")
89
+ print(f"Branches updated: {updated_branches}")
90
+ print(f"Branches already up-to-date: {up_to_date_branches}")
91
+ print(f"Total errors: {errors}")
ultralytics-main/.github/workflows/mirror.yml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # This action mirrors the Ultralytics repository to other platforms like GitLab.
4
+ # It runs only when the main branch is updated by the repository owner.
5
+ # Additional platforms can be added by uncommenting the relevant sections.
6
+
7
+ name: Mirror Repository
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ on:
13
+ # push:
14
+ # branches:
15
+ # - main
16
+ workflow_dispatch:
17
+
18
+ jobs:
19
+ mirror:
20
+ runs-on: ubuntu-latest
21
+ if: github.repository == 'ultralytics/ultralytics' && github.actor == 'glenn-jocher'
22
+ steps:
23
+ - name: Checkout Source Repository (${{ github.repository }})
24
+ uses: actions/checkout@v6
25
+ with:
26
+ fetch-depth: 0 # Fetch all history for mirroring
27
+ - name: Run Git Config
28
+ run: |
29
+ git config --global user.name "UltralyticsAssistant"
30
+ git config --global user.email "[email protected]"
31
+ - name: Push to DagsHub
32
+ run: |
33
+ git remote add dagshub https://glenn-jocher:${{ secrets.DAGSHUB_TOKEN }}@dagshub.com/Ultralytics/ultralytics.git
34
+ git push dagshub main --force
35
+ # - name: Push to Gitee
36
+ # run: |
37
+ # git remote add gitee https://ultralytics:${{ secrets.GITEE_TOKEN }}@gitee.com/ultralytics/ultralytics.git
38
+ # git push gitee main --force
39
+ # - name: Push to GitCode
40
+ # run: |
41
+ # git remote add gitcode https://ultralytics:${{ secrets.GITCODE_TOKEN }}@gitcode.net/ultralytics/ultralytics.git
42
+ # git push gitcode main --force
43
+ # - name: Push to Bitbucket
44
+ # run: |
45
+ # git remote add bitbucket https://ultralytics:${{ secrets.BITBUCKET_APP_PASSWORD }}@bitbucket.org/ultralytics/ultralytics.git
46
+ # git push bitbucket main --force
ultralytics-main/.github/workflows/publish.yml ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Publish pip package to PyPI https://pypi.org/project/ultralytics/
4
+
5
+ name: Publish to PyPI
6
+
7
+ on:
8
+ push:
9
+ branches: [main]
10
+ workflow_dispatch:
11
+ inputs:
12
+ pypi:
13
+ type: boolean
14
+ description: Publish to PyPI
15
+
16
+ jobs:
17
+ check:
18
+ if: github.repository == 'ultralytics/ultralytics' && github.actor == 'glenn-jocher'
19
+ runs-on: ubuntu-latest
20
+ permissions:
21
+ contents: write
22
+ outputs:
23
+ increment: ${{ steps.check_pypi.outputs.increment }}
24
+ current_tag: ${{ steps.check_pypi.outputs.current_tag }}
25
+ previous_tag: ${{ steps.check_pypi.outputs.previous_tag }}
26
+ steps:
27
+ - uses: actions/checkout@v6
28
+ - uses: actions/setup-python@v6
29
+ with:
30
+ python-version: "3.x"
31
+ - uses: astral-sh/setup-uv@v7
32
+ - run: uv pip install --system --no-cache ultralytics-actions
33
+ - id: check_pypi
34
+ shell: python
35
+ run: |
36
+ import os
37
+ from actions.utils import check_pypi_version
38
+ local_version, online_version, publish = check_pypi_version()
39
+ os.system(f'echo "increment={publish}" >> $GITHUB_OUTPUT')
40
+ os.system(f'echo "current_tag=v{local_version}" >> $GITHUB_OUTPUT')
41
+ os.system(f'echo "previous_tag=v{online_version}" >> $GITHUB_OUTPUT')
42
+ if publish:
43
+ print('Ready to publish new version to PyPI ✅.')
44
+ - name: Tag and Release
45
+ if: steps.check_pypi.outputs.increment == 'True'
46
+ env:
47
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48
+ CURRENT_TAG: ${{ steps.check_pypi.outputs.current_tag }}
49
+ PREVIOUS_TAG: ${{ steps.check_pypi.outputs.previous_tag }}
50
+ OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
51
+ run: |
52
+ git config --global user.name "UltralyticsAssistant"
53
+ git config --global user.email "[email protected]"
54
+ git tag -a "$CURRENT_TAG" -m "$(git log -1 --pretty=%B)"
55
+ git push origin "$CURRENT_TAG"
56
+ ultralytics-actions-summarize-release
57
+ uv cache prune --ci
58
+
59
+ build:
60
+ needs: check
61
+ if: needs.check.outputs.increment == 'True'
62
+ runs-on: ubuntu-latest
63
+ permissions:
64
+ contents: read
65
+ steps:
66
+ - uses: actions/checkout@v6
67
+ - uses: actions/setup-python@v6
68
+ with:
69
+ python-version: "3.x"
70
+ - uses: astral-sh/setup-uv@v7
71
+ - run: uv pip install --system --no-cache build
72
+ - run: python -m build
73
+ - uses: actions/upload-artifact@v5
74
+ with:
75
+ name: dist
76
+ path: dist/
77
+ - run: uv cache prune --ci
78
+
79
+ publish:
80
+ needs: [check, build]
81
+ if: needs.check.outputs.increment == 'True'
82
+ runs-on: ubuntu-latest
83
+ environment: # for GitHub Deployments tab
84
+ name: Release - PyPI
85
+ url: https://pypi.org/p/ultralytics
86
+ permissions:
87
+ id-token: write # for PyPI trusted publishing
88
+ steps:
89
+ - uses: actions/download-artifact@v6
90
+ with:
91
+ name: dist
92
+ path: dist/
93
+ - uses: pypa/gh-action-pypi-publish@release/v1
94
+
95
+ sbom:
96
+ needs: [check, build, publish]
97
+ if: needs.check.outputs.increment == 'True'
98
+ runs-on: ubuntu-latest
99
+ permissions:
100
+ contents: write
101
+ steps:
102
+ - uses: actions/checkout@v6
103
+ - uses: actions/setup-python@v6
104
+ with:
105
+ python-version: "3.x"
106
+ - uses: astral-sh/setup-uv@v7
107
+ - run: |
108
+ uv venv sbom-env
109
+ uv pip install -e .
110
+ env:
111
+ VIRTUAL_ENV: sbom-env
112
+ - uses: anchore/sbom-action@v0
113
+ with:
114
+ format: spdx-json
115
+ output-file: sbom.spdx.json
116
+ path: sbom-env
117
+ - run: gh release upload ${{ needs.check.outputs.current_tag }} sbom.spdx.json
118
+ env:
119
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
120
+
121
+ notify:
122
+ needs: [check, publish]
123
+ if: always() && needs.check.outputs.increment == 'True'
124
+ runs-on: ubuntu-latest
125
+ permissions:
126
+ contents: read
127
+ steps:
128
+ - uses: actions/checkout@v6
129
+ - name: Extract PR Details
130
+ env:
131
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
132
+ run: |
133
+ PR_JSON=$(gh pr list --search "${GITHUB_SHA}" --state merged --json number,title --jq '.[0]')
134
+ PR_NUMBER=$(echo "${PR_JSON}" | jq -r '.number')
135
+ PR_TITLE=$(echo "${PR_JSON}" | jq -r '.title' | sed 's/"/\\"/g')
136
+ echo "PR_NUMBER=${PR_NUMBER}" >> "${GITHUB_ENV}"
137
+ echo "PR_TITLE=${PR_TITLE}" >> "${GITHUB_ENV}"
138
+ - name: Notify Success
139
+ if: needs.publish.result == 'success' && github.event_name == 'push'
140
+ uses: slackapi/[email protected]
141
+ with:
142
+ webhook-type: incoming-webhook
143
+ webhook: ${{ secrets.SLACK_WEBHOOK_URL_YOLO }}
144
+ payload: |
145
+ text: "<!channel> GitHub Actions success for ${{ github.workflow }} ✅\n\n\n*Repository:* https://github.com/${{ github.repository }}\n*Action:* https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\n*Author:* ${{ github.actor }}\n*Event:* NEW `${{ github.repository }} ${{ needs.check.outputs.current_tag }}` pip package published 😃\n*Job Status:* ${{ job.status }}\n*Pull Request:* <https://github.com/${{ github.repository }}/pull/${{ env.PR_NUMBER }}> ${{ env.PR_TITLE }}\n"
146
+ - name: Notify Failure
147
+ if: needs.publish.result != 'success'
148
+ uses: slackapi/[email protected]
149
+ with:
150
+ webhook-type: incoming-webhook
151
+ webhook: ${{ secrets.SLACK_WEBHOOK_URL_YOLO }}
152
+ payload: |
153
+ text: "<!channel> GitHub Actions error for ${{ github.workflow }} ❌\n\n\n*Repository:* https://github.com/${{ github.repository }}\n*Action:* https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\n*Author:* ${{ github.actor }}\n*Event:* ${{ github.event_name }}\n*Job Status:* ${{ job.status }}\n*Pull Request:* <https://github.com/${{ github.repository }}/pull/${{ env.PR_NUMBER }}> ${{ env.PR_TITLE }}\n"
ultralytics-main/.github/workflows/stale.yml ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ name: Close stale issues
4
+ on:
5
+ schedule:
6
+ - cron: "0 0 * * *" # Runs at 00:00 UTC every day
7
+
8
+ permissions:
9
+ pull-requests: write
10
+ issues: write
11
+
12
+ jobs:
13
+ stale:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/stale@v10
17
+ with:
18
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
19
+
20
+ stale-issue-message: |
21
+ 👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.
22
+
23
+ For additional resources and information, please see the links below:
24
+
25
+ - **Docs**: https://docs.ultralytics.com
26
+ - **HUB**: https://hub.ultralytics.com
27
+ - **Community**: https://community.ultralytics.com
28
+
29
+ Feel free to inform us of any other **issues** you discover or **feature requests** that come to mind in the future. Pull Requests (PRs) are also always welcomed!
30
+
31
+ Thank you for your contributions to YOLO 🚀 and Vision AI ⭐
32
+
33
+ stale-pr-message: |
34
+ 👋 Hello there! We wanted to let you know that we've decided to close this pull request due to inactivity. We appreciate the effort you put into contributing to our project, but unfortunately, not all contributions are suitable or aligned with our product roadmap.
35
+
36
+ We hope you understand our decision, and please don't let it discourage you from contributing to open source projects in the future. We value all of our community members and their contributions, and we encourage you to keep exploring new projects and ways to get involved.
37
+
38
+ For additional resources and information, please see the links below:
39
+
40
+ - **Docs**: https://docs.ultralytics.com
41
+ - **HUB**: https://hub.ultralytics.com
42
+ - **Community**: https://community.ultralytics.com
43
+
44
+ Thank you for your contributions to YOLO 🚀 and Vision AI ⭐
45
+
46
+ ignore-pr-updates: true
47
+ remove-pr-stale-when-updated: false
48
+ exempt-all-assignees: true
49
+ days-before-issue-stale: 30
50
+ days-before-issue-close: 10
51
+ days-before-pr-stale: 90
52
+ days-before-pr-close: 30
53
+ exempt-issue-labels: "documentation,tutorial,TODO"
54
+ exempt-pr-labels: "TODO"
55
+ operations-per-run: 300 # The maximum number of operations per run, used to control rate limiting.
ultralytics-main/.gitignore ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ pip-wheel-metadata/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+ requirements.txt
30
+ setup.py
31
+ ultralytics.egg-info
32
+
33
+ # PyInstaller
34
+ # Usually these files are written by a python script from a template
35
+ # before PyInstaller builds the exe, so as to inject date/other info into it.
36
+ *.manifest
37
+ *.spec
38
+
39
+ # Installer logs
40
+ pip-log.txt
41
+ pip-delete-this-directory.txt
42
+
43
+ # Unit test / coverage reports
44
+ htmlcov/
45
+ .tox/
46
+ .nox/
47
+ .coverage
48
+ .coverage.*
49
+ .cache
50
+ nosetests.xml
51
+ coverage.xml
52
+ *.cover
53
+ *.py,cover
54
+ .hypothesis/
55
+ .pytest_cache/
56
+ mlruns/
57
+
58
+ # Translations
59
+ *.mo
60
+ *.pot
61
+
62
+ # Django stuff:
63
+ *.log
64
+ local_settings.py
65
+ db.sqlite3
66
+ db.sqlite3-journal
67
+
68
+ # Flask stuff:
69
+ instance/
70
+ .webassets-cache
71
+
72
+ # Scrapy stuff:
73
+ .scrapy
74
+
75
+ # Sphinx documentation
76
+ docs/_build/
77
+
78
+ # PyBuilder
79
+ target/
80
+
81
+ # Jupyter Notebook
82
+ .ipynb_checkpoints
83
+
84
+ # IPython
85
+ profile_default/
86
+ ipython_config.py
87
+
88
+ # Profiling
89
+ *.pclprof
90
+
91
+ # pyenv
92
+ .python-version
93
+
94
+ # pipenv
95
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
96
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
97
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
98
+ # install all needed dependencies.
99
+ #Pipfile.lock
100
+
101
+ # UV
102
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
103
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
104
+ # commonly ignored for libraries.
105
+ uv.lock
106
+
107
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
108
+ __pypackages__/
109
+
110
+ # Celery stuff
111
+ celerybeat-schedule
112
+ celerybeat.pid
113
+
114
+ # SageMath parsed files
115
+ *.sage.py
116
+
117
+ # Environments
118
+ .env
119
+ .venv
120
+ .idea
121
+ env/
122
+ venv/
123
+ ENV/
124
+ env.bak/
125
+ venv.bak/
126
+
127
+ # Spyder project settings
128
+ .spyderproject
129
+ .spyproject
130
+
131
+ # VSCode project settings
132
+ .vscode/
133
+ .devcontainer/
134
+
135
+ # Rope project settings
136
+ .ropeproject
137
+
138
+ # mkdocs documentation
139
+ /site
140
+
141
+ # mypy
142
+ .mypy_cache/
143
+ .dmypy.json
144
+ dmypy.json
145
+
146
+ # Pyre type checker
147
+ .pyre/
148
+
149
+ # datasets and projects (ignore /datasets dir at root only to allow for docs/en/datasets dir)
150
+ /datasets
151
+ runs/
152
+ wandb/
153
+ .DS_Store
154
+
155
+ # Neural Network weights -----------------------------------------------------------------------------------------------
156
+ weights/
157
+ *.weights
158
+ *.pt
159
+ *.ts
160
+ *.pb
161
+ *.onnx
162
+ *.engine
163
+ *.mlmodel
164
+ *.mlpackage
165
+ *.torchscript
166
+ *.tflite
167
+ *.h5
168
+ *.mnn
169
+ *_saved_model/
170
+ *_web_model/
171
+ *_openvino_model/
172
+ *_paddle_model/
173
+ *_ncnn_model/
174
+ *_imx_model/
175
+ pnnx*
176
+ *.rknn
177
+
178
+ # Autogenerated files for tests
179
+ /ultralytics/assets/
180
+
181
+ # calibration image
182
+ calibration_*.npy
183
+
184
+ # Videos and Pictures
185
+ *.mp4
186
+ *.avi
187
+ *.mov
188
+ *.mkv
189
+ *.webm
190
+ *.jpg
191
+ *.jpeg
192
+ *.png
193
+ *.bmp
194
+ *.tiff
195
+ *.gif
196
+ *.svg
197
+ *.webp
198
+ *.heic
199
+ *.ico
200
+ *.raw
ultralytics-main/CITATION.cff ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This CITATION.cff file was generated with https://bit.ly/cffinit
2
+
3
+ cff-version: 1.2.0
4
+ title: Ultralytics YOLO
5
+ message: >-
6
+ If you use this software, please cite it using the
7
+ metadata from this file.
8
+ type: software
9
+ authors:
10
+ - given-names: Glenn
11
+ family-names: Jocher
12
+ affiliation: Ultralytics
13
+ orcid: "https://orcid.org/0000-0001-5950-6979"
14
+ - family-names: Qiu
15
+ given-names: Jing
16
+ affiliation: Ultralytics
17
+ orcid: "https://orcid.org/0000-0003-3783-7069"
18
+ - given-names: Ayush
19
+ family-names: Chaurasia
20
+ affiliation: Ultralytics
21
+ orcid: "https://orcid.org/0000-0002-7603-6750"
22
+ repository-code: "https://github.com/ultralytics/ultralytics"
23
+ url: "https://ultralytics.com"
24
+ license: AGPL-3.0
25
+ version: 8.0.0
26
+ date-released: "2023-01-10"
ultralytics-main/CONTRIBUTING.md ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <a href="https://www.ultralytics.com/" target="_blank"><img src="https://raw.githubusercontent.com/ultralytics/assets/main/logo/Ultralytics_Logotype_Original.svg" width="320" alt="Ultralytics logo"></a>
2
+
3
+ # Contributing to Ultralytics Open-Source Projects
4
+
5
+ Welcome! We're thrilled that you're considering contributing to our [Ultralytics](https://www.ultralytics.com/) [open-source](https://github.com/ultralytics) projects. Your involvement not only helps enhance the quality of our repositories but also benefits the entire [computer vision](https://www.ultralytics.com/glossary/computer-vision-cv) community. This guide provides clear guidelines and best practices to help you get started.
6
+
7
+ [![Ultralytics open-source contributors](https://raw.githubusercontent.com/ultralytics/assets/main/im/image-contributors.png)](https://github.com/ultralytics/ultralytics/graphs/contributors)
8
+
9
+ ## 🤝 Code of Conduct
10
+
11
+ To ensure a welcoming and inclusive environment for everyone, all contributors must adhere to our [Code of Conduct](https://docs.ultralytics.com/help/code-of-conduct/). **Respect**, **kindness**, and **professionalism** are at the heart of our community.
12
+
13
+ ## 🚀 Contributing via Pull Requests
14
+
15
+ We greatly appreciate contributions in the form of [pull requests (PRs)](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests). To make the review process as smooth as possible, please follow these steps:
16
+
17
+ 1. **[Fork the repository](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo):** Start by forking the relevant Ultralytics repository (e.g., [ultralytics/ultralytics](https://github.com/ultralytics/ultralytics)) to your GitHub account.
18
+ 2. **[Create a branch](https://docs.github.com/en/desktop/making-changes-in-a-branch/managing-branches-in-github-desktop):** Create a new branch in your forked repository with a clear, descriptive name reflecting your changes (e.g., `fix-issue-123`, `add-feature-xyz`).
19
+ 3. **Make your changes:** Implement your improvements or fixes. Ensure your code adheres to the project's style guidelines and doesn't introduce new errors or warnings.
20
+ 4. **Test your changes:** Before submitting, test your changes locally to confirm they work as expected and don't cause [regressions](https://en.wikipedia.org/wiki/Software_regression). Add tests if you're introducing new functionality.
21
+ 5. **[Commit your changes](https://docs.github.com/en/desktop/making-changes-in-a-branch/committing-and-reviewing-changes-to-your-project-in-github-desktop):** Commit your changes with concise and descriptive commit messages. If your changes address a specific issue, include the issue number (e.g., `Fix #123: Corrected calculation error.`).
22
+ 6. **[Create a pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request):** Submit a pull request from your branch to the `main` branch of the original Ultralytics repository. Provide a clear title and a detailed description explaining the purpose and scope of your changes.
23
+
24
+ ### 📝 CLA Signing
25
+
26
+ Before we can merge your pull request, you must sign our [Contributor License Agreement (CLA)](https://docs.ultralytics.com/help/CLA/). This legal agreement ensures that your contributions are properly licensed, allowing the project to continue being distributed under the [AGPL-3.0 license](https://www.ultralytics.com/legal/agpl-3-0-software-license).
27
+
28
+ After submitting your pull request, the CLA bot will guide you through the signing process. To sign the CLA, simply add a comment in your PR stating:
29
+
30
+ ```text
31
+ I have read the CLA Document and I sign the CLA
32
+ ```
33
+
34
+ ### ✍️ Google-Style Docstrings
35
+
36
+ When adding new functions or classes, please include [Google-style docstrings](https://google.github.io/styleguide/pyguide.html). These docstrings provide clear, standardized documentation that helps other developers understand and maintain your code.
37
+
38
+ #### Example Google-style
39
+
40
+ This example illustrates a Google-style docstring. Ensure that both input and output `types` are always enclosed in parentheses, e.g., `(bool)`.
41
+
42
+ ```python
43
+ def example_function(arg1, arg2=4):
44
+ """Example function demonstrating Google-style docstrings.
45
+
46
+ Args:
47
+ arg1 (int): The first argument.
48
+ arg2 (int): The second argument, with a default value of 4.
49
+
50
+ Returns:
51
+ (bool): True if successful, False otherwise.
52
+
53
+ Examples:
54
+ >>> result = example_function(1, 2) # returns False
55
+ """
56
+ if arg1 == arg2:
57
+ return True
58
+ return False
59
+ ```
60
+
61
+ #### Example Google-style with type hints
62
+
63
+ This example includes both a Google-style docstring and [type hints](https://docs.python.org/3/library/typing.html) for arguments and returns, though using either independently is also acceptable.
64
+
65
+ ```python
66
+ def example_function(arg1: int, arg2: int = 4) -> bool:
67
+ """Example function demonstrating Google-style docstrings.
68
+
69
+ Args:
70
+ arg1: The first argument.
71
+ arg2: The second argument, with a default value of 4.
72
+
73
+ Returns:
74
+ True if successful, False otherwise.
75
+
76
+ Examples:
77
+ >>> result = example_function(1, 2) # returns False
78
+ """
79
+ if arg1 == arg2:
80
+ return True
81
+ return False
82
+ ```
83
+
84
+ #### Example Single-line
85
+
86
+ For smaller or simpler functions, a single-line docstring may be sufficient. The docstring must use three double-quotes, be a complete sentence, start with a capital letter, and end with a period.
87
+
88
+ ```python
89
+ def example_small_function(arg1: int, arg2: int = 4) -> bool:
90
+ """Example function with a single-line docstring."""
91
+ return arg1 == arg2
92
+ ```
93
+
94
+ ### ✅ GitHub Actions CI Tests
95
+
96
+ All pull requests must pass the [GitHub Actions](https://github.com/features/actions) [Continuous Integration](https://docs.ultralytics.com/help/CI/) (CI) tests before they can be merged. These tests include linting, unit tests, and other checks to ensure that your changes meet the project's quality standards. Review the CI output and address any issues that arise.
97
+
98
+ ## ✨ Best Practices for Code Contributions
99
+
100
+ When contributing code to Ultralytics projects, keep these best practices in mind:
101
+
102
+ - **Avoid code duplication:** Reuse existing code wherever possible and minimize unnecessary arguments.
103
+ - **Make smaller, focused changes:** Focus on targeted modifications rather than large-scale changes.
104
+ - **Simplify when possible:** Look for opportunities to simplify the code or remove unnecessary parts.
105
+ - **Consider compatibility:** Before making changes, consider whether they might break existing code using Ultralytics.
106
+ - **Use consistent formatting:** Tools like [Ruff Formatter](https://github.com/astral-sh/ruff) can help maintain stylistic consistency.
107
+ - **Add appropriate tests:** Include [tests](https://docs.ultralytics.com/guides/model-testing/) for new features to ensure they work as expected.
108
+
109
+ ## 👀 Reviewing Pull Requests
110
+
111
+ Reviewing pull requests is another valuable way to contribute. When reviewing PRs:
112
+
113
+ - **Check for unit tests:** Verify that the PR includes tests for new features or changes.
114
+ - **Review documentation updates:** Ensure [documentation](https://docs.ultralytics.com/) is updated to reflect changes.
115
+ - **Evaluate performance impact:** Consider how changes might affect [performance](https://docs.ultralytics.com/guides/yolo-performance-metrics/).
116
+ - **Verify CI tests:** Confirm all [Continuous Integration tests](https://docs.ultralytics.com/help/CI/) are passing.
117
+ - **Provide constructive feedback:** Offer specific, clear feedback about any issues or concerns.
118
+ - **Recognize effort:** Acknowledge the author's work to maintain a positive collaborative atmosphere.
119
+
120
+ ## 🐞 Reporting Bugs
121
+
122
+ We highly value bug reports as they help us improve the quality and reliability of our projects. When reporting a bug via [GitHub Issues](https://github.com/ultralytics/ultralytics/issues):
123
+
124
+ - **Check existing issues:** Search first to see if the bug has already been reported.
125
+ - **Provide a [Minimum Reproducible Example](https://docs.ultralytics.com/help/minimum-reproducible-example/):** Create a small, self-contained code snippet that consistently reproduces the issue. This is crucial for efficient debugging.
126
+ - **Describe the environment:** Specify your operating system, Python version, relevant library versions (e.g., [`torch`](https://pytorch.org/), [`ultralytics`](https://github.com/ultralytics/ultralytics)), and hardware ([CPU](https://en.wikipedia.org/wiki/Central_processing_unit)/[GPU](https://www.ultralytics.com/glossary/gpu-graphics-processing-unit)).
127
+ - **Explain expected vs. actual behavior:** Clearly state what you expected to happen and what actually occurred. Include any error messages or tracebacks.
128
+
129
+ ## 📜 License
130
+
131
+ Ultralytics uses the [GNU Affero General Public License v3.0 (AGPL-3.0)](https://www.ultralytics.com/legal/agpl-3-0-software-license) for its repositories. This license promotes [openness](https://en.wikipedia.org/wiki/Openness), [transparency](https://www.ultralytics.com/glossary/transparency-in-ai), and [collaborative improvement](https://en.wikipedia.org/wiki/Collaborative_software) in software development. It ensures that all users have the freedom to use, modify, and share the software, fostering a strong community of collaboration and innovation.
132
+
133
+ We encourage all contributors to familiarize themselves with the terms of the [AGPL-3.0 license](https://opensource.org/license/agpl-v3) to contribute effectively and ethically to the Ultralytics open-source community.
134
+
135
+ ## 🌍 Open-Sourcing Your YOLO Project Under AGPL-3.0
136
+
137
+ Using Ultralytics YOLO models or code in your project? The [AGPL-3.0 license](https://opensource.org/license/agpl-v3) requires that your entire derivative work also be open-sourced under AGPL-3.0. This ensures modifications and larger projects built upon open-source foundations remain open.
138
+
139
+ ### Why AGPL-3.0 Compliance Matters
140
+
141
+ - **Keeps Software Open:** Ensures that improvements and derivative works benefit the community.
142
+ - **Legal Requirement:** Using AGPL-3.0 licensed code binds your project to its terms.
143
+ - **Fosters Collaboration:** Encourages sharing and transparency.
144
+
145
+ If you prefer not to open-source your project, consider obtaining an [Enterprise License](https://www.ultralytics.com/license).
146
+
147
+ ### How to Comply with AGPL-3.0
148
+
149
+ Complying means making the **complete corresponding source code** of your project publicly available under the AGPL-3.0 license.
150
+
151
+ 1. **Choose Your Starting Point:**
152
+ - **Fork Ultralytics YOLO:** Directly fork the [Ultralytics YOLO repository](https://github.com/ultralytics/ultralytics) if building closely upon it.
153
+ - **Use Ultralytics Template:** Start with the [Ultralytics template repository](https://github.com/ultralytics/template) for a clean, modular setup integrating YOLO.
154
+
155
+ 2. **License Your Project:**
156
+ - Add a `LICENSE` file containing the full text of the [AGPL-3.0 license](https://opensource.org/license/agpl-v3).
157
+ - Add a notice at the top of each source file indicating the license.
158
+
159
+ 3. **Publish Your Source Code:**
160
+ - Make your **entire project's source code** publicly accessible (e.g., on GitHub). This includes:
161
+ - The complete larger application or system that incorporates the YOLO model or code.
162
+ - Any modifications made to the original Ultralytics YOLO code.
163
+ - Scripts for training, validation, inference.
164
+ - [Model weights](https://www.ultralytics.com/glossary/model-weights) if modified or fine-tuned.
165
+ - [Configuration files](https://docs.ultralytics.com/usage/cfg/), environment setups (`requirements.txt`, [`Dockerfiles`](https://docs.docker.com/reference/dockerfile/)).
166
+ - Backend and frontend code if it's part of a [web application](https://en.wikipedia.org/wiki/Web_application).
167
+ - Any [third-party libraries](<https://en.wikipedia.org/wiki/Library_(computing)#Third-party>) you've modified.
168
+ - [Training data](https://www.ultralytics.com/glossary/training-data) if required to run/retrain _and_ redistributable.
169
+
170
+ 4. **Document Clearly:**
171
+ - Update your `README.md` to state that the project is licensed under AGPL-3.0.
172
+ - Include clear instructions on how to set up, build, and run your project from the source code.
173
+ - Attribute Ultralytics YOLO appropriately, linking back to the [original repository](https://github.com/ultralytics/ultralytics). Example:
174
+ ```markdown
175
+ This project utilizes code from [Ultralytics YOLO](https://github.com/ultralytics/ultralytics), licensed under AGPL-3.0.
176
+ ```
177
+
178
+ ### Example Repository Structure
179
+
180
+ Refer to the [Ultralytics Template Repository](https://github.com/ultralytics/template) for a practical example structure:
181
+
182
+ ```
183
+ my-yolo-project/
184
+
185
+ ├── LICENSE # Full AGPL-3.0 license text
186
+ ├── README.md # Project description, setup, usage, license info & attribution
187
+ ├── pyproject.toml # Dependencies (or requirements.txt)
188
+ ├── scripts/ # Training/inference scripts
189
+ │ └── train.py
190
+ ├── src/ # Your project's source code
191
+ │ ├── __init__.py
192
+ │ ├── data_loader.py
193
+ │ └── model_wrapper.py # Code interacting with YOLO
194
+ ├── tests/ # Unit/integration tests
195
+ ├── configs/ # YAML/JSON config files
196
+ ├── docker/ # Dockerfiles, if used
197
+ │ └── Dockerfile
198
+ └── .github/ # GitHub specific files (e.g., workflows for CI)
199
+ └── workflows/
200
+ └── ci.yml
201
+ ```
202
+
203
+ By following these guidelines, you ensure compliance with AGPL-3.0, supporting the open-source ecosystem that enables powerful tools like Ultralytics YOLO.
204
+
205
+ ## 🎉 Conclusion
206
+
207
+ Thank you for your interest in contributing to [Ultralytics](https://www.ultralytics.com/) [open-source](https://github.com/ultralytics) YOLO projects. Your participation is essential in shaping the future of our software and building a vibrant community of innovation and collaboration. Whether you're enhancing code, reporting bugs, or suggesting new features, your contributions are invaluable.
208
+
209
+ We're excited to see your ideas come to life and appreciate your commitment to advancing [object detection](https://www.ultralytics.com/glossary/object-detection) technology. Together, let's continue to grow and innovate in this exciting open-source journey. Happy coding! 🚀🌟
210
+
211
+ ## FAQ
212
+
213
+ ### Why should I contribute to Ultralytics YOLO open-source repositories?
214
+
215
+ Contributing to Ultralytics YOLO open-source repositories improves the software, making it more robust and feature-rich for the entire community. Contributions can include code enhancements, bug fixes, documentation improvements, and new feature implementations. Additionally, contributing allows you to collaborate with other skilled developers and experts in the field, enhancing your own skills and reputation. For details on how to get started, refer to the [Contributing via Pull Requests](#-contributing-via-pull-requests) section.
216
+
217
+ ### How do I sign the Contributor License Agreement (CLA) for Ultralytics YOLO?
218
+
219
+ To sign the Contributor License Agreement (CLA), follow the instructions provided by the CLA bot after submitting your pull request. This process ensures that your contributions are properly licensed under the AGPL-3.0 license, maintaining the legal integrity of the open-source project. Add a comment in your pull request stating:
220
+
221
+ ```text
222
+ I have read the CLA Document and I sign the CLA
223
+ ```
224
+
225
+ For more information, see the [CLA Signing](#-cla-signing) section.
226
+
227
+ ### What are Google-style docstrings, and why are they required for Ultralytics YOLO contributions?
228
+
229
+ Google-style docstrings provide clear, concise documentation for functions and classes, improving code readability and maintainability. These docstrings outline the function's purpose, arguments, and return values with specific formatting rules. When contributing to Ultralytics YOLO, following Google-style docstrings ensures that your additions are well-documented and easily understood. For examples and guidelines, visit the [Google-Style Docstrings](#-google-style-docstrings) section.
230
+
231
+ ### How can I ensure my changes pass the GitHub Actions CI tests?
232
+
233
+ Before your pull request can be merged, it must pass all GitHub Actions Continuous Integration (CI) tests. These tests include linting, unit tests, and other checks to ensure the code meets the project's quality standards. Review the CI output and fix any issues. For detailed information on the CI process and troubleshooting tips, see the [GitHub Actions CI Tests](#-github-actions-ci-tests) section.
234
+
235
+ ### How do I report a bug in Ultralytics YOLO repositories?
236
+
237
+ To report a bug, provide a clear and concise [Minimum Reproducible Example](https://docs.ultralytics.com/help/minimum-reproducible-example/) along with your bug report. This helps developers quickly identify and fix the issue. Ensure your example is minimal yet sufficient to replicate the problem. For more detailed steps on reporting bugs, refer to the [Reporting Bugs](#-reporting-bugs) section.
238
+
239
+ ### What does the AGPL-3.0 license mean if I use Ultralytics YOLO in my own project?
240
+
241
+ If you use Ultralytics YOLO code or models (licensed under AGPL-3.0) in your project, the AGPL-3.0 license requires that your entire project (the derivative work) must also be licensed under AGPL-3.0 and its complete source code must be made publicly available. This ensures that the open-source nature of the software is preserved throughout its derivatives. If you cannot meet these requirements, you need to obtain an [Enterprise License](https://www.ultralytics.com/license). See the [Open-Sourcing Your Project](#-open-sourcing-your-yolo-project-under-agpl-30) section for details.
ultralytics-main/LICENSE ADDED
@@ -0,0 +1,661 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU AFFERO GENERAL PUBLIC LICENSE
2
+ Version 3, 19 November 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU Affero General Public License is a free, copyleft license for
11
+ software and other kinds of works, specifically designed to ensure
12
+ cooperation with the community in the case of network server software.
13
+
14
+ The licenses for most software and other practical works are designed
15
+ to take away your freedom to share and change the works. By contrast,
16
+ our General Public Licenses are intended to guarantee your freedom to
17
+ share and change all versions of a program--to make sure it remains free
18
+ software for all its users.
19
+
20
+ When we speak of free software, we are referring to freedom, not
21
+ price. Our General Public Licenses are designed to make sure that you
22
+ have the freedom to distribute copies of free software (and charge for
23
+ them if you wish), that you receive source code or can get it if you
24
+ want it, that you can change the software or use pieces of it in new
25
+ free programs, and that you know you can do these things.
26
+
27
+ Developers that use our General Public Licenses protect your rights
28
+ with two steps: (1) assert copyright on the software, and (2) offer
29
+ you this License which gives you legal permission to copy, distribute
30
+ and/or modify the software.
31
+
32
+ A secondary benefit of defending all users' freedom is that
33
+ improvements made in alternate versions of the program, if they
34
+ receive widespread use, become available for other developers to
35
+ incorporate. Many developers of free software are heartened and
36
+ encouraged by the resulting cooperation. However, in the case of
37
+ software used on network servers, this result may fail to come about.
38
+ The GNU General Public License permits making a modified version and
39
+ letting the public access it on a server without ever releasing its
40
+ source code to the public.
41
+
42
+ The GNU Affero General Public License is designed specifically to
43
+ ensure that, in such cases, the modified source code becomes available
44
+ to the community. It requires the operator of a network server to
45
+ provide the source code of the modified version running there to the
46
+ users of that server. Therefore, public use of a modified version, on
47
+ a publicly accessible server, gives the public access to the source
48
+ code of the modified version.
49
+
50
+ An older license, called the Affero General Public License and
51
+ published by Affero, was designed to accomplish similar goals. This is
52
+ a different license, not a version of the Affero GPL, but Affero has
53
+ released a new version of the Affero GPL which permits relicensing under
54
+ this license.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ TERMS AND CONDITIONS
60
+
61
+ 0. Definitions.
62
+
63
+ "This License" refers to version 3 of the GNU Affero General Public License.
64
+
65
+ "Copyright" also means copyright-like laws that apply to other kinds of
66
+ works, such as semiconductor masks.
67
+
68
+ "The Program" refers to any copyrightable work licensed under this
69
+ License. Each licensee is addressed as "you". "Licensees" and
70
+ "recipients" may be individuals or organizations.
71
+
72
+ To "modify" a work means to copy from or adapt all or part of the work
73
+ in a fashion requiring copyright permission, other than the making of an
74
+ exact copy. The resulting work is called a "modified version" of the
75
+ earlier work or a work "based on" the earlier work.
76
+
77
+ A "covered work" means either the unmodified Program or a work based
78
+ on the Program.
79
+
80
+ To "propagate" a work means to do anything with it that, without
81
+ permission, would make you directly or secondarily liable for
82
+ infringement under applicable copyright law, except executing it on a
83
+ computer or modifying a private copy. Propagation includes copying,
84
+ distribution (with or without modification), making available to the
85
+ public, and in some countries other activities as well.
86
+
87
+ To "convey" a work means any kind of propagation that enables other
88
+ parties to make or receive copies. Mere interaction with a user through
89
+ a computer network, with no transfer of a copy, is not conveying.
90
+
91
+ An interactive user interface displays "Appropriate Legal Notices"
92
+ to the extent that it includes a convenient and prominently visible
93
+ feature that (1) displays an appropriate copyright notice, and (2)
94
+ tells the user that there is no warranty for the work (except to the
95
+ extent that warranties are provided), that licensees may convey the
96
+ work under this License, and how to view a copy of this License. If
97
+ the interface presents a list of user commands or options, such as a
98
+ menu, a prominent item in the list meets this criterion.
99
+
100
+ 1. Source Code.
101
+
102
+ The "source code" for a work means the preferred form of the work
103
+ for making modifications to it. "Object code" means any non-source
104
+ form of a work.
105
+
106
+ A "Standard Interface" means an interface that either is an official
107
+ standard defined by a recognized standards body, or, in the case of
108
+ interfaces specified for a particular programming language, one that
109
+ is widely used among developers working in that language.
110
+
111
+ The "System Libraries" of an executable work include anything, other
112
+ than the work as a whole, that (a) is included in the normal form of
113
+ packaging a Major Component, but which is not part of that Major
114
+ Component, and (b) serves only to enable use of the work with that
115
+ Major Component, or to implement a Standard Interface for which an
116
+ implementation is available to the public in source code form. A
117
+ "Major Component", in this context, means a major essential component
118
+ (kernel, window system, and so on) of the specific operating system
119
+ (if any) on which the executable work runs, or a compiler used to
120
+ produce the work, or an object code interpreter used to run it.
121
+
122
+ The "Corresponding Source" for a work in object code form means all
123
+ the source code needed to generate, install, and (for an executable
124
+ work) run the object code and to modify the work, including scripts to
125
+ control those activities. However, it does not include the work's
126
+ System Libraries, or general-purpose tools or generally available free
127
+ programs which are used unmodified in performing those activities but
128
+ which are not part of the work. For example, Corresponding Source
129
+ includes interface definition files associated with source files for
130
+ the work, and the source code for shared libraries and dynamically
131
+ linked subprograms that the work is specifically designed to require,
132
+ such as by intimate data communication or control flow between those
133
+ subprograms and other parts of the work.
134
+
135
+ The Corresponding Source need not include anything that users
136
+ can regenerate automatically from other parts of the Corresponding
137
+ Source.
138
+
139
+ The Corresponding Source for a work in source code form is that
140
+ same work.
141
+
142
+ 2. Basic Permissions.
143
+
144
+ All rights granted under this License are granted for the term of
145
+ copyright on the Program, and are irrevocable provided the stated
146
+ conditions are met. This License explicitly affirms your unlimited
147
+ permission to run the unmodified Program. The output from running a
148
+ covered work is covered by this License only if the output, given its
149
+ content, constitutes a covered work. This License acknowledges your
150
+ rights of fair use or other equivalent, as provided by copyright law.
151
+
152
+ You may make, run and propagate covered works that you do not
153
+ convey, without conditions so long as your license otherwise remains
154
+ in force. You may convey covered works to others for the sole purpose
155
+ of having them make modifications exclusively for you, or provide you
156
+ with facilities for running those works, provided that you comply with
157
+ the terms of this License in conveying all material for which you do
158
+ not control copyright. Those thus making or running the covered works
159
+ for you must do so exclusively on your behalf, under your direction
160
+ and control, on terms that prohibit them from making any copies of
161
+ your copyrighted material outside their relationship with you.
162
+
163
+ Conveying under any other circumstances is permitted solely under
164
+ the conditions stated below. Sublicensing is not allowed; section 10
165
+ makes it unnecessary.
166
+
167
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
168
+
169
+ No covered work shall be deemed part of an effective technological
170
+ measure under any applicable law fulfilling obligations under article
171
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
172
+ similar laws prohibiting or restricting circumvention of such
173
+ measures.
174
+
175
+ When you convey a covered work, you waive any legal power to forbid
176
+ circumvention of technological measures to the extent such circumvention
177
+ is effected by exercising rights under this License with respect to
178
+ the covered work, and you disclaim any intention to limit operation or
179
+ modification of the work as a means of enforcing, against the work's
180
+ users, your or third parties' legal rights to forbid circumvention of
181
+ technological measures.
182
+
183
+ 4. Conveying Verbatim Copies.
184
+
185
+ You may convey verbatim copies of the Program's source code as you
186
+ receive it, in any medium, provided that you conspicuously and
187
+ appropriately publish on each copy an appropriate copyright notice;
188
+ keep intact all notices stating that this License and any
189
+ non-permissive terms added in accord with section 7 apply to the code;
190
+ keep intact all notices of the absence of any warranty; and give all
191
+ recipients a copy of this License along with the Program.
192
+
193
+ You may charge any price or no price for each copy that you convey,
194
+ and you may offer support or warranty protection for a fee.
195
+
196
+ 5. Conveying Modified Source Versions.
197
+
198
+ You may convey a work based on the Program, or the modifications to
199
+ produce it from the Program, in the form of source code under the
200
+ terms of section 4, provided that you also meet all of these conditions:
201
+
202
+ a) The work must carry prominent notices stating that you modified
203
+ it, and giving a relevant date.
204
+
205
+ b) The work must carry prominent notices stating that it is
206
+ released under this License and any conditions added under section
207
+ 7. This requirement modifies the requirement in section 4 to
208
+ "keep intact all notices".
209
+
210
+ c) You must license the entire work, as a whole, under this
211
+ License to anyone who comes into possession of a copy. This
212
+ License will therefore apply, along with any applicable section 7
213
+ additional terms, to the whole of the work, and all its parts,
214
+ regardless of how they are packaged. This License gives no
215
+ permission to license the work in any other way, but it does not
216
+ invalidate such permission if you have separately received it.
217
+
218
+ d) If the work has interactive user interfaces, each must display
219
+ Appropriate Legal Notices; however, if the Program has interactive
220
+ interfaces that do not display Appropriate Legal Notices, your
221
+ work need not make them do so.
222
+
223
+ A compilation of a covered work with other separate and independent
224
+ works, which are not by their nature extensions of the covered work,
225
+ and which are not combined with it such as to form a larger program,
226
+ in or on a volume of a storage or distribution medium, is called an
227
+ "aggregate" if the compilation and its resulting copyright are not
228
+ used to limit the access or legal rights of the compilation's users
229
+ beyond what the individual works permit. Inclusion of a covered work
230
+ in an aggregate does not cause this License to apply to the other
231
+ parts of the aggregate.
232
+
233
+ 6. Conveying Non-Source Forms.
234
+
235
+ You may convey a covered work in object code form under the terms
236
+ of sections 4 and 5, provided that you also convey the
237
+ machine-readable Corresponding Source under the terms of this License,
238
+ in one of these ways:
239
+
240
+ a) Convey the object code in, or embodied in, a physical product
241
+ (including a physical distribution medium), accompanied by the
242
+ Corresponding Source fixed on a durable physical medium
243
+ customarily used for software interchange.
244
+
245
+ b) Convey the object code in, or embodied in, a physical product
246
+ (including a physical distribution medium), accompanied by a
247
+ written offer, valid for at least three years and valid for as
248
+ long as you offer spare parts or customer support for that product
249
+ model, to give anyone who possesses the object code either (1) a
250
+ copy of the Corresponding Source for all the software in the
251
+ product that is covered by this License, on a durable physical
252
+ medium customarily used for software interchange, for a price no
253
+ more than your reasonable cost of physically performing this
254
+ conveying of source, or (2) access to copy the
255
+ Corresponding Source from a network server at no charge.
256
+
257
+ c) Convey individual copies of the object code with a copy of the
258
+ written offer to provide the Corresponding Source. This
259
+ alternative is allowed only occasionally and noncommercially, and
260
+ only if you received the object code with such an offer, in accord
261
+ with subsection 6b.
262
+
263
+ d) Convey the object code by offering access from a designated
264
+ place (gratis or for a charge), and offer equivalent access to the
265
+ Corresponding Source in the same way through the same place at no
266
+ further charge. You need not require recipients to copy the
267
+ Corresponding Source along with the object code. If the place to
268
+ copy the object code is a network server, the Corresponding Source
269
+ may be on a different server (operated by you or a third party)
270
+ that supports equivalent copying facilities, provided you maintain
271
+ clear directions next to the object code saying where to find the
272
+ Corresponding Source. Regardless of what server hosts the
273
+ Corresponding Source, you remain obligated to ensure that it is
274
+ available for as long as needed to satisfy these requirements.
275
+
276
+ e) Convey the object code using peer-to-peer transmission, provided
277
+ you inform other peers where the object code and Corresponding
278
+ Source of the work are being offered to the general public at no
279
+ charge under subsection 6d.
280
+
281
+ A separable portion of the object code, whose source code is excluded
282
+ from the Corresponding Source as a System Library, need not be
283
+ included in conveying the object code work.
284
+
285
+ A "User Product" is either (1) a "consumer product", which means any
286
+ tangible personal property which is normally used for personal, family,
287
+ or household purposes, or (2) anything designed or sold for incorporation
288
+ into a dwelling. In determining whether a product is a consumer product,
289
+ doubtful cases shall be resolved in favor of coverage. For a particular
290
+ product received by a particular user, "normally used" refers to a
291
+ typical or common use of that class of product, regardless of the status
292
+ of the particular user or of the way in which the particular user
293
+ actually uses, or expects or is expected to use, the product. A product
294
+ is a consumer product regardless of whether the product has substantial
295
+ commercial, industrial or non-consumer uses, unless such uses represent
296
+ the only significant mode of use of the product.
297
+
298
+ "Installation Information" for a User Product means any methods,
299
+ procedures, authorization keys, or other information required to install
300
+ and execute modified versions of a covered work in that User Product from
301
+ a modified version of its Corresponding Source. The information must
302
+ suffice to ensure that the continued functioning of the modified object
303
+ code is in no case prevented or interfered with solely because
304
+ modification has been made.
305
+
306
+ If you convey an object code work under this section in, or with, or
307
+ specifically for use in, a User Product, and the conveying occurs as
308
+ part of a transaction in which the right of possession and use of the
309
+ User Product is transferred to the recipient in perpetuity or for a
310
+ fixed term (regardless of how the transaction is characterized), the
311
+ Corresponding Source conveyed under this section must be accompanied
312
+ by the Installation Information. But this requirement does not apply
313
+ if neither you nor any third party retains the ability to install
314
+ modified object code on the User Product (for example, the work has
315
+ been installed in ROM).
316
+
317
+ The requirement to provide Installation Information does not include a
318
+ requirement to continue to provide support service, warranty, or updates
319
+ for a work that has been modified or installed by the recipient, or for
320
+ the User Product in which it has been modified or installed. Access to a
321
+ network may be denied when the modification itself materially and
322
+ adversely affects the operation of the network or violates the rules and
323
+ protocols for communication across the network.
324
+
325
+ Corresponding Source conveyed, and Installation Information provided,
326
+ in accord with this section must be in a format that is publicly
327
+ documented (and with an implementation available to the public in
328
+ source code form), and must require no special password or key for
329
+ unpacking, reading or copying.
330
+
331
+ 7. Additional Terms.
332
+
333
+ "Additional permissions" are terms that supplement the terms of this
334
+ License by making exceptions from one or more of its conditions.
335
+ Additional permissions that are applicable to the entire Program shall
336
+ be treated as though they were included in this License, to the extent
337
+ that they are valid under applicable law. If additional permissions
338
+ apply only to part of the Program, that part may be used separately
339
+ under those permissions, but the entire Program remains governed by
340
+ this License without regard to the additional permissions.
341
+
342
+ When you convey a copy of a covered work, you may at your option
343
+ remove any additional permissions from that copy, or from any part of
344
+ it. (Additional permissions may be written to require their own
345
+ removal in certain cases when you modify the work.) You may place
346
+ additional permissions on material, added by you to a covered work,
347
+ for which you have or can give appropriate copyright permission.
348
+
349
+ Notwithstanding any other provision of this License, for material you
350
+ add to a covered work, you may (if authorized by the copyright holders of
351
+ that material) supplement the terms of this License with terms:
352
+
353
+ a) Disclaiming warranty or limiting liability differently from the
354
+ terms of sections 15 and 16 of this License; or
355
+
356
+ b) Requiring preservation of specified reasonable legal notices or
357
+ author attributions in that material or in the Appropriate Legal
358
+ Notices displayed by works containing it; or
359
+
360
+ c) Prohibiting misrepresentation of the origin of that material, or
361
+ requiring that modified versions of such material be marked in
362
+ reasonable ways as different from the original version; or
363
+
364
+ d) Limiting the use for publicity purposes of names of licensors or
365
+ authors of the material; or
366
+
367
+ e) Declining to grant rights under trademark law for use of some
368
+ trade names, trademarks, or service marks; or
369
+
370
+ f) Requiring indemnification of licensors and authors of that
371
+ material by anyone who conveys the material (or modified versions of
372
+ it) with contractual assumptions of liability to the recipient, for
373
+ any liability that these contractual assumptions directly impose on
374
+ those licensors and authors.
375
+
376
+ All other non-permissive additional terms are considered "further
377
+ restrictions" within the meaning of section 10. If the Program as you
378
+ received it, or any part of it, contains a notice stating that it is
379
+ governed by this License along with a term that is a further
380
+ restriction, you may remove that term. If a license document contains
381
+ a further restriction but permits relicensing or conveying under this
382
+ License, you may add to a covered work material governed by the terms
383
+ of that license document, provided that the further restriction does
384
+ not survive such relicensing or conveying.
385
+
386
+ If you add terms to a covered work in accord with this section, you
387
+ must place, in the relevant source files, a statement of the
388
+ additional terms that apply to those files, or a notice indicating
389
+ where to find the applicable terms.
390
+
391
+ Additional terms, permissive or non-permissive, may be stated in the
392
+ form of a separately written license, or stated as exceptions;
393
+ the above requirements apply either way.
394
+
395
+ 8. Termination.
396
+
397
+ You may not propagate or modify a covered work except as expressly
398
+ provided under this License. Any attempt otherwise to propagate or
399
+ modify it is void, and will automatically terminate your rights under
400
+ this License (including any patent licenses granted under the third
401
+ paragraph of section 11).
402
+
403
+ However, if you cease all violation of this License, then your
404
+ license from a particular copyright holder is reinstated (a)
405
+ provisionally, unless and until the copyright holder explicitly and
406
+ finally terminates your license, and (b) permanently, if the copyright
407
+ holder fails to notify you of the violation by some reasonable means
408
+ prior to 60 days after the cessation.
409
+
410
+ Moreover, your license from a particular copyright holder is
411
+ reinstated permanently if the copyright holder notifies you of the
412
+ violation by some reasonable means, this is the first time you have
413
+ received notice of violation of this License (for any work) from that
414
+ copyright holder, and you cure the violation prior to 30 days after
415
+ your receipt of the notice.
416
+
417
+ Termination of your rights under this section does not terminate the
418
+ licenses of parties who have received copies or rights from you under
419
+ this License. If your rights have been terminated and not permanently
420
+ reinstated, you do not qualify to receive new licenses for the same
421
+ material under section 10.
422
+
423
+ 9. Acceptance Not Required for Having Copies.
424
+
425
+ You are not required to accept this License in order to receive or
426
+ run a copy of the Program. Ancillary propagation of a covered work
427
+ occurring solely as a consequence of using peer-to-peer transmission
428
+ to receive a copy likewise does not require acceptance. However,
429
+ nothing other than this License grants you permission to propagate or
430
+ modify any covered work. These actions infringe copyright if you do
431
+ not accept this License. Therefore, by modifying or propagating a
432
+ covered work, you indicate your acceptance of this License to do so.
433
+
434
+ 10. Automatic Licensing of Downstream Recipients.
435
+
436
+ Each time you convey a covered work, the recipient automatically
437
+ receives a license from the original licensors, to run, modify and
438
+ propagate that work, subject to this License. You are not responsible
439
+ for enforcing compliance by third parties with this License.
440
+
441
+ An "entity transaction" is a transaction transferring control of an
442
+ organization, or substantially all assets of one, or subdividing an
443
+ organization, or merging organizations. If propagation of a covered
444
+ work results from an entity transaction, each party to that
445
+ transaction who receives a copy of the work also receives whatever
446
+ licenses to the work the party's predecessor in interest had or could
447
+ give under the previous paragraph, plus a right to possession of the
448
+ Corresponding Source of the work from the predecessor in interest, if
449
+ the predecessor has it or can get it with reasonable efforts.
450
+
451
+ You may not impose any further restrictions on the exercise of the
452
+ rights granted or affirmed under this License. For example, you may
453
+ not impose a license fee, royalty, or other charge for exercise of
454
+ rights granted under this License, and you may not initiate litigation
455
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
456
+ any patent claim is infringed by making, using, selling, offering for
457
+ sale, or importing the Program or any portion of it.
458
+
459
+ 11. Patents.
460
+
461
+ A "contributor" is a copyright holder who authorizes use under this
462
+ License of the Program or a work on which the Program is based. The
463
+ work thus licensed is called the contributor's "contributor version".
464
+
465
+ A contributor's "essential patent claims" are all patent claims
466
+ owned or controlled by the contributor, whether already acquired or
467
+ hereafter acquired, that would be infringed by some manner, permitted
468
+ by this License, of making, using, or selling its contributor version,
469
+ but do not include claims that would be infringed only as a
470
+ consequence of further modification of the contributor version. For
471
+ purposes of this definition, "control" includes the right to grant
472
+ patent sublicenses in a manner consistent with the requirements of
473
+ this License.
474
+
475
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
476
+ patent license under the contributor's essential patent claims, to
477
+ make, use, sell, offer for sale, import and otherwise run, modify and
478
+ propagate the contents of its contributor version.
479
+
480
+ In the following three paragraphs, a "patent license" is any express
481
+ agreement or commitment, however denominated, not to enforce a patent
482
+ (such as an express permission to practice a patent or covenant not to
483
+ sue for patent infringement). To "grant" such a patent license to a
484
+ party means to make such an agreement or commitment not to enforce a
485
+ patent against the party.
486
+
487
+ If you convey a covered work, knowingly relying on a patent license,
488
+ and the Corresponding Source of the work is not available for anyone
489
+ to copy, free of charge and under the terms of this License, through a
490
+ publicly available network server or other readily accessible means,
491
+ then you must either (1) cause the Corresponding Source to be so
492
+ available, or (2) arrange to deprive yourself of the benefit of the
493
+ patent license for this particular work, or (3) arrange, in a manner
494
+ consistent with the requirements of this License, to extend the patent
495
+ license to downstream recipients. "Knowingly relying" means you have
496
+ actual knowledge that, but for the patent license, your conveying the
497
+ covered work in a country, or your recipient's use of the covered work
498
+ in a country, would infringe one or more identifiable patents in that
499
+ country that you have reason to believe are valid.
500
+
501
+ If, pursuant to or in connection with a single transaction or
502
+ arrangement, you convey, or propagate by procuring conveyance of, a
503
+ covered work, and grant a patent license to some of the parties
504
+ receiving the covered work authorizing them to use, propagate, modify
505
+ or convey a specific copy of the covered work, then the patent license
506
+ you grant is automatically extended to all recipients of the covered
507
+ work and works based on it.
508
+
509
+ A patent license is "discriminatory" if it does not include within
510
+ the scope of its coverage, prohibits the exercise of, or is
511
+ conditioned on the non-exercise of one or more of the rights that are
512
+ specifically granted under this License. You may not convey a covered
513
+ work if you are a party to an arrangement with a third party that is
514
+ in the business of distributing software, under which you make payment
515
+ to the third party based on the extent of your activity of conveying
516
+ the work, and under which the third party grants, to any of the
517
+ parties who would receive the covered work from you, a discriminatory
518
+ patent license (a) in connection with copies of the covered work
519
+ conveyed by you (or copies made from those copies), or (b) primarily
520
+ for and in connection with specific products or compilations that
521
+ contain the covered work, unless you entered into that arrangement,
522
+ or that patent license was granted, prior to 28 March 2007.
523
+
524
+ Nothing in this License shall be construed as excluding or limiting
525
+ any implied license or other defenses to infringement that may
526
+ otherwise be available to you under applicable patent law.
527
+
528
+ 12. No Surrender of Others' Freedom.
529
+
530
+ If conditions are imposed on you (whether by court order, agreement or
531
+ otherwise) that contradict the conditions of this License, they do not
532
+ excuse you from the conditions of this License. If you cannot convey a
533
+ covered work so as to satisfy simultaneously your obligations under this
534
+ License and any other pertinent obligations, then as a consequence you may
535
+ not convey it at all. For example, if you agree to terms that obligate you
536
+ to collect a royalty for further conveying from those to whom you convey
537
+ the Program, the only way you could satisfy both those terms and this
538
+ License would be to refrain entirely from conveying the Program.
539
+
540
+ 13. Remote Network Interaction; Use with the GNU General Public License.
541
+
542
+ Notwithstanding any other provision of this License, if you modify the
543
+ Program, your modified version must prominently offer all users
544
+ interacting with it remotely through a computer network (if your version
545
+ supports such interaction) an opportunity to receive the Corresponding
546
+ Source of your version by providing access to the Corresponding Source
547
+ from a network server at no charge, through some standard or customary
548
+ means of facilitating copying of software. This Corresponding Source
549
+ shall include the Corresponding Source for any work covered by version 3
550
+ of the GNU General Public License that is incorporated pursuant to the
551
+ following paragraph.
552
+
553
+ Notwithstanding any other provision of this License, you have
554
+ permission to link or combine any covered work with a work licensed
555
+ under version 3 of the GNU General Public License into a single
556
+ combined work, and to convey the resulting work. The terms of this
557
+ License will continue to apply to the part which is the covered work,
558
+ but the work with which it is combined will remain governed by version
559
+ 3 of the GNU General Public License.
560
+
561
+ 14. Revised Versions of this License.
562
+
563
+ The Free Software Foundation may publish revised and/or new versions of
564
+ the GNU Affero General Public License from time to time. Such new versions
565
+ will be similar in spirit to the present version, but may differ in detail to
566
+ address new problems or concerns.
567
+
568
+ Each version is given a distinguishing version number. If the
569
+ Program specifies that a certain numbered version of the GNU Affero General
570
+ Public License "or any later version" applies to it, you have the
571
+ option of following the terms and conditions either of that numbered
572
+ version or of any later version published by the Free Software
573
+ Foundation. If the Program does not specify a version number of the
574
+ GNU Affero General Public License, you may choose any version ever published
575
+ by the Free Software Foundation.
576
+
577
+ If the Program specifies that a proxy can decide which future
578
+ versions of the GNU Affero General Public License can be used, that proxy's
579
+ public statement of acceptance of a version permanently authorizes you
580
+ to choose that version for the Program.
581
+
582
+ Later license versions may give you additional or different
583
+ permissions. However, no additional obligations are imposed on any
584
+ author or copyright holder as a result of your choosing to follow a
585
+ later version.
586
+
587
+ 15. Disclaimer of Warranty.
588
+
589
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
590
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
591
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
592
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
593
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
594
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
595
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
596
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
597
+
598
+ 16. Limitation of Liability.
599
+
600
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
601
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
602
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
603
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
604
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
605
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
606
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
607
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
608
+ SUCH DAMAGES.
609
+
610
+ 17. Interpretation of Sections 15 and 16.
611
+
612
+ If the disclaimer of warranty and limitation of liability provided
613
+ above cannot be given local legal effect according to their terms,
614
+ reviewing courts shall apply local law that most closely approximates
615
+ an absolute waiver of all civil liability in connection with the
616
+ Program, unless a warranty or assumption of liability accompanies a
617
+ copy of the Program in return for a fee.
618
+
619
+ END OF TERMS AND CONDITIONS
620
+
621
+ How to Apply These Terms to Your New Programs
622
+
623
+ If you develop a new program, and you want it to be of the greatest
624
+ possible use to the public, the best way to achieve this is to make it
625
+ free software which everyone can redistribute and change under these terms.
626
+
627
+ To do so, attach the following notices to the program. It is safest
628
+ to attach them to the start of each source file to most effectively
629
+ state the exclusion of warranty; and each file should have at least
630
+ the "copyright" line and a pointer to where the full notice is found.
631
+
632
+ <one line to give the program's name and a brief idea of what it does.>
633
+ Copyright (C) <year> <name of author>
634
+
635
+ This program is free software: you can redistribute it and/or modify
636
+ it under the terms of the GNU Affero General Public License as published by
637
+ the Free Software Foundation, either version 3 of the License, or
638
+ (at your option) any later version.
639
+
640
+ This program is distributed in the hope that it will be useful,
641
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
642
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
643
+ GNU Affero General Public License for more details.
644
+
645
+ You should have received a copy of the GNU Affero General Public License
646
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
647
+
648
+ Also add information on how to contact you by electronic and paper mail.
649
+
650
+ If your software can interact with users remotely through a computer
651
+ network, you should also make sure that it provides a way for users to
652
+ get its source. For example, if your program is a web application, its
653
+ interface could display a "Source" link that leads users to an archive
654
+ of the code. There are many ways you could offer source, and different
655
+ solutions will be better for different programs; see section 13 for the
656
+ specific requirements.
657
+
658
+ You should also get your employer (if you work as a programmer) or school,
659
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
660
+ For more information on this, and how to apply and follow the GNU AGPL, see
661
+ <https://www.gnu.org/licenses/>.
ultralytics-main/README.md ADDED
@@ -0,0 +1,285 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div align="center">
2
+ <p>
3
+ <a href="https://www.ultralytics.com/events/yolovision?utm_source=github&utm_medium=org&utm_campaign=yv25_event" target="_blank">
4
+ <img width="100%" src="https://raw.githubusercontent.com/ultralytics/assets/main/yolov8/banner-yolov8.png" alt="Ultralytics YOLO banner"></a>
5
+ </p>
6
+
7
+ [中文](https://docs.ultralytics.com/zh/) | [한국어](https://docs.ultralytics.com/ko/) | [日本語](https://docs.ultralytics.com/ja/) | [Русский](https://docs.ultralytics.com/ru/) | [Deutsch](https://docs.ultralytics.com/de/) | [Français](https://docs.ultralytics.com/fr/) | [Español](https://docs.ultralytics.com/es) | [Português](https://docs.ultralytics.com/pt/) | [Türkçe](https://docs.ultralytics.com/tr/) | [Tiếng Việt](https://docs.ultralytics.com/vi/) | [العربية](https://docs.ultralytics.com/ar/) <br>
8
+
9
+ <div>
10
+ <a href="https://github.com/ultralytics/ultralytics/actions/workflows/ci.yml"><img src="https://github.com/ultralytics/ultralytics/actions/workflows/ci.yml/badge.svg" alt="Ultralytics CI"></a>
11
+ <a href="https://clickpy.clickhouse.com/dashboard/ultralytics"><img src="https://static.pepy.tech/badge/ultralytics" alt="Ultralytics Downloads"></a>
12
+ <a href="https://zenodo.org/badge/latestdoi/264818686"><img src="https://zenodo.org/badge/264818686.svg" alt="Ultralytics YOLO Citation"></a>
13
+ <a href="https://discord.com/invite/ultralytics"><img alt="Ultralytics Discord" src="https://img.shields.io/discord/1089800235347353640?logo=discord&logoColor=white&label=Discord&color=blue"></a>
14
+ <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>
15
+ <a href="https://www.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>
16
+ <br>
17
+ <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>
18
+ <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>
19
+ <a href="https://www.kaggle.com/models/ultralytics/yolo11"><img src="https://kaggle.com/static/images/open-in-kaggle.svg" alt="Open Ultralytics In Kaggle"></a>
20
+ <a href="https://mybinder.org/v2/gh/ultralytics/ultralytics/HEAD?labpath=examples%2Ftutorial.ipynb"><img src="https://mybinder.org/badge_logo.svg" alt="Open Ultralytics In Binder"></a>
21
+ </div>
22
+ </div>
23
+ <br>
24
+
25
+ [Ultralytics](https://www.ultralytics.com/) creates cutting-edge, state-of-the-art (SOTA) [YOLO models](https://www.ultralytics.com/yolo) built on years of foundational research in computer vision and AI. Constantly updated for performance and flexibility, our models are **fast**, **accurate**, and **easy to use**. They excel at [object detection](https://docs.ultralytics.com/tasks/detect/), [tracking](https://docs.ultralytics.com/modes/track/), [instance segmentation](https://docs.ultralytics.com/tasks/segment/), [image classification](https://docs.ultralytics.com/tasks/classify/), and [pose estimation](https://docs.ultralytics.com/tasks/pose/) tasks.
26
+
27
+ Find detailed documentation in the [Ultralytics Docs](https://docs.ultralytics.com/). Get support via [GitHub Issues](https://github.com/ultralytics/ultralytics/issues/new/choose). Join discussions on [Discord](https://discord.com/invite/ultralytics), [Reddit](https://www.reddit.com/r/ultralytics/), and the [Ultralytics Community Forums](https://community.ultralytics.com/)!
28
+
29
+ Request an Enterprise License for commercial use at [Ultralytics Licensing](https://www.ultralytics.com/license).
30
+
31
+ <a href="https://docs.ultralytics.com/models/yolo11/" target="_blank">
32
+ <img width="100%" src="https://raw.githubusercontent.com/ultralytics/assets/refs/heads/main/yolo/performance-comparison.png" alt="YOLO11 performance plots">
33
+ </a>
34
+
35
+ <div align="center">
36
+ <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>
37
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%" alt="space">
38
+ <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>
39
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%" alt="space">
40
+ <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>
41
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%" alt="space">
42
+ <a href="https://www.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>
43
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%" alt="space">
44
+ <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>
45
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%" alt="space">
46
+ <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>
47
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%" alt="space">
48
+ <a href="https://discord.com/invite/ultralytics"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-discord.png" width="2%" alt="Ultralytics Discord"></a>
49
+ </div>
50
+
51
+ ## 📄 Documentation
52
+
53
+ See below for quickstart installation and usage examples. For comprehensive guidance on training, validation, prediction, and deployment, refer to our full [Ultralytics Docs](https://docs.ultralytics.com/).
54
+
55
+ <details open>
56
+ <summary>Install</summary>
57
+
58
+ Install the `ultralytics` package, including all [requirements](https://github.com/ultralytics/ultralytics/blob/main/pyproject.toml), in a [**Python>=3.8**](https://www.python.org/) environment with [**PyTorch>=1.8**](https://pytorch.org/get-started/locally/).
59
+
60
+ [![PyPI - Version](https://img.shields.io/pypi/v/ultralytics?logo=pypi&logoColor=white)](https://pypi.org/project/ultralytics/) [![Ultralytics Downloads](https://static.pepy.tech/badge/ultralytics)](https://clickpy.clickhouse.com/dashboard/ultralytics) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ultralytics?logo=python&logoColor=gold)](https://pypi.org/project/ultralytics/)
61
+
62
+ ```bash
63
+ pip install ultralytics
64
+ ```
65
+
66
+ For alternative installation methods, including [Conda](https://anaconda.org/conda-forge/ultralytics), [Docker](https://hub.docker.com/r/ultralytics/ultralytics), and building from source via Git, please consult the [Quickstart Guide](https://docs.ultralytics.com/quickstart/).
67
+
68
+ [![Conda Version](https://img.shields.io/conda/vn/conda-forge/ultralytics?logo=condaforge)](https://anaconda.org/conda-forge/ultralytics) [![Docker Image Version](https://img.shields.io/docker/v/ultralytics/ultralytics?sort=semver&logo=docker)](https://hub.docker.com/r/ultralytics/ultralytics) [![Ultralytics Docker Pulls](https://img.shields.io/docker/pulls/ultralytics/ultralytics?logo=docker)](https://hub.docker.com/r/ultralytics/ultralytics)
69
+
70
+ </details>
71
+
72
+ <details open>
73
+ <summary>Usage</summary>
74
+
75
+ ### CLI
76
+
77
+ You can use Ultralytics YOLO directly from the Command Line Interface (CLI) with the `yolo` command:
78
+
79
+ ```bash
80
+ # Predict using a pretrained YOLO model (e.g., YOLO11n) on an image
81
+ yolo predict model=yolo11n.pt source='https://ultralytics.com/images/bus.jpg'
82
+ ```
83
+
84
+ The `yolo` command supports various tasks and modes, accepting additional arguments like `imgsz=640`. Explore the YOLO [CLI Docs](https://docs.ultralytics.com/usage/cli/) for more examples.
85
+
86
+ ### Python
87
+
88
+ Ultralytics YOLO can also be integrated directly into your Python projects. It accepts the same [configuration arguments](https://docs.ultralytics.com/usage/cfg/) as the CLI:
89
+
90
+ ```python
91
+ from ultralytics import YOLO
92
+
93
+ # Load a pretrained YOLO11n model
94
+ model = YOLO("yolo11n.pt")
95
+
96
+ # Train the model on the COCO8 dataset for 100 epochs
97
+ train_results = model.train(
98
+ data="coco8.yaml", # Path to dataset configuration file
99
+ epochs=100, # Number of training epochs
100
+ imgsz=640, # Image size for training
101
+ device="cpu", # Device to run on (e.g., 'cpu', 0, [0,1,2,3])
102
+ )
103
+
104
+ # Evaluate the model's performance on the validation set
105
+ metrics = model.val()
106
+
107
+ # Perform object detection on an image
108
+ results = model("path/to/image.jpg") # Predict on an image
109
+ results[0].show() # Display results
110
+
111
+ # Export the model to ONNX format for deployment
112
+ path = model.export(format="onnx") # Returns the path to the exported model
113
+ ```
114
+
115
+ Discover more examples in the YOLO [Python Docs](https://docs.ultralytics.com/usage/python/).
116
+
117
+ </details>
118
+
119
+ ## ✨ Models
120
+
121
+ Ultralytics supports a wide range of YOLO models, from early versions like [YOLOv3](https://docs.ultralytics.com/models/yolov3/) to the latest [YOLO11](https://docs.ultralytics.com/models/yolo11/). The tables below showcase YOLO11 models pretrained on the [COCO](https://docs.ultralytics.com/datasets/detect/coco/) dataset for [Detection](https://docs.ultralytics.com/tasks/detect/), [Segmentation](https://docs.ultralytics.com/tasks/segment/), and [Pose Estimation](https://docs.ultralytics.com/tasks/pose/). Additionally, [Classification](https://docs.ultralytics.com/tasks/classify/) models pretrained on the [ImageNet](https://docs.ultralytics.com/datasets/classify/imagenet/) dataset are available. [Tracking](https://docs.ultralytics.com/modes/track/) mode is compatible with all Detection, Segmentation, and Pose models. All [Models](https://docs.ultralytics.com/models/) are automatically downloaded from the latest Ultralytics [release](https://github.com/ultralytics/assets/releases) upon first use.
122
+
123
+ <a href="https://docs.ultralytics.com/tasks/" target="_blank">
124
+ <img width="100%" src="https://github.com/ultralytics/docs/releases/download/0/ultralytics-yolov8-tasks-banner.avif" alt="Ultralytics YOLO supported tasks">
125
+ </a>
126
+ <br>
127
+ <br>
128
+
129
+ <details open><summary>Detection (COCO)</summary>
130
+
131
+ Explore the [Detection Docs](https://docs.ultralytics.com/tasks/detect/) for usage examples. These models are trained on the [COCO dataset](https://cocodataset.org/), featuring 80 object classes.
132
+
133
+ | Model | size<br><sup>(pixels) | mAP<sup>val<br>50-95 | Speed<br><sup>CPU ONNX<br>(ms) | Speed<br><sup>T4 TensorRT10<br>(ms) | params<br><sup>(M) | FLOPs<br><sup>(B) |
134
+ | ------------------------------------------------------------------------------------ | --------------------- | -------------------- | ------------------------------ | ----------------------------------- | ------------------ | ----------------- |
135
+ | [YOLO11n](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11n.pt) | 640 | 39.5 | 56.1 ± 0.8 | 1.5 ± 0.0 | 2.6 | 6.5 |
136
+ | [YOLO11s](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11s.pt) | 640 | 47.0 | 90.0 ± 1.2 | 2.5 ± 0.0 | 9.4 | 21.5 |
137
+ | [YOLO11m](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11m.pt) | 640 | 51.5 | 183.2 ± 2.0 | 4.7 ± 0.1 | 20.1 | 68.0 |
138
+ | [YOLO11l](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11l.pt) | 640 | 53.4 | 238.6 ± 1.4 | 6.2 ± 0.1 | 25.3 | 86.9 |
139
+ | [YOLO11x](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11x.pt) | 640 | 54.7 | 462.8 ± 6.7 | 11.3 ± 0.2 | 56.9 | 194.9 |
140
+
141
+ - **mAP<sup>val</sup>** values refer to single-model single-scale performance on the [COCO val2017](https://cocodataset.org/) dataset. See [YOLO Performance Metrics](https://docs.ultralytics.com/guides/yolo-performance-metrics/) for details. <br>Reproduce with `yolo val detect data=coco.yaml device=0`
142
+ - **Speed** metrics are averaged over COCO val images using an [Amazon EC2 P4d](https://aws.amazon.com/ec2/instance-types/p4/) instance. CPU speeds measured with [ONNX](https://onnx.ai/) export. GPU speeds measured with [TensorRT](https://developer.nvidia.com/tensorrt) export. <br>Reproduce with `yolo val detect data=coco.yaml batch=1 device=0|cpu`
143
+
144
+ </details>
145
+
146
+ <details><summary>Segmentation (COCO)</summary>
147
+
148
+ Refer to the [Segmentation Docs](https://docs.ultralytics.com/tasks/segment/) for usage examples. These models are trained on [COCO-Seg](https://docs.ultralytics.com/datasets/segment/coco/), including 80 classes.
149
+
150
+ | Model | size<br><sup>(pixels) | mAP<sup>box<br>50-95 | mAP<sup>mask<br>50-95 | Speed<br><sup>CPU ONNX<br>(ms) | Speed<br><sup>T4 TensorRT10<br>(ms) | params<br><sup>(M) | FLOPs<br><sup>(B) |
151
+ | -------------------------------------------------------------------------------------------- | --------------------- | -------------------- | --------------------- | ------------------------------ | ----------------------------------- | ------------------ | ----------------- |
152
+ | [YOLO11n-seg](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11n-seg.pt) | 640 | 38.9 | 32.0 | 65.9 ± 1.1 | 1.8 ± 0.0 | 2.9 | 9.7 |
153
+ | [YOLO11s-seg](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11s-seg.pt) | 640 | 46.6 | 37.8 | 117.6 ± 4.9 | 2.9 ± 0.0 | 10.1 | 33.0 |
154
+ | [YOLO11m-seg](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11m-seg.pt) | 640 | 51.5 | 41.5 | 281.6 ± 1.2 | 6.3 ± 0.1 | 22.4 | 113.2 |
155
+ | [YOLO11l-seg](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11l-seg.pt) | 640 | 53.4 | 42.9 | 344.2 ± 3.2 | 7.8 ± 0.2 | 27.6 | 132.2 |
156
+ | [YOLO11x-seg](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11x-seg.pt) | 640 | 54.7 | 43.8 | 664.5 ± 3.2 | 15.8 ± 0.7 | 62.1 | 296.4 |
157
+
158
+ - **mAP<sup>val</sup>** values are for single-model single-scale on the [COCO val2017](https://cocodataset.org/) dataset. See [YOLO Performance Metrics](https://docs.ultralytics.com/guides/yolo-performance-metrics/) for details. <br>Reproduce with `yolo val segment data=coco.yaml device=0`
159
+ - **Speed** metrics are averaged over COCO val images using an [Amazon EC2 P4d](https://aws.amazon.com/ec2/instance-types/p4/) instance. CPU speeds measured with [ONNX](https://onnx.ai/) export. GPU speeds measured with [TensorRT](https://developer.nvidia.com/tensorrt) export. <br>Reproduce with `yolo val segment data=coco.yaml batch=1 device=0|cpu`
160
+
161
+ </details>
162
+
163
+ <details><summary>Classification (ImageNet)</summary>
164
+
165
+ Consult the [Classification Docs](https://docs.ultralytics.com/tasks/classify/) for usage examples. These models are trained on [ImageNet](https://docs.ultralytics.com/datasets/classify/imagenet/), covering 1000 classes.
166
+
167
+ | Model | size<br><sup>(pixels) | acc<br><sup>top1 | acc<br><sup>top5 | Speed<br><sup>CPU ONNX<br>(ms) | Speed<br><sup>T4 TensorRT10<br>(ms) | params<br><sup>(M) | FLOPs<br><sup>(B) at 224 |
168
+ | -------------------------------------------------------------------------------------------- | --------------------- | ---------------- | ---------------- | ------------------------------ | ----------------------------------- | ------------------ | ------------------------ |
169
+ | [YOLO11n-cls](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11n-cls.pt) | 224 | 70.0 | 89.4 | 5.0 ± 0.3 | 1.1 ± 0.0 | 2.8 | 0.5 |
170
+ | [YOLO11s-cls](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11s-cls.pt) | 224 | 75.4 | 92.7 | 7.9 ± 0.2 | 1.3 ± 0.0 | 6.7 | 1.6 |
171
+ | [YOLO11m-cls](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11m-cls.pt) | 224 | 77.3 | 93.9 | 17.2 ± 0.4 | 2.0 ± 0.0 | 11.6 | 4.9 |
172
+ | [YOLO11l-cls](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11l-cls.pt) | 224 | 78.3 | 94.3 | 23.2 ± 0.3 | 2.8 ± 0.0 | 14.1 | 6.2 |
173
+ | [YOLO11x-cls](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11x-cls.pt) | 224 | 79.5 | 94.9 | 41.4 ± 0.9 | 3.8 ± 0.0 | 29.6 | 13.6 |
174
+
175
+ - **acc** values represent model accuracy on the [ImageNet](https://www.image-net.org/) dataset validation set. <br>Reproduce with `yolo val classify data=path/to/ImageNet device=0`
176
+ - **Speed** metrics are averaged over ImageNet val images using an [Amazon EC2 P4d](https://aws.amazon.com/ec2/instance-types/p4/) instance. CPU speeds measured with [ONNX](https://onnx.ai/) export. GPU speeds measured with [TensorRT](https://developer.nvidia.com/tensorrt) export. <br>Reproduce with `yolo val classify data=path/to/ImageNet batch=1 device=0|cpu`
177
+
178
+ </details>
179
+
180
+ <details><summary>Pose (COCO)</summary>
181
+
182
+ See the [Pose Estimation Docs](https://docs.ultralytics.com/tasks/pose/) for usage examples. These models are trained on [COCO-Pose](https://docs.ultralytics.com/datasets/pose/coco/), focusing on the 'person' class.
183
+
184
+ | 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>T4 TensorRT10<br>(ms) | params<br><sup>(M) | FLOPs<br><sup>(B) |
185
+ | ---------------------------------------------------------------------------------------------- | --------------------- | --------------------- | ------------------ | ------------------------------ | ----------------------------------- | ------------------ | ----------------- |
186
+ | [YOLO11n-pose](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11n-pose.pt) | 640 | 50.0 | 81.0 | 52.4 ± 0.5 | 1.7 ± 0.0 | 2.9 | 7.4 |
187
+ | [YOLO11s-pose](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11s-pose.pt) | 640 | 58.9 | 86.3 | 90.5 ± 0.6 | 2.6 ± 0.0 | 9.9 | 23.1 |
188
+ | [YOLO11m-pose](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11m-pose.pt) | 640 | 64.9 | 89.4 | 187.3 ± 0.8 | 4.9 ± 0.1 | 20.9 | 71.4 |
189
+ | [YOLO11l-pose](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11l-pose.pt) | 640 | 66.1 | 89.9 | 247.7 ± 1.1 | 6.4 ± 0.1 | 26.1 | 90.3 |
190
+ | [YOLO11x-pose](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11x-pose.pt) | 640 | 69.5 | 91.1 | 488.0 ± 13.9 | 12.1 ± 0.2 | 58.8 | 202.8 |
191
+
192
+ - **mAP<sup>val</sup>** values are for single-model single-scale on the [COCO Keypoints val2017](https://docs.ultralytics.com/datasets/pose/coco/) dataset. See [YOLO Performance Metrics](https://docs.ultralytics.com/guides/yolo-performance-metrics/) for details. <br>Reproduce with `yolo val pose data=coco-pose.yaml device=0`
193
+ - **Speed** metrics are averaged over COCO val images using an [Amazon EC2 P4d](https://aws.amazon.com/ec2/instance-types/p4/) instance. CPU speeds measured with [ONNX](https://onnx.ai/) export. GPU speeds measured with [TensorRT](https://developer.nvidia.com/tensorrt) export. <br>Reproduce with `yolo val pose data=coco-pose.yaml batch=1 device=0|cpu`
194
+
195
+ </details>
196
+
197
+ <details><summary>Oriented Bounding Boxes (DOTAv1)</summary>
198
+
199
+ Check the [OBB Docs](https://docs.ultralytics.com/tasks/obb/) for usage examples. These models are trained on [DOTAv1](https://docs.ultralytics.com/datasets/obb/dota-v2/#dota-v10/), including 15 classes.
200
+
201
+ | Model | size<br><sup>(pixels) | mAP<sup>test<br>50 | Speed<br><sup>CPU ONNX<br>(ms) | Speed<br><sup>T4 TensorRT10<br>(ms) | params<br><sup>(M) | FLOPs<br><sup>(B) |
202
+ | -------------------------------------------------------------------------------------------- | --------------------- | ------------------ | ------------------------------ | ----------------------------------- | ------------------ | ----------------- |
203
+ | [YOLO11n-obb](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11n-obb.pt) | 1024 | 78.4 | 117.6 ± 0.8 | 4.4 ± 0.0 | 2.7 | 16.8 |
204
+ | [YOLO11s-obb](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11s-obb.pt) | 1024 | 79.5 | 219.4 ± 4.0 | 5.1 ± 0.0 | 9.7 | 57.1 |
205
+ | [YOLO11m-obb](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11m-obb.pt) | 1024 | 80.9 | 562.8 ± 2.9 | 10.1 ± 0.4 | 20.9 | 182.8 |
206
+ | [YOLO11l-obb](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11l-obb.pt) | 1024 | 81.0 | 712.5 ± 5.0 | 13.5 ± 0.6 | 26.1 | 231.2 |
207
+ | [YOLO11x-obb](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11x-obb.pt) | 1024 | 81.3 | 1408.6 ± 7.7 | 28.6 ± 1.0 | 58.8 | 519.1 |
208
+
209
+ - **mAP<sup>test</sup>** values are for single-model multiscale performance on the [DOTAv1 test set](https://captain-whu.github.io/DOTA/dataset.html). <br>Reproduce by `yolo val obb data=DOTAv1.yaml device=0 split=test` and submit merged results to the [DOTA evaluation server](https://captain-whu.github.io/DOTA/evaluation.html).
210
+ - **Speed** metrics are averaged over [DOTAv1 val images](https://docs.ultralytics.com/datasets/obb/dota-v2/#dota-v10) using an [Amazon EC2 P4d](https://aws.amazon.com/ec2/instance-types/p4/) instance. CPU speeds measured with [ONNX](https://onnx.ai/) export. GPU speeds measured with [TensorRT](https://developer.nvidia.com/tensorrt) export. <br>Reproduce by `yolo val obb data=DOTAv1.yaml batch=1 device=0|cpu`
211
+
212
+ </details>
213
+
214
+ ## 🧩 Integrations
215
+
216
+ 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 partners like [Weights & Biases](https://docs.ultralytics.com/integrations/weights-biases/), [Comet ML](https://docs.ultralytics.com/integrations/comet/), [Roboflow](https://docs.ultralytics.com/integrations/roboflow/), and [Intel OpenVINO](https://docs.ultralytics.com/integrations/openvino/), can optimize your AI workflow. Explore more at [Ultralytics Integrations](https://docs.ultralytics.com/integrations/).
217
+
218
+ <a href="https://docs.ultralytics.com/integrations/" target="_blank">
219
+ <img width="100%" src="https://github.com/ultralytics/assets/raw/main/yolov8/banner-integrations.png" alt="Ultralytics active learning integrations">
220
+ </a>
221
+ <br>
222
+ <br>
223
+
224
+ <div align="center">
225
+ <a href="https://www.ultralytics.com/hub">
226
+ <img src="https://github.com/ultralytics/assets/raw/main/partners/logo-ultralytics-hub.png" width="10%" alt="Ultralytics HUB logo"></a>
227
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="15%" height="0" alt="space">
228
+ <a href="https://docs.ultralytics.com/integrations/weights-biases/">
229
+ <img src="https://github.com/ultralytics/assets/raw/main/partners/logo-wb.png" width="10%" alt="Weights & Biases logo"></a>
230
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="15%" height="0" alt="space">
231
+ <a href="https://docs.ultralytics.com/integrations/comet/">
232
+ <img src="https://github.com/ultralytics/assets/raw/main/partners/logo-comet.png" width="10%" alt="Comet ML logo"></a>
233
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="15%" height="0" alt="space">
234
+ <a href="https://docs.ultralytics.com/integrations/neural-magic/">
235
+ <img src="https://github.com/ultralytics/assets/raw/main/partners/logo-neuralmagic.png" width="10%" alt="Neural Magic logo"></a>
236
+ </div>
237
+
238
+ | Ultralytics HUB 🌟 | Weights & Biases | Comet | Neural Magic |
239
+ | :-----------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------: |
240
+ | Streamline YOLO workflows: Label, train, and deploy effortlessly with [Ultralytics HUB](https://hub.ultralytics.com/). Try now! | Track experiments, hyperparameters, and results with [Weights & Biases](https://docs.ultralytics.com/integrations/weights-biases/). | Free forever, [Comet ML](https://docs.ultralytics.com/integrations/comet/) lets you save YOLO models, resume training, and interactively visualize predictions. | Run YOLO inference up to 6x faster with [Neural Magic DeepSparse](https://docs.ultralytics.com/integrations/neural-magic/). |
241
+
242
+ ## 🌟 Ultralytics HUB
243
+
244
+ Experience seamless AI with [Ultralytics HUB](https://hub.ultralytics.com/), the all-in-one platform for data visualization, training YOLO models, and deployment—no coding required. Transform images into actionable insights and bring your AI visions to life effortlessly using our cutting-edge platform and user-friendly [Ultralytics App](https://www.ultralytics.com/app-install). Start your journey for **Free** today!
245
+
246
+ <a href="https://www.ultralytics.com/hub" target="_blank">
247
+ <img width="100%" src="https://github.com/ultralytics/assets/raw/main/im/ultralytics-hub.png" alt="Ultralytics HUB preview image"></a>
248
+
249
+ ## 🤝 Contribute
250
+
251
+ We thrive on community collaboration! Ultralytics YOLO wouldn't be the SOTA framework it is without contributions from developers like you. Please see our [Contributing Guide](https://docs.ultralytics.com/help/contributing/) to get started. We also welcome your feedback—share your experience by completing our [Survey](https://www.ultralytics.com/survey?utm_source=github&utm_medium=social&utm_campaign=Survey). A huge **Thank You** 🙏 to everyone who contributes!
252
+
253
+ <!-- SVG image from https://opencollective.com/ultralytics/contributors.svg?width=1280 -->
254
+
255
+ [![Ultralytics open-source contributors](https://raw.githubusercontent.com/ultralytics/assets/main/im/image-contributors.png)](https://github.com/ultralytics/ultralytics/graphs/contributors)
256
+
257
+ We look forward to your contributions to help make the Ultralytics ecosystem even better!
258
+
259
+ ## 📜 License
260
+
261
+ Ultralytics offers two licensing options to suit different needs:
262
+
263
+ - **AGPL-3.0 License**: This [OSI-approved](https://opensource.org/license/agpl-v3) open-source license is perfect for students, researchers, and enthusiasts. It encourages open collaboration and knowledge sharing. See the [LICENSE](https://github.com/ultralytics/ultralytics/blob/main/LICENSE) file for full details.
264
+ - **Ultralytics Enterprise License**: Designed for commercial use, this license allows for the seamless integration of Ultralytics software and AI models into commercial products and services, bypassing the open-source requirements of AGPL-3.0. If your use case involves commercial deployment, please contact us via [Ultralytics Licensing](https://www.ultralytics.com/license).
265
+
266
+ ## 📞 Contact
267
+
268
+ For bug reports and feature requests related to Ultralytics software, please visit [GitHub Issues](https://github.com/ultralytics/ultralytics/issues). For questions, discussions, and community support, join our active communities on [Discord](https://discord.com/invite/ultralytics), [Reddit](https://www.reddit.com/r/ultralytics/), and the [Ultralytics Community Forums](https://community.ultralytics.com/). We're here to help with all things Ultralytics!
269
+
270
+ <br>
271
+ <div align="center">
272
+ <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>
273
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
274
+ <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>
275
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
276
+ <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>
277
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
278
+ <a href="https://www.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>
279
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
280
+ <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>
281
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
282
+ <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>
283
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
284
+ <a href="https://discord.com/invite/ultralytics"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-discord.png" width="3%" alt="Ultralytics Discord"></a>
285
+ </div>
ultralytics-main/README.zh-CN.md ADDED
@@ -0,0 +1,285 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div align="center">
2
+ <p>
3
+ <a href="https://www.ultralytics.com/events/yolovision?utm_source=github&utm_medium=org&utm_campaign=yv25_event" target="_blank">
4
+ <img width="100%" src="https://raw.githubusercontent.com/ultralytics/assets/main/yolov8/banner-yolov8.png" alt="Ultralytics YOLO banner"></a>
5
+ </p>
6
+
7
+ [中文](https://docs.ultralytics.com/zh/) | [한국어](https://docs.ultralytics.com/ko/) | [日本語](https://docs.ultralytics.com/ja/) | [Русский](https://docs.ultralytics.com/ru/) | [Deutsch](https://docs.ultralytics.com/de/) | [Français](https://docs.ultralytics.com/fr/) | [Español](https://docs.ultralytics.com/es) | [Português](https://docs.ultralytics.com/pt/) | [Türkçe](https://docs.ultralytics.com/tr/) | [Tiếng Việt](https://docs.ultralytics.com/vi/) | [العربية](https://docs.ultralytics.com/ar/) <br>
8
+
9
+ <div>
10
+ <a href="https://github.com/ultralytics/ultralytics/actions/workflows/ci.yml"><img src="https://github.com/ultralytics/ultralytics/actions/workflows/ci.yml/badge.svg" alt="Ultralytics CI"></a>
11
+ <a href="https://clickpy.clickhouse.com/dashboard/ultralytics"><img src="https://static.pepy.tech/badge/ultralytics" alt="Ultralytics Downloads"></a>
12
+ <a href="https://zenodo.org/badge/latestdoi/264818686"><img src="https://zenodo.org/badge/264818686.svg" alt="Ultralytics YOLO Citation"></a>
13
+ <a href="https://discord.com/invite/ultralytics"><img alt="Ultralytics Discord" src="https://img.shields.io/discord/1089800235347353640?logo=discord&logoColor=white&label=Discord&color=blue"></a>
14
+ <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>
15
+ <a href="https://www.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>
16
+ <br>
17
+ <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>
18
+ <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>
19
+ <a href="https://www.kaggle.com/models/ultralytics/yolo11"><img src="https://kaggle.com/static/images/open-in-kaggle.svg" alt="Open Ultralytics In Kaggle"></a>
20
+ <a href="https://mybinder.org/v2/gh/ultralytics/ultralytics/HEAD?labpath=examples%2Ftutorial.ipynb"><img src="https://mybinder.org/badge_logo.svg" alt="Open Ultralytics In Binder"></a>
21
+ </div>
22
+ </div>
23
+ <br>
24
+
25
+ [Ultralytics](https://www.ultralytics.com/) 基于多年在计算机视觉和人工智能领域的基础研究,创造了尖端的、最先进的 (SOTA) [YOLO 模型](https://www.ultralytics.com/yolo)。我们的模型不断更新以提高性能和灵活性,具有**速度快**、**精度高**和**易于使用**的特点。它们在[目标检测](https://docs.ultralytics.com/tasks/detect/)、[跟踪](https://docs.ultralytics.com/modes/track/)、[实例分割](https://docs.ultralytics.com/tasks/segment/)、[图像分类](https://docs.ultralytics.com/tasks/classify/)和[姿态估计](https://docs.ultralytics.com/tasks/pose/)任务中表现出色。
26
+
27
+ 在 [Ultralytics 文档](https://docs.ultralytics.com/)中查找详细文档。通过 [GitHub Issues](https://github.com/ultralytics/ultralytics/issues/new/choose) 获取支持。加入 [Discord](https://discord.com/invite/ultralytics)、[Reddit](https://www.reddit.com/r/ultralytics/) 和 [Ultralytics 社区论坛](https://community.ultralytics.com/)参与讨论!
28
+
29
+ 如需商业用途,请在 [Ultralytics 授权许可](https://www.ultralytics.com/license)申请企业许可证。
30
+
31
+ <a href="https://docs.ultralytics.com/models/yolo11/" target="_blank">
32
+ <img width="100%" src="https://raw.githubusercontent.com/ultralytics/assets/refs/heads/main/yolo/performance-comparison.png" alt="YOLO11 performance plots">
33
+ </a>
34
+
35
+ <div align="center">
36
+ <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>
37
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%" alt="space">
38
+ <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>
39
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%" alt="space">
40
+ <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>
41
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%" alt="space">
42
+ <a href="https://www.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>
43
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%" alt="space">
44
+ <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>
45
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%" alt="space">
46
+ <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>
47
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%" alt="space">
48
+ <a href="https://discord.com/invite/ultralytics"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-discord.png" width="2%" alt="Ultralytics Discord"></a>
49
+ </div>
50
+
51
+ ## 📄 文档
52
+
53
+ 请参阅下文了解快速安装和使用示例。有关训练、验证、预测和部署的全面指南,请参阅我们的完整 [Ultralytics 文档](https://docs.ultralytics.com/)。
54
+
55
+ <details open>
56
+ <summary>安装</summary>
57
+
58
+ 在 [**Python>=3.8**](https://www.python.org/) 环境中安装 `ultralytics` 包,包括所有[依赖项](https://github.com/ultralytics/ultralytics/blob/main/pyproject.toml),并确保 [**PyTorch>=1.8**](https://pytorch.org/get-started/locally/)。
59
+
60
+ [![PyPI - Version](https://img.shields.io/pypi/v/ultralytics?logo=pypi&logoColor=white)](https://pypi.org/project/ultralytics/) [![Ultralytics Downloads](https://static.pepy.tech/badge/ultralytics)](https://clickpy.clickhouse.com/dashboard/ultralytics) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ultralytics?logo=python&logoColor=gold)](https://pypi.org/project/ultralytics/)
61
+
62
+ ```bash
63
+ pip install ultralytics
64
+ ```
65
+
66
+ 有关其他安装方法,包括 [Conda](https://anaconda.org/conda-forge/ultralytics)、[Docker](https://hub.docker.com/r/ultralytics/ultralytics) 以及通过 Git 从源代码构建,请查阅[快速入门指南](https://docs.ultralytics.com/quickstart/)。
67
+
68
+ [![Conda Version](https://img.shields.io/conda/vn/conda-forge/ultralytics?logo=condaforge)](https://anaconda.org/conda-forge/ultralytics) [![Docker Image Version](https://img.shields.io/docker/v/ultralytics/ultralytics?sort=semver&logo=docker)](https://hub.docker.com/r/ultralytics/ultralytics) [![Ultralytics Docker Pulls](https://img.shields.io/docker/pulls/ultralytics/ultralytics?logo=docker)](https://hub.docker.com/r/ultralytics/ultralytics)
69
+
70
+ </details>
71
+
72
+ <details open>
73
+ <summary>使用方法</summary>
74
+
75
+ ### CLI
76
+
77
+ 您可以直接通过命令行界面 (CLI) 使用 `yolo` 命令来运行 Ultralytics YOLO:
78
+
79
+ ```bash
80
+ # 使用预训练的 YOLO 模型 (例如 YOLO11n) 对图像进行预测
81
+ yolo predict model=yolo11n.pt source='https://ultralytics.com/images/bus.jpg'
82
+ ```
83
+
84
+ `yolo` 命令支持各种任务和模式,并接受额外的参数,如 `imgsz=640`。浏览 YOLO [CLI 文档](https://docs.ultralytics.com/usage/cli/)获取更多示例。
85
+
86
+ ### Python
87
+
88
+ Ultralytics YOLO 也可以直接集成到您的 Python 项目中。它接受与 CLI 相同的[配置参数](https://docs.ultralytics.com/usage/cfg/):
89
+
90
+ ```python
91
+ from ultralytics import YOLO
92
+
93
+ # 加载一个预训练的 YOLO11n 模型
94
+ model = YOLO("yolo11n.pt")
95
+
96
+ # 在 COCO8 数据集上训练模型 100 个周期
97
+ train_results = model.train(
98
+ data="coco8.yaml", # 数据集配置文件路径
99
+ epochs=100, # 训练周期数
100
+ imgsz=640, # 训练图像尺寸
101
+ device="cpu", # 运行设备 (例如 'cpu', 0, [0,1,2,3])
102
+ )
103
+
104
+ # 评估模型在验证集上的性能
105
+ metrics = model.val()
106
+
107
+ # 对图像执行目标检测
108
+ results = model("path/to/image.jpg") # 对图像进行预测
109
+ results[0].show() # 显示结果
110
+
111
+ # 将模型导出为 ONNX 格式以进行部署
112
+ path = model.export(format="onnx") # 返回导出模型的路径
113
+ ```
114
+
115
+ 在 YOLO [Python 文档](https://docs.ultralytics.com/usage/python/)中发现更多示例。
116
+
117
+ </details>
118
+
119
+ ## ✨ 模型
120
+
121
+ Ultralytics 支持广泛的 YOLO 模型,从早期的版本如 [YOLOv3](https://docs.ultralytics.com/models/yolov3/) 到最新的 [YOLO11](https://docs.ultralytics.com/models/yolo11/)。下表展示了在 [COCO](https://docs.ultralytics.com/datasets/detect/coco/) 数据集上预训练的 YOLO11 模型,用于[检测](https://docs.ultralytics.com/tasks/detect/)、[分割](https://docs.ultralytics.com/tasks/segment/)和[姿态估计](https://docs.ultralytics.com/tasks/pose/)任务。此外,还提供了在 [ImageNet](https://docs.ultralytics.com/datasets/classify/imagenet/) 数据集上预训练的[分类](https://docs.ultralytics.com/tasks/classify/)模型。[跟踪](https://docs.ultralytics.com/modes/track/)模式与所有检测、分割和姿态模型兼容。所有[模型](https://docs.ultralytics.com/models/)在首次使用时都���自动从最新的 Ultralytics [发布版本](https://github.com/ultralytics/assets/releases)下载。
122
+
123
+ <a href="https://docs.ultralytics.com/tasks/" target="_blank">
124
+ <img width="100%" src="https://github.com/ultralytics/docs/releases/download/0/ultralytics-yolov8-tasks-banner.avif" alt="Ultralytics YOLO supported tasks">
125
+ </a>
126
+ <br>
127
+ <br>
128
+
129
+ <details open><summary>检测 (COCO)</summary>
130
+
131
+ 浏览[检测文档](https://docs.ultralytics.com/tasks/detect/)获取使用示例。这些模型在 [COCO 数据集](https://cocodataset.org/)上训练,包含 80 个对象类别。
132
+
133
+ | 模型 | 尺寸<br><sup>(像素) | mAP<sup>val<br>50-95 | 速度<br><sup>CPU ONNX<br>(毫秒) | 速度<br><sup>T4 TensorRT10<br>(毫秒) | 参数<br><sup>(百万) | FLOPs<br><sup>(十亿) |
134
+ | ------------------------------------------------------------------------------------ | ------------------- | -------------------- | ------------------------------- | ------------------------------------ | ------------------- | -------------------- |
135
+ | [YOLO11n](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11n.pt) | 640 | 39.5 | 56.1 ± 0.8 | 1.5 ± 0.0 | 2.6 | 6.5 |
136
+ | [YOLO11s](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11s.pt) | 640 | 47.0 | 90.0 ± 1.2 | 2.5 ± 0.0 | 9.4 | 21.5 |
137
+ | [YOLO11m](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11m.pt) | 640 | 51.5 | 183.2 ± 2.0 | 4.7 ± 0.1 | 20.1 | 68.0 |
138
+ | [YOLO11l](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11l.pt) | 640 | 53.4 | 238.6 ± 1.4 | 6.2 ± 0.1 | 25.3 | 86.9 |
139
+ | [YOLO11x](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11x.pt) | 640 | 54.7 | 462.8 ± 6.7 | 11.3 ± 0.2 | 56.9 | 194.9 |
140
+
141
+ - **mAP<sup>val</sup>** 值指的是在 [COCO val2017](https://cocodataset.org/) 数据集上的单模型单尺度性能。详见 [YOLO 性能指标](https://docs.ultralytics.com/guides/yolo-performance-metrics/)。<br>使用 `yolo val detect data=coco.yaml device=0` 复现结果。
142
+ - **速度** 指标是在 [Amazon EC2 P4d](https://aws.amazon.com/ec2/instance-types/p4/) 实例上对 COCO val 图像进行平均测量的。CPU 速度使用 [ONNX](https://onnx.ai/) 导出进行测量。GPU 速度使用 [TensorRT](https://developer.nvidia.com/tensorrt) 导出进行测量。<br>使用 `yolo val detect data=coco.yaml batch=1 device=0|cpu` 复现结果。
143
+
144
+ </details>
145
+
146
+ <details><summary>分割 (COCO)</summary>
147
+
148
+ 请参阅[分割文档](https://docs.ultralytics.com/tasks/segment/)获取使用示例。这些模型在 [COCO-Seg](https://docs.ultralytics.com/datasets/segment/coco/) 数据集上训练,包含 80 个类别。
149
+
150
+ | 模型 | 尺寸<br><sup>(像素) | mAP<sup>box<br>50-95 | mAP<sup>mask<br>50-95 | 速度<br><sup>CPU ONNX<br>(毫秒) | 速度<br><sup>T4 TensorRT10<br>(毫秒) | 参数<br><sup>(百万) | FLOPs<br><sup>(十亿) |
151
+ | -------------------------------------------------------------------------------------------- | ------------------- | -------------------- | --------------------- | ------------------------------- | ------------------------------------ | ------------------- | -------------------- |
152
+ | [YOLO11n-seg](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11n-seg.pt) | 640 | 38.9 | 32.0 | 65.9 ± 1.1 | 1.8 ± 0.0 | 2.9 | 9.7 |
153
+ | [YOLO11s-seg](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11s-seg.pt) | 640 | 46.6 | 37.8 | 117.6 ± 4.9 | 2.9 ± 0.0 | 10.1 | 33.0 |
154
+ | [YOLO11m-seg](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11m-seg.pt) | 640 | 51.5 | 41.5 | 281.6 ± 1.2 | 6.3 ± 0.1 | 22.4 | 113.2 |
155
+ | [YOLO11l-seg](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11l-seg.pt) | 640 | 53.4 | 42.9 | 344.2 ± 3.2 | 7.8 ± 0.2 | 27.6 | 132.2 |
156
+ | [YOLO11x-seg](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11x-seg.pt) | 640 | 54.7 | 43.8 | 664.5 ± 3.2 | 15.8 ± 0.7 | 62.1 | 296.4 |
157
+
158
+ - **mAP<sup>val</sup>** 值指的是在 [COCO val2017](https://cocodataset.org/) 数据集上的单模型单尺度性能。详见 [YOLO 性能指标](https://docs.ultralytics.com/guides/yolo-performance-metrics/)。<br>使用 `yolo val segment data=coco.yaml device=0` 复现结果。
159
+ - **速度** 指标是在 [Amazon EC2 P4d](https://aws.amazon.com/ec2/instance-types/p4/) 实例上对 COCO val 图像进行平均测量的。CPU 速度使用 [ONNX](https://onnx.ai/) 导出进行测量。GPU 速度使用 [TensorRT](https://developer.nvidia.com/tensorrt) 导出进行测量。<br>使用 `yolo val segment data=coco.yaml batch=1 device=0|cpu` 复现结果。
160
+
161
+ </details>
162
+
163
+ <details><summary>分类 (ImageNet)</summary>
164
+
165
+ 请查阅[分类文档](https://docs.ultralytics.com/tasks/classify/)获取使用示例。这些模型在 [ImageNet](https://docs.ultralytics.com/datasets/classify/imagenet/) 数据集上训练,涵盖 1000 个类别。
166
+
167
+ | 模型 | 尺寸<br><sup>(像素) | acc<br><sup>top1 | acc<br><sup>top5 | 速度<br><sup>CPU ONNX<br>(毫秒) | 速度<br><sup>T4 TensorRT10<br>(毫秒) | 参数<br><sup>(百万) | FLOPs<br><sup>(十亿) @ 224 |
168
+ | -------------------------------------------------------------------------------------------- | ------------------- | ---------------- | ---------------- | ------------------------------- | ------------------------------------ | ------------------- | -------------------------- |
169
+ | [YOLO11n-cls](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11n-cls.pt) | 224 | 70.0 | 89.4 | 5.0 ± 0.3 | 1.1 ± 0.0 | 2.8 | 0.5 |
170
+ | [YOLO11s-cls](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11s-cls.pt) | 224 | 75.4 | 92.7 | 7.9 ± 0.2 | 1.3 ± 0.0 | 6.7 | 1.6 |
171
+ | [YOLO11m-cls](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11m-cls.pt) | 224 | 77.3 | 93.9 | 17.2 ± 0.4 | 2.0 ± 0.0 | 11.6 | 4.9 |
172
+ | [YOLO11l-cls](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11l-cls.pt) | 224 | 78.3 | 94.3 | 23.2 ± 0.3 | 2.8 ± 0.0 | 14.1 | 6.2 |
173
+ | [YOLO11x-cls](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11x-cls.pt) | 224 | 79.5 | 94.9 | 41.4 ± 0.9 | 3.8 ± 0.0 | 29.6 | 13.6 |
174
+
175
+ - **acc** 值表示模型在 [ImageNet](https://www.image-net.org/) 数据集验证集上的准确率。<br>使用 `yolo val classify data=path/to/ImageNet device=0` 复现结果。
176
+ - **速度** 指标是在 [Amazon EC2 P4d](https://aws.amazon.com/ec2/instance-types/p4/) 实例上对 ImageNet val 图像进行平均测量的。CPU 速度使用 [ONNX](https://onnx.ai/) 导出进行测量。GPU 速度使用 [TensorRT](https://developer.nvidia.com/tensorrt) 导出进行测量。<br>使用 `yolo val classify data=path/to/ImageNet batch=1 device=0|cpu` 复现结果。
177
+
178
+ </details>
179
+
180
+ <details><summary>姿态估计 (COCO)</summary>
181
+
182
+ 请参阅[姿态估计文档](https://docs.ultralytics.com/tasks/pose/)获取使用示例。这些模型在 [COCO-Pose](https://docs.ultralytics.com/datasets/pose/coco/) 数据集上训练,专注于 'person' 类别。
183
+
184
+ | 模型 | 尺寸<br><sup>(像素) | mAP<sup>pose<br>50-95 | mAP<sup>pose<br>50 | 速度<br><sup>CPU ONNX<br>(毫秒) | 速度<br><sup>T4 TensorRT10<br>(毫秒) | 参数<br><sup>(百万) | FLOPs<br><sup>(十亿) |
185
+ | ---------------------------------------------------------------------------------------------- | ------------------- | --------------------- | ------------------ | ------------------------------- | ------------------------------------ | ------------------- | -------------------- |
186
+ | [YOLO11n-pose](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11n-pose.pt) | 640 | 50.0 | 81.0 | 52.4 ± 0.5 | 1.7 ± 0.0 | 2.9 | 7.4 |
187
+ | [YOLO11s-pose](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11s-pose.pt) | 640 | 58.9 | 86.3 | 90.5 ± 0.6 | 2.6 ± 0.0 | 9.9 | 23.1 |
188
+ | [YOLO11m-pose](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11m-pose.pt) | 640 | 64.9 | 89.4 | 187.3 ± 0.8 | 4.9 ± 0.1 | 20.9 | 71.4 |
189
+ | [YOLO11l-pose](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11l-pose.pt) | 640 | 66.1 | 89.9 | 247.7 ± 1.1 | 6.4 ± 0.1 | 26.1 | 90.3 |
190
+ | [YOLO11x-pose](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11x-pose.pt) | 640 | 69.5 | 91.1 | 488.0 ± 13.9 | 12.1 ± 0.2 | 58.8 | 202.8 |
191
+
192
+ - **mAP<sup>val</sup>** 值指的是在 [COCO Keypoints val2017](https://docs.ultralytics.com/datasets/pose/coco/) 数据集上的单模型单尺度性能。详见 [YOLO 性能指标](https://docs.ultralytics.com/guides/yolo-performance-metrics/)。<br>使用 `yolo val pose data=coco-pose.yaml device=0` 复现结果。
193
+ - **速度** 指标是在 [Amazon EC2 P4d](https://aws.amazon.com/ec2/instance-types/p4/) 实例上对 COCO val 图像进行平均测量的。CPU 速度使用 [ONNX](https://onnx.ai/) 导出进行测量。GPU 速度使用 [TensorRT](https://developer.nvidia.com/tensorrt) 导出进行测量。<br>使用 `yolo val pose data=coco-pose.yaml batch=1 device=0|cpu` 复现结果。
194
+
195
+ </details>
196
+
197
+ <details><summary>定向边界框 (DOTAv1)</summary>
198
+
199
+ 请查阅 [OBB 文档](https://docs.ultralytics.com/tasks/obb/)获取使用示例。这些模型在 [DOTAv1](https://docs.ultralytics.com/datasets/obb/dota-v2/#dota-v10) 数据集上训练,包含 15 个类别。
200
+
201
+ | 模型 | 尺寸<br><sup>(像素) | mAP<sup>test<br>50 | 速度<br><sup>CPU ONNX<br>(毫秒) | 速度<br><sup>T4 TensorRT10<br>(毫秒) | 参数<br><sup>(百万) | FLOPs<br><sup>(十亿) |
202
+ | -------------------------------------------------------------------------------------------- | ------------------- | ------------------ | ------------------------------- | ------------------------------------ | ------------------- | -------------------- |
203
+ | [YOLO11n-obb](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11n-obb.pt) | 1024 | 78.4 | 117.6 ± 0.8 | 4.4 ± 0.0 | 2.7 | 16.8 |
204
+ | [YOLO11s-obb](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11s-obb.pt) | 1024 | 79.5 | 219.4 ± 4.0 | 5.1 ± 0.0 | 9.7 | 57.1 |
205
+ | [YOLO11m-obb](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11m-obb.pt) | 1024 | 80.9 | 562.8 ± 2.9 | 10.1 ± 0.4 | 20.9 | 182.8 |
206
+ | [YOLO11l-obb](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11l-obb.pt) | 1024 | 81.0 | 712.5 ± 5.0 | 13.5 ± 0.6 | 26.1 | 231.2 |
207
+ | [YOLO11x-obb](https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11x-obb.pt) | 1024 | 81.3 | 1408.6 ± 7.7 | 28.6 ± 1.0 | 58.8 | 519.1 |
208
+
209
+ - **mAP<sup>test</sup>** 值指的是在 [DOTAv1 测试集](https://captain-whu.github.io/DOTA/dataset.html)上的单模型多尺度性能。<br>通过 `yolo val obb data=DOTAv1.yaml device=0 split=test` 复现结果,并将合并后的结果提交到 [DOTA 评估服务器](https://captain-whu.github.io/DOTA/evaluation.html)。
210
+ - **速度** 指标是在 [Amazon EC2 P4d](https://aws.amazon.com/ec2/instance-types/p4/) 实例上对 [DOTAv1 val 图像](https://docs.ultralytics.com/datasets/obb/dota-v2/#dota-v10)进行平均测量的。CPU 速度使用 [ONNX](https://onnx.ai/) 导出进行测量。GPU 速度使用 [TensorRT](https://developer.nvidia.com/tensorrt) 导出进行测量。<br>通过 `yolo val obb data=DOTAv1.yaml batch=1 device=0|cpu` 复现结果。
211
+
212
+ </details>
213
+
214
+ ## 🧩 集成
215
+
216
+ 我们与领先 AI 平台的关键集成扩展了 Ultralytics 产品的功能,增强了数据集标注、训练、可视化和模型管理等任务。了解 Ultralytics 如何与 [Weights & Biases](https://docs.ultralytics.com/integrations/weights-biases/)、[Comet ML](https://docs.ultralytics.com/integrations/comet/)、[Roboflow](https://docs.ultralytics.com/integrations/roboflow/) 和 [Intel OpenVINO](https://docs.ultralytics.com/integrations/openvino/) 等合作伙伴协作,优化您的 AI 工作流程。��� [Ultralytics 集成](https://docs.ultralytics.com/integrations/)了解更多信息。
217
+
218
+ <a href="https://docs.ultralytics.com/integrations/" target="_blank">
219
+ <img width="100%" src="https://github.com/ultralytics/assets/raw/main/yolov8/banner-integrations.png" alt="Ultralytics active learning integrations">
220
+ </a>
221
+ <br>
222
+ <br>
223
+
224
+ <div align="center">
225
+ <a href="https://www.ultralytics.com/hub">
226
+ <img src="https://github.com/ultralytics/assets/raw/main/partners/logo-ultralytics-hub.png" width="10%" alt="Ultralytics HUB logo"></a>
227
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="15%" height="0" alt="space">
228
+ <a href="https://docs.ultralytics.com/integrations/weights-biases/">
229
+ <img src="https://github.com/ultralytics/assets/raw/main/partners/logo-wb.png" width="10%" alt="Weights & Biases logo"></a>
230
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="15%" height="0" alt="space">
231
+ <a href="https://docs.ultralytics.com/integrations/comet/">
232
+ <img src="https://github.com/ultralytics/assets/raw/main/partners/logo-comet.png" width="10%" alt="Comet ML logo"></a>
233
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="15%" height="0" alt="space">
234
+ <a href="https://docs.ultralytics.com/integrations/neural-magic/">
235
+ <img src="https://github.com/ultralytics/assets/raw/main/partners/logo-neuralmagic.png" width="10%" alt="Neural Magic logo"></a>
236
+ </div>
237
+
238
+ | Ultralytics HUB 🌟 | Weights & Biases | Comet | Neural Magic |
239
+ | :-----------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------: |
240
+ | 简化 YOLO 工作流程:使用 [Ultralytics HUB](https://hub.ultralytics.com/) 轻松进行标注、训练和部署。立即试用! | 使用 [Weights & Biases](https://docs.ultralytics.com/integrations/weights-biases/) 跟踪实验、超参数和结果。 | 永久免费的 [Comet ML](https://docs.ultralytics.com/integrations/comet/) 让您能够保存 YOLO 模型、恢复训练并交互式地可视化预测结果。 | 使用 [Neural Magic DeepSparse](https://docs.ultralytics.com/integrations/neural-magic/),将 YOLO 推理速度提高多达 6 倍。 |
241
+
242
+ ## 🌟 Ultralytics HUB
243
+
244
+ 通过 [Ultralytics HUB](https://hub.ultralytics.com/) 体验无缝 AI,这是一个集数据可视化、训练 YOLO 模型和部署于一体的平台——无需编码。使用我们尖端的平台和用户友好的 [Ultralytics App](https://www.ultralytics.com/app-install),轻松将图像转化为可操作的见解,并将您的 AI 愿景变为现实。立即**免费**开始您的旅程!
245
+
246
+ <a href="https://www.ultralytics.com/hub" target="_blank">
247
+ <img width="100%" src="https://github.com/ultralytics/assets/raw/main/im/ultralytics-hub.png" alt="Ultralytics HUB preview image"></a>
248
+
249
+ ## 🤝 贡献
250
+
251
+ 我们依靠社区协作蓬勃发展!没有像您这样的开发者的贡献,Ultralytics YOLO 就不会成为如今最先进的框架。请参阅我们的[贡献指南](https://docs.ultralytics.com/help/contributing/)开始贡献。我们也欢迎您的反馈——通过完成我们的[调查问卷](https://www.ultralytics.com/survey?utm_source=github&utm_medium=social&utm_campaign=Survey)分享您的体验。非常**感谢** 🙏 每一位贡献者!
252
+
253
+ <!-- SVG image from https://opencollective.com/ultralytics/contributors.svg?width=1280 -->
254
+
255
+ [![Ultralytics open-source contributors](https://raw.githubusercontent.com/ultralytics/assets/main/im/image-contributors.png)](https://github.com/ultralytics/ultralytics/graphs/contributors)
256
+
257
+ 我们期待您的贡献,帮助 Ultralytics 生态系统变得更好!
258
+
259
+ ## 📜 许可证
260
+
261
+ Ultralytics 提供两种许可选项以满足不同需求:
262
+
263
+ - **AGPL-3.0 许可证**:这种经 [OSI 批准](https://opensource.org/license/agpl-v3)的开源许可证非常适合学生、研究人员和爱好者。它鼓励开放协作和知识共享。有关完整详细信息,请参阅 [LICENSE](https://github.com/ultralytics/ultralytics/blob/main/LICENSE) 文件。
264
+ - **Ultralytics 企业许可证**:专为商业用途设计,此许可证允许将 Ultralytics 软件和 AI 模型无缝集成到商业产品和服务中,绕过 AGPL-3.0 的开源要求���如果您的使用场景涉及商业部署,请通过 [Ultralytics 授权许可](https://www.ultralytics.com/license)与我们联系。
265
+
266
+ ## 📞 联系方式
267
+
268
+ 有关 Ultralytics 软件的错误报告和功能请求,请访问 [GitHub Issues](https://github.com/ultralytics/ultralytics/issues)。如有疑问、讨论和社区支持,请加入我们在 [Discord](https://discord.com/invite/ultralytics)、[Reddit](https://www.reddit.com/r/ultralytics/?rdt=44154) 和 [Ultralytics 社区论坛](https://community.ultralytics.com/)上的活跃社区。我们随时为您提供有关 Ultralytics 的所有帮助!
269
+
270
+ <br>
271
+ <div align="center">
272
+ <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>
273
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
274
+ <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>
275
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
276
+ <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>
277
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
278
+ <a href="https://www.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>
279
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
280
+ <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>
281
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
282
+ <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>
283
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
284
+ <a href="https://discord.com/invite/ultralytics"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-discord.png" width="3%" alt="Ultralytics Discord"></a>
285
+ </div>
ultralytics-main/docker/Dockerfile ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Builds ultralytics/ultralytics:latest image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics
4
+ # Image is CUDA-optimized for YOLO single/multi-GPU training and inference
5
+
6
+ # Start FROM PyTorch image https://hub.docker.com/r/pytorch/pytorch or nvcr.io/nvidia/pytorch:25.02-py3
7
+ FROM pytorch/pytorch:2.9.1-cuda12.8-cudnn9-runtime
8
+
9
+ # Set environment variables
10
+ # Avoid DDP error "MKL_THREADING_LAYER=INTEL is incompatible with libgomp.so.1 library"
11
+ # Suppress TensorFlow cuDNN, cuBLAS, and cuFFT Registration Warnings
12
+ ENV PYTHONUNBUFFERED=1 \
13
+ PYTHONDONTWRITEBYTECODE=1 \
14
+ PIP_NO_CACHE_DIR=1 \
15
+ PIP_BREAK_SYSTEM_PACKAGES=1 \
16
+ MKL_THREADING_LAYER=GNU \
17
+ OMP_NUM_THREADS=1 \
18
+ TF_CPP_MIN_LOG_LEVEL=3
19
+
20
+ # Downloads to user config dir
21
+ ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.ttf \
22
+ https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.Unicode.ttf \
23
+ /root/.config/Ultralytics/
24
+
25
+ # Install linux packages
26
+ # gnupg required for Edge TPU install
27
+ # libsm6 required by libqxcb to create QT-based windows for visualization; set 'QT_DEBUG_PLUGINS=1' to test in docker
28
+ RUN apt-get update && \
29
+ apt-get install -y --no-install-recommends \
30
+ gcc git zip unzip wget curl htop libgl1 libglib2.0-0 gnupg libsm6 && \
31
+ apt-get clean && \
32
+ rm -rf /var/lib/apt/lists/*
33
+
34
+ # Create working directory
35
+ WORKDIR /ultralytics
36
+
37
+ # Copy contents and configure git
38
+ COPY . .
39
+ RUN sed -i '/^\[http "https:\/\/github\.com\/"\]/,+1d' .git/config && \
40
+ sed -i'' -e 's/"opencv-python/"opencv-python-headless/' pyproject.toml
41
+ ADD https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11n.pt .
42
+
43
+ # Install pip packages
44
+ RUN uv pip install --system -e "." albumentations faster-coco-eval wandb && \
45
+ # Remove extra build files \
46
+ rm -rf tmp /root/.config/Ultralytics/persistent_cache.json
47
+
48
+ # Usage Examples -------------------------------------------------------------------------------------------------------
49
+
50
+ # Build and Push
51
+ # t=ultralytics/ultralytics:latest && sudo docker build -f docker/Dockerfile -t $t . && sudo docker push $t
52
+
53
+ # Pull and Run with access to all GPUs
54
+ # t=ultralytics/ultralytics:latest && sudo docker pull $t && sudo docker run -it --ipc=host --gpus all $t
55
+
56
+ # Pull and Run with access to GPUs 2 and 3 (inside container CUDA devices will appear as 0 and 1)
57
+ # t=ultralytics/ultralytics:latest && sudo docker pull $t && sudo docker run -it --ipc=host --gpus '"device=2,3"' $t
58
+
59
+ # Pull and Run with local directory access
60
+ # t=ultralytics/ultralytics:latest && sudo docker pull $t && sudo docker run -it --ipc=host --gpus all -v "$(pwd)"/shared/datasets:/datasets $t
61
+
62
+ # Kill all
63
+ # sudo docker kill $(sudo docker ps -q)
64
+
65
+ # Kill all image-based
66
+ # sudo docker kill $(sudo docker ps -qa --filter ancestor=ultralytics/ultralytics:latest)
67
+
68
+ # DockerHub tag update
69
+ # t=ultralytics/ultralytics:latest tnew=ultralytics/ultralytics:v6.2 && sudo docker pull $t && sudo docker tag $t $tnew && sudo docker push $tnew
70
+
71
+ # Clean up
72
+ # sudo docker system prune -a --volumes
73
+
74
+ # Update Ubuntu drivers
75
+ # https://www.maketecheasier.com/install-nvidia-drivers-ubuntu/
76
+
77
+ # DDP test
78
+ # python -m torch.distributed.run --nproc_per_node 2 --master_port 1 train.py --epochs 3
79
+
80
+ # GCP VM from Image
81
+ # docker.io/ultralytics/ultralytics:latest
ultralytics-main/docker/Dockerfile-arm64 ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Builds ultralytics/ultralytics:latest-arm64 image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics
4
+ # Image is aarch64-compatible for Apple M1, M2, M3, Raspberry Pi and other ARM architectures
5
+
6
+ # Start FROM Ubuntu image https://hub.docker.com/_/ubuntu with "FROM arm64v8/ubuntu:22.04" (deprecated)
7
+ # Start FROM Debian image for arm64v8 https://hub.docker.com/r/arm64v8/debian (deprecated)
8
+ # Start FROM official arm64v8 Ubuntu 24.04 image https://hub.docker.com/layers/arm64v8/ubuntu/24.04/
9
+ FROM arm64v8/ubuntu:24.04
10
+
11
+ # Set environment variables
12
+ ENV PYTHONUNBUFFERED=1 \
13
+ PYTHONDONTWRITEBYTECODE=1 \
14
+ PIP_NO_CACHE_DIR=1 \
15
+ PIP_BREAK_SYSTEM_PACKAGES=1
16
+
17
+ # Downloads to user config dir
18
+ ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.ttf \
19
+ https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.Unicode.ttf \
20
+ /root/.config/Ultralytics/
21
+
22
+ # Install linux packages
23
+ # pkg-config and libhdf5-dev (not included) are needed to build 'h5py==3.11.0' aarch64 wheel required by 'tensorflow'
24
+ # gnupg required for Edge TPU install
25
+ RUN apt update && \
26
+ apt upgrade -y && \
27
+ apt install -y --no-install-recommends \
28
+ python3-pip git zip unzip wget curl htop gcc libgl1 libglib2.0-0 gnupg && \
29
+ apt clean && \
30
+ rm -rf /var/lib/apt/lists/*
31
+
32
+ # Create working directory
33
+ WORKDIR /ultralytics
34
+
35
+ # Copy contents and configure git
36
+ COPY . .
37
+ RUN sed -i '/^\[http "https:\/\/github\.com\/"\]/,+1d' .git/config && \
38
+ sed -i'' -e 's/"opencv-python/"opencv-python-headless/' pyproject.toml
39
+ ADD https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11n.pt .
40
+
41
+ # Install pip packages, create python symlink, and remove build files
42
+ RUN pip install uv && \
43
+ uv pip install --system -e ".[export]" --break-system-packages && \
44
+ # Creates a symbolic link to make 'python' point to 'python3'
45
+ ln -sf /usr/bin/python3 /usr/bin/python && \
46
+ # Remove extra build files
47
+ rm -rf /root/.config/Ultralytics/persistent_cache.json
48
+
49
+ # Usage Examples -------------------------------------------------------------------------------------------------------
50
+
51
+ # Build and Push
52
+ # t=ultralytics/ultralytics:latest-arm64 && sudo docker build --platform linux/arm64 -f docker/Dockerfile-arm64 -t $t . && sudo docker push $t
53
+
54
+ # Run
55
+ # t=ultralytics/ultralytics:latest-arm64 && sudo docker run -it --ipc=host $t
56
+
57
+ # Pull and Run
58
+ # t=ultralytics/ultralytics:latest-arm64 && sudo docker pull $t && sudo docker run -it --ipc=host $t
59
+
60
+ # Pull and Run with local volume mounted
61
+ # t=ultralytics/ultralytics:latest-arm64 && sudo docker pull $t && sudo docker run -it --ipc=host -v "$(pwd)"/shared/datasets:/datasets $t
ultralytics-main/docker/Dockerfile-conda ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Builds ultralytics/ultralytics:latest-conda image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics
4
+ # Image is optimized for Ultralytics Anaconda (https://anaconda.org/conda-forge/ultralytics) installation and usage
5
+
6
+ # Start FROM miniconda3 image https://hub.docker.com/r/continuumio/miniconda3
7
+ FROM continuumio/miniconda3:latest
8
+
9
+ # Set environment variables
10
+ ENV PYTHONUNBUFFERED=1 \
11
+ PYTHONDONTWRITEBYTECODE=1 \
12
+ PIP_NO_CACHE_DIR=1 \
13
+ PIP_BREAK_SYSTEM_PACKAGES=1
14
+
15
+ # Downloads to user config dir
16
+ ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.ttf \
17
+ https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.Unicode.ttf \
18
+ /root/.config/Ultralytics/
19
+
20
+ # Install linux packages and conda packages
21
+ RUN apt-get update && \
22
+ apt-get install -y --no-install-recommends libgl1 && \
23
+ # Install conda packages
24
+ # mkl required to fix 'OSError: libmkl_intel_lp64.so.2: cannot open shared object file: No such file or directory'
25
+ conda config --set solver libmamba && \
26
+ conda install pytorch torchvision pytorch-cuda=12.1 -c pytorch -c nvidia && \
27
+ conda install -c conda-forge ultralytics mkl && \
28
+ # Remove extra build files
29
+ rm -rf /var/lib/apt/lists/* /root/.config/Ultralytics/persistent_cache.json
30
+
31
+ # Copy model
32
+ ADD https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11n.pt .
33
+
34
+ # Usage Examples -------------------------------------------------------------------------------------------------------
35
+
36
+ # Build and Push
37
+ # t=ultralytics/ultralytics:latest-conda && sudo docker build -f docker/Dockerfile-conda -t $t . && sudo docker push $t
38
+
39
+ # Run
40
+ # t=ultralytics/ultralytics:latest-conda && sudo docker run -it --ipc=host $t
41
+
42
+ # Pull and Run
43
+ # t=ultralytics/ultralytics:latest-conda && sudo docker pull $t && sudo docker run -it --ipc=host $t
44
+
45
+ # Pull and Run with local volume mounted
46
+ # t=ultralytics/ultralytics:latest-conda && sudo docker pull $t && sudo docker run -it --ipc=host -v "$(pwd)"/shared/datasets:/datasets $t
ultralytics-main/docker/Dockerfile-cpu ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Builds ultralytics/ultralytics:latest-cpu image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics
4
+ # Lightweight CPU image optimized for inference (extends latest-python)
5
+
6
+ # Build from Ultralytics Python image
7
+ FROM ultralytics/ultralytics:latest-python
8
+
9
+ # Set default command to bash
10
+ CMD ["/bin/bash"]
11
+
12
+ # Usage Examples -------------------------------------------------------------------------------------------------------
13
+
14
+ # Build and Push
15
+ # t=ultralytics/ultralytics:latest-cpu && sudo docker build -f docker/Dockerfile-cpu -t $t . && sudo docker push $t
16
+
17
+ # Run
18
+ # t=ultralytics/ultralytics:latest-cpu && sudo docker run -it --ipc=host --name NAME $t
19
+
20
+ # Pull and Run
21
+ # t=ultralytics/ultralytics:latest-cpu && sudo docker pull $t && sudo docker run -it --ipc=host --name NAME $t
22
+
23
+ # Pull and Run with local volume mounted
24
+ # t=ultralytics/ultralytics:latest-cpu && sudo docker pull $t && sudo docker run -it --ipc=host -v "$(pwd)"/shared/datasets:/datasets $t
ultralytics-main/docker/Dockerfile-export ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Export-optimized derivative of ultralytics/ultralytics:latest for testing and benchmarks
4
+ # Includes all export format dependencies and pre-installed export packages
5
+
6
+ FROM ultralytics/ultralytics:latest
7
+
8
+ # Install export dependencies and run exports to AutoInstall packages
9
+ # Numpy 1.26.4 required due to TF export bug with torch 2.8
10
+ # Note tensorrt installed on-demand as depends on runtime environment CUDA version
11
+ RUN uv pip install --system -e ".[export]" "onnxruntime-gpu" paddlepaddle x2paddle numpy==1.26.4 && \
12
+ # Run exports to AutoInstall packages \
13
+ yolo export model=tmp/yolo11n.pt format=edgetpu imgsz=32 && \
14
+ yolo export model=tmp/yolo11n.pt format=ncnn imgsz=32 && \
15
+ # Remove temporary files \
16
+ rm -rf tmp /root/.config/Ultralytics/persistent_cache.json
ultralytics-main/docker/Dockerfile-jetson-jetpack4 ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Builds ultralytics/ultralytics:latest-jetson-jetpack4 image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics
4
+ # Supports JetPack4.x for YOLO on Jetson Nano, TX2, Xavier NX, AGX Xavier
5
+
6
+ # Start FROM https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-cuda
7
+ FROM nvcr.io/nvidia/l4t-cuda:10.2.460-runtime
8
+
9
+ # Set environment variables
10
+ ENV PYTHONUNBUFFERED=1 \
11
+ PYTHONDONTWRITEBYTECODE=1
12
+
13
+ # Downloads to user config dir
14
+ ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.ttf \
15
+ https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.Unicode.ttf \
16
+ /root/.config/Ultralytics/
17
+
18
+ # Add NVIDIA repositories for TensorRT dependencies
19
+ RUN wget -q -O - https://repo.download.nvidia.com/jetson/jetson-ota-public.asc | apt-key add - && \
20
+ echo "deb https://repo.download.nvidia.com/jetson/common r32.7 main" > /etc/apt/sources.list.d/nvidia-l4t-apt-source.list && \
21
+ echo "deb https://repo.download.nvidia.com/jetson/t194 r32.7 main" >> /etc/apt/sources.list.d/nvidia-l4t-apt-source.list
22
+
23
+ # Install dependencies
24
+ # pkg-config and libhdf5-dev (not included) are needed to build 'h5py==3.11.0' aarch64 wheel required by 'tensorflow'
25
+ # gnupg required for Edge TPU install
26
+ RUN apt-get update && \
27
+ apt-get install -y --no-install-recommends \
28
+ git python3.8 python3.8-dev python3-pip python3-libnvinfer libopenmpi-dev libopenblas-base libomp-dev gcc \
29
+ && rm -rf /var/lib/apt/lists/*
30
+
31
+ # Create symbolic links for python3.8 and pip3
32
+ RUN ln -sf /usr/bin/python3.8 /usr/bin/python3 && \
33
+ ln -s /usr/bin/pip3 /usr/bin/pip
34
+
35
+ # Create working directory
36
+ WORKDIR /ultralytics
37
+
38
+ # Copy contents and configure git
39
+ COPY . .
40
+ RUN sed -i '/^\[http "https:\/\/github\.com\/"\]/,+1d' .git/config && \
41
+ sed -i'' -e 's/"opencv-python/"opencv-python-headless/' pyproject.toml
42
+ ADD https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11n.pt .
43
+
44
+ # Replace pyproject.toml TF.js version with 'tensorflowjs>=3.9.0' for JetPack4 compatibility
45
+ RUN sed -i 's/^\( *"tensorflowjs\)>=.*\(".*\)/\1>=3.9.0\2/' pyproject.toml
46
+
47
+ # Install pip packages (pip must be upgraded first before installing uv due to missing setuptools)
48
+ RUN python3 -m pip install --upgrade pip && \
49
+ python3 -m pip install uv
50
+ # Install pip packages and remove extra build files
51
+ # Onnxruntime and TensorRT from https://elinux.org/Jetson_Zoo and https://forums.developer.nvidia.com/t/pytorch-for-jetson/72048
52
+ RUN uv pip install --system \
53
+ https://github.com/ultralytics/assets/releases/download/v0.0.0/onnxruntime_gpu-1.8.0-cp38-cp38-linux_aarch64.whl \
54
+ https://github.com/ultralytics/assets/releases/download/v0.0.0/tensorrt-8.2.0.6-cp38-none-linux_aarch64.whl \
55
+ https://github.com/ultralytics/assets/releases/download/v0.0.0/torch-1.11.0a0+gitbc2c6ed-cp38-cp38-linux_aarch64.whl \
56
+ https://github.com/ultralytics/assets/releases/download/v0.0.0/torchvision-0.12.0a0+9b5a3fe-cp38-cp38-linux_aarch64.whl && \
57
+ uv pip install --system -e ".[export]" && \
58
+ # Remove extra build files
59
+ rm -rf *.whl /root/.config/Ultralytics/persistent_cache.json
60
+
61
+ # Usage Examples -------------------------------------------------------------------------------------------------------
62
+
63
+ # Build and Push
64
+ # t=ultralytics/ultralytics:latest-jetson-jetpack4 && sudo docker build --platform linux/arm64 -f docker/Dockerfile-jetson-jetpack4 -t $t . && sudo docker push $t
65
+
66
+ # Run
67
+ # t=ultralytics/ultralytics:latest-jetson-jetpack4 && sudo docker run -it --ipc=host $t
68
+
69
+ # Pull and Run
70
+ # t=ultralytics/ultralytics:latest-jetson-jetpack4 && sudo docker pull $t && sudo docker run -it --ipc=host $t
71
+
72
+ # Pull and Run with NVIDIA runtime
73
+ # t=ultralytics/ultralytics:latest-jetson-jetpack4 && sudo docker pull $t && sudo docker run -it --ipc=host --runtime=nvidia $t
ultralytics-main/docker/Dockerfile-jetson-jetpack5 ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Builds ultralytics/ultralytics:latest-jetson-jetpack5 image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics
4
+ # Supports JetPack5.1.2 for YOLO on Jetson Xavier NX, AGX Xavier, AGX Orin, Orin Nano and Orin NX
5
+
6
+ # Start FROM https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-jetpack
7
+ FROM nvcr.io/nvidia/l4t-jetpack:r35.4.1
8
+
9
+ # Set environment variables
10
+ ENV PYTHONUNBUFFERED=1 \
11
+ PYTHONDONTWRITEBYTECODE=1 \
12
+ PIP_NO_CACHE_DIR=1 \
13
+ PIP_BREAK_SYSTEM_PACKAGES=1
14
+
15
+ # Downloads to user config dir
16
+ ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.ttf \
17
+ https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.Unicode.ttf \
18
+ /root/.config/Ultralytics/
19
+
20
+ # Install dependencies
21
+ RUN apt-get update && \
22
+ apt-get install -y --no-install-recommends \
23
+ git python3-pip libopenmpi-dev libopenblas-base libomp-dev \
24
+ && rm -rf /var/lib/apt/lists/*
25
+
26
+ # Create working directory
27
+ WORKDIR /ultralytics
28
+
29
+ # Copy contents and configure git
30
+ COPY . .
31
+ RUN sed -i '/^\[http "https:\/\/github\.com\/"\]/,+1d' .git/config && \
32
+ sed -i'' -e 's/"opencv-python/"opencv-python-headless/' pyproject.toml
33
+ ADD https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11n.pt .
34
+
35
+ # Replace pyproject.toml TF.js version with 'tensorflowjs>=3.9.0' for JetPack5 compatibility and install packages
36
+ RUN sed -i 's/^\( *"tensorflowjs\)>=.*\(".*\)/\1>=3.9.0\2/' pyproject.toml && \
37
+ python3 -m pip install --upgrade pip uv
38
+
39
+ # Pip install onnxruntime-gpu, torch, torchvision and ultralytics, then remove build files
40
+ RUN uv pip install --system \
41
+ https://github.com/ultralytics/assets/releases/download/v0.0.0/onnxruntime_gpu-1.18.0-cp38-cp38-linux_aarch64.whl \
42
+ https://github.com/ultralytics/assets/releases/download/v0.0.0/torch-2.2.0-cp38-cp38-linux_aarch64.whl \
43
+ https://github.com/ultralytics/assets/releases/download/v0.0.0/torchvision-0.17.2+c1d70fe-cp38-cp38-linux_aarch64.whl && \
44
+ uv pip install --system -e ".[export]" && \
45
+ # Remove extra build files
46
+ rm -rf *.whl /root/.config/Ultralytics/persistent_cache.json
47
+
48
+ # Usage Examples -------------------------------------------------------------------------------------------------------
49
+
50
+ # Build and Push
51
+ # t=ultralytics/ultralytics:latest-jetson-jetpack5 && sudo docker build --platform linux/arm64 -f docker/Dockerfile-jetson-jetpack5 -t $t . && sudo docker push $t
52
+
53
+ # Run
54
+ # t=ultralytics/ultralytics:latest-jetson-jetpack5 && sudo docker run -it --ipc=host $t
55
+
56
+ # Pull and Run
57
+ # t=ultralytics/ultralytics:latest-jetson-jetpack5 && sudo docker pull $t && sudo docker run -it --ipc=host $t
58
+
59
+ # Pull and Run with NVIDIA runtime
60
+ # t=ultralytics/ultralytics:latest-jetson-jetpack5 && sudo docker pull $t && sudo docker run -it --ipc=host --runtime=nvidia $t
ultralytics-main/docker/Dockerfile-jetson-jetpack6 ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Builds ultralytics/ultralytics:latest-jetson-jetpack6 image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics
4
+ # Supports JetPack6.1 for YOLO on Jetson AGX Orin, Orin NX and Orin Nano Series
5
+
6
+ # Start FROM https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-jetpack
7
+ FROM nvcr.io/nvidia/l4t-jetpack:r36.4.0
8
+
9
+ # Set environment variables
10
+ ENV PYTHONUNBUFFERED=1 \
11
+ PYTHONDONTWRITEBYTECODE=1 \
12
+ PIP_NO_CACHE_DIR=1 \
13
+ PIP_BREAK_SYSTEM_PACKAGES=1
14
+
15
+ # Downloads to user config dir
16
+ ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.ttf \
17
+ https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.Unicode.ttf \
18
+ /root/.config/Ultralytics/
19
+
20
+ # Install dependencies and cleanup
21
+ ADD https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/arm64/cuda-keyring_1.1-1_all.deb .
22
+ RUN dpkg -i cuda-keyring_1.1-1_all.deb && \
23
+ apt-get update && \
24
+ apt-get install -y --no-install-recommends \
25
+ git python3-pip libopenmpi-dev libopenblas-base libomp-dev libcusparselt0 libcusparselt-dev && \
26
+ rm -rf /var/lib/apt/lists/* cuda-keyring_1.1-1_all.deb
27
+
28
+ # Create working directory
29
+ WORKDIR /ultralytics
30
+
31
+ # Copy contents and configure git
32
+ COPY . .
33
+ RUN sed -i '/^\[http "https:\/\/github\.com\/"\]/,+1d' .git/config && \
34
+ sed -i'' -e 's/"opencv-python/"opencv-python-headless/' pyproject.toml
35
+ ADD https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11n.pt .
36
+
37
+ # Pip install numpy, onnxruntime-gpu, torch, torchvision and ultralytics, then remove build files
38
+ RUN python3 -m pip install --upgrade pip uv && \
39
+ uv pip install --system \
40
+ numpy==1.26.4 \
41
+ https://github.com/ultralytics/assets/releases/download/v0.0.0/onnxruntime_gpu-1.20.0-cp310-cp310-linux_aarch64.whl \
42
+ https://github.com/ultralytics/assets/releases/download/v0.0.0/torch-2.5.0a0+872d972e41.nv24.08-cp310-cp310-linux_aarch64.whl \
43
+ https://github.com/ultralytics/assets/releases/download/v0.0.0/torchvision-0.20.0a0+afc54f7-cp310-cp310-linux_aarch64.whl && \
44
+ uv pip install --system -e ".[export]" && \
45
+ # Remove extra build files
46
+ rm -rf *.whl /root/.config/Ultralytics/persistent_cache.json
47
+
48
+ # Usage Examples -------------------------------------------------------------------------------------------------------
49
+
50
+ # Build and Push
51
+ # t=ultralytics/ultralytics:latest-jetson-jetpack6 && sudo docker build --platform linux/arm64 -f docker/Dockerfile-jetson-jetpack6 -t $t . && sudo docker push $t
52
+
53
+ # Run
54
+ # t=ultralytics/ultralytics:latest-jetson-jetpack6 && sudo docker run -it --ipc=host $t
55
+
56
+ # Pull and Run
57
+ # t=ultralytics/ultralytics:latest-jetson-jetpack6 && sudo docker pull $t && sudo docker run -it --ipc=host $t
58
+
59
+ # Pull and Run with NVIDIA runtime
60
+ # t=ultralytics/ultralytics:latest-jetson-jetpack6 && sudo docker pull $t && sudo docker run -it --ipc=host --runtime=nvidia $t
ultralytics-main/docker/Dockerfile-jupyter ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Builds ultralytics/ultralytics:latest-jupyter image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics
4
+ # Image provides JupyterLab interface for interactive YOLO development and includes tutorial notebooks
5
+
6
+ # Start from Python-based Ultralytics image for full Python environment
7
+ FROM ultralytics/ultralytics:latest-python
8
+
9
+ # Install JupyterLab for interactive development
10
+ RUN uv pip install --system jupyterlab && \
11
+ # Create persistent data directory structure
12
+ mkdir -p /data/{datasets,weights,runs} && \
13
+ # Configure YOLO directories
14
+ yolo settings datasets_dir="/data/datasets" weights_dir="/data/weights" runs_dir="/data/runs" && \
15
+ rm -rf tmp /root/.config/Ultralytics/persistent_cache.json
16
+
17
+ # Start JupyterLab with tutorial notebook
18
+ ENTRYPOINT ["/usr/local/bin/jupyter", "lab", "--allow-root", "--ip=*", "/ultralytics/examples/tutorial.ipynb"]
19
+
20
+ # Usage Examples -------------------------------------------------------------------------------------------------------
21
+
22
+ # Build and Push
23
+ # t=ultralytics/ultralytics:latest-jupyter && sudo docker build -f docker/Dockerfile-jupyter -t $t . && sudo docker push $t
24
+
25
+ # Run
26
+ # t=ultralytics/ultralytics:latest-jupyter && sudo docker run -it --ipc=host -p 8888:8888 $t
27
+
28
+ # Pull and Run
29
+ # t=ultralytics/ultralytics:latest-jupyter && sudo docker pull $t && sudo docker run -it --ipc=host -p 8888:8888 $t
30
+
31
+ # Pull and Run with local volume mounted
32
+ # t=ultralytics/ultralytics:latest-jupyter && sudo docker pull $t && sudo docker run -it --ipc=host -p 8888:8888 -v "$(pwd)"/datasets:/data/datasets $t
ultralytics-main/docker/Dockerfile-python ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Builds ultralytics/ultralytics:latest-python image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics
4
+ # Lightweight CPU image optimized for YOLO inference
5
+
6
+ # Use official Python base image for reproducibility (3.11.10 for export and 3.12.10 for inference)
7
+ FROM python:3.11.10-slim-bookworm
8
+
9
+ # Set environment variables
10
+ ENV PYTHONUNBUFFERED=1 \
11
+ PYTHONDONTWRITEBYTECODE=1 \
12
+ PIP_NO_CACHE_DIR=1 \
13
+ PIP_BREAK_SYSTEM_PACKAGES=1
14
+
15
+ # Downloads to user config dir
16
+ ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.ttf \
17
+ https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.Unicode.ttf \
18
+ /root/.config/Ultralytics/
19
+
20
+ # Install linux packages
21
+ RUN apt-get update && \
22
+ apt-get install -y --no-install-recommends \
23
+ python3-pip git zip unzip wget curl htop libgl1 libglib2.0-0 && \
24
+ apt-get clean && \
25
+ rm -rf /var/lib/apt/lists/*
26
+
27
+ # Create working directory
28
+ WORKDIR /ultralytics
29
+
30
+ # Copy contents and configure git
31
+ COPY . .
32
+ RUN sed -i '/^\[http "https:\/\/github\.com\/"\]/,+1d' .git/config && \
33
+ sed -i'' -e 's/"opencv-python/"opencv-python-headless/' pyproject.toml
34
+ ADD https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11n.pt .
35
+
36
+ # Install pip packages
37
+ RUN pip install uv && \
38
+ uv pip install --system -e . --extra-index-url https://download.pytorch.org/whl/cpu --index-strategy unsafe-best-match && \
39
+ # Remove extra build files
40
+ rm -rf tmp ~/.cache /root/.config/Ultralytics/persistent_cache.json
41
+
42
+ # Usage Examples -------------------------------------------------------------------------------------------------------
43
+
44
+ # Build and Push
45
+ # t=ultralytics/ultralytics:latest-python && sudo docker build -f docker/Dockerfile-python -t $t . && sudo docker push $t
46
+
47
+ # Run
48
+ # t=ultralytics/ultralytics:latest-python && sudo docker run -it --ipc=host $t
49
+
50
+ # Pull and Run
51
+ # t=ultralytics/ultralytics:latest-python && sudo docker pull $t && sudo docker run -it --ipc=host $t
52
+
53
+ # Pull and Run with local volume mounted
54
+ # t=ultralytics/ultralytics:latest-python && sudo docker pull $t && sudo docker run -it --ipc=host -v "$(pwd)"/shared/datasets:/datasets $t
ultralytics-main/docker/Dockerfile-python-export ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Builds ultralytics/ultralytics:latest-python-export image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics
4
+ # Full-featured image with export capabilities for YOLO model conversion
5
+
6
+ # Build from lightweight Ultralytics Python image
7
+ FROM ultralytics/ultralytics:latest-python
8
+
9
+ # Install export-specific system packages
10
+ # gnupg required for Edge TPU install
11
+ # Java runtime environment (default-jre-headless) required for Sony IMX export
12
+ RUN apt-get update && \
13
+ apt-get install -y --no-install-recommends gnupg default-jre-headless && \
14
+ apt-get clean && \
15
+ rm -rf /var/lib/apt/lists/*
16
+
17
+ # Install export dependencies and run exports to AutoInstall packages
18
+ # Prevent torch upgrade to 2.9.0 which has issues with imx export
19
+ RUN sed -i -e 's/"torch>=1.8.0/"torch>=1.8.0,<=2.8.0/' pyproject.toml
20
+ RUN uv pip install --system -e ".[export]" && \
21
+ # Need lower version of 'numpy' for Sony IMX export
22
+ uv pip install --system numpy==1.26.4 && \
23
+ # Run exports to AutoInstall packages
24
+ yolo export model=tmp/yolo11n.pt format=edgetpu imgsz=32 && \
25
+ yolo export model=tmp/yolo11n.pt format=ncnn imgsz=32 && \
26
+ yolo export model=tmp/yolo11n.pt format=imx imgsz=32 && \
27
+ uv pip install --system paddlepaddle x2paddle && \
28
+ # Remove extra build files
29
+ rm -rf tmp /root/.config/Ultralytics/persistent_cache.json
30
+
31
+ # Usage Examples -------------------------------------------------------------------------------------------------------
32
+
33
+ # Build and Push
34
+ # t=ultralytics/ultralytics:latest-python-export && sudo docker build -f docker/Dockerfile-python-export -t $t . && sudo docker push $t
35
+
36
+ # Run
37
+ # t=ultralytics/ultralytics:latest-python-export && sudo docker run -it --ipc=host $t
38
+
39
+ # Pull and Run
40
+ # t=ultralytics/ultralytics:latest-python-export && sudo docker pull $t && sudo docker run -it --ipc=host $t
41
+
42
+ # Pull and Run with local volume mounted
43
+ # t=ultralytics/ultralytics:latest-python-export && sudo docker pull $t && sudo docker run -it --ipc=host -v "$(pwd)"/shared/datasets:/datasets $t
ultralytics-main/docker/Dockerfile-runner ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Builds GitHub actions CI runner image for deployment to DockerHub https://hub.docker.com/r/ultralytics/ultralytics
4
+ # Image is CUDA-optimized for YOLO single/multi-GPU training and inference tests
5
+
6
+ # Start FROM Ultralytics GPU image
7
+ FROM ultralytics/ultralytics:latest
8
+
9
+ # Set additional environment variables for runner
10
+ ARG RUNNER_VERSION=2.329.0
11
+ ENV RUNNER_ALLOW_RUNASROOT=1 \
12
+ DEBIAN_FRONTEND=noninteractive
13
+
14
+ # Set the working directory
15
+ WORKDIR /actions-runner
16
+
17
+ # Download and unpack the latest runner from https://github.com/actions/runner and install dependencies
18
+ RUN FILENAME=actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz && \
19
+ curl -o "$FILENAME" -L "https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/${FILENAME}" && \
20
+ tar xzf "$FILENAME" && \
21
+ rm "$FILENAME" && \
22
+ # Install runner dependencies \
23
+ uv pip install --system pytest-cov && \
24
+ ./bin/installdependencies.sh && \
25
+ apt-get -y install libicu-dev
26
+
27
+ # JSON ENTRYPOINT command to configure and start runner with default TOKEN and NAME
28
+ ENTRYPOINT ["sh", "-c", "./config.sh --url https://github.com/ultralytics/ultralytics --token ${GITHUB_RUNNER_TOKEN:-TOKEN} --name ${GITHUB_RUNNER_NAME:-NAME} --labels gpu-latest --replace && ./run.sh"]
29
+
30
+ # Usage Examples -------------------------------------------------------------------------------------------------------
31
+
32
+ # Build and Push
33
+ # t=ultralytics/ultralytics:latest-runner && sudo docker build -f docker/Dockerfile-runner -t $t . && sudo docker push $t
34
+
35
+ # Pull and Run in detached mode with access to GPUs 0 and 1
36
+ # t=ultralytics/ultralytics:latest-runner && sudo docker run -d -e GITHUB_RUNNER_TOKEN=TOKEN -e GITHUB_RUNNER_NAME=NAME --ipc=host --gpus '"device=0,1"' $t
ultralytics-main/docs/README.md ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <a href="https://www.ultralytics.com/" target="_blank"><img src="https://raw.githubusercontent.com/ultralytics/assets/main/logo/Ultralytics_Logotype_Original.svg" width="320" alt="Ultralytics logo"></a>
2
+
3
+ # 📚 Ultralytics Docs
4
+
5
+ Welcome to Ultralytics Docs, your comprehensive resource for understanding and utilizing our state-of-the-art [machine learning](https://www.ultralytics.com/glossary/machine-learning-ml) tools and models, including [Ultralytics YOLO](https://docs.ultralytics.com/models/yolo11/). These documents are actively maintained and deployed to [https://docs.ultralytics.com](https://docs.ultralytics.com/) for easy access.
6
+
7
+ [![pages-build-deployment](https://github.com/ultralytics/docs/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/ultralytics/docs/actions/workflows/pages/pages-build-deployment)
8
+ [![Check Broken links](https://github.com/ultralytics/docs/actions/workflows/links.yml/badge.svg)](https://github.com/ultralytics/docs/actions/workflows/links.yml)
9
+ [![Check Domains](https://github.com/ultralytics/docs/actions/workflows/check_domains.yml/badge.svg)](https://github.com/ultralytics/docs/actions/workflows/check_domains.yml)
10
+ [![Ultralytics Actions](https://github.com/ultralytics/docs/actions/workflows/format.yml/badge.svg)](https://github.com/ultralytics/docs/actions/workflows/format.yml)
11
+
12
+ <a href="https://discord.com/invite/ultralytics"><img alt="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://www.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>
13
+
14
+ ## 🛠️ Installation
15
+
16
+ [![PyPI - Version](https://img.shields.io/pypi/v/ultralytics?logo=pypi&logoColor=white)](https://pypi.org/project/ultralytics/)
17
+ [![Downloads](https://static.pepy.tech/badge/ultralytics)](https://clickpy.clickhouse.com/dashboard/ultralytics)
18
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ultralytics?logo=python&logoColor=gold)](https://pypi.org/project/ultralytics/)
19
+
20
+ To install the `ultralytics` package in developer mode, which allows you to modify the source code directly, ensure you have [Git](https://git-scm.com/) and [Python](https://www.python.org/) 3.8 or later installed on your system. Then, follow these steps:
21
+
22
+ 1. Clone the `ultralytics` repository to your local machine using Git:
23
+
24
+ ```bash
25
+ git clone https://github.com/ultralytics/ultralytics.git
26
+ ```
27
+
28
+ 2. Navigate to the cloned repository's root directory:
29
+
30
+ ```bash
31
+ cd ultralytics
32
+ ```
33
+
34
+ 3. Install the package in editable mode (`-e`) along with its development dependencies (`[dev]`) using [pip](https://pip.pypa.io/en/stable/):
35
+
36
+ ```bash
37
+ pip install -e '.[dev]'
38
+ ```
39
+
40
+ This command installs the `ultralytics` package such that changes to the source code are immediately reflected in your environment, ideal for development.
41
+
42
+ ## 🚀 Building and Serving Locally
43
+
44
+ The `mkdocs serve` command builds and serves a local version of your [MkDocs](https://www.mkdocs.org/) documentation. This is highly useful during development and testing to preview changes.
45
+
46
+ ```bash
47
+ mkdocs serve
48
+ ```
49
+
50
+ - **Command Breakdown:**
51
+ - `mkdocs`: The main MkDocs command-line interface tool.
52
+ - `serve`: The subcommand used to build and locally serve your documentation site.
53
+ - **Note:**
54
+ - `mkdocs serve` includes live reloading, automatically updating the preview in your browser as you save changes to the documentation files.
55
+ - To stop the local server, simply press `CTRL+C` in your terminal.
56
+
57
+ ## 🌍 Building and Serving Multi-Language
58
+
59
+ If your documentation supports multiple languages, follow these steps to build and preview all versions:
60
+
61
+ 1. Stage all new or modified language Markdown (`.md`) files using Git:
62
+
63
+ ```bash
64
+ git add docs/**/*.md -f
65
+ ```
66
+
67
+ 2. Build all language versions into the `/site` directory. This script ensures that relevant root-level files are included and clears the previous build:
68
+
69
+ ```bash
70
+ # Clear existing /site directory to prevent conflicts
71
+ rm -rf site
72
+
73
+ # Build the default language site using the primary config file
74
+ mkdocs build -f docs/mkdocs.yml
75
+
76
+ # Loop through each language-specific config file and build its site
77
+ for file in docs/mkdocs_*.yml; do
78
+ echo "Building MkDocs site with $file"
79
+ mkdocs build -f "$file"
80
+ done
81
+ ```
82
+
83
+ 3. To preview the complete multi-language site locally, navigate into the build output directory and start a simple [Python HTTP server](https://docs.python.org/3/library/http.server.html):
84
+ ```bash
85
+ cd site
86
+ python -m http.server
87
+ # Open http://localhost:8000 in your preferred web browser
88
+ ```
89
+ Access the live preview site at `http://localhost:8000`.
90
+
91
+ ## 📤 Deploying Your Documentation Site
92
+
93
+ To deploy your MkDocs documentation site, choose a hosting provider and configure your deployment method. Common options include [GitHub Pages](https://pages.github.com/), GitLab Pages, or other static site hosting services.
94
+
95
+ - Configure deployment settings within your `mkdocs.yml` file.
96
+ - Use your hosting provider's recommended workflow (for example running `mkdocs build` in CI or `mkdocs gh-deploy` for GitHub Pages) to publish the generated `site/` directory.
97
+
98
+ * **GitHub Pages Deployment Example:**
99
+ If deploying to GitHub Pages, you can use the built-in command:
100
+
101
+ ```bash
102
+ mkdocs gh-deploy
103
+ ```
104
+
105
+ After deployment, you might need to update the "Custom domain" settings in your repository's settings page if you wish to use a personalized URL.
106
+
107
+ ![GitHub Pages Custom Domain Setting](https://github.com/ultralytics/docs/releases/download/0/github-pages-custom-domain-setting.avif)
108
+
109
+ - For detailed instructions on various deployment methods, consult the official [MkDocs Deploying your docs guide](https://www.mkdocs.org/user-guide/deploying-your-docs/).
110
+
111
+ ## 💡 Contribute
112
+
113
+ We deeply value contributions from the open-source community to enhance Ultralytics projects. Your input helps drive innovation! Please review our [Contributing Guide](https://docs.ultralytics.com/help/contributing/) for detailed information on how to get involved. You can also share your feedback and ideas through our [Survey](https://www.ultralytics.com/survey?utm_source=github&utm_medium=social&utm_campaign=Survey). A heartfelt thank you 🙏 to all our contributors for their dedication and support!
114
+
115
+ ![Ultralytics open-source contributors](https://raw.githubusercontent.com/ultralytics/assets/main/im/image-contributors.png)
116
+
117
+ We look forward to your contributions!
118
+
119
+ ## 📜 License
120
+
121
+ Ultralytics Docs are available under two licensing options to accommodate different usage scenarios:
122
+
123
+ - **AGPL-3.0 License**: Ideal for students, researchers, and enthusiasts involved in academic pursuits and open collaboration. See the [LICENSE](https://github.com/ultralytics/docs/blob/main/LICENSE) file for full details. This license promotes sharing improvements back with the community.
124
+ - **Enterprise License**: Designed for commercial applications, this license allows seamless integration of Ultralytics software and [AI models](https://docs.ultralytics.com/models/) into commercial products and services. Visit [Ultralytics Licensing](https://www.ultralytics.com/license) for more information on obtaining an Enterprise License.
125
+
126
+ ## ✉️ Contact
127
+
128
+ For bug reports, feature requests, and other issues related to the documentation, please use [GitHub Issues](https://github.com/ultralytics/docs/issues). For discussions, questions, and community support, join the conversation with peers and the Ultralytics team on our [Discord server](https://discord.com/invite/ultralytics)!
129
+
130
+ <br>
131
+ <div align="center">
132
+ <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>
133
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
134
+ <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>
135
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
136
+ <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>
137
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
138
+ <a href="https://www.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>
139
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
140
+ <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>
141
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
142
+ <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>
143
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
144
+ <a href="https://discord.com/invite/ultralytics"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-discord.png" width="3%" alt="Ultralytics Discord"></a>
145
+ </div>
ultralytics-main/docs/build_docs.py ADDED
@@ -0,0 +1,691 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+ """
3
+ Automates building and post-processing of MkDocs documentation, especially for multilingual projects.
4
+
5
+ This script streamlines generating localized documentation and updating HTML links for correct formatting.
6
+
7
+ Key Features:
8
+ - Automated building of MkDocs documentation: Compiles main documentation and localized versions from separate
9
+ MkDocs configuration files.
10
+ - Post-processing of generated HTML files: Updates HTML files to remove '.md' from internal links, ensuring
11
+ correct navigation in web-based documentation.
12
+
13
+ Usage:
14
+ - Run from the root directory of your MkDocs project.
15
+ - Ensure MkDocs is installed and configuration files (main and localized) are present.
16
+ - The script builds documentation using MkDocs, then scans HTML files in 'site' to update links.
17
+ - Ideal for projects with Markdown documentation served as a static website.
18
+
19
+ Note:
20
+ - Requires Python and MkDocs to be installed and configured.
21
+ """
22
+
23
+ from __future__ import annotations
24
+
25
+ import os
26
+ import re
27
+ import shutil
28
+ import subprocess
29
+ import tempfile
30
+ import time
31
+ from pathlib import Path
32
+
33
+ import yaml
34
+ from bs4 import BeautifulSoup
35
+ from minijinja import Environment, load_from_path
36
+
37
+ try:
38
+ from plugin import postprocess_site # mkdocs-ultralytics-plugin
39
+ except ImportError:
40
+ postprocess_site = None
41
+
42
+ from build_reference import build_reference_docs, build_reference_for
43
+
44
+ from ultralytics.utils import LINUX, LOGGER, MACOS
45
+ from ultralytics.utils.tqdm import TQDM
46
+
47
+ os.environ["JUPYTER_PLATFORM_DIRS"] = "1" # fix DeprecationWarning: Jupyter is migrating to use standard platformdirs
48
+ DOCS = Path(__file__).parent.resolve()
49
+ SITE = DOCS.parent / "site"
50
+ LINK_PATTERN = re.compile(r"(https?://[^\s()<>]*[^\s()<>.,:;!?\'\"])")
51
+ TITLE_PATTERN = re.compile(r"<title>(.*?)</title>", flags=re.IGNORECASE | re.DOTALL)
52
+ MD_LINK_PATTERN = re.compile(r'(["\']?)([^"\'>\s]+?)\.md(["\']?)')
53
+ DOC_KIND_LABELS = {"Class", "Function", "Method", "Property"}
54
+ DOC_KIND_COLORS = {
55
+ "Class": "#039dfc", # blue
56
+ "Method": "#ef5eff", # magenta
57
+ "Function": "#fc9803", # orange
58
+ "Property": "#02e835", # green
59
+ }
60
+
61
+
62
+ def prepare_docs_markdown(clone_repos: bool = True):
63
+ """Build docs using mkdocs."""
64
+ LOGGER.info("Removing existing build artifacts")
65
+ shutil.rmtree(SITE, ignore_errors=True)
66
+ shutil.rmtree(DOCS / "repos", ignore_errors=True)
67
+
68
+ if clone_repos:
69
+ # Get hub-sdk repo
70
+ repo = "https://github.com/ultralytics/hub-sdk"
71
+ local_dir = DOCS / "repos" / Path(repo).name
72
+ subprocess.run(
73
+ ["git", "clone", "-q", "--depth=1", "--single-branch", "-b", "main", repo, str(local_dir)], check=True
74
+ )
75
+ shutil.rmtree(DOCS / "en/hub/sdk", ignore_errors=True) # delete if exists
76
+ shutil.copytree(local_dir / "docs", DOCS / "en/hub/sdk") # for docs
77
+ LOGGER.info(f"Cloned/Updated {repo} in {local_dir}")
78
+
79
+ # Get docs repo
80
+ repo = "https://github.com/ultralytics/docs"
81
+ local_dir = DOCS / "repos" / Path(repo).name
82
+ subprocess.run(
83
+ ["git", "clone", "-q", "--depth=1", "--single-branch", "-b", "main", repo, str(local_dir)], check=True
84
+ )
85
+ shutil.rmtree(DOCS / "en/compare", ignore_errors=True) # delete if exists
86
+ shutil.copytree(local_dir / "docs/en/compare", DOCS / "en/compare") # for docs
87
+ LOGGER.info(f"Cloned/Updated {repo} in {local_dir}")
88
+
89
+ # Add frontmatter
90
+ for file in TQDM((DOCS / "en").rglob("*.md"), desc="Adding frontmatter"):
91
+ update_markdown_files(file)
92
+
93
+
94
+ def update_markdown_files(md_filepath: Path):
95
+ """Create or update a Markdown file, ensuring frontmatter is present."""
96
+ if md_filepath.exists():
97
+ content = md_filepath.read_text().strip()
98
+
99
+ # Replace apostrophes
100
+ content = content.replace("‘", "'").replace("’", "'")
101
+
102
+ # Add frontmatter if missing
103
+ if not content.strip().startswith("---\n"):
104
+ header = "---\ncomments: true\ndescription: TODO ADD DESCRIPTION\nkeywords: TODO ADD KEYWORDS\n---\n\n"
105
+ content = header + content
106
+
107
+ # Ensure MkDocs admonitions "=== " lines are preceded and followed by empty newlines
108
+ lines = content.split("\n")
109
+ new_lines = []
110
+ for i, line in enumerate(lines):
111
+ stripped_line = line.strip()
112
+ if stripped_line.startswith("=== "):
113
+ if i > 0 and new_lines[-1] != "":
114
+ new_lines.append("")
115
+ new_lines.append(line)
116
+ if i < len(lines) - 1 and lines[i + 1].strip() != "":
117
+ new_lines.append("")
118
+ else:
119
+ new_lines.append(line)
120
+ content = "\n".join(new_lines)
121
+
122
+ # Add EOF newline if missing
123
+ if not content.endswith("\n"):
124
+ content += "\n"
125
+
126
+ # Save page
127
+ md_filepath.write_text(content)
128
+ return
129
+
130
+
131
+ def update_docs_html():
132
+ """Update titles, edit links, and convert plaintext links in HTML documentation in one pass."""
133
+ from concurrent.futures import ProcessPoolExecutor
134
+
135
+ html_files = list(SITE.rglob("*.html"))
136
+ if not html_files:
137
+ LOGGER.info("Updated HTML files: 0")
138
+ return
139
+ desc = f"Updating HTML at {SITE}"
140
+ max_workers = os.cpu_count() or 1
141
+ with ProcessPoolExecutor(max_workers=max_workers) as executor:
142
+ pbar = TQDM(executor.map(_process_html_file, html_files), total=len(html_files), desc=desc)
143
+ updated = 0
144
+ for res in pbar:
145
+ updated += bool(res)
146
+ pbar.set_description(f"{desc} ({updated}/{len(html_files)} updated)")
147
+
148
+
149
+ def _process_html_file(html_file: Path) -> bool:
150
+ """Process a single HTML file; returns True if modified."""
151
+ try:
152
+ content = html_file.read_text(encoding="utf-8")
153
+ except Exception as e:
154
+ LOGGER.warning(f"Could not read {html_file}: {e}")
155
+ return False
156
+
157
+ changed = False
158
+ try:
159
+ rel_path = html_file.relative_to(SITE).as_posix()
160
+ except ValueError:
161
+ rel_path = html_file.name
162
+
163
+ # For pages sourced from external repos (hub-sdk, compare), drop edit/copy buttons to avoid wrong links
164
+ if rel_path.startswith(("hub/sdk/", "compare/")):
165
+ before = content
166
+ content = re.sub(
167
+ r'<a[^>]*class="[^"]*md-content__button[^"]*"[^>]*>.*?</a>',
168
+ "",
169
+ content,
170
+ flags=re.IGNORECASE | re.DOTALL,
171
+ )
172
+ if content != before:
173
+ changed = True
174
+
175
+ if rel_path == "404.html":
176
+ new_content = re.sub(r"<title>.*?</title>", "<title>Ultralytics Docs - Not Found</title>", content)
177
+ if new_content != content:
178
+ content, changed = new_content, True
179
+
180
+ new_content = update_docs_soup(content, html_file=html_file)
181
+ if new_content != content:
182
+ content, changed = new_content, True
183
+
184
+ new_content = _rewrite_md_links(content)
185
+ if new_content != content:
186
+ content, changed = new_content, True
187
+
188
+ if changed:
189
+ try:
190
+ html_file.write_text(content, encoding="utf-8")
191
+ return True
192
+ except Exception as e:
193
+ LOGGER.warning(f"Could not write {html_file}: {e}")
194
+ return False
195
+
196
+
197
+ def update_docs_soup(content: str, html_file: Path | None = None, max_title_length: int = 70) -> str:
198
+ """Convert plaintext links to HTML hyperlinks, truncate long meta titles, and remove code line hrefs."""
199
+ title_match = TITLE_PATTERN.search(content)
200
+ needs_title_trim = bool(
201
+ title_match and len(title_match.group(1)) > max_title_length and "-" in title_match.group(1)
202
+ )
203
+ needs_link_conversion = ("<p" in content or "<li" in content) and bool(LINK_PATTERN.search(content))
204
+ needs_codelineno_cleanup = "__codelineno-" in content
205
+ rel_path = ""
206
+ if html_file:
207
+ try:
208
+ rel_path = html_file.relative_to(SITE).as_posix()
209
+ except Exception:
210
+ rel_path = html_file.as_posix()
211
+ needs_kind_highlight = "reference" in rel_path or "reference" in content
212
+
213
+ if not (needs_title_trim or needs_link_conversion or needs_codelineno_cleanup or needs_kind_highlight):
214
+ return content
215
+
216
+ try:
217
+ soup = BeautifulSoup(content, "lxml")
218
+ except Exception:
219
+ soup = BeautifulSoup(content, "html.parser")
220
+ modified = False
221
+
222
+ # Truncate long meta title if needed
223
+ title_tag = soup.find("title") if needs_title_trim else None
224
+ if title_tag and len(title_tag.text) > max_title_length and "-" in title_tag.text:
225
+ title_tag.string = title_tag.text.rsplit("-", 1)[0].strip()
226
+ modified = True
227
+
228
+ # Find the main content area
229
+ main_content = soup.find("main") or soup.find("div", class_="md-content")
230
+ if not main_content:
231
+ return str(soup) if modified else content
232
+
233
+ # Convert plaintext links to HTML hyperlinks
234
+ if needs_link_conversion:
235
+ for paragraph in main_content.select("p, li"):
236
+ for text_node in paragraph.find_all(string=True, recursive=False):
237
+ if text_node.parent.name not in {"a", "code"}:
238
+ new_text = LINK_PATTERN.sub(r'<a href="\1">\1</a>', str(text_node))
239
+ if "<a href=" in new_text:
240
+ text_node.replace_with(BeautifulSoup(new_text, "html.parser"))
241
+ modified = True
242
+
243
+ # Remove href attributes from code line numbers in code blocks
244
+ if needs_codelineno_cleanup:
245
+ for a in soup.select('a[href^="#__codelineno-"], a[id^="__codelineno-"]'):
246
+ if a.string: # If the a tag has text (the line number)
247
+ # Check if parent is a span with class="normal"
248
+ if a.parent and a.parent.name == "span" and "normal" in a.parent.get("class", []):
249
+ del a.parent["class"]
250
+ a.replace_with(a.string) # Replace with just the text
251
+ else: # If it has no text
252
+ a.replace_with(soup.new_tag("span")) # Replace with an empty span
253
+ modified = True
254
+
255
+ def highlight_labels(nodes):
256
+ """Inject doc-kind badges into headings and nav entries."""
257
+ nonlocal modified
258
+
259
+ for node in nodes:
260
+ if not node.contents:
261
+ continue
262
+ first = node.contents[0]
263
+ if hasattr(first, "get") and "doc-kind" in (first.get("class") or []):
264
+ continue
265
+ text = first if isinstance(first, str) else getattr(first, "string", "")
266
+ if not text:
267
+ continue
268
+ stripped = str(text).strip()
269
+ if not stripped:
270
+ continue
271
+ kind = stripped.split()[0].rstrip(":")
272
+ if kind not in DOC_KIND_LABELS:
273
+ continue
274
+ span = soup.new_tag("span", attrs={"class": f"doc-kind doc-kind-{kind.lower()}"})
275
+ span.string = kind.lower()
276
+ first.replace_with(span)
277
+ tail = str(text)[len(kind) :]
278
+ tail_stripped = tail.lstrip()
279
+ if tail_stripped.startswith(kind):
280
+ tail = tail_stripped[len(kind) :]
281
+ if not tail and len(node.contents) > 0:
282
+ tail = " "
283
+ if tail:
284
+ span.insert_after(tail)
285
+ modified = True
286
+
287
+ highlight_labels(soup.select("main h1, main h2, main h3, main h4, main h5"))
288
+ highlight_labels(soup.select("nav.md-nav--secondary .md-ellipsis, nav.md-nav__list .md-ellipsis"))
289
+
290
+ if "reference" in rel_path:
291
+ for ellipsis in soup.select("nav.md-nav--secondary .md-ellipsis"):
292
+ kind = ellipsis.find(class_=lambda c: c and "doc-kind" in c.split())
293
+ text = str(kind.next_sibling).strip() if kind and kind.next_sibling else ellipsis.get_text(strip=True)
294
+ if "." not in text:
295
+ continue
296
+ ellipsis.clear()
297
+ short = text.rsplit(".", 1)[-1]
298
+ if kind:
299
+ ellipsis.append(kind)
300
+ ellipsis.append(f" {short}")
301
+ else:
302
+ ellipsis.append(short)
303
+ modified = True
304
+
305
+ if needs_kind_highlight and not modified and soup.select(".doc-kind"):
306
+ # Ensure style injection when pre-existing badges are present
307
+ modified = True
308
+
309
+ if modified:
310
+ head = soup.find("head")
311
+ if head and not soup.select("style[data-doc-kind]"):
312
+ style = soup.new_tag("style", attrs={"data-doc-kind": "true"})
313
+ style.string = (
314
+ ".doc-kind{display:inline-flex;align-items:center;gap:0.25em;padding:0.21em 0.59em;border-radius:999px;"
315
+ "font-weight:700;font-size:0.81em;letter-spacing:0.06em;text-transform:uppercase;"
316
+ "line-height:1;color:var(--doc-kind-color,#f8fafc);"
317
+ "background:var(--doc-kind-bg,rgba(255,255,255,0.12));}"
318
+ f".doc-kind-class{{--doc-kind-color:{DOC_KIND_COLORS['Class']};--doc-kind-bg:rgba(3,157,252,0.22);}}"
319
+ f".doc-kind-function{{--doc-kind-color:{DOC_KIND_COLORS['Function']};--doc-kind-bg:rgba(252,152,3,0.22);}}"
320
+ f".doc-kind-method{{--doc-kind-color:{DOC_KIND_COLORS['Method']};--doc-kind-bg:rgba(239,94,255,0.22);}}"
321
+ f".doc-kind-property{{--doc-kind-color:{DOC_KIND_COLORS['Property']};--doc-kind-bg:rgba(2,232,53,0.22);}}"
322
+ )
323
+ head.append(style)
324
+
325
+ return str(soup) if modified else content
326
+
327
+
328
+ def _rewrite_md_links(content: str) -> str:
329
+ """Replace .md references with trailing slashes in HTML content, skipping GitHub links."""
330
+ if ".md" not in content:
331
+ return content
332
+
333
+ lines = []
334
+ for line in content.split("\n"):
335
+ if "github.com" not in line:
336
+ line = line.replace("index.md", "")
337
+ line = MD_LINK_PATTERN.sub(r"\1\2/\3", line)
338
+ lines.append(line)
339
+ return "\n".join(lines)
340
+
341
+
342
+ # Precompiled regex patterns for minification
343
+ HTML_COMMENT = re.compile(r"<!--[\s\S]*?-->")
344
+ HTML_PRESERVE = re.compile(r"<(pre|code|textarea|script)[^>]*>[\s\S]*?</\1>", re.IGNORECASE)
345
+ HTML_TAG_SPACE = re.compile(r">\s+<")
346
+ HTML_MULTI_SPACE = re.compile(r"\s{2,}")
347
+ HTML_EMPTY_LINE = re.compile(r"^\s*$\n", re.MULTILINE)
348
+ CSS_COMMENT = re.compile(r"/\*[\s\S]*?\*/")
349
+
350
+
351
+ def remove_comments_and_empty_lines(content: str, file_type: str) -> str:
352
+ """Remove comments and empty lines from a string of code, preserving newlines and URLs.
353
+
354
+ Args:
355
+ content (str): Code content to process.
356
+ file_type (str): Type of file ('html', 'css', or 'js').
357
+
358
+ Returns:
359
+ (str): Cleaned content with comments and empty lines removed.
360
+
361
+ Notes:
362
+ Typical reductions for Ultralytics Docs are:
363
+ - Total HTML reduction: 2.83% (1301.56 KB saved)
364
+ - Total CSS reduction: 1.75% (2.61 KB saved)
365
+ - Total JS reduction: 13.51% (99.31 KB saved)
366
+ """
367
+ if file_type == "html":
368
+ content = HTML_COMMENT.sub("", content) # Remove HTML comments
369
+ # Preserve whitespace in <pre>, <code>, <textarea> tags
370
+ preserved = []
371
+
372
+ def preserve(match):
373
+ """Mark HTML blocks that should not be minified."""
374
+ preserved.append(match.group(0))
375
+ return f"___PRESERVE_{len(preserved) - 1}___"
376
+
377
+ content = HTML_PRESERVE.sub(preserve, content)
378
+ content = HTML_TAG_SPACE.sub("><", content) # Remove whitespace between tags
379
+ content = HTML_MULTI_SPACE.sub(" ", content) # Collapse multiple spaces
380
+ content = HTML_EMPTY_LINE.sub("", content) # Remove empty lines
381
+ # Restore preserved content
382
+ for i, text in enumerate(preserved):
383
+ content = content.replace(f"___PRESERVE_{i}___", text)
384
+ elif file_type == "css":
385
+ content = CSS_COMMENT.sub("", content) # Remove CSS comments
386
+ # Remove whitespace around specific characters
387
+ content = re.sub(r"\s*([{}:;,])\s*", r"\1", content)
388
+ # Remove empty lines
389
+ content = re.sub(r"^\s*\n", "", content, flags=re.MULTILINE)
390
+ # Collapse multiple spaces to single space
391
+ content = re.sub(r"\s{2,}", " ", content)
392
+ # Remove all newlines
393
+ content = re.sub(r"\n", "", content)
394
+ elif file_type == "js":
395
+ # Handle JS single-line comments (preserving http:// and https://)
396
+ lines = content.split("\n")
397
+ processed_lines = []
398
+ for line in lines:
399
+ # Only remove comments if they're not part of a URL
400
+ if "//" in line and "http://" not in line and "https://" not in line:
401
+ processed_lines.append(line.partition("//")[0])
402
+ else:
403
+ processed_lines.append(line)
404
+ content = "\n".join(processed_lines)
405
+
406
+ # Remove JS multi-line comments and clean whitespace
407
+ content = re.sub(r"/\*[\s\S]*?\*/", "", content)
408
+ # Remove empty lines
409
+ content = re.sub(r"^\s*\n", "", content, flags=re.MULTILINE)
410
+ # Collapse multiple spaces to single space
411
+ content = re.sub(r"\s{2,}", " ", content)
412
+
413
+ # Safe space removal around punctuation and operators (never include colons - breaks JS)
414
+ content = re.sub(r"\s*([;{}])\s*", r"\1", content)
415
+ content = re.sub(r"(\w)\s*\(|\)\s*{|\s*([+\-*/=])\s*", lambda m: m.group(0).replace(" ", ""), content)
416
+
417
+ return content
418
+
419
+
420
+ def minify_files(html: bool = True, css: bool = True, js: bool = True):
421
+ """Minify HTML, CSS, and JS files and print total reduction stats."""
422
+ minify, compress, jsmin = None, None, None
423
+ try:
424
+ if html:
425
+ from minify_html import minify
426
+ if css:
427
+ from csscompressor import compress
428
+ if js:
429
+ import jsmin
430
+ except ImportError as e:
431
+ LOGGER.info(f"Missing required package: {e}")
432
+ return
433
+
434
+ stats = {}
435
+ for ext, minifier in {
436
+ "html": (lambda x: minify(x, keep_closing_tags=True, minify_css=True, minify_js=True)) if html else None,
437
+ "css": compress if css else None,
438
+ "js": jsmin.jsmin if js else None,
439
+ }.items():
440
+ orig = minified = 0
441
+ files = list(SITE.rglob(f"*.{ext}"))
442
+ if not files:
443
+ continue
444
+ pbar = TQDM(files, desc=f"Minifying {ext.upper()} - reduced 0.00% (0.00 KB saved)")
445
+ for f in pbar:
446
+ content = f.read_text(encoding="utf-8")
447
+ out = minifier(content) if minifier else remove_comments_and_empty_lines(content, ext)
448
+ orig += len(content)
449
+ minified += len(out)
450
+ f.write_text(out, encoding="utf-8")
451
+ saved = orig - minified
452
+ pct = (saved / orig) * 100 if orig else 0.0
453
+ pbar.set_description(f"Minifying {ext.upper()} - reduced {pct:.2f}% ({saved / 1024:.2f} KB saved)")
454
+ stats[ext] = {"original": orig, "minified": minified}
455
+
456
+
457
+ def render_jinja_macros() -> None:
458
+ """Render MiniJinja macros in markdown files before building with MkDocs."""
459
+ mkdocs_yml = DOCS.parent / "mkdocs.yml"
460
+ default_yaml = DOCS.parent / "ultralytics" / "cfg" / "default.yaml"
461
+
462
+ class SafeFallbackLoader(yaml.SafeLoader):
463
+ """SafeLoader that gracefully skips unknown tags (required for mkdocs.yml)."""
464
+
465
+ def _ignore_unknown(loader, tag_suffix, node):
466
+ """Gracefully handle YAML tags that aren't registered."""
467
+ if isinstance(node, yaml.ScalarNode):
468
+ return loader.construct_scalar(node)
469
+ if isinstance(node, yaml.SequenceNode):
470
+ return loader.construct_sequence(node)
471
+ if isinstance(node, yaml.MappingNode):
472
+ return loader.construct_mapping(node)
473
+ return None
474
+
475
+ SafeFallbackLoader.add_multi_constructor("", _ignore_unknown)
476
+
477
+ def load_yaml(path: Path, *, safe_loader: yaml.Loader = yaml.SafeLoader) -> dict:
478
+ """Load YAML safely, returning an empty dict on errors."""
479
+ if not path.exists():
480
+ return {}
481
+ try:
482
+ with open(path, encoding="utf-8") as f:
483
+ return yaml.load(f, Loader=safe_loader) or {}
484
+ except Exception as e:
485
+ LOGGER.warning(f"Could not load {path}: {e}")
486
+ return {}
487
+
488
+ mkdocs_cfg = load_yaml(mkdocs_yml, safe_loader=SafeFallbackLoader)
489
+ extra_vars = mkdocs_cfg.get("extra", {}) or {}
490
+ site_name = mkdocs_cfg.get("site_name", "Ultralytics Docs")
491
+ extra_vars.update(load_yaml(default_yaml))
492
+
493
+ env = Environment(
494
+ loader=load_from_path([DOCS / "en", DOCS]),
495
+ auto_escape_callback=lambda _: False,
496
+ trim_blocks=True,
497
+ lstrip_blocks=True,
498
+ keep_trailing_newline=True,
499
+ )
500
+
501
+ def indent_filter(value: str, width: int = 4, first: bool = False, blank: bool = False) -> str:
502
+ """Mimic Jinja's indent filter to preserve macros compatibility."""
503
+ prefix = " " * int(width)
504
+ result = []
505
+ for i, line in enumerate(str(value).splitlines(keepends=True)):
506
+ if not line.strip() and not blank:
507
+ result.append(line)
508
+ continue
509
+ if i == 0 and not first:
510
+ result.append(line)
511
+ else:
512
+ result.append(prefix + line)
513
+ return "".join(result)
514
+
515
+ env.add_filter("indent", indent_filter)
516
+ reserved_keys = {"name"}
517
+ base_context = {**extra_vars, "page": {"meta": {}}, "config": {"site_name": site_name}}
518
+
519
+ files_processed = 0
520
+ files_with_macros = 0
521
+ macros_total = 0
522
+
523
+ pbar = TQDM((DOCS / "en").rglob("*.md"), desc="MiniJinja: 0 macros, 0 pages")
524
+ for md_file in pbar:
525
+ if "macros" in md_file.parts or "reference" in md_file.parts:
526
+ continue
527
+ files_processed += 1
528
+
529
+ try:
530
+ content = md_file.read_text(encoding="utf-8")
531
+ except Exception as e:
532
+ LOGGER.warning(f"Could not read {md_file}: {e}")
533
+ continue
534
+ if "{{" not in content and "{%" not in content:
535
+ continue
536
+
537
+ parts = content.split("---\n")
538
+ frontmatter = ""
539
+ frontmatter_data = {}
540
+ markdown_content = content
541
+ if content.startswith("---\n") and len(parts) >= 3:
542
+ frontmatter = f"---\n{parts[1]}---\n"
543
+ markdown_content = "---\n".join(parts[2:])
544
+ try:
545
+ frontmatter_data = yaml.safe_load(parts[1]) or {}
546
+ except Exception as e:
547
+ LOGGER.warning(f"Could not parse frontmatter in {md_file}: {e}")
548
+
549
+ macro_hits = markdown_content.count("{{") + markdown_content.count("{%")
550
+ if not macro_hits:
551
+ continue
552
+
553
+ context = {k: v for k, v in base_context.items() if k not in reserved_keys}
554
+ context.update({k: v for k, v in frontmatter_data.items() if k not in reserved_keys})
555
+ context["page"] = context.get("page", {})
556
+ context["page"]["meta"] = frontmatter_data
557
+
558
+ try:
559
+ rendered = env.render_str(markdown_content, name=str(md_file.relative_to(DOCS)), **context)
560
+ except Exception as e:
561
+ LOGGER.warning(f"Error rendering macros in {md_file}: {e}")
562
+ continue
563
+
564
+ md_file.write_text(frontmatter + rendered, encoding="utf-8")
565
+ files_with_macros += 1
566
+ macros_total += macro_hits
567
+ pbar.set_description(f"MiniJinja: {macros_total} macros, {files_with_macros} pages")
568
+
569
+
570
+ def backup_docs_sources() -> tuple[Path, list[tuple[Path, Path]]]:
571
+ """Create a temporary backup of docs sources so we can fully restore after building."""
572
+ backup_root = Path(tempfile.mkdtemp(prefix="docs_backup_", dir=str(DOCS.parent)))
573
+ sources = [DOCS / "en", DOCS / "macros"]
574
+ copied: list[tuple[Path, Path]] = []
575
+ for src in sources:
576
+ if not src.exists():
577
+ continue
578
+ dst = backup_root / src.name
579
+ shutil.copytree(src, dst)
580
+ copied.append((src, dst))
581
+ return backup_root, copied
582
+
583
+
584
+ def restore_docs_sources(backup_root: Path, backups: list[tuple[Path, Path]]):
585
+ """Restore docs sources from the temporary backup."""
586
+ for src, dst in backups:
587
+ shutil.rmtree(src, ignore_errors=True)
588
+ if dst.exists():
589
+ shutil.copytree(dst, src)
590
+ shutil.rmtree(backup_root, ignore_errors=True)
591
+
592
+
593
+ def main():
594
+ """Build docs, update titles and edit links, minify HTML, and print local server command."""
595
+ start_time = time.perf_counter()
596
+ backup_root: Path | None = None
597
+ docs_backups: list[tuple[Path, Path]] = []
598
+ restored = False
599
+
600
+ def restore_all():
601
+ """Restore docs sources from backup once build steps complete."""
602
+ nonlocal restored
603
+ if backup_root:
604
+ LOGGER.info("Restoring docs directory from backup")
605
+ restore_docs_sources(backup_root, docs_backups)
606
+ restored = True
607
+
608
+ try:
609
+ backup_root, docs_backups = backup_docs_sources()
610
+ prepare_docs_markdown()
611
+ build_reference_docs(update_nav=False)
612
+ # Render reference docs for any extra packages present (e.g., hub-sdk)
613
+ extra_refs = [
614
+ {
615
+ "package": DOCS / "repos" / "hub-sdk" / "hub_sdk",
616
+ "reference_dir": DOCS / "en" / "hub" / "sdk" / "reference",
617
+ "repo": "ultralytics/hub-sdk",
618
+ },
619
+ ]
620
+ for ref in extra_refs:
621
+ if ref["package"].exists():
622
+ build_reference_for(ref["package"], ref["reference_dir"], ref["repo"], update_nav=False)
623
+ render_jinja_macros()
624
+
625
+ # Remove cloned repos before serving/building to keep the tree lean during mkdocs processing
626
+ shutil.rmtree(DOCS / "repos", ignore_errors=True)
627
+
628
+ # Build the main documentation
629
+ LOGGER.info(f"Building docs from {DOCS}")
630
+ subprocess.run(["zensical", "build", "-f", str(DOCS.parent / "mkdocs.yml")], check=True)
631
+ LOGGER.info(f"Site built at {SITE}")
632
+
633
+ # Update docs HTML pages
634
+ update_docs_html()
635
+
636
+ # Post-process site for meta tags, authors, social cards, and mkdocstrings polish
637
+ if postprocess_site:
638
+ postprocess_site(
639
+ site_dir=SITE,
640
+ docs_dir=DOCS / "en",
641
+ site_url="https://docs.ultralytics.com",
642
+ default_image="https://raw.githubusercontent.com/ultralytics/assets/main/yolov8/banner-yolov8.png",
643
+ default_author="[email protected]",
644
+ add_desc=False,
645
+ add_image=True,
646
+ add_authors=True,
647
+ add_json_ld=True,
648
+ add_share_buttons=True,
649
+ add_css=False,
650
+ verbose=True,
651
+ )
652
+ else:
653
+ LOGGER.warning("postprocess_site not available; skipping mkdocstrings postprocessing")
654
+
655
+ # Minify files
656
+ minify_files(html=False, css=False, js=False)
657
+
658
+ # Print results and auto-serve on macOS
659
+ size = sum(f.stat().st_size for f in SITE.rglob("*") if f.is_file()) >> 20
660
+ duration = time.perf_counter() - start_time
661
+ LOGGER.info(f"Docs built correctly ✅ ({size:.1f}MB, {duration:.1f}s)")
662
+
663
+ # Restore sources before optionally serving
664
+ restore_all()
665
+
666
+ if (MACOS or LINUX) and not os.getenv("GITHUB_ACTIONS"):
667
+ import webbrowser
668
+
669
+ url = "http://localhost:8000"
670
+ LOGGER.info(f"Opening browser at {url}")
671
+ webbrowser.open(url)
672
+ try:
673
+ subprocess.run(["python", "-m", "http.server", "--directory", str(SITE), "8000"], check=True)
674
+ except KeyboardInterrupt:
675
+ LOGGER.info(f"\n✅ Server stopped. Restart at {url}")
676
+ except Exception as e:
677
+ if "Address already in use" in str(e):
678
+ LOGGER.info("Port 8000 in use; skipping auto-serve. Serve manually if needed.")
679
+ else:
680
+ LOGGER.info(f"\n❌ Server failed: {e}")
681
+ else:
682
+ LOGGER.info('Serve site at http://localhost:8000 with "python -m http.server --directory site"')
683
+ finally:
684
+ if not restored:
685
+ restore_all()
686
+ shutil.rmtree(DOCS.parent / "hub_sdk", ignore_errors=True)
687
+ shutil.rmtree(DOCS / "repos", ignore_errors=True)
688
+
689
+
690
+ if __name__ == "__main__":
691
+ main()
ultralytics-main/docs/build_reference.py ADDED
@@ -0,0 +1,1191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+ """
3
+ Helper file to build Ultralytics Docs reference section.
4
+
5
+ This script recursively walks through the ultralytics directory and builds a MkDocs reference section of *.md files
6
+ composed of classes and functions, and also creates a navigation menu for use in mkdocs.yaml.
7
+
8
+ Note: Must be run from repository root directory. Do not run from docs directory.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ import ast
14
+ import html
15
+ import re
16
+ import subprocess
17
+ import textwrap
18
+ from collections import defaultdict
19
+ from collections.abc import Iterable
20
+ from dataclasses import dataclass, field
21
+ from pathlib import Path
22
+ from typing import Literal
23
+
24
+ from ultralytics.utils.tqdm import TQDM
25
+
26
+ # Constants
27
+ FILE = Path(__file__).resolve()
28
+ REPO_ROOT = FILE.parents[1]
29
+ PACKAGE_DIR = REPO_ROOT / "ultralytics"
30
+ REFERENCE_DIR = PACKAGE_DIR.parent / "docs/en/reference"
31
+ GITHUB_REPO = "ultralytics/ultralytics"
32
+ SIGNATURE_LINE_LENGTH = 120
33
+ # Use Font Awesome brand GitHub icon (CSS already loaded via mkdocs.yml and HTML head)
34
+ GITHUB_ICON = '<i class="fa-brands fa-github" aria-hidden="true" style="margin-right:6px;"></i>'
35
+
36
+ MKDOCS_YAML = PACKAGE_DIR.parent / "mkdocs.yml"
37
+ INCLUDE_SPECIAL_METHODS = {
38
+ "__call__",
39
+ "__dir__",
40
+ "__enter__",
41
+ "__exit__",
42
+ "__aenter__",
43
+ "__aexit__",
44
+ "__getitem__",
45
+ "__iter__",
46
+ "__len__",
47
+ "__next__",
48
+ "__getattr__",
49
+ }
50
+ PROPERTY_DECORATORS = {"property", "cached_property"}
51
+ CLASS_DEF_RE = re.compile(r"(?:^|\n)class\s(\w+)(?:\(|:)")
52
+ FUNC_DEF_RE = re.compile(r"(?:^|\n)(?:async\s+)?def\s(\w+)\(")
53
+ SECTION_ENTRY_RE = re.compile(r"([\w*]+)\s*(?:\(([^)]+)\))?:\s*(.*)")
54
+ RETURNS_RE = re.compile(r"([^:]+):\s*(.*)")
55
+
56
+
57
+ @dataclass
58
+ class ParameterDoc:
59
+ """Structured documentation for parameters, attributes, and exceptions."""
60
+
61
+ name: str
62
+ type: str | None
63
+ description: str
64
+ default: str | None = None
65
+
66
+
67
+ @dataclass
68
+ class ReturnDoc:
69
+ """Structured documentation for return and yield values."""
70
+
71
+ type: str | None
72
+ description: str
73
+
74
+
75
+ @dataclass
76
+ class ParsedDocstring:
77
+ """Normalized representation of a Google-style docstring."""
78
+
79
+ summary: str = ""
80
+ description: str = ""
81
+ params: list[ParameterDoc] = field(default_factory=list)
82
+ attributes: list[ParameterDoc] = field(default_factory=list)
83
+ returns: list[ReturnDoc] = field(default_factory=list)
84
+ yields: list[ReturnDoc] = field(default_factory=list)
85
+ raises: list[ParameterDoc] = field(default_factory=list)
86
+ notes: list[str] = field(default_factory=list)
87
+ examples: list[str] = field(default_factory=list)
88
+
89
+
90
+ @dataclass
91
+ class DocItem:
92
+ """Represents a documented symbol (class, function, method, or property)."""
93
+
94
+ name: str
95
+ qualname: str
96
+ kind: Literal["class", "function", "method", "property"]
97
+ signature: str
98
+ doc: ParsedDocstring
99
+ signature_params: list[ParameterDoc]
100
+ lineno: int
101
+ end_lineno: int
102
+ bases: list[str] = field(default_factory=list)
103
+ children: list[DocItem] = field(default_factory=list)
104
+ module_path: str = ""
105
+ source: str = ""
106
+
107
+
108
+ @dataclass
109
+ class DocumentedModule:
110
+ """Container for all documented items within a Python module."""
111
+
112
+ path: Path
113
+ module_path: str
114
+ classes: list[DocItem]
115
+ functions: list[DocItem]
116
+
117
+
118
+ # --------------------------------------------------------------------------------------------- #
119
+ # Placeholder (legacy) generation for mkdocstrings-style stubs
120
+ # --------------------------------------------------------------------------------------------- #
121
+
122
+
123
+ def extract_classes_and_functions(filepath: Path) -> tuple[list[str], list[str]]:
124
+ """Extract top-level class and (a)sync function names from a Python file."""
125
+ content = filepath.read_text()
126
+ classes = CLASS_DEF_RE.findall(content)
127
+ functions = FUNC_DEF_RE.findall(content)
128
+ return classes, functions
129
+
130
+
131
+ def create_placeholder_markdown(py_filepath: Path, module_path: str, classes: list[str], functions: list[str]) -> Path:
132
+ """Create a minimal Markdown stub used by mkdocstrings."""
133
+ md_filepath = REFERENCE_DIR / py_filepath.relative_to(PACKAGE_DIR).with_suffix(".md")
134
+ exists = md_filepath.exists()
135
+
136
+ header_content = ""
137
+ if exists:
138
+ current = md_filepath.read_text()
139
+ if current.startswith("---"):
140
+ parts = current.split("---", 2)
141
+ if len(parts) > 2:
142
+ header_content = f"---{parts[1]}---\n\n"
143
+ if not header_content:
144
+ header_content = "---\ndescription: TODO ADD DESCRIPTION\nkeywords: TODO ADD KEYWORDS\n---\n\n"
145
+
146
+ module_path_dots = module_path
147
+ module_path_fs = module_path.replace(".", "/")
148
+ url = f"https://github.com/{GITHUB_REPO}/blob/main/{module_path_fs}.py"
149
+ pretty = url.replace("__init__.py", "\\_\\_init\\_\\_.py")
150
+
151
+ title_content = f"# Reference for `{module_path_fs}.py`\n\n" + contribution_admonition(
152
+ pretty, url, kind="success", title="Improvements"
153
+ )
154
+
155
+ md_content = ["<br>\n\n"]
156
+ md_content.extend(f"## ::: {module_path_dots}.{cls}\n\n<br><br><hr><br>\n\n" for cls in classes)
157
+ md_content.extend(f"## ::: {module_path_dots}.{func}\n\n<br><br><hr><br>\n\n" for func in functions)
158
+ if md_content[-1:]:
159
+ md_content[-1] = md_content[-1].replace("<hr><br>\n\n", "")
160
+
161
+ md_filepath.parent.mkdir(parents=True, exist_ok=True)
162
+ md_filepath.write_text(header_content + title_content + "".join(md_content) + "\n")
163
+
164
+ return _relative_to_workspace(md_filepath)
165
+
166
+
167
+ def _get_source(src: str, node: ast.AST) -> str:
168
+ """Return the source segment for an AST node with safe fallbacks."""
169
+ segment = ast.get_source_segment(src, node)
170
+ if segment:
171
+ return segment
172
+ try:
173
+ return ast.unparse(node)
174
+ except Exception:
175
+ return ""
176
+
177
+
178
+ def _format_annotation(annotation: ast.AST | None, src: str) -> str | None:
179
+ """Format a type annotation into a compact string."""
180
+ if annotation is None:
181
+ return None
182
+ text = _get_source(src, annotation).strip()
183
+ return " ".join(text.split()) if text else None
184
+
185
+
186
+ def _format_default(default: ast.AST | None, src: str) -> str | None:
187
+ """Format a default value expression for display."""
188
+ if default is None:
189
+ return None
190
+ text = _get_source(src, default).strip()
191
+ return " ".join(text.split()) if text else None
192
+
193
+
194
+ def _format_parameter(arg: ast.arg, default: ast.AST | None, src: str) -> str:
195
+ """Render a single parameter with annotation and default value."""
196
+ annotation = _format_annotation(arg.annotation, src)
197
+ rendered = arg.arg
198
+ if annotation:
199
+ rendered += f": {annotation}"
200
+ default_value = _format_default(default, src)
201
+ if default_value is not None:
202
+ rendered += f" = {default_value}"
203
+ return rendered
204
+
205
+
206
+ def collect_signature_parameters(args: ast.arguments, src: str, *, skip_self: bool = True) -> list[ParameterDoc]:
207
+ """Collect parameters from an ast.arguments object with types and defaults."""
208
+ params: list[ParameterDoc] = []
209
+
210
+ def add_param(arg: ast.arg, default_value: ast.AST | None = None):
211
+ """Append a parameter entry, optionally skipping self/cls."""
212
+ name = arg.arg
213
+ if skip_self and name in {"self", "cls"}:
214
+ return
215
+ params.append(
216
+ ParameterDoc(
217
+ name=name,
218
+ type=_format_annotation(arg.annotation, src),
219
+ description="",
220
+ default=_format_default(default_value, src),
221
+ )
222
+ )
223
+
224
+ posonly = list(getattr(args, "posonlyargs", []))
225
+ regular = list(getattr(args, "args", []))
226
+ defaults = list(getattr(args, "defaults", []))
227
+ total_regular = len(posonly) + len(regular)
228
+ default_offset = total_regular - len(defaults)
229
+
230
+ combined = posonly + regular
231
+ for idx, arg in enumerate(combined):
232
+ default = defaults[idx - default_offset] if idx >= default_offset else None
233
+ add_param(arg, default)
234
+
235
+ vararg = getattr(args, "vararg", None)
236
+ if vararg:
237
+ add_param(vararg)
238
+ params[-1].name = f"*{params[-1].name}"
239
+
240
+ kwonly = list(getattr(args, "kwonlyargs", []))
241
+ kw_defaults = list(getattr(args, "kw_defaults", []))
242
+ for kwarg, default in zip(kwonly, kw_defaults):
243
+ add_param(kwarg, default)
244
+
245
+ kwarg = getattr(args, "kwarg", None)
246
+ if kwarg:
247
+ add_param(kwarg)
248
+ params[-1].name = f"**{params[-1].name}"
249
+
250
+ return params
251
+
252
+
253
+ def format_signature(
254
+ node: ast.AST, src: str, *, is_class: bool = False, is_async: bool = False, display_name: str | None = None
255
+ ) -> str:
256
+ """Build a readable signature string for classes, functions, and methods."""
257
+ if not isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)):
258
+ return ""
259
+
260
+ if isinstance(node, ast.ClassDef):
261
+ init_method = next(
262
+ (n for n in node.body if isinstance(n, (ast.FunctionDef, ast.AsyncFunctionDef)) and n.name == "__init__"),
263
+ None,
264
+ )
265
+ args = (
266
+ init_method.args
267
+ if init_method
268
+ else ast.arguments(
269
+ posonlyargs=[], args=[], vararg=None, kwonlyargs=[], kw_defaults=[], kwarg=None, defaults=[]
270
+ )
271
+ )
272
+ else:
273
+ args = node.args
274
+ name = display_name or getattr(node, "name", "")
275
+ params: list[str] = []
276
+
277
+ posonly = list(getattr(args, "posonlyargs", []))
278
+ regular = list(getattr(args, "args", []))
279
+ defaults = list(getattr(args, "defaults", []))
280
+ total_regular = len(posonly) + len(regular)
281
+ default_offset = total_regular - len(defaults)
282
+
283
+ combined = posonly + regular
284
+ for idx, arg in enumerate(combined):
285
+ default = defaults[idx - default_offset] if idx >= default_offset else None
286
+ params.append(_format_parameter(arg, default, src))
287
+ if posonly and idx == len(posonly) - 1:
288
+ params.append("/")
289
+
290
+ vararg = getattr(args, "vararg", None)
291
+ if vararg:
292
+ rendered = _format_parameter(vararg, None, src)
293
+ params.append(f"*{rendered}")
294
+
295
+ kwonly = list(getattr(args, "kwonlyargs", []))
296
+ kw_defaults = list(getattr(args, "kw_defaults", []))
297
+ if kwonly:
298
+ if not vararg:
299
+ params.append("*")
300
+ for kwarg, default in zip(kwonly, kw_defaults):
301
+ params.append(_format_parameter(kwarg, default, src))
302
+
303
+ kwarg = getattr(args, "kwarg", None)
304
+ if kwarg:
305
+ rendered = _format_parameter(kwarg, None, src)
306
+ params.append(f"**{rendered}")
307
+
308
+ return_annotation = (
309
+ _format_annotation(node.returns, src)
310
+ if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)) and node.returns
311
+ else None
312
+ )
313
+
314
+ prefix = "" if is_class else ("async def " if is_async else "def ")
315
+ signature = f"{prefix}{name}({', '.join(params)})"
316
+ if return_annotation:
317
+ signature += f" -> {return_annotation}"
318
+
319
+ if len(signature) <= SIGNATURE_LINE_LENGTH or not params:
320
+ return signature
321
+
322
+ raw_signature = _get_definition_signature(node, src)
323
+ return raw_signature or signature
324
+
325
+
326
+ def _split_section_entries(lines: list[str]) -> list[list[str]]:
327
+ """Split a docstring section into entries based on indentation."""
328
+ entries: list[list[str]] = []
329
+ current: list[str] = []
330
+ base_indent: int | None = None
331
+
332
+ for raw_line in lines:
333
+ if not raw_line.strip():
334
+ if current:
335
+ current.append("")
336
+ continue
337
+ indent = len(raw_line) - len(raw_line.lstrip(" "))
338
+ if base_indent is None:
339
+ base_indent = indent
340
+ if indent <= base_indent and current:
341
+ entries.append(current)
342
+ current = [raw_line]
343
+ else:
344
+ current.append(raw_line)
345
+ if current:
346
+ entries.append(current)
347
+ return entries
348
+
349
+
350
+ def _parse_named_entries(lines: list[str]) -> list[ParameterDoc]:
351
+ """Parse Args/Attributes/Raises style sections."""
352
+ entries = []
353
+ for block in _split_section_entries(lines):
354
+ text = textwrap.dedent("\n".join(block)).strip()
355
+ if not text:
356
+ continue
357
+ first_line, *rest = text.splitlines()
358
+ match = SECTION_ENTRY_RE.match(first_line)
359
+ if match:
360
+ name, type_hint, desc = match.groups()
361
+ description = " ".join(desc.split())
362
+ if rest:
363
+ description = f"{description}\n" + "\n".join(rest)
364
+ entries.append(ParameterDoc(name=name, type=type_hint, description=_normalize_text(description)))
365
+ else:
366
+ entries.append(ParameterDoc(name=text, type=None, description=""))
367
+ return entries
368
+
369
+
370
+ def _parse_returns(lines: list[str]) -> list[ReturnDoc]:
371
+ """Parse Returns/Yields sections."""
372
+ entries = []
373
+ for block in _split_section_entries(lines):
374
+ text = textwrap.dedent("\n".join(block)).strip()
375
+ if not text:
376
+ continue
377
+ match = RETURNS_RE.match(text)
378
+ if match:
379
+ type_hint, desc = match.groups()
380
+ cleaned_type = type_hint.strip()
381
+ if cleaned_type.startswith("(") and cleaned_type.endswith(")"):
382
+ cleaned_type = cleaned_type[1:-1].strip()
383
+ entries.append(ReturnDoc(type=cleaned_type, description=_normalize_text(desc.strip())))
384
+ else:
385
+ entries.append(ReturnDoc(type=None, description=_normalize_text(text)))
386
+ return entries
387
+
388
+
389
+ SECTION_ALIASES = {
390
+ "args": "params",
391
+ "arguments": "params",
392
+ "parameters": "params",
393
+ "params": "params",
394
+ "returns": "returns",
395
+ "return": "returns",
396
+ "yields": "yields",
397
+ "yield": "yields",
398
+ "raises": "raises",
399
+ "exceptions": "raises",
400
+ "exception": "raises",
401
+ "attributes": "attributes",
402
+ "attr": "attributes",
403
+ "examples": "examples",
404
+ "example": "examples",
405
+ "notes": "notes",
406
+ "note": "notes",
407
+ "methods": "methods",
408
+ }
409
+
410
+
411
+ def _normalize_text(text: str) -> str:
412
+ """Collapse single newlines within paragraphs while preserving paragraph breaks."""
413
+ if not text:
414
+ return ""
415
+ paragraphs: list[str] = []
416
+ current: list[str] = []
417
+ for line in text.splitlines():
418
+ stripped = line.strip()
419
+ if not stripped:
420
+ if current:
421
+ paragraphs.append(" ".join(current))
422
+ current = []
423
+ continue
424
+ current.append(stripped)
425
+ if current:
426
+ paragraphs.append(" ".join(current))
427
+ return "\n\n".join(paragraphs)
428
+
429
+
430
+ def parse_google_docstring(docstring: str | None) -> ParsedDocstring:
431
+ """Parse a Google-style docstring into structured data."""
432
+ if not docstring:
433
+ return ParsedDocstring()
434
+
435
+ lines = textwrap.dedent(docstring).splitlines()
436
+ while lines and not lines[0].strip():
437
+ lines.pop(0)
438
+ if not lines:
439
+ return ParsedDocstring()
440
+
441
+ summary = _normalize_text(lines[0].strip())
442
+ body = lines[1:]
443
+
444
+ sections: defaultdict[str, list[str]] = defaultdict(list)
445
+ current = "description"
446
+ for line in body:
447
+ stripped = line.strip()
448
+ key = SECTION_ALIASES.get(stripped.rstrip(":").lower())
449
+ if key and stripped.endswith(":"):
450
+ current = key
451
+ continue
452
+ if current != "methods": # ignore "Methods:" sections; methods are rendered from AST
453
+ sections[current].append(line)
454
+
455
+ description = "\n".join(sections.pop("description", [])).strip("\n")
456
+ description = _normalize_text(description)
457
+
458
+ return ParsedDocstring(
459
+ summary=summary,
460
+ description=description,
461
+ params=_parse_named_entries(sections.get("params", [])),
462
+ attributes=_parse_named_entries(sections.get("attributes", [])),
463
+ returns=_parse_returns(sections.get("returns", [])),
464
+ yields=_parse_returns(sections.get("yields", [])),
465
+ raises=_parse_named_entries(sections.get("raises", [])),
466
+ notes=[textwrap.dedent("\n".join(sections.get("notes", []))).strip()] if sections.get("notes") else [],
467
+ examples=[textwrap.dedent("\n".join(sections.get("examples", []))).strip()] if sections.get("examples") else [],
468
+ )
469
+
470
+
471
+ def merge_docstrings(base: ParsedDocstring, extra: ParsedDocstring, ignore_summary: bool = True) -> ParsedDocstring:
472
+ """Merge init docstring content into a class docstring."""
473
+
474
+ # Keep existing class docs; append init docs only when they introduce new entries (class takes priority).
475
+ def _merge_unique(base_items, extra_items, key):
476
+ seen = {key(item) for item in base_items}
477
+ base_items.extend(item for item in extra_items if key(item) not in seen)
478
+ return base_items
479
+
480
+ if not base.summary and extra.summary and not ignore_summary:
481
+ base.summary = extra.summary
482
+ if extra.description:
483
+ base.description = "\n\n".join(filter(None, [base.description, extra.description]))
484
+ _merge_unique(base.params, extra.params, lambda p: (p.name, p.type, p.description, p.default))
485
+ _merge_unique(base.attributes, extra.attributes, lambda p: (p.name, p.type, p.description, p.default))
486
+ _merge_unique(base.returns, extra.returns, lambda r: (r.type, r.description))
487
+ _merge_unique(base.yields, extra.yields, lambda r: (r.type, r.description))
488
+ _merge_unique(base.raises, extra.raises, lambda r: (r.name, r.type, r.description, r.default))
489
+ _merge_unique(base.notes, extra.notes, lambda n: n.strip())
490
+ _merge_unique(base.examples, extra.examples, lambda e: e.strip())
491
+ return base
492
+
493
+
494
+ def _should_document(name: str, *, allow_private: bool = False) -> bool:
495
+ """Decide whether to include a symbol based on its name."""
496
+ if name in INCLUDE_SPECIAL_METHODS:
497
+ return True
498
+ if name.startswith("_"):
499
+ return allow_private
500
+ return True
501
+
502
+
503
+ def _collect_source_block(src: str, node: ast.AST, end_line: int | None = None) -> str:
504
+ """Return a dedented source snippet for the given node up to an optional end line."""
505
+ if not hasattr(node, "lineno") or not hasattr(node, "end_lineno"):
506
+ return ""
507
+ lines = src.splitlines()
508
+ # Include decorators by starting from the first decorator line if present
509
+ decorator_lines = [getattr(d, "lineno", node.lineno) for d in getattr(node, "decorator_list", [])]
510
+ start_line = min([*decorator_lines, node.lineno]) if decorator_lines else node.lineno
511
+ start = max(start_line - 1, 0)
512
+ end = end_line or getattr(node, "end_lineno", node.lineno)
513
+ snippet = "\n".join(lines[start:end])
514
+ return textwrap.dedent(snippet).rstrip()
515
+
516
+
517
+ def _get_definition_signature(node: ast.AST, src: str) -> str:
518
+ """Return the original multi-line definition signature from source if available."""
519
+ if not hasattr(node, "lineno"):
520
+ return ""
521
+ lines = src.splitlines()[node.lineno - 1 :]
522
+ collected: list[str] = []
523
+ for line in lines:
524
+ stripped = line.strip()
525
+ if not stripped:
526
+ continue
527
+ collected.append(line)
528
+ if stripped.endswith(":"):
529
+ break
530
+ header = textwrap.dedent("\n".join(collected)).rstrip()
531
+ return header[:-1].rstrip() if header.endswith(":") else header
532
+
533
+
534
+ def parse_function(
535
+ node: ast.FunctionDef | ast.AsyncFunctionDef,
536
+ module_path: str,
537
+ src: str,
538
+ *,
539
+ parent: str | None = None,
540
+ allow_private: bool = False,
541
+ ) -> DocItem | None:
542
+ """Parse a function or method node into a DocItem."""
543
+ raw_docstring = ast.get_docstring(node)
544
+ if not _should_document(node.name, allow_private=allow_private) and not raw_docstring:
545
+ return None
546
+
547
+ is_async = isinstance(node, ast.AsyncFunctionDef)
548
+ doc = parse_google_docstring(raw_docstring)
549
+ qualname = f"{module_path}.{node.name}" if not parent else f"{parent}.{node.name}"
550
+ decorators = {_get_source(src, d).split(".")[-1] for d in node.decorator_list}
551
+ kind: Literal["function", "method", "property"] = "method" if parent else "function"
552
+ if decorators & PROPERTY_DECORATORS:
553
+ kind = "property"
554
+
555
+ signature_params = collect_signature_parameters(node.args, src, skip_self=bool(parent))
556
+
557
+ return DocItem(
558
+ name=node.name,
559
+ qualname=qualname,
560
+ kind=kind,
561
+ signature=format_signature(node, src, is_async=is_async),
562
+ doc=doc,
563
+ signature_params=signature_params,
564
+ lineno=node.lineno,
565
+ end_lineno=node.end_lineno or node.lineno,
566
+ bases=[],
567
+ children=[],
568
+ module_path=module_path,
569
+ source=_collect_source_block(src, node),
570
+ )
571
+
572
+
573
+ def parse_class(node: ast.ClassDef, module_path: str, src: str) -> DocItem:
574
+ """Parse a class node, merging __init__ docs and collecting methods."""
575
+ class_doc = parse_google_docstring(ast.get_docstring(node))
576
+
577
+ init_node: ast.FunctionDef | ast.AsyncFunctionDef | None = next(
578
+ (n for n in node.body if isinstance(n, (ast.FunctionDef, ast.AsyncFunctionDef)) and n.name == "__init__"),
579
+ None,
580
+ )
581
+ signature_params: list[ParameterDoc] = []
582
+ if init_node:
583
+ init_doc = parse_google_docstring(ast.get_docstring(init_node))
584
+ class_doc = merge_docstrings(class_doc, init_doc, ignore_summary=True)
585
+ signature_params = collect_signature_parameters(init_node.args, src, skip_self=True)
586
+
587
+ bases = [_get_source(src, b) for b in node.bases] if node.bases else []
588
+ signature_node = init_node or node
589
+ class_signature = format_signature(signature_node, src, is_class=True, display_name=node.name)
590
+
591
+ methods: list[DocItem] = []
592
+ for child in node.body:
593
+ if isinstance(child, (ast.FunctionDef, ast.AsyncFunctionDef)) and child is not init_node:
594
+ method_doc = parse_function(child, module_path, src, parent=f"{module_path}.{node.name}")
595
+ if method_doc:
596
+ methods.append(method_doc)
597
+
598
+ return DocItem(
599
+ name=node.name,
600
+ qualname=f"{module_path}.{node.name}",
601
+ kind="class",
602
+ signature=class_signature,
603
+ doc=class_doc,
604
+ signature_params=signature_params,
605
+ lineno=node.lineno,
606
+ end_lineno=node.end_lineno or node.lineno,
607
+ bases=bases,
608
+ children=methods,
609
+ module_path=module_path,
610
+ source=_collect_source_block(src, node, end_line=init_node.end_lineno if init_node else node.lineno),
611
+ )
612
+
613
+
614
+ def parse_module(py_filepath: Path) -> DocumentedModule | None:
615
+ """Parse a Python module into structured documentation objects."""
616
+ try:
617
+ src = py_filepath.read_text(encoding="utf-8")
618
+ except Exception:
619
+ return None
620
+ try:
621
+ tree = ast.parse(src)
622
+ except SyntaxError:
623
+ return None
624
+
625
+ module_path = (
626
+ f"{PACKAGE_DIR.name}.{py_filepath.relative_to(PACKAGE_DIR).with_suffix('').as_posix().replace('/', '.')}"
627
+ )
628
+ classes: list[DocItem] = []
629
+ functions: list[DocItem] = []
630
+
631
+ for node in tree.body:
632
+ if isinstance(node, ast.ClassDef):
633
+ classes.append(parse_class(node, module_path, src))
634
+ elif isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
635
+ func = parse_function(node, module_path, src, parent=None)
636
+ if func:
637
+ functions.append(func)
638
+
639
+ return DocumentedModule(path=py_filepath, module_path=module_path, classes=classes, functions=functions)
640
+
641
+
642
+ def _render_section(title: str, entries: Iterable[str], level: int) -> str:
643
+ """Render a section with a given heading level."""
644
+ entries = list(entries)
645
+ if not entries:
646
+ return ""
647
+ heading = f"{'#' * level} {title}\n"
648
+ body = "\n".join(entries).rstrip()
649
+ return f"{heading}{body}\n\n"
650
+
651
+
652
+ def _render_table(headers: list[str], rows: list[list[str]], level: int, title: str | None = None) -> str:
653
+ """Render a Markdown table with an optional heading."""
654
+ if not rows:
655
+ return ""
656
+
657
+ def _clean_cell(value: str | None) -> str:
658
+ """Normalize table cell values for Markdown output."""
659
+ if value is None:
660
+ return ""
661
+ return str(value).replace("\n", "<br>").strip()
662
+
663
+ rows = [[_clean_cell(c) for c in row] for row in rows]
664
+ table_lines = ["| " + " | ".join(headers) + " |", "| " + " | ".join("---" for _ in headers) + " |"]
665
+ for row in rows:
666
+ table_lines.append("| " + " | ".join(row) + " |")
667
+ heading = f"{'#' * level} {title}\n" if title else ""
668
+ return f"{heading}" + "\n".join(table_lines) + "\n\n"
669
+
670
+
671
+ def _code_fence(source: str, lang: str = "python") -> str:
672
+ """Return a fenced code block with optional language for highlighting."""
673
+ return f"```{lang}\n{source}\n```"
674
+
675
+
676
+ def _merge_params(doc_params: list[ParameterDoc], signature_params: list[ParameterDoc]) -> list[ParameterDoc]:
677
+ """Merge docstring params with signature params to include defaults/types."""
678
+ sig_map = {p.name.lstrip("*"): p for p in signature_params}
679
+ merged: list[ParameterDoc] = []
680
+
681
+ seen = set()
682
+ for dp in doc_params:
683
+ sig = sig_map.get(dp.name.lstrip("*"))
684
+ merged.append(
685
+ ParameterDoc(
686
+ name=dp.name,
687
+ type=dp.type or (sig.type if sig else None),
688
+ description=dp.description,
689
+ default=sig.default if sig else None,
690
+ )
691
+ )
692
+ seen.add(dp.name.lstrip("*"))
693
+
694
+ for name, sig in sig_map.items():
695
+ if name in seen:
696
+ continue
697
+ merged.append(sig)
698
+
699
+ return merged
700
+
701
+
702
+ DEFAULT_SECTION_ORDER = ["args", "returns", "examples", "notes", "attributes", "yields", "raises"]
703
+ SUMMARY_BADGE_MAP = {"Classes": "class", "Properties": "property", "Methods": "method", "Functions": "function"}
704
+
705
+
706
+ def contribution_admonition(pretty: str, url: str, *, kind: str = "note", title: str | None = None) -> str:
707
+ """Return a standardized contribution call-to-action admonition."""
708
+ label = f' "{title}"' if title else ""
709
+ body = (
710
+ f"This page is sourced from [{pretty}]({url}). Have an improvement or example to add? "
711
+ f"Open a [Pull Request](https://docs.ultralytics.com/help/contributing/) — thank you! 🙏"
712
+ )
713
+ return f"!!! {kind}{label}\n\n {body}\n\n"
714
+
715
+
716
+ def _relative_to_workspace(path: Path) -> Path:
717
+ """Return path relative to workspace root when possible."""
718
+ try:
719
+ return path.relative_to(PACKAGE_DIR.parent)
720
+ except ValueError:
721
+ return path
722
+
723
+
724
+ def render_source_panel(item: DocItem, module_url: str, module_path: str) -> str:
725
+ """Render a collapsible source panel with a GitHub link."""
726
+ if not item.source:
727
+ return ""
728
+ source_url = f"{module_url}#L{item.lineno}-L{item.end_lineno}"
729
+ summary = f"Source code in <code>{html.escape(module_path)}.py</code>"
730
+ return (
731
+ "<details>\n"
732
+ f"<summary>{summary}</summary>\n\n"
733
+ f'<a href="{source_url}">{GITHUB_ICON}View on GitHub</a>\n'
734
+ f"{_code_fence(item.source)}\n"
735
+ "</details>\n"
736
+ )
737
+
738
+
739
+ def render_docstring(
740
+ doc: ParsedDocstring,
741
+ level: int,
742
+ signature_params: list[ParameterDoc] | None = None,
743
+ section_order: list[str] | None = None,
744
+ extra_sections: dict[str, str] | None = None,
745
+ ) -> str:
746
+ """Convert a ParsedDocstring into Markdown with tables similar to mkdocstrings."""
747
+ parts: list[str] = []
748
+ if doc.summary:
749
+ parts.append(doc.summary)
750
+ if doc.description:
751
+ parts.append(doc.description)
752
+
753
+ sig_params = signature_params or []
754
+ merged_params = _merge_params(doc.params, sig_params)
755
+
756
+ sections: dict[str, str] = {}
757
+
758
+ if merged_params:
759
+ rows = []
760
+ for p in merged_params:
761
+ default_val = f"`{p.default}`" if p.default not in (None, "") else "*required*"
762
+ rows.append(
763
+ [
764
+ f"`{p.name}`",
765
+ f"`{p.type}`" if p.type else "",
766
+ p.description.strip() if p.description else "",
767
+ default_val,
768
+ ]
769
+ )
770
+ table = _render_table(["Name", "Type", "Description", "Default"], rows, level, title=None)
771
+ sections["args"] = f"**Args**\n\n{table}"
772
+
773
+ if doc.returns:
774
+ rows = []
775
+ for r in doc.returns:
776
+ rows.append([f"`{r.type}`" if r.type else "", r.description])
777
+ table = _render_table(["Type", "Description"], rows, level, title=None)
778
+ sections["returns"] = f"**Returns**\n\n{table}"
779
+
780
+ if doc.examples:
781
+ code_block = "\n\n".join(f"```python\n{example.strip()}\n```" for example in doc.examples if example.strip())
782
+ if code_block:
783
+ sections["examples"] = f"**Examples**\n\n{code_block}\n\n"
784
+
785
+ if doc.notes:
786
+ note_text = "\n\n".join(doc.notes).strip()
787
+ indented = textwrap.indent(note_text, " ")
788
+ sections["notes"] = f'!!! note "Notes"\n\n{indented}\n\n'
789
+
790
+ if doc.attributes:
791
+ rows = []
792
+ for a in doc.attributes:
793
+ rows.append(
794
+ [f"`{a.name}`", f"`{a.type}`" if a.type else "", a.description.strip() if a.description else ""]
795
+ )
796
+ table = _render_table(["Name", "Type", "Description"], rows, level, title=None)
797
+ sections["attributes"] = f"**Attributes**\n\n{table}"
798
+
799
+ if doc.yields:
800
+ rows = []
801
+ for r in doc.yields:
802
+ rows.append([f"`{r.type}`" if r.type else "", r.description])
803
+ table = _render_table(["Type", "Description"], rows, level, title=None)
804
+ sections["yields"] = f"**Yields**\n\n{table}"
805
+
806
+ if doc.raises:
807
+ rows = []
808
+ for e in doc.raises:
809
+ type_cell = e.type or e.name
810
+ rows.append([f"`{type_cell}`" if type_cell else "", e.description or ""])
811
+ table = _render_table(["Type", "Description"], rows, level, title=None)
812
+ sections["raises"] = f"**Raises**\n\n{table}"
813
+
814
+ if extra_sections:
815
+ sections.update({k: v for k, v in extra_sections.items() if v})
816
+ # Ensure section order contains unique entries to avoid duplicate renders (e.g., classes injecting "examples")
817
+ order = list(dict.fromkeys(section_order or DEFAULT_SECTION_ORDER))
818
+
819
+ ordered_sections: list[str] = []
820
+ seen = set()
821
+ for key in order:
822
+ section = sections.get(key)
823
+ if section:
824
+ ordered_sections.append(section)
825
+ seen.add(key)
826
+
827
+ for key, section in sections.items():
828
+ if key not in seen:
829
+ ordered_sections.append(section)
830
+
831
+ parts.extend(filter(None, ordered_sections))
832
+ return "\n\n".join([p.rstrip() for p in parts if p]).strip() + ("\n\n" if parts else "")
833
+
834
+
835
+ def item_anchor(item: DocItem) -> str:
836
+ """Create a stable anchor for a documented item."""
837
+ return item.qualname
838
+
839
+
840
+ def display_qualname(item: DocItem) -> str:
841
+ """Return a cleaned, fully-qualified name for display (strip __init__ noise)."""
842
+ return item.qualname.replace(".__init__.", ".")
843
+
844
+
845
+ def render_summary_tabs(module: DocumentedModule) -> str:
846
+ """Render a tabbed summary of classes, methods, and functions for quick navigation."""
847
+ tab_entries: list[tuple[str, list[str]]] = []
848
+
849
+ if module.classes:
850
+ tab_entries.append(
851
+ (
852
+ "Classes",
853
+ [f"- [`{cls.name}`](#{item_anchor(cls)})" for cls in module.classes],
854
+ )
855
+ )
856
+
857
+ property_links = []
858
+ method_links = []
859
+ for cls in module.classes:
860
+ for child in cls.children:
861
+ if child.kind == "property":
862
+ property_links.append(f"- [`{cls.name}.{child.name}`](#{item_anchor(child)})")
863
+ for child in cls.children:
864
+ if child.kind == "method":
865
+ method_links.append(f"- [`{cls.name}.{child.name}`](#{item_anchor(child)})")
866
+ if property_links:
867
+ tab_entries.append(("Properties", property_links))
868
+ if method_links:
869
+ tab_entries.append(("Methods", method_links))
870
+
871
+ if module.functions:
872
+ tab_entries.append(
873
+ (
874
+ "Functions",
875
+ [f"- [`{func.name}`](#{item_anchor(func)})" for func in module.functions],
876
+ )
877
+ )
878
+
879
+ if not tab_entries:
880
+ return ""
881
+
882
+ lines = ['!!! abstract "Summary"\n']
883
+ for label, bullets in tab_entries:
884
+ badge_class = SUMMARY_BADGE_MAP.get(label, label.lower())
885
+ label_badge = f'<span class="doc-kind doc-kind-{badge_class}">{label}</span>'
886
+ lines.append(f' === "{label_badge}"\n')
887
+ lines.append("\n".join(f" {line}" for line in bullets))
888
+ lines.append("") # Blank line after each tab block
889
+ return "\n".join(lines).rstrip() + "\n\n"
890
+
891
+
892
+ def render_item(item: DocItem, module_url: str, module_path: str, level: int = 2) -> str:
893
+ """Render a class, function, or method to Markdown."""
894
+ anchor = item_anchor(item)
895
+ title_prefix = item.kind.capitalize()
896
+ anchor_id = anchor.replace("_", r"\_") # escape underscores so attr_list keeps them in the id
897
+ heading = f"{'#' * level} {title_prefix} `{display_qualname(item)}` {{#{anchor_id}}}"
898
+ signature_block = f"```python\n{item.signature}\n```\n"
899
+
900
+ parts = [heading, signature_block]
901
+
902
+ if item.bases:
903
+ bases = ", ".join(f"`{b}`" for b in item.bases)
904
+ parts.append(f"**Bases:** {bases}\n")
905
+
906
+ if item.kind == "class":
907
+ method_section = None
908
+ if item.children:
909
+ props = [c for c in item.children if c.kind == "property"]
910
+ methods = [c for c in item.children if c.kind == "method"]
911
+ methods.sort(key=lambda m: (not m.name.startswith("__"), m.name))
912
+
913
+ rows = []
914
+ for child in props + methods:
915
+ summary = child.doc.summary or (
916
+ _normalize_text(child.doc.description).split("\n\n")[0] if child.doc.description else ""
917
+ )
918
+ rows.append([f"[`{child.name}`](#{item_anchor(child)})", summary.strip()])
919
+ if rows:
920
+ table = _render_table(["Name", "Description"], rows, level + 1, title=None)
921
+ method_section = f"**Methods**\n\n{table}"
922
+
923
+ order = ["args", "attributes", "methods", "examples", *DEFAULT_SECTION_ORDER]
924
+ rendered = render_docstring(
925
+ item.doc,
926
+ level + 1,
927
+ signature_params=item.signature_params,
928
+ section_order=order,
929
+ extra_sections={"methods": method_section} if method_section else None,
930
+ )
931
+ parts.append(rendered)
932
+ else:
933
+ parts.append(render_docstring(item.doc, level + 1, signature_params=item.signature_params))
934
+
935
+ if item.kind == "class" and item.source:
936
+ parts.append(render_source_panel(item, module_url, module_path))
937
+
938
+ if item.children:
939
+ props = [c for c in item.children if c.kind == "property"]
940
+ methods = [c for c in item.children if c.kind == "method"]
941
+ methods.sort(key=lambda m: (not m.name.startswith("__"), m.name))
942
+
943
+ ordered_children = props + methods
944
+ parts.append("<br>\n")
945
+ for idx, child in enumerate(ordered_children):
946
+ parts.append(render_item(child, module_url, module_path, level + 1))
947
+ if idx != len(ordered_children) - 1:
948
+ parts.append("<br>\n")
949
+
950
+ if item.source and item.kind != "class":
951
+ parts.append(render_source_panel(item, module_url, module_path))
952
+
953
+ return "\n\n".join(p.rstrip() for p in parts if p).rstrip() + "\n\n"
954
+
955
+
956
+ def render_module_markdown(module: DocumentedModule) -> str:
957
+ """Render the full module reference content."""
958
+ module_path = module.module_path.replace(".", "/")
959
+ module_url = f"https://github.com/{GITHUB_REPO}/blob/main/{module_path}.py"
960
+ content: list[str] = ["<br>\n"]
961
+
962
+ summary_tabs = render_summary_tabs(module)
963
+ if summary_tabs:
964
+ content.append(summary_tabs)
965
+
966
+ sections: list[str] = []
967
+ for idx, cls in enumerate(module.classes):
968
+ sections.append(render_item(cls, module_url, module_path, level=2))
969
+ if idx != len(module.classes) - 1 or module.functions:
970
+ sections.append("<br><br><hr><br>\n")
971
+ for idx, func in enumerate(module.functions):
972
+ sections.append(render_item(func, module_url, module_path, level=2))
973
+ if idx != len(module.functions) - 1:
974
+ sections.append("<br><br><hr><br>\n")
975
+
976
+ content.extend(sections)
977
+ return "\n".join(content).rstrip() + "\n\n<br><br>\n"
978
+
979
+
980
+ def create_markdown(module: DocumentedModule) -> Path:
981
+ """Create a Markdown file containing the API reference for the given Python module."""
982
+ md_filepath = REFERENCE_DIR / module.path.relative_to(PACKAGE_DIR).with_suffix(".md")
983
+ exists = md_filepath.exists()
984
+
985
+ header_content = ""
986
+ if exists:
987
+ for part in md_filepath.read_text().split("---"):
988
+ if "description:" in part or "comments:" in part:
989
+ header_content += f"---{part}---\n\n"
990
+ if not header_content:
991
+ header_content = "---\ndescription: TODO ADD DESCRIPTION\nkeywords: TODO ADD KEYWORDS\n---\n\n"
992
+
993
+ module_path_fs = module.module_path.replace(".", "/")
994
+ url = f"https://github.com/{GITHUB_REPO}/blob/main/{module_path_fs}.py"
995
+ pretty = url.replace("__init__.py", "\\_\\_init\\_\\_.py") # Properly display __init__.py filenames
996
+
997
+ title_content = f"# Reference for `{module_path_fs}.py`\n\n" + contribution_admonition(
998
+ pretty, url, kind="success", title="Improvements"
999
+ )
1000
+
1001
+ md_filepath.parent.mkdir(parents=True, exist_ok=True)
1002
+ md_filepath.write_text(header_content + title_content + render_module_markdown(module))
1003
+
1004
+ if not exists:
1005
+ subprocess.run(["git", "add", "-f", str(md_filepath)], check=True, cwd=REPO_ROOT)
1006
+
1007
+ return _relative_to_workspace(md_filepath)
1008
+
1009
+
1010
+ def nested_dict():
1011
+ """Create and return a nested defaultdict."""
1012
+ return defaultdict(nested_dict)
1013
+
1014
+
1015
+ def sort_nested_dict(d: dict) -> dict:
1016
+ """Sort a nested dictionary recursively."""
1017
+ return {k: sort_nested_dict(v) if isinstance(v, dict) else v for k, v in sorted(d.items())}
1018
+
1019
+
1020
+ def create_nav_menu_yaml(nav_items: list[str]) -> str:
1021
+ """Create and return a YAML string for the navigation menu."""
1022
+ nav_tree = nested_dict()
1023
+
1024
+ for item_str in nav_items:
1025
+ item = Path(item_str)
1026
+ parts = item.parts
1027
+ current_level = nav_tree["reference"]
1028
+ for part in parts[2:-1]: # Skip docs/reference and filename
1029
+ current_level = current_level[part]
1030
+ current_level[parts[-1].replace(".md", "")] = item
1031
+
1032
+ def _dict_to_yaml(d, level=0):
1033
+ """Convert a nested dictionary to a YAML-formatted string with indentation."""
1034
+ yaml_str = ""
1035
+ indent = " " * level
1036
+ for k, v in sorted(d.items()):
1037
+ if isinstance(v, dict):
1038
+ yaml_str += f"{indent}- {k}:\n{_dict_to_yaml(v, level + 1)}"
1039
+ else:
1040
+ yaml_str += f"{indent}- {k}: {str(v).replace('docs/en/', '')}\n"
1041
+ return yaml_str
1042
+
1043
+ reference_yaml = _dict_to_yaml(sort_nested_dict(nav_tree))
1044
+ print(f"Scan complete, generated reference section with {len(reference_yaml.splitlines())} lines")
1045
+ return reference_yaml
1046
+
1047
+
1048
+ def extract_document_paths(yaml_section: str) -> list[str]:
1049
+ """Extract document paths from a YAML section, ignoring formatting and structure."""
1050
+ paths = []
1051
+ # Match all paths that appear after a colon in the YAML
1052
+ path_matches = re.findall(r":\s*([^\s][^:\n]*?)(?:\n|$)", yaml_section)
1053
+ for path in path_matches:
1054
+ # Clean up the path
1055
+ path = path.strip()
1056
+ if path and not path.startswith("-") and not path.endswith(":"):
1057
+ paths.append(path)
1058
+ return sorted(paths)
1059
+
1060
+
1061
+ def update_mkdocs_file(reference_yaml: str) -> None:
1062
+ """Update the mkdocs.yaml file with the new reference section only if changes in document paths are detected."""
1063
+ mkdocs_content = MKDOCS_YAML.read_text()
1064
+
1065
+ # Find the top-level Reference section
1066
+ ref_pattern = r"(\n - Reference:[\s\S]*?)(?=\n - \w|$)"
1067
+ ref_match = re.search(ref_pattern, mkdocs_content)
1068
+
1069
+ # Build new section with proper indentation
1070
+ new_section_lines = ["\n - Reference:"]
1071
+ new_section_lines.extend(
1072
+ f" {line}"
1073
+ for line in reference_yaml.splitlines()
1074
+ if line.strip() != "- reference:" # Skip redundant header
1075
+ )
1076
+ new_ref_section = "\n".join(new_section_lines) + "\n"
1077
+
1078
+ if ref_match:
1079
+ # We found an existing Reference section
1080
+ ref_section = ref_match.group(1)
1081
+ print(f"Found existing top-level Reference section ({len(ref_section)} chars)")
1082
+
1083
+ # Compare only document paths
1084
+ existing_paths = extract_document_paths(ref_section)
1085
+ new_paths = extract_document_paths(new_ref_section)
1086
+
1087
+ # Check if the document paths are the same (ignoring structure or formatting differences)
1088
+ if len(existing_paths) == len(new_paths) and set(existing_paths) == set(new_paths):
1089
+ print(f"No changes detected in document paths ({len(existing_paths)} items). Skipping update.")
1090
+ return
1091
+
1092
+ print(f"Changes detected: {len(new_paths)} document paths vs {len(existing_paths)} existing")
1093
+
1094
+ # Update content
1095
+ new_content = mkdocs_content.replace(ref_section, new_ref_section)
1096
+ MKDOCS_YAML.write_text(new_content)
1097
+ subprocess.run(["npx", "prettier", "--write", str(MKDOCS_YAML)], check=False, cwd=PACKAGE_DIR.parent)
1098
+ print(f"Updated Reference section in {MKDOCS_YAML}")
1099
+ elif help_match := re.search(r"(\n - Help:)", mkdocs_content):
1100
+ # No existing Reference section, we need to add it
1101
+ help_section = help_match.group(1)
1102
+ # Insert before Help section
1103
+ new_content = mkdocs_content.replace(help_section, f"{new_ref_section}{help_section}")
1104
+ MKDOCS_YAML.write_text(new_content)
1105
+ print(f"Added new Reference section before Help in {MKDOCS_YAML}")
1106
+ else:
1107
+ print("Could not find a suitable location to add Reference section")
1108
+
1109
+
1110
+ def _finalize_reference(nav_items: list[str], update_nav: bool, created: int, created_label: str) -> list[str]:
1111
+ """Optionally sync navigation and print creation summary."""
1112
+ if update_nav:
1113
+ update_mkdocs_file(create_nav_menu_yaml(nav_items))
1114
+ if created:
1115
+ print(f"Created {created} new {created_label}")
1116
+ return nav_items
1117
+
1118
+
1119
+ def build_reference(update_nav: bool = True) -> list[str]:
1120
+ """Create placeholder reference files (legacy mkdocstrings flow)."""
1121
+ return build_reference_placeholders(update_nav=update_nav)
1122
+
1123
+
1124
+ def build_reference_placeholders(update_nav: bool = True) -> list[str]:
1125
+ """Create minimal placeholder reference files (mkdocstrings-style) and optionally update nav."""
1126
+ nav_items: list[str] = []
1127
+ created = 0
1128
+
1129
+ for py_filepath in TQDM(list(PACKAGE_DIR.rglob("*.py")), desc="Building reference stubs", unit="file"):
1130
+ classes, functions = extract_classes_and_functions(py_filepath)
1131
+ if not classes and not functions:
1132
+ continue
1133
+ module_path = (
1134
+ f"{PACKAGE_DIR.name}.{py_filepath.relative_to(PACKAGE_DIR).with_suffix('').as_posix().replace('/', '.')}"
1135
+ )
1136
+ exists = (REFERENCE_DIR / py_filepath.relative_to(PACKAGE_DIR).with_suffix(".md")).exists()
1137
+ md_rel = create_placeholder_markdown(py_filepath, module_path, classes, functions)
1138
+ nav_items.append(str(md_rel))
1139
+ if not exists:
1140
+ created += 1
1141
+ if update_nav:
1142
+ update_mkdocs_file(create_nav_menu_yaml(nav_items))
1143
+ if created:
1144
+ print(f"Created {created} new reference stub files")
1145
+ return nav_items
1146
+
1147
+
1148
+ def build_reference_docs(update_nav: bool = False) -> list[str]:
1149
+ """Render full docstring-based reference content."""
1150
+ nav_items: list[str] = []
1151
+ created = 0
1152
+
1153
+ desc = f"Docstrings {GITHUB_REPO or PACKAGE_DIR.name}"
1154
+ for py_filepath in TQDM(list(PACKAGE_DIR.rglob("*.py")), desc=desc, unit="file"):
1155
+ md_target = REFERENCE_DIR / py_filepath.relative_to(PACKAGE_DIR).with_suffix(".md")
1156
+ exists_before = md_target.exists()
1157
+ module = parse_module(py_filepath)
1158
+ if not module or (not module.classes and not module.functions):
1159
+ continue
1160
+ md_rel_filepath = create_markdown(module)
1161
+ if not exists_before:
1162
+ created += 1
1163
+ nav_items.append(str(md_rel_filepath))
1164
+
1165
+ if update_nav:
1166
+ update_mkdocs_file(create_nav_menu_yaml(nav_items))
1167
+ if created:
1168
+ print(f"Created {created} new reference files")
1169
+ return nav_items
1170
+
1171
+
1172
+ def build_reference_for(
1173
+ package_dir: Path, reference_dir: Path, github_repo: str, update_nav: bool = False
1174
+ ) -> list[str]:
1175
+ """Temporarily switch package context to build reference docs for another project."""
1176
+ global PACKAGE_DIR, REFERENCE_DIR, GITHUB_REPO
1177
+ prev = (PACKAGE_DIR, REFERENCE_DIR, GITHUB_REPO)
1178
+ try:
1179
+ PACKAGE_DIR, REFERENCE_DIR, GITHUB_REPO = package_dir, reference_dir, github_repo
1180
+ return build_reference_docs(update_nav=update_nav)
1181
+ finally:
1182
+ PACKAGE_DIR, REFERENCE_DIR, GITHUB_REPO = prev
1183
+
1184
+
1185
+ def main():
1186
+ """CLI entrypoint."""
1187
+ build_reference(update_nav=True)
1188
+
1189
+
1190
+ if __name__ == "__main__":
1191
+ main()
ultralytics-main/docs/coming_soon_template.md ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ description: Discover what's next for Ultralytics with our under-construction page, previewing new, groundbreaking AI and ML features coming soon.
3
+ keywords: Ultralytics, coming soon, under construction, new features, AI updates, ML advancements, YOLO, technology preview
4
+ ---
5
+
6
+ # Under Construction 🏗️🌟
7
+
8
+ Welcome to the [Ultralytics](https://www.ultralytics.com/) "Under Construction" page! Here, we're hard at work developing the [next generation](https://www.ultralytics.com/glossary/foundation-model) of [AI](https://www.ultralytics.com/glossary/artificial-intelligence-ai) and [ML](https://www.ultralytics.com/glossary/machine-learning-ml) innovations. This page serves as a teaser for the exciting updates and new features we're eager to share with you!
9
+
10
+ ## Exciting New Features on the Way 🎉
11
+
12
+ - **Innovative Breakthroughs:** Get ready for [advanced features](https://docs.ultralytics.com/) and services designed to [transform your AI and ML experience](https://www.ultralytics.com/solutions).
13
+ - **New Horizons:** Anticipate novel products that [redefine AI and ML capabilities](https://docs.ultralytics.com/tasks/).
14
+ - **Enhanced Services:** We're upgrading our [services](https://www.ultralytics.com/hub) for greater [efficiency](https://docs.ultralytics.com/modes/benchmark/) and user-friendliness.
15
+
16
+ ## Stay Updated 🚧
17
+
18
+ This page is your go-to resource for the latest integration updates and feature rollouts. Stay connected through:
19
+
20
+ - **Newsletter:** Subscribe to [our Ultralytics newsletter](https://www.ultralytics.com/#newsletter) for announcements, releases, and early access updates.
21
+ - **Social Media:** Follow [Ultralytics on LinkedIn](https://www.linkedin.com/company/ultralytics) for behind-the-scenes content, product news, and community highlights.
22
+ - **Blog:** Dive into the [Ultralytics AI blog](https://www.ultralytics.com/blog) for in-depth articles, tutorials, and use-case spotlights.
23
+
24
+ ## We Value Your Input 🗣️
25
+
26
+ Help shape the future of Ultralytics HUB by sharing your ideas, feedback, and integration requests through our [official contact form](https://www.ultralytics.com/contact).
27
+
28
+ ## Thank You, Community! 🌍
29
+
30
+ Your [contributions](https://docs.ultralytics.com/help/contributing/) and ongoing support fuel our commitment to pushing the boundaries of [AI innovation](https://github.com/ultralytics/ultralytics). Stay tuned—exciting things are just around the corner!
31
+
32
+ ---
33
+
34
+ Excited for what's coming? Bookmark this page and check out our [Quickstart Guide](https://docs.ultralytics.com/quickstart/) to get started with our current tools while you wait. Get ready for a transformative AI and ML journey with Ultralytics! 🛠️🤖
ultralytics-main/docs/en/CNAME ADDED
@@ -0,0 +1 @@
 
 
1
+ docs.ultralytics.com
ultralytics-main/docs/en/datasets/classify/caltech101.md ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ comments: true
3
+ description: Explore the widely-used Caltech-101 dataset with 9,000 images across 101 categories. Ideal for object recognition tasks in machine learning and computer vision.
4
+ keywords: Caltech-101, dataset, object recognition, machine learning, computer vision, YOLO, deep learning, research, AI
5
+ ---
6
+
7
+ # Caltech-101 Dataset
8
+
9
+ The [Caltech-101](https://data.caltech.edu/records/mzrjq-6wc02) dataset is a widely used dataset for object recognition tasks, containing around 9,000 images from 101 object categories. The categories were chosen to reflect a variety of real-world objects, and the images themselves were carefully selected and annotated to provide a challenging benchmark for object recognition algorithms.
10
+
11
+ <p align="center">
12
+ <br>
13
+ <iframe loading="lazy" width="720" height="405" src="https://www.youtube.com/embed/isc06_9qnM0"
14
+ title="YouTube video player" frameborder="0"
15
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
16
+ allowfullscreen>
17
+ </iframe>
18
+ <br>
19
+ <strong>Watch:</strong> How to Train <a href="https://www.ultralytics.com/glossary/image-classification">Image Classification</a> Model using Caltech-256 Dataset with Ultralytics HUB
20
+ </p>
21
+
22
+ !!! note "Automatic Data Splitting"
23
+
24
+ The Caltech-101 dataset, as provided, does not come with pre-defined train/validation splits. However, when you use the training commands provided in the usage examples below, the Ultralytics framework will automatically split the dataset for you. The default split used is 80% for the training set and 20% for the validation set.
25
+
26
+ ## Key Features
27
+
28
+ - The Caltech-101 dataset comprises around 9,000 color images divided into 101 categories.
29
+ - The categories encompass a wide variety of objects, including animals, vehicles, household items, and people.
30
+ - The number of images per category varies, with about 40 to 800 images in each category.
31
+ - Images are of variable sizes, with most images being medium resolution.
32
+ - Caltech-101 is widely used for training and testing in the field of machine learning, particularly for object recognition tasks.
33
+
34
+ ## Dataset Structure
35
+
36
+ Unlike many other datasets, the Caltech-101 dataset is not formally split into training and testing sets. Users typically create their own splits based on their specific needs. However, a common practice is to use a random subset of images for training (e.g., 30 images per category) and the remaining images for testing.
37
+
38
+ ## Applications
39
+
40
+ The Caltech-101 dataset is extensively used for training and evaluating [deep learning](https://www.ultralytics.com/glossary/deep-learning-dl) models in object recognition tasks, such as [Convolutional Neural Networks](https://www.ultralytics.com/glossary/convolutional-neural-network-cnn) (CNNs), [Support Vector Machines](https://www.ultralytics.com/glossary/support-vector-machine-svm) (SVMs), and various other machine learning algorithms. Its wide variety of categories and high-quality images make it an excellent dataset for research and development in the field of [machine learning](https://www.ultralytics.com/glossary/machine-learning-ml) and [computer vision](https://www.ultralytics.com/glossary/computer-vision-cv).
41
+
42
+ ## Usage
43
+
44
+ To train a YOLO model on the Caltech-101 dataset for 100 [epochs](https://www.ultralytics.com/glossary/epoch), you can use the following code snippets. For a comprehensive list of available arguments, refer to the model [Training](../../modes/train.md) page.
45
+
46
+ !!! example "Train Example"
47
+
48
+ === "Python"
49
+
50
+ ```python
51
+ from ultralytics import YOLO
52
+
53
+ # Load a model
54
+ model = YOLO("yolo11n-cls.pt") # load a pretrained model (recommended for training)
55
+
56
+ # Train the model
57
+ results = model.train(data="caltech101", epochs=100, imgsz=416)
58
+ ```
59
+
60
+ === "CLI"
61
+
62
+ ```bash
63
+ # Start training from a pretrained *.pt model
64
+ yolo classify train data=caltech101 model=yolo11n-cls.pt epochs=100 imgsz=416
65
+ ```
66
+
67
+ ## Sample Images and Annotations
68
+
69
+ The Caltech-101 dataset contains high-quality color images of various objects, providing a well-structured dataset for [image classification](https://www.ultralytics.com/glossary/image-classification) tasks. Here are some examples of images from the dataset:
70
+
71
+ ![Dataset sample image](https://github.com/ultralytics/docs/releases/download/0/caltech101-sample-image.avif)
72
+
73
+ The example showcases the variety and complexity of the objects in the Caltech-101 dataset, emphasizing the significance of a diverse dataset for training robust object recognition models.
74
+
75
+ ## Citations and Acknowledgments
76
+
77
+ If you use the Caltech-101 dataset in your research or development work, please cite the following paper:
78
+
79
+ !!! quote ""
80
+
81
+ === "BibTeX"
82
+
83
+ ```bibtex
84
+ @article{fei2007learning,
85
+ title={Learning generative visual models from few training examples: An incremental Bayesian approach tested on 101 object categories},
86
+ author={Fei-Fei, Li and Fergus, Rob and Perona, Pietro},
87
+ journal={Computer vision and Image understanding},
88
+ volume={106},
89
+ number={1},
90
+ pages={59--70},
91
+ year={2007},
92
+ publisher={Elsevier}
93
+ }
94
+ ```
95
+
96
+ We would like to acknowledge Li Fei-Fei, Rob Fergus, and Pietro Perona for creating and maintaining the Caltech-101 dataset as a valuable resource for the machine learning and computer vision research community. For more information about the Caltech-101 dataset and its creators, visit the [Caltech-101 dataset website](https://data.caltech.edu/records/mzrjq-6wc02).
97
+
98
+ ## FAQ
99
+
100
+ ### What is the Caltech-101 dataset used for in machine learning?
101
+
102
+ The [Caltech-101](https://data.caltech.edu/records/mzrjq-6wc02) dataset is widely used in machine learning for object recognition tasks. It contains around 9,000 images across 101 categories, providing a challenging benchmark for evaluating object recognition algorithms. Researchers leverage it to train and test models, especially Convolutional [Neural Networks](https://www.ultralytics.com/glossary/neural-network-nn) (CNNs) and Support Vector Machines (SVMs), in computer vision.
103
+
104
+ ### How can I train an Ultralytics YOLO model on the Caltech-101 dataset?
105
+
106
+ To train an Ultralytics YOLO model on the Caltech-101 dataset, you can use the provided code snippets. For example, to train for 100 epochs:
107
+
108
+ !!! example "Train Example"
109
+
110
+ === "Python"
111
+
112
+ ```python
113
+ from ultralytics import YOLO
114
+
115
+ # Load a model
116
+ model = YOLO("yolo11n-cls.pt") # load a pretrained model (recommended for training)
117
+
118
+ # Train the model
119
+ results = model.train(data="caltech101", epochs=100, imgsz=416)
120
+ ```
121
+
122
+ === "CLI"
123
+
124
+ ```bash
125
+ # Start training from a pretrained *.pt model
126
+ yolo classify train data=caltech101 model=yolo11n-cls.pt epochs=100 imgsz=416
127
+ ```
128
+
129
+ For more detailed arguments and options, refer to the model [Training](../../modes/train.md) page.
130
+
131
+ ### What are the key features of the Caltech-101 dataset?
132
+
133
+ The Caltech-101 dataset includes:
134
+
135
+ - Around 9,000 color images across 101 categories.
136
+ - Categories covering a diverse range of objects, including animals, vehicles, and household items.
137
+ - Variable number of images per category, typically between 40 and 800.
138
+ - Variable image sizes, with most being medium resolution.
139
+
140
+ These features make it an excellent choice for training and evaluating object recognition models in machine learning and computer vision.
141
+
142
+ ### Why should I cite the Caltech-101 dataset in my research?
143
+
144
+ Citing the Caltech-101 dataset in your research acknowledges the creators' contributions and provides a reference for others who might use the dataset. The recommended citation is:
145
+
146
+ !!! quote ""
147
+
148
+ === "BibTeX"
149
+
150
+ ```bibtex
151
+ @article{fei2007learning,
152
+ title={Learning generative visual models from few training examples: An incremental Bayesian approach tested on 101 object categories},
153
+ author={Fei-Fei, Li and Fergus, Rob and Perona, Pietro},
154
+ journal={Computer vision and Image understanding},
155
+ volume={106},
156
+ number={1},
157
+ pages={59--70},
158
+ year={2007},
159
+ publisher={Elsevier}
160
+ }
161
+ ```
162
+
163
+ Citing helps in maintaining the integrity of academic work and assists peers in locating the original resource.
164
+
165
+ ### Can I use Ultralytics HUB for training models on the Caltech-101 dataset?
166
+
167
+ Yes, you can use [Ultralytics HUB](https://www.ultralytics.com/hub) for training models on the Caltech-101 dataset. Ultralytics HUB provides an intuitive platform for managing datasets, training models, and deploying them without extensive coding. For a detailed guide, refer to the [how to train your custom models with Ultralytics HUB](https://www.ultralytics.com/blog/how-to-train-your-custom-models-with-ultralytics-hub) blog post.
ultralytics-main/docs/en/datasets/classify/caltech256.md ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ comments: true
3
+ description: Explore the Caltech-256 dataset, featuring 30,000 images across 257 categories, ideal for training and testing object recognition algorithms.
4
+ keywords: Caltech-256 dataset, object classification, image dataset, machine learning, computer vision, deep learning, YOLO, training dataset
5
+ ---
6
+
7
+ # Caltech-256 Dataset
8
+
9
+ The [Caltech-256](https://data.caltech.edu/records/nyy15-4j048) dataset is an extensive collection of images used for object classification tasks. It contains around 30,000 images divided into 257 categories (256 object categories and 1 background category). The images are carefully curated and annotated to provide a challenging and diverse benchmark for object recognition algorithms.
10
+
11
+ <p align="center">
12
+ <br>
13
+ <iframe loading="lazy" width="720" height="405" src="https://www.youtube.com/embed/isc06_9qnM0"
14
+ title="YouTube video player" frameborder="0"
15
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
16
+ allowfullscreen>
17
+ </iframe>
18
+ <br>
19
+ <strong>Watch:</strong> How to Train <a href="https://www.ultralytics.com/glossary/image-classification">Image Classification</a> Model using Caltech-256 Dataset with Ultralytics HUB
20
+ </p>
21
+
22
+ !!! note "Automatic Data Splitting"
23
+
24
+ The Caltech-256 dataset, as provided, does not come with pre-defined train/validation splits. However, when you use the training commands provided in the usage examples below, the Ultralytics framework will automatically split the dataset for you. The default split used is 80% for the training set and 20% for the validation set.
25
+
26
+ ## Key Features
27
+
28
+ - The Caltech-256 dataset comprises around 30,000 color images divided into 257 categories.
29
+ - Each category contains a minimum of 80 images.
30
+ - The categories encompass a wide variety of real-world objects, including animals, vehicles, household items, and people.
31
+ - Images are of variable sizes and resolutions.
32
+ - Caltech-256 is widely used for training and testing in the field of machine learning, particularly for object recognition tasks.
33
+
34
+ ## Dataset Structure
35
+
36
+ Like [Caltech-101](../classify/caltech101.md), the Caltech-256 dataset does not have a formal split between training and testing sets. Users typically create their own splits according to their specific needs. A common practice is to use a random subset of images for training and the remaining images for testing.
37
+
38
+ ## Applications
39
+
40
+ The Caltech-256 dataset is extensively used for training and evaluating [deep learning](https://www.ultralytics.com/glossary/deep-learning-dl) models in object recognition tasks, such as [Convolutional Neural Networks](https://www.ultralytics.com/glossary/convolutional-neural-network-cnn) (CNNs), [Support Vector Machines](https://www.ultralytics.com/glossary/support-vector-machine-svm) (SVMs), and various other machine learning algorithms. Its diverse set of categories and high-quality images make it an invaluable dataset for research and development in the field of machine learning and [computer vision](https://www.ultralytics.com/glossary/computer-vision-cv).
41
+
42
+ ## Usage
43
+
44
+ To train a YOLO model on the Caltech-256 dataset for 100 [epochs](https://www.ultralytics.com/glossary/epoch), you can use the following code snippets. For a comprehensive list of available arguments, refer to the model [Training](../../modes/train.md) page.
45
+
46
+ !!! example "Train Example"
47
+
48
+ === "Python"
49
+
50
+ ```python
51
+ from ultralytics import YOLO
52
+
53
+ # Load a model
54
+ model = YOLO("yolo11n-cls.pt") # load a pretrained model (recommended for training)
55
+
56
+ # Train the model
57
+ results = model.train(data="caltech256", epochs=100, imgsz=416)
58
+ ```
59
+
60
+ === "CLI"
61
+
62
+ ```bash
63
+ # Start training from a pretrained *.pt model
64
+ yolo classify train data=caltech256 model=yolo11n-cls.pt epochs=100 imgsz=416
65
+ ```
66
+
67
+ ## Sample Images and Annotations
68
+
69
+ The Caltech-256 dataset contains high-quality color images of various objects, providing a comprehensive dataset for object recognition tasks. Here are some examples of images from the dataset ([credit](https://ml4a.github.io/demos/tsne_viewer.html)):
70
+
71
+ ![Dataset sample image](https://github.com/ultralytics/docs/releases/download/0/caltech256-sample-image.avif)
72
+
73
+ The example showcases the diversity and complexity of the objects in the Caltech-256 dataset, emphasizing the importance of a varied dataset for training robust object recognition models.
74
+
75
+ ## Citations and Acknowledgments
76
+
77
+ If you use the Caltech-256 dataset in your research or development work, please cite the following paper:
78
+
79
+ !!! quote ""
80
+
81
+ === "BibTeX"
82
+
83
+ ```bibtex
84
+ @article{griffin2007caltech,
85
+ title={Caltech-256 object category dataset},
86
+ author={Griffin, Gregory and Holub, Alex and Perona, Pietro},
87
+ year={2007}
88
+ }
89
+ ```
90
+
91
+ We would like to acknowledge Gregory Griffin, Alex Holub, and Pietro Perona for creating and maintaining the Caltech-256 dataset as a valuable resource for the [machine learning](https://www.ultralytics.com/glossary/machine-learning-ml) and computer vision research community. For more information about the Caltech-256 dataset and its creators, visit the [Caltech-256 dataset website](https://data.caltech.edu/records/nyy15-4j048).
92
+
93
+ ## FAQ
94
+
95
+ ### What is the Caltech-256 dataset and why is it important for machine learning?
96
+
97
+ The [Caltech-256](https://data.caltech.edu/records/nyy15-4j048) dataset is a large image dataset used primarily for object classification tasks in machine learning and computer vision. It consists of around 30,000 color images divided into 257 categories, covering a wide range of real-world objects. The dataset's diverse and high-quality images make it an excellent benchmark for evaluating object recognition algorithms, which is crucial for developing robust machine learning models.
98
+
99
+ ### How can I train a YOLO model on the Caltech-256 dataset using Python or CLI?
100
+
101
+ To train a YOLO model on the Caltech-256 dataset for 100 [epochs](https://www.ultralytics.com/glossary/epoch), you can use the following code snippets. Refer to the model [Training](../../modes/train.md) page for additional options.
102
+
103
+ !!! example "Train Example"
104
+
105
+ === "Python"
106
+
107
+ ```python
108
+ from ultralytics import YOLO
109
+
110
+ # Load a model
111
+ model = YOLO("yolo11n-cls.pt") # load a pretrained model
112
+
113
+ # Train the model
114
+ results = model.train(data="caltech256", epochs=100, imgsz=416)
115
+ ```
116
+
117
+ === "CLI"
118
+
119
+ ```bash
120
+ # Start training from a pretrained *.pt model
121
+ yolo classify train data=caltech256 model=yolo11n-cls.pt epochs=100 imgsz=416
122
+ ```
123
+
124
+ ### What are the most common use cases for the Caltech-256 dataset?
125
+
126
+ The Caltech-256 dataset is widely used for various object recognition tasks such as:
127
+
128
+ - Training Convolutional [Neural Networks](https://www.ultralytics.com/glossary/neural-network-nn) (CNNs)
129
+ - Evaluating the performance of Support Vector Machines (SVMs)
130
+ - Benchmarking new deep learning algorithms
131
+ - Developing [object detection](https://www.ultralytics.com/glossary/object-detection) models using frameworks like Ultralytics YOLO
132
+
133
+ Its diversity and comprehensive annotations make it ideal for research and development in machine learning and computer vision.
134
+
135
+ ### How is the Caltech-256 dataset structured and split for training and testing?
136
+
137
+ The Caltech-256 dataset does not come with a predefined split for training and testing. Users typically create their own splits according to their specific needs. A common approach is to randomly select a subset of images for training and use the remaining images for testing. This flexibility allows users to tailor the dataset to their specific project requirements and experimental setups.
138
+
139
+ ### Why should I use Ultralytics YOLO for training models on the Caltech-256 dataset?
140
+
141
+ Ultralytics YOLO models offer several advantages for training on the Caltech-256 dataset:
142
+
143
+ - **High Accuracy**: YOLO models are known for their state-of-the-art performance in object detection tasks.
144
+ - **Speed**: They provide real-time inference capabilities, making them suitable for applications requiring quick predictions.
145
+ - **Ease of Use**: With [Ultralytics HUB](https://www.ultralytics.com/hub), users can train, validate, and deploy models without extensive coding.
146
+ - **Pretrained Models**: Starting from pretrained models, like `yolo11n-cls.pt`, can significantly reduce training time and improve model [accuracy](https://www.ultralytics.com/glossary/accuracy).
147
+
148
+ For more details, explore our [comprehensive training guide](../../modes/train.md) and learn about [image classification](../../tasks/classify.md) with Ultralytics YOLO.
ultralytics-main/docs/en/datasets/classify/cifar10.md ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ comments: true
3
+ description: Explore the CIFAR-10 dataset, featuring 60,000 color images in 10 classes. Learn about its structure, applications, and how to train models using YOLO.
4
+ keywords: CIFAR-10, dataset, machine learning, computer vision, image classification, YOLO, deep learning, neural networks
5
+ ---
6
+
7
+ # CIFAR-10 Dataset
8
+
9
+ The [CIFAR-10](https://www.cs.toronto.edu/~kriz/cifar.html) (Canadian Institute For Advanced Research) dataset is a collection of images used widely for [machine learning](https://www.ultralytics.com/glossary/machine-learning-ml) and computer vision algorithms. It was developed by researchers at the CIFAR institute and consists of 60,000 32x32 color images in 10 different classes.
10
+
11
+ <p align="center">
12
+ <br>
13
+ <iframe loading="lazy" width="720" height="405" src="https://www.youtube.com/embed/fLBbyhPbWzY"
14
+ title="YouTube video player" frameborder="0"
15
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
16
+ allowfullscreen>
17
+ </iframe>
18
+ <br>
19
+ <strong>Watch:</strong> How to Train an <a href="https://www.ultralytics.com/glossary/image-classification">Image Classification</a> Model with CIFAR-10 Dataset using Ultralytics YOLO11
20
+ </p>
21
+
22
+ ## Key Features
23
+
24
+ - The CIFAR-10 dataset consists of 60,000 images, divided into 10 classes.
25
+ - Each class contains 6,000 images, split into 5,000 for training and 1,000 for testing.
26
+ - The images are colored and of size 32x32 pixels.
27
+ - The 10 different classes represent airplanes, cars, birds, cats, deer, dogs, frogs, horses, ships, and trucks.
28
+ - CIFAR-10 is commonly used for training and testing in the field of machine learning and computer vision.
29
+
30
+ ## Dataset Structure
31
+
32
+ The CIFAR-10 dataset is split into two subsets:
33
+
34
+ 1. **Training Set**: This subset contains 50,000 images used for training machine learning models.
35
+ 2. **Testing Set**: This subset consists of 10,000 images used for testing and benchmarking the trained models.
36
+
37
+ ## Applications
38
+
39
+ The CIFAR-10 dataset is widely used for training and evaluating [deep learning](https://www.ultralytics.com/glossary/deep-learning-dl) models in image classification tasks, such as [Convolutional Neural Networks](https://www.ultralytics.com/glossary/convolutional-neural-network-cnn) (CNNs), [Support Vector Machines](https://www.ultralytics.com/glossary/support-vector-machine-svm) (SVMs), and various other machine learning algorithms. The diversity of the dataset in terms of classes and the presence of color images make it a well-rounded dataset for research and development in the field of machine learning and computer vision.
40
+
41
+ ## Usage
42
+
43
+ To train a YOLO model on the CIFAR-10 dataset for 100 [epochs](https://www.ultralytics.com/glossary/epoch) with an image size of 32x32, you can use the following code snippets. For a comprehensive list of available arguments, refer to the model [Training](../../modes/train.md) page.
44
+
45
+ !!! example "Train Example"
46
+
47
+ === "Python"
48
+
49
+ ```python
50
+ from ultralytics import YOLO
51
+
52
+ # Load a model
53
+ model = YOLO("yolo11n-cls.pt") # load a pretrained model (recommended for training)
54
+
55
+ # Train the model
56
+ results = model.train(data="cifar10", epochs=100, imgsz=32)
57
+ ```
58
+
59
+ === "CLI"
60
+
61
+ ```bash
62
+ # Start training from a pretrained *.pt model
63
+ yolo classify train data=cifar10 model=yolo11n-cls.pt epochs=100 imgsz=32
64
+ ```
65
+
66
+ ## Sample Images and Annotations
67
+
68
+ The CIFAR-10 dataset contains color images of various objects, providing a well-structured dataset for image classification tasks. Here are some examples of images from the dataset:
69
+
70
+ ![Dataset sample image](https://github.com/ultralytics/docs/releases/download/0/cifar10-sample-image.avif)
71
+
72
+ The example showcases the variety and complexity of the objects in the CIFAR-10 dataset, highlighting the importance of a diverse dataset for training robust image classification models.
73
+
74
+ ## Citations and Acknowledgments
75
+
76
+ If you use the CIFAR-10 dataset in your research or development work, please cite the following paper:
77
+
78
+ !!! quote ""
79
+
80
+ === "BibTeX"
81
+
82
+ ```bibtex
83
+ @TECHREPORT{Krizhevsky09learningmultiple,
84
+ author={Alex Krizhevsky},
85
+ title={Learning multiple layers of features from tiny images},
86
+ institution={},
87
+ year={2009}
88
+ }
89
+ ```
90
+
91
+ We would like to acknowledge Alex Krizhevsky for creating and maintaining the CIFAR-10 dataset as a valuable resource for the machine learning and [computer vision](https://www.ultralytics.com/glossary/computer-vision-cv) research community. For more information about the CIFAR-10 dataset and its creator, visit the [CIFAR-10 dataset website](https://www.cs.toronto.edu/~kriz/cifar.html).
92
+
93
+ ## FAQ
94
+
95
+ ### How can I train a YOLO model on the CIFAR-10 dataset?
96
+
97
+ To train a YOLO model on the CIFAR-10 dataset using Ultralytics, you can follow the examples provided for both Python and CLI. Here is a basic example to train your model for 100 epochs with an image size of 32x32 pixels:
98
+
99
+ !!! example
100
+
101
+ === "Python"
102
+
103
+ ```python
104
+ from ultralytics import YOLO
105
+
106
+ # Load a model
107
+ model = YOLO("yolo11n-cls.pt") # load a pretrained model (recommended for training)
108
+
109
+ # Train the model
110
+ results = model.train(data="cifar10", epochs=100, imgsz=32)
111
+ ```
112
+
113
+ === "CLI"
114
+
115
+ ```bash
116
+ # Start training from a pretrained *.pt model
117
+ yolo classify train data=cifar10 model=yolo11n-cls.pt epochs=100 imgsz=32
118
+ ```
119
+
120
+ For more details, refer to the model [Training](../../modes/train.md) page.
121
+
122
+ ### What are the key features of the CIFAR-10 dataset?
123
+
124
+ The CIFAR-10 dataset consists of 60,000 color images divided into 10 classes. Each class contains 6,000 images, with 5,000 for training and 1,000 for testing. The images are 32x32 pixels in size and vary across the following categories:
125
+
126
+ - Airplanes
127
+ - Cars
128
+ - Birds
129
+ - Cats
130
+ - Deer
131
+ - Dogs
132
+ - Frogs
133
+ - Horses
134
+ - Ships
135
+ - Trucks
136
+
137
+ This diverse dataset is essential for training image classification models in fields such as machine learning and computer vision. For more information, visit the CIFAR-10 sections on [dataset structure](#dataset-structure) and [applications](#applications).
138
+
139
+ ### Why use the CIFAR-10 dataset for image classification tasks?
140
+
141
+ The CIFAR-10 dataset is an excellent benchmark for image classification due to its diversity and structure. It contains a balanced mix of 60,000 labeled images across 10 different categories, which helps in training robust and generalized models. It is widely used for evaluating deep learning models, including Convolutional [Neural Networks](https://www.ultralytics.com/glossary/neural-network-nn) (CNNs) and other machine learning algorithms. The dataset is relatively small, making it suitable for quick experimentation and algorithm development. Explore its numerous applications in the [applications](#applications) section.
142
+
143
+ ### How is the CIFAR-10 dataset structured?
144
+
145
+ The CIFAR-10 dataset is structured into two main subsets:
146
+
147
+ 1. **Training Set**: Contains 50,000 images used for training machine learning models.
148
+ 2. **Testing Set**: Consists of 10,000 images for testing and benchmarking the trained models.
149
+
150
+ Each subset comprises images categorized into 10 classes, with their annotations readily available for model training and evaluation. For more detailed information, refer to the [dataset structure](#dataset-structure) section.
151
+
152
+ ### How can I cite the CIFAR-10 dataset in my research?
153
+
154
+ If you use the CIFAR-10 dataset in your research or development projects, make sure to cite the following paper:
155
+
156
+ !!! quote ""
157
+
158
+ === "BibTeX"
159
+
160
+ ```bibtex
161
+ @TECHREPORT{Krizhevsky09learningmultiple,
162
+ author={Alex Krizhevsky},
163
+ title={Learning multiple layers of features from tiny images},
164
+ institution={},
165
+ year={2009}
166
+ }
167
+ ```
168
+
169
+ Acknowledging the dataset's creators helps support continued research and development in the field. For more details, see the [citations and acknowledgments](#citations-and-acknowledgments) section.
170
+
171
+ ### What are some practical examples of using the CIFAR-10 dataset?
172
+
173
+ The CIFAR-10 dataset is often used for training image classification models, such as Convolutional Neural Networks (CNNs) and Support Vector Machines (SVMs). These models can be employed in various computer vision tasks including [object detection](https://www.ultralytics.com/glossary/object-detection), [image recognition](https://www.ultralytics.com/glossary/image-recognition), and automated tagging. To see some practical examples, check the code snippets in the [usage](#usage) section.
ultralytics-main/docs/en/datasets/classify/cifar100.md ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ comments: true
3
+ description: Explore the CIFAR-100 dataset, consisting of 60,000 32x32 color images across 100 classes. Ideal for machine learning and computer vision tasks.
4
+ keywords: CIFAR-100, dataset, machine learning, computer vision, image classification, deep learning, YOLO, training, testing, Alex Krizhevsky
5
+ ---
6
+
7
+ # CIFAR-100 Dataset
8
+
9
+ The [CIFAR-100](https://www.cs.toronto.edu/~kriz/cifar.html) (Canadian Institute For Advanced Research) dataset is a significant extension of the CIFAR-10 dataset, composed of 60,000 32x32 color images in 100 different classes. It was developed by researchers at the CIFAR institute, offering a more challenging dataset for more complex machine learning and [computer vision](https://www.ultralytics.com/glossary/computer-vision-cv) tasks.
10
+
11
+ <p align="center">
12
+ <br>
13
+ <iframe loading="lazy" width="720" height="405" src="https://www.youtube.com/embed/6bZeCs0xwO4"
14
+ title="YouTube video player" frameborder="0"
15
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
16
+ allowfullscreen>
17
+ </iframe>
18
+ <br>
19
+ <strong>Watch:</strong> How to Train Ultralytics YOLO11 on CIFAR-100 | Step-by-Step Image Classification Tutorial 🚀
20
+ </p>
21
+
22
+ ## Key Features
23
+
24
+ - The CIFAR-100 dataset consists of 60,000 images, divided into 100 classes.
25
+ - Each class contains 600 images, split into 500 for training and 100 for testing.
26
+ - The images are colored and of size 32x32 pixels.
27
+ - The 100 different classes are grouped into 20 coarse categories for higher level classification.
28
+ - CIFAR-100 is commonly used for training and testing in the field of machine learning and computer vision.
29
+
30
+ ## Dataset Structure
31
+
32
+ The CIFAR-100 dataset is split into two subsets:
33
+
34
+ 1. **Training Set**: This subset contains 50,000 images used for training machine learning models.
35
+ 2. **Testing Set**: This subset consists of 10,000 images used for testing and benchmarking the trained models.
36
+
37
+ ## Applications
38
+
39
+ The CIFAR-100 dataset is extensively used for training and evaluating deep learning models in [image classification](https://www.ultralytics.com/glossary/image-classification) tasks, such as [Convolutional Neural Networks](https://www.ultralytics.com/glossary/convolutional-neural-network-cnn) (CNNs), [Support Vector Machines](https://www.ultralytics.com/glossary/support-vector-machine-svm) (SVMs), and various other machine learning algorithms. The diversity of the dataset in terms of classes and the presence of color images make it a more challenging and comprehensive dataset for research and development in the field of [machine learning](https://www.ultralytics.com/glossary/machine-learning-ml) and computer vision.
40
+
41
+ ## Usage
42
+
43
+ To train a YOLO model on the CIFAR-100 dataset for 100 [epochs](https://www.ultralytics.com/glossary/epoch) with an image size of 32x32, you can use the following code snippets. For a comprehensive list of available arguments, refer to the model [Training](../../modes/train.md) page.
44
+
45
+ !!! example "Train Example"
46
+
47
+ === "Python"
48
+
49
+ ```python
50
+ from ultralytics import YOLO
51
+
52
+ # Load a model
53
+ model = YOLO("yolo11n-cls.pt") # load a pretrained model (recommended for training)
54
+
55
+ # Train the model
56
+ results = model.train(data="cifar100", epochs=100, imgsz=32)
57
+ ```
58
+
59
+ === "CLI"
60
+
61
+ ```bash
62
+ # Start training from a pretrained *.pt model
63
+ yolo classify train data=cifar100 model=yolo11n-cls.pt epochs=100 imgsz=32
64
+ ```
65
+
66
+ ## Sample Images and Annotations
67
+
68
+ The CIFAR-100 dataset contains color images of various objects, providing a well-structured dataset for image classification tasks. Here are some examples of images from the dataset:
69
+
70
+ ![Dataset sample image](https://github.com/ultralytics/docs/releases/download/0/cifar100-sample-image.avif)
71
+
72
+ The example showcases the variety and complexity of the objects in the CIFAR-100 dataset, highlighting the importance of a diverse dataset for training robust image classification models.
73
+
74
+ ## Citations and Acknowledgments
75
+
76
+ If you use the CIFAR-100 dataset in your research or development work, please cite the following paper:
77
+
78
+ !!! quote ""
79
+
80
+ === "BibTeX"
81
+
82
+ ```bibtex
83
+ @TECHREPORT{Krizhevsky09learningmultiple,
84
+ author={Alex Krizhevsky},
85
+ title={Learning multiple layers of features from tiny images},
86
+ institution={},
87
+ year={2009}
88
+ }
89
+ ```
90
+
91
+ We would like to acknowledge Alex Krizhevsky for creating and maintaining the CIFAR-100 dataset as a valuable resource for the machine learning and computer vision research community. For more information about the CIFAR-100 dataset and its creator, visit the [CIFAR-100 dataset website](https://www.cs.toronto.edu/~kriz/cifar.html).
92
+
93
+ ## FAQ
94
+
95
+ ### What is the CIFAR-100 dataset and why is it significant?
96
+
97
+ The [CIFAR-100 dataset](https://www.cs.toronto.edu/~kriz/cifar.html) is a large collection of 60,000 32x32 color images classified into 100 classes. Developed by the Canadian Institute For Advanced Research (CIFAR), it provides a challenging dataset ideal for complex machine learning and computer vision tasks. Its significance lies in the diversity of classes and the small size of the images, making it a valuable resource for training and testing [deep learning](https://www.ultralytics.com/glossary/deep-learning-dl) models, like Convolutional [Neural Networks](https://www.ultralytics.com/glossary/neural-network-nn) (CNNs), using frameworks such as [Ultralytics YOLO](https://docs.ultralytics.com/models/yolo11/).
98
+
99
+ ### How do I train a YOLO model on the CIFAR-100 dataset?
100
+
101
+ You can train a YOLO model on the CIFAR-100 dataset using either Python or CLI commands. Here's how:
102
+
103
+ !!! example "Train Example"
104
+
105
+ === "Python"
106
+
107
+ ```python
108
+ from ultralytics import YOLO
109
+
110
+ # Load a model
111
+ model = YOLO("yolo11n-cls.pt") # load a pretrained model (recommended for training)
112
+
113
+ # Train the model
114
+ results = model.train(data="cifar100", epochs=100, imgsz=32)
115
+ ```
116
+
117
+ === "CLI"
118
+
119
+ ```bash
120
+ # Start training from a pretrained *.pt model
121
+ yolo classify train data=cifar100 model=yolo11n-cls.pt epochs=100 imgsz=32
122
+ ```
123
+
124
+ For a comprehensive list of available arguments, please refer to the model [Training](../../modes/train.md) page.
125
+
126
+ ### What are the primary applications of the CIFAR-100 dataset?
127
+
128
+ The CIFAR-100 dataset is extensively used in training and evaluating deep learning models for image classification. Its diverse set of 100 classes, grouped into 20 coarse categories, provides a challenging environment for testing algorithms such as Convolutional Neural Networks (CNNs), Support Vector Machines (SVMs), and various other machine learning approaches. This dataset is a key resource in research and development within machine learning and computer vision fields, particularly for [object recognition](https://docs.ultralytics.com/tasks/classify/) and classification tasks.
129
+
130
+ ### How is the CIFAR-100 dataset structured?
131
+
132
+ The CIFAR-100 dataset is split into two main subsets:
133
+
134
+ 1. **Training Set**: Contains 50,000 images used for training machine learning models.
135
+ 2. **Testing Set**: Consists of 10,000 images used for testing and benchmarking the trained models.
136
+
137
+ Each of the 100 classes contains 600 images, with 500 images for training and 100 for testing, making it uniquely suited for rigorous academic and industrial research.
138
+
139
+ ### Where can I find sample images and annotations from the CIFAR-100 dataset?
140
+
141
+ The CIFAR-100 dataset includes a variety of color images of various objects, making it a structured dataset for image classification tasks. You can refer to the documentation page to see [sample images and annotations](#sample-images-and-annotations). These examples highlight the dataset's diversity and complexity, important for training robust image classification models. For more datasets suitable for classification tasks, check out [Ultralytics' classification datasets overview](https://docs.ultralytics.com/datasets/classify/).
ultralytics-main/docs/en/datasets/classify/fashion-mnist.md ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ comments: true
3
+ description: Explore the Fashion-MNIST dataset, a modern replacement for MNIST with 70,000 Zalando article images. Ideal for benchmarking machine learning models.
4
+ keywords: Fashion-MNIST, image classification, Zalando dataset, machine learning, deep learning, CNN, dataset overview
5
+ ---
6
+
7
+ # Fashion-MNIST Dataset
8
+
9
+ The [Fashion-MNIST](https://github.com/zalandoresearch/fashion-mnist) dataset is a database of Zalando's article images—consisting of a training set of 60,000 examples and a test set of 10,000 examples. Each example is a 28x28 grayscale image, associated with a label from 10 classes. Fashion-MNIST is intended to serve as a direct drop-in replacement for the original MNIST dataset for benchmarking [machine learning](https://www.ultralytics.com/glossary/machine-learning-ml) algorithms.
10
+
11
+ <p align="center">
12
+ <br>
13
+ <iframe loading="lazy" width="720" height="405" src="https://www.youtube.com/embed/eX5ad6udQ9Q"
14
+ title="YouTube video player" frameborder="0"
15
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
16
+ allowfullscreen>
17
+ </iframe>
18
+ <br>
19
+ <strong>Watch:</strong> How to do <a href="https://www.ultralytics.com/glossary/image-classification">Image Classification</a> on Fashion MNIST Dataset using Ultralytics YOLO11
20
+ </p>
21
+
22
+ ## Key Features
23
+
24
+ - Fashion-MNIST contains 60,000 training images and 10,000 testing images of Zalando's article images.
25
+ - The dataset comprises grayscale images of size 28x28 pixels.
26
+ - Each pixel has a single pixel-value associated with it, indicating the lightness or darkness of that pixel, with higher numbers meaning darker. This pixel-value is an integer between 0 and 255.
27
+ - Fashion-MNIST is widely used for training and testing in the field of machine learning, especially for image classification tasks.
28
+
29
+ ## Dataset Structure
30
+
31
+ The Fashion-MNIST dataset is split into two subsets:
32
+
33
+ 1. **Training Set**: This subset contains 60,000 images used for training machine learning models.
34
+ 2. **Testing Set**: This subset consists of 10,000 images used for testing and benchmarking the trained models.
35
+
36
+ ## Labels
37
+
38
+ Each training and test example is assigned to one of the following labels:
39
+
40
+ ```
41
+ 0. T-shirt/top
42
+ 1. Trouser
43
+ 2. Pullover
44
+ 3. Dress
45
+ 4. Coat
46
+ 5. Sandal
47
+ 6. Shirt
48
+ 7. Sneaker
49
+ 8. Bag
50
+ 9. Ankle boot
51
+ ```
52
+
53
+ ## Applications
54
+
55
+ The Fashion-MNIST dataset is widely used for training and evaluating deep learning models in image classification tasks, such as [Convolutional Neural Networks](https://www.ultralytics.com/glossary/convolutional-neural-network-cnn) (CNNs), [Support Vector Machines](https://www.ultralytics.com/glossary/support-vector-machine-svm) (SVMs), and various other machine learning algorithms. The dataset's simple and well-structured format makes it an essential resource for researchers and practitioners in the field of machine learning and computer vision.
56
+
57
+ ## Usage
58
+
59
+ To train a CNN model on the Fashion-MNIST dataset for 100 [epochs](https://www.ultralytics.com/glossary/epoch) with an image size of 28x28, you can use the following code snippets. For a comprehensive list of available arguments, refer to the model [Training](../../modes/train.md) page.
60
+
61
+ !!! example "Train Example"
62
+
63
+ === "Python"
64
+
65
+ ```python
66
+ from ultralytics import YOLO
67
+
68
+ # Load a model
69
+ model = YOLO("yolo11n-cls.pt") # load a pretrained model (recommended for training)
70
+
71
+ # Train the model
72
+ results = model.train(data="fashion-mnist", epochs=100, imgsz=28)
73
+ ```
74
+
75
+ === "CLI"
76
+
77
+ ```bash
78
+ # Start training from a pretrained *.pt model
79
+ yolo classify train data=fashion-mnist model=yolo11n-cls.pt epochs=100 imgsz=28
80
+ ```
81
+
82
+ ## Sample Images and Annotations
83
+
84
+ The Fashion-MNIST dataset contains grayscale images of Zalando's article images, providing a well-structured dataset for image classification tasks. Here are some examples of images from the dataset:
85
+
86
+ ![Dataset sample image](https://github.com/ultralytics/docs/releases/download/0/fashion-mnist-sample.avif)
87
+
88
+ The example showcases the variety and complexity of the images in the Fashion-MNIST dataset, highlighting the importance of a diverse dataset for training robust image classification models.
89
+
90
+ ## Acknowledgments
91
+
92
+ If you use the Fashion-MNIST dataset in your research or development work, please acknowledge the dataset by linking to the [GitHub repository](https://github.com/zalandoresearch/fashion-mnist). This dataset was made available by Zalando Research.
93
+
94
+ ## FAQ
95
+
96
+ ### What is the Fashion-MNIST dataset and how is it different from MNIST?
97
+
98
+ The [Fashion-MNIST](https://github.com/zalandoresearch/fashion-mnist) dataset is a collection of 70,000 grayscale images of Zalando's article images, intended as a modern replacement for the original MNIST dataset. It serves as a benchmark for machine learning models in the context of image classification tasks. Unlike MNIST, which contains handwritten digits, Fashion-MNIST consists of 28x28-pixel images categorized into 10 fashion-related classes, such as T-shirt/top, trouser, and ankle boot.
99
+
100
+ ### How can I train a YOLO model on the Fashion-MNIST dataset?
101
+
102
+ To train an Ultralytics YOLO model on the Fashion-MNIST dataset, you can use both Python and CLI commands. Here's a quick example to get you started:
103
+
104
+ !!! example "Train Example"
105
+
106
+ === "Python"
107
+
108
+ ```python
109
+ from ultralytics import YOLO
110
+
111
+ # Load a pretrained model
112
+ model = YOLO("yolo11n-cls.pt")
113
+
114
+ # Train the model on Fashion-MNIST
115
+ results = model.train(data="fashion-mnist", epochs=100, imgsz=28)
116
+ ```
117
+
118
+
119
+ === "CLI"
120
+
121
+ ```bash
122
+ yolo classify train data=fashion-mnist model=yolo11n-cls.pt epochs=100 imgsz=28
123
+ ```
124
+
125
+ For more detailed training parameters, refer to the [Training page](../../modes/train.md).
126
+
127
+ ### Why should I use the Fashion-MNIST dataset for benchmarking my machine learning models?
128
+
129
+ The [Fashion-MNIST](https://github.com/zalandoresearch/fashion-mnist) dataset is widely recognized in the [deep learning](https://www.ultralytics.com/glossary/deep-learning-dl) community as a robust alternative to MNIST. It offers a more complex and varied set of images, making it an excellent choice for benchmarking image classification models. The dataset's structure, comprising 60,000 training images and 10,000 testing images, each labeled with one of 10 classes, makes it ideal for evaluating the performance of different machine learning algorithms in a more challenging context.
130
+
131
+ ### Can I use Ultralytics YOLO for image classification tasks like Fashion-MNIST?
132
+
133
+ Yes, Ultralytics YOLO models can be used for image classification tasks, including those involving the Fashion-MNIST dataset. YOLO11, for example, supports various vision tasks such as detection, segmentation, and classification. To get started with image classification tasks, refer to the [Classification page](https://docs.ultralytics.com/tasks/classify/).
134
+
135
+ ### What are the key features and structure of the Fashion-MNIST dataset?
136
+
137
+ The Fashion-MNIST dataset is divided into two main subsets: 60,000 training images and 10,000 testing images. Each image is a 28x28-pixel grayscale picture representing one of 10 fashion-related classes. The simplicity and well-structured format make it ideal for training and evaluating models in machine learning and [computer vision](https://www.ultralytics.com/glossary/computer-vision-cv) tasks. For more details on the dataset structure, see the [Dataset Structure section](#dataset-structure).
138
+
139
+ ### How can I acknowledge the use of the Fashion-MNIST dataset in my research?
140
+
141
+ If you utilize the Fashion-MNIST dataset in your research or development projects, it's important to acknowledge it by linking to the [GitHub repository](https://github.com/zalandoresearch/fashion-mnist). This helps in attributing the data to Zalando Research, who made the dataset available for public use.
ultralytics-main/docs/en/datasets/classify/imagenet.md ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ comments: true
3
+ description: Explore the extensive ImageNet dataset and discover its role in advancing deep learning in computer vision. Access pretrained models and training examples.
4
+ keywords: ImageNet, deep learning, visual recognition, computer vision, pretrained models, YOLO, dataset, object detection, image classification
5
+ ---
6
+
7
+ # ImageNet Dataset
8
+
9
+ [ImageNet](https://www.image-net.org/) is a large-scale database of annotated images designed for use in visual object recognition research. It contains over 14 million images, with each image annotated using WordNet synsets, making it one of the most extensive resources available for training [deep learning](https://www.ultralytics.com/glossary/deep-learning-dl) models in [computer vision](https://www.ultralytics.com/glossary/computer-vision-cv) tasks.
10
+
11
+ ## ImageNet Pretrained Models
12
+
13
+ {% include "macros/yolo-cls-perf.md" %}
14
+
15
+ ## Key Features
16
+
17
+ - ImageNet contains over 14 million high-resolution images spanning thousands of object categories.
18
+ - The dataset is organized according to the WordNet hierarchy, with each synset representing a category.
19
+ - ImageNet is widely used for training and benchmarking in the field of computer vision, particularly for [image classification](https://www.ultralytics.com/glossary/image-classification) and [object detection](https://www.ultralytics.com/glossary/object-detection) tasks.
20
+ - The annual ImageNet Large Scale Visual Recognition Challenge (ILSVRC) has been instrumental in advancing computer vision research.
21
+
22
+ ## Dataset Structure
23
+
24
+ The ImageNet dataset is organized using the WordNet hierarchy. Each node in the hierarchy represents a category, and each category is described by a synset (a collection of synonymous terms). The images in ImageNet are annotated with one or more synsets, providing a rich resource for training models to recognize various objects and their relationships.
25
+
26
+ ## ImageNet Large Scale Visual Recognition Challenge (ILSVRC)
27
+
28
+ The annual [ImageNet Large Scale Visual Recognition Challenge (ILSVRC)](https://image-net.org/challenges/LSVRC/) has been an important event in the field of computer vision. It has provided a platform for researchers and developers to evaluate their algorithms and models on a large-scale dataset with standardized evaluation metrics. The ILSVRC has led to significant advancements in the development of deep learning models for image classification, object detection, and other computer vision tasks.
29
+
30
+ ## Applications
31
+
32
+ The ImageNet dataset is widely used for training and evaluating deep learning models in various computer vision tasks, such as image classification, object detection, and object localization. Some popular deep learning architectures, such as [AlexNet](https://en.wikipedia.org/wiki/AlexNet), [VGG](https://arxiv.org/abs/1409.1556), and [ResNet](https://arxiv.org/abs/1512.03385), were developed and benchmarked using the ImageNet dataset.
33
+
34
+ ## Usage
35
+
36
+ To train a deep learning model on the ImageNet dataset for 100 [epochs](https://www.ultralytics.com/glossary/epoch) with an image size of 224x224, you can use the following code snippets. For a comprehensive list of available arguments, refer to the model [Training](../../modes/train.md) page.
37
+
38
+ !!! example "Train Example"
39
+
40
+ === "Python"
41
+
42
+ ```python
43
+ from ultralytics import YOLO
44
+
45
+ # Load a model
46
+ model = YOLO("yolo11n-cls.pt") # load a pretrained model (recommended for training)
47
+
48
+ # Train the model
49
+ results = model.train(data="imagenet", epochs=100, imgsz=224)
50
+ ```
51
+
52
+ === "CLI"
53
+
54
+ ```bash
55
+ # Start training from a pretrained *.pt model
56
+ yolo classify train data=imagenet model=yolo11n-cls.pt epochs=100 imgsz=224
57
+ ```
58
+
59
+ ## Sample Images and Annotations
60
+
61
+ The ImageNet dataset contains high-resolution images spanning thousands of object categories, providing a diverse and extensive dataset for training and evaluating computer vision models. Here are some examples of images from the dataset:
62
+
63
+ ![Dataset sample images](https://github.com/ultralytics/docs/releases/download/0/imagenet-sample-images.avif)
64
+
65
+ The example showcases the variety and complexity of the images in the ImageNet dataset, highlighting the importance of a diverse dataset for training robust computer vision models.
66
+
67
+ ## Citations and Acknowledgments
68
+
69
+ If you use the ImageNet dataset in your research or development work, please cite the following paper:
70
+
71
+ !!! quote ""
72
+
73
+ === "BibTeX"
74
+
75
+ ```bibtex
76
+ @article{ILSVRC15,
77
+ author = {Olga Russakovsky and Jia Deng and Hao Su and Jonathan Krause and Sanjeev Satheesh and Sean Ma and Zhiheng Huang and Andrej Karpathy and Aditya Khosla and Michael Bernstein and Alexander C. Berg and Li Fei-Fei},
78
+ title={ImageNet Large Scale Visual Recognition Challenge},
79
+ year={2015},
80
+ journal={International Journal of Computer Vision (IJCV)},
81
+ volume={115},
82
+ number={3},
83
+ pages={211-252}
84
+ }
85
+ ```
86
+
87
+ We would like to acknowledge the ImageNet team, led by Olga Russakovsky, Jia Deng, and Li Fei-Fei, for creating and maintaining the ImageNet dataset as a valuable resource for the [machine learning](https://www.ultralytics.com/glossary/machine-learning-ml) and computer vision research community. For more information about the ImageNet dataset and its creators, visit the [ImageNet website](https://www.image-net.org/).
88
+
89
+ ## FAQ
90
+
91
+ ### What is the ImageNet dataset and how is it used in computer vision?
92
+
93
+ The [ImageNet dataset](https://www.image-net.org/) is a large-scale database consisting of over 14 million high-resolution images categorized using WordNet synsets. It is extensively used in visual object recognition research, including image classification and object detection. The dataset's annotations and sheer volume provide a rich resource for training deep learning models. Notably, models like AlexNet, VGG, and ResNet have been trained and benchmarked using ImageNet, showcasing its role in advancing computer vision.
94
+
95
+ ### How can I use a pretrained YOLO model for image classification on the ImageNet dataset?
96
+
97
+ To use a pretrained Ultralytics YOLO model for image classification on the ImageNet dataset, follow these steps:
98
+
99
+ !!! example "Train Example"
100
+
101
+ === "Python"
102
+
103
+ ```python
104
+ from ultralytics import YOLO
105
+
106
+ # Load a model
107
+ model = YOLO("yolo11n-cls.pt") # load a pretrained model (recommended for training)
108
+
109
+ # Train the model
110
+ results = model.train(data="imagenet", epochs=100, imgsz=224)
111
+ ```
112
+
113
+ === "CLI"
114
+
115
+ ```bash
116
+ # Start training from a pretrained *.pt model
117
+ yolo classify train data=imagenet model=yolo11n-cls.pt epochs=100 imgsz=224
118
+ ```
119
+
120
+ For more in-depth training instruction, refer to our [Training page](../../modes/train.md).
121
+
122
+ ### Why should I use the Ultralytics YOLO11 pretrained models for my ImageNet dataset projects?
123
+
124
+ Ultralytics YOLO11 pretrained models offer state-of-the-art performance in terms of speed and [accuracy](https://www.ultralytics.com/glossary/accuracy) for various computer vision tasks. For example, the YOLO11n-cls model, with a top-1 accuracy of 70.0% and a top-5 accuracy of 89.4%, is optimized for real-time applications. Pretrained models reduce the computational resources required for training from scratch and accelerate development cycles. Learn more about the performance metrics of YOLO11 models in the [ImageNet Pretrained Models section](#imagenet-pretrained-models).
125
+
126
+ ### How is the ImageNet dataset structured, and why is it important?
127
+
128
+ The ImageNet dataset is organized using the WordNet hierarchy, where each node in the hierarchy represents a category described by a synset (a collection of synonymous terms). This structure allows for detailed annotations, making it ideal for training models to recognize a wide variety of objects. The diversity and annotation richness of ImageNet make it a valuable dataset for developing robust and generalizable deep learning models. More about this organization can be found in the [Dataset Structure](#dataset-structure) section.
129
+
130
+ ### What role does the ImageNet Large Scale Visual Recognition Challenge (ILSVRC) play in computer vision?
131
+
132
+ The annual [ImageNet Large Scale Visual Recognition Challenge (ILSVRC)](https://image-net.org/challenges/LSVRC/) has been pivotal in driving advancements in computer vision by providing a competitive platform for evaluating algorithms on a large-scale, standardized dataset. It offers standardized evaluation metrics, fostering innovation and development in areas such as image classification, object detection, and [image segmentation](https://www.ultralytics.com/glossary/image-segmentation). The challenge has continuously pushed the boundaries of what is possible with deep learning and computer vision technologies.
ultralytics-main/docs/en/datasets/classify/imagenet10.md ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ comments: true
3
+ description: Discover ImageNet10 a compact version of ImageNet for rapid model testing and CI checks. Perfect for quick evaluations in computer vision tasks.
4
+ keywords: ImageNet10, ImageNet, Ultralytics, CI tests, sanity checks, training pipelines, computer vision, deep learning, dataset
5
+ ---
6
+
7
+ # ImageNet10 Dataset
8
+
9
+ The [ImageNet10](https://github.com/ultralytics/assets/releases/download/v0.0.0/imagenet10.zip) dataset is a small-scale subset of the [ImageNet](https://www.image-net.org/) database, developed by [Ultralytics](https://www.ultralytics.com/) and designed for CI tests, sanity checks, and fast testing of training pipelines. This dataset is composed of the first image in the training set and the first image from the validation set of the first 10 classes in ImageNet. Although significantly smaller, it retains the structure and diversity of the original ImageNet dataset.
10
+
11
+ ## Key Features
12
+
13
+ - ImageNet10 is a compact version of ImageNet, with 20 images representing the first 10 classes of the original dataset.
14
+ - The dataset is organized according to the WordNet hierarchy, mirroring the structure of the full ImageNet dataset.
15
+ - It is ideally suited for CI tests, sanity checks, and rapid testing of training pipelines in [computer vision](https://www.ultralytics.com/glossary/computer-vision-cv) tasks.
16
+ - Although not designed for model benchmarking, it can provide a quick indication of a model's basic functionality and correctness.
17
+
18
+ ## Dataset Structure
19
+
20
+ The ImageNet10 dataset, like the original [ImageNet](../classify/imagenet.md), is organized using the WordNet hierarchy. Each of the 10 classes in ImageNet10 is described by a synset (a collection of synonymous terms). The images in ImageNet10 are annotated with one or more synsets, providing a compact resource for testing models to recognize various objects and their relationships.
21
+
22
+ ## Applications
23
+
24
+ The ImageNet10 dataset is useful for quickly testing and debugging computer vision models and pipelines. Its small size allows for rapid iteration, making it ideal for [continuous integration](../../help/CI.md) tests and sanity checks. It can also be used for fast preliminary testing of new models or changes to existing models before moving on to full-scale testing with the complete [ImageNet dataset](../classify/imagenet.md).
25
+
26
+ ## Usage
27
+
28
+ To test a deep learning model on the ImageNet10 dataset with an image size of 224x224, you can use the following code snippets. For a comprehensive list of available arguments, refer to the model [Training](../../modes/train.md) page.
29
+
30
+ !!! example "Test Example"
31
+
32
+ === "Python"
33
+
34
+ ```python
35
+ from ultralytics import YOLO
36
+
37
+ # Load a model
38
+ model = YOLO("yolo11n-cls.pt") # load a pretrained model (recommended for training)
39
+
40
+ # Train the model
41
+ results = model.train(data="imagenet10", epochs=5, imgsz=224)
42
+ ```
43
+
44
+ === "CLI"
45
+
46
+ ```bash
47
+ # Start training from a pretrained *.pt model
48
+ yolo classify train data=imagenet10 model=yolo11n-cls.pt epochs=5 imgsz=224
49
+ ```
50
+
51
+ ## Sample Images and Annotations
52
+
53
+ The ImageNet10 dataset contains a subset of images from the original ImageNet dataset. These images are chosen to represent the first 10 classes in the dataset, providing a diverse yet compact dataset for quick testing and evaluation.
54
+
55
+ ![Dataset sample images](https://github.com/ultralytics/docs/releases/download/0/imagenet10-sample-images.avif)
56
+
57
+ The example showcases the variety and complexity of the images in the ImageNet10 dataset, highlighting its usefulness for sanity checks and quick testing of computer vision models.
58
+
59
+ ## Citations and Acknowledgments
60
+
61
+ If you use the ImageNet10 dataset in your research or development work, please cite the original ImageNet paper:
62
+
63
+ !!! quote ""
64
+
65
+ === "BibTeX"
66
+
67
+ ```bibtex
68
+ @article{ILSVRC15,
69
+ author = {Olga Russakovsky and Jia Deng and Hao Su and Jonathan Krause and Sanjeev Satheesh and Sean Ma and Zhiheng Huang and Andrej Karpathy and Aditya Khosla and Michael Bernstein and Alexander C. Berg and Li Fei-Fei},
70
+ title={ImageNet Large Scale Visual Recognition Challenge},
71
+ year={2015},
72
+ journal={International Journal of Computer Vision (IJCV)},
73
+ volume={115},
74
+ number={3},
75
+ pages={211-252}
76
+ }
77
+ ```
78
+
79
+ We would like to acknowledge the ImageNet team, led by Olga Russakovsky, Jia Deng, and Li Fei-Fei, for creating and maintaining the ImageNet dataset. The ImageNet10 dataset, while a compact subset, is a valuable resource for quick testing and debugging in the [machine learning](https://www.ultralytics.com/glossary/machine-learning-ml) and computer vision research community. For more information about the ImageNet dataset and its creators, visit the [ImageNet website](https://www.image-net.org/).
80
+
81
+ ## FAQ
82
+
83
+ ### What is the ImageNet10 dataset and how is it different from the full ImageNet dataset?
84
+
85
+ The [ImageNet10](https://github.com/ultralytics/assets/releases/download/v0.0.0/imagenet10.zip) dataset is a compact subset of the original [ImageNet](https://www.image-net.org/) database, created by Ultralytics for rapid CI tests, sanity checks, and training pipeline evaluations. ImageNet10 comprises only 20 images, representing the first image in the training and validation sets of the first 10 classes in ImageNet. Despite its small size, it maintains the structure and diversity of the full dataset, making it ideal for quick testing but not for benchmarking models.
86
+
87
+ ### How can I use the ImageNet10 dataset to test my deep learning model?
88
+
89
+ To test your deep learning model on the ImageNet10 dataset with an image size of 224x224, use the following code snippets.
90
+
91
+ !!! example "Test Example"
92
+
93
+ === "Python"
94
+
95
+ ```python
96
+ from ultralytics import YOLO
97
+
98
+ # Load a model
99
+ model = YOLO("yolo11n-cls.pt") # load a pretrained model (recommended for training)
100
+
101
+ # Train the model
102
+ results = model.train(data="imagenet10", epochs=5, imgsz=224)
103
+ ```
104
+
105
+ === "CLI"
106
+
107
+ ```bash
108
+ # Start training from a pretrained *.pt model
109
+ yolo classify train data=imagenet10 model=yolo11n-cls.pt epochs=5 imgsz=224
110
+ ```
111
+
112
+ Refer to the [Training](../../modes/train.md) page for a comprehensive list of available arguments.
113
+
114
+ ### Why should I use the ImageNet10 dataset for CI tests and sanity checks?
115
+
116
+ The ImageNet10 dataset is designed specifically for CI tests, sanity checks, and quick evaluations in [deep learning](https://www.ultralytics.com/glossary/deep-learning-dl) pipelines. Its small size allows for rapid iteration and testing, making it perfect for continuous integration processes where speed is crucial. By maintaining the structural complexity and diversity of the original ImageNet dataset, ImageNet10 provides a reliable indication of a model's basic functionality and correctness without the overhead of processing a large dataset.
117
+
118
+ ### What are the main features of the ImageNet10 dataset?
119
+
120
+ The ImageNet10 dataset has several key features:
121
+
122
+ - **Compact Size**: With only 20 images, it allows for rapid testing and debugging.
123
+ - **Structured Organization**: Follows the WordNet hierarchy, similar to the full ImageNet dataset.
124
+ - **CI and Sanity Checks**: Ideally suited for continuous integration tests and sanity checks.
125
+ - **Not for Benchmarking**: While useful for quick model evaluations, it is not designed for extensive benchmarking.
126
+
127
+ ### How does ImageNet10 compare to other small datasets like ImageNette?
128
+
129
+ While both [ImageNet10](imagenet10.md) and [ImageNette](imagenette.md) are subsets of ImageNet, they serve different purposes. ImageNet10 contains just 20 images (2 per class) from the first 10 classes of ImageNet, making it extremely lightweight for CI testing and quick sanity checks. In contrast, ImageNette contains thousands of images across 10 easily distinguishable classes, making it more suitable for actual model training and development. ImageNet10 is designed for verification of pipeline functionality, while ImageNette is better for meaningful but faster-than-full-ImageNet training experiments.
ultralytics-main/docs/en/datasets/classify/imagenette.md ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ comments: true
3
+ description: Explore the ImageNette dataset, a subset of ImageNet with 10 classes for efficient training and evaluation of image classification models. Ideal for ML and CV projects.
4
+ keywords: ImageNette dataset, ImageNet subset, image classification, machine learning, deep learning, YOLO, Convolutional Neural Networks, ML dataset, education, training
5
+ ---
6
+
7
+ # ImageNette Dataset
8
+
9
+ The [ImageNette](https://github.com/fastai/imagenette) dataset is a subset of the larger [ImageNet](https://www.image-net.org/) dataset, but it only includes 10 easily distinguishable classes. It was created to provide a quicker, easier-to-use version of ImageNet for software development and education.
10
+
11
+ ## Key Features
12
+
13
+ - ImageNette contains images from 10 different classes such as tench, English springer, cassette player, chain saw, church, French horn, garbage truck, gas pump, golf ball, parachute.
14
+ - The dataset comprises colored images of varying dimensions.
15
+ - ImageNette is widely used for training and testing in the field of machine learning, especially for image classification tasks.
16
+
17
+ ## Dataset Structure
18
+
19
+ The ImageNette dataset is split into two subsets:
20
+
21
+ 1. **Training Set**: This subset contains several thousands of images used for training machine learning models. The exact number varies per class.
22
+ 2. **Validation Set**: This subset consists of several hundreds of images used for validating and benchmarking the trained models. Again, the exact number varies per class.
23
+
24
+ ## Applications
25
+
26
+ The ImageNette dataset is widely used for training and evaluating [deep learning](https://www.ultralytics.com/glossary/deep-learning-dl) models in image classification tasks, such as [Convolutional Neural Networks](https://www.ultralytics.com/glossary/convolutional-neural-network-cnn) (CNNs), and various other machine learning algorithms. The dataset's straightforward format and well-chosen classes make it a handy resource for both beginner and experienced practitioners in the field of [machine learning](https://www.ultralytics.com/glossary/machine-learning-ml) and [computer vision](https://www.ultralytics.com/glossary/computer-vision-cv).
27
+
28
+ ## Usage
29
+
30
+ To train a model on the ImageNette dataset for 100 epochs with a standard image size of 224x224, you can use the following code snippets. For a comprehensive list of available arguments, refer to the model [Training](../../modes/train.md) page.
31
+
32
+ !!! example "Train Example"
33
+
34
+ === "Python"
35
+
36
+ ```python
37
+ from ultralytics import YOLO
38
+
39
+ # Load a model
40
+ model = YOLO("yolo11n-cls.pt") # load a pretrained model (recommended for training)
41
+
42
+ # Train the model
43
+ results = model.train(data="imagenette", epochs=100, imgsz=224)
44
+ ```
45
+
46
+ === "CLI"
47
+
48
+ ```bash
49
+ # Start training from a pretrained *.pt model
50
+ yolo classify train data=imagenette model=yolo11n-cls.pt epochs=100 imgsz=224
51
+ ```
52
+
53
+ ## Sample Images and Annotations
54
+
55
+ The ImageNette dataset contains colored images of various objects and scenes, providing a diverse dataset for [image classification](https://www.ultralytics.com/glossary/image-classification) tasks. Here are some examples of images from the dataset:
56
+
57
+ ![Dataset sample image](https://github.com/ultralytics/docs/releases/download/0/imagenette-sample-image.avif)
58
+
59
+ The example showcases the variety and complexity of the images in the ImageNette dataset, highlighting the importance of a diverse dataset for training robust image classification models.
60
+
61
+ ## ImageNette160 and ImageNette320
62
+
63
+ For faster prototyping and training, the ImageNette dataset is also available in two reduced sizes: [ImageNette160](https://github.com/fastai/imagenette) and [ImageNette320](https://github.com/fastai/imagenette). These datasets maintain the same classes and structure as the full ImageNette dataset, but the images are resized to a smaller dimension. As such, these versions of the dataset are particularly useful for preliminary model testing, or when computational resources are limited.
64
+
65
+ To use these datasets, simply replace 'imagenette' with 'imagenette160' or 'imagenette320' in the training command. The following code snippets illustrate this:
66
+
67
+ !!! example "Train Example with ImageNette160"
68
+
69
+ === "Python"
70
+
71
+ ```python
72
+ from ultralytics import YOLO
73
+
74
+ # Load a model
75
+ model = YOLO("yolo11n-cls.pt") # load a pretrained model (recommended for training)
76
+
77
+ # Train the model with ImageNette160
78
+ results = model.train(data="imagenette160", epochs=100, imgsz=160)
79
+ ```
80
+
81
+ === "CLI"
82
+
83
+ ```bash
84
+ # Start training from a pretrained *.pt model with ImageNette160
85
+ yolo classify train data=imagenette160 model=yolo11n-cls.pt epochs=100 imgsz=160
86
+ ```
87
+
88
+ !!! example "Train Example with ImageNette320"
89
+
90
+ === "Python"
91
+
92
+ ```python
93
+ from ultralytics import YOLO
94
+
95
+ # Load a model
96
+ model = YOLO("yolo11n-cls.pt") # load a pretrained model (recommended for training)
97
+
98
+ # Train the model with ImageNette320
99
+ results = model.train(data="imagenette320", epochs=100, imgsz=320)
100
+ ```
101
+
102
+ === "CLI"
103
+
104
+ ```bash
105
+ # Start training from a pretrained *.pt model with ImageNette320
106
+ yolo classify train data=imagenette320 model=yolo11n-cls.pt epochs=100 imgsz=320
107
+ ```
108
+
109
+ These smaller versions of the dataset allow for rapid iterations during the development process while still providing valuable and realistic image classification tasks.
110
+
111
+ ## Citations and Acknowledgments
112
+
113
+ If you use the ImageNette dataset in your research or development work, please acknowledge it appropriately. For more information about the ImageNette dataset, visit the [ImageNette dataset GitHub page](https://github.com/fastai/imagenette).
114
+
115
+ ## FAQ
116
+
117
+ ### What is the ImageNette dataset?
118
+
119
+ The [ImageNette dataset](https://github.com/fastai/imagenette) is a simplified subset of the larger [ImageNet dataset](https://www.image-net.org/), featuring only 10 easily distinguishable classes such as tench, English springer, and French horn. It was created to offer a more manageable dataset for efficient training and evaluation of image classification models. This dataset is particularly useful for quick software development and educational purposes in [machine learning](https://www.ultralytics.com/glossary/machine-learning-ml) and computer vision.
120
+
121
+ ### How can I use the ImageNette dataset for training a YOLO model?
122
+
123
+ To train a YOLO model on the ImageNette dataset for 100 [epochs](https://www.ultralytics.com/glossary/epoch), you can use the following commands. Make sure to have the Ultralytics YOLO environment set up.
124
+
125
+ !!! example "Train Example"
126
+
127
+ === "Python"
128
+
129
+ ```python
130
+ from ultralytics import YOLO
131
+
132
+ # Load a model
133
+ model = YOLO("yolo11n-cls.pt") # load a pretrained model (recommended for training)
134
+
135
+ # Train the model
136
+ results = model.train(data="imagenette", epochs=100, imgsz=224)
137
+ ```
138
+
139
+ === "CLI"
140
+
141
+ ```bash
142
+ # Start training from a pretrained *.pt model
143
+ yolo classify train data=imagenette model=yolo11n-cls.pt epochs=100 imgsz=224
144
+ ```
145
+
146
+ For more details, see the [Training](../../modes/train.md) documentation page.
147
+
148
+ ### Why should I use ImageNette for image classification tasks?
149
+
150
+ The ImageNette dataset is advantageous for several reasons:
151
+
152
+ - **Quick and Simple**: It contains only 10 classes, making it less complex and time-consuming compared to larger datasets.
153
+ - **Educational Use**: Ideal for learning and teaching the basics of image classification since it requires less computational power and time.
154
+ - **Versatility**: Widely used to train and benchmark various machine learning models, especially in image classification.
155
+
156
+ For more details on model training and dataset management, explore the [Dataset Structure](#dataset-structure) section.
157
+
158
+ ### Can the ImageNette dataset be used with different image sizes?
159
+
160
+ Yes, the ImageNette dataset is also available in two resized versions: ImageNette160 and ImageNette320. These versions help in faster prototyping and are especially useful when computational resources are limited.
161
+
162
+ !!! example "Train Example with ImageNette160"
163
+
164
+ === "Python"
165
+
166
+ ```python
167
+ from ultralytics import YOLO
168
+
169
+ # Load a model
170
+ model = YOLO("yolo11n-cls.pt")
171
+
172
+ # Train the model with ImageNette160
173
+ results = model.train(data="imagenette160", epochs=100, imgsz=160)
174
+ ```
175
+
176
+ === "CLI"
177
+
178
+ ```bash
179
+ # Start training from a pretrained *.pt model with ImageNette160
180
+ yolo classify train data=imagenette160 model=yolo11n-cls.pt epochs=100 imgsz=160
181
+ ```
182
+
183
+ For more information, refer to [Training with ImageNette160 and ImageNette320](#imagenette160-and-imagenette320).
184
+
185
+ ### What are some practical applications of the ImageNette dataset?
186
+
187
+ The ImageNette dataset is extensively used in:
188
+
189
+ - **Educational Settings**: To educate beginners in machine learning and [computer vision](https://www.ultralytics.com/glossary/computer-vision-cv).
190
+ - **Software Development**: For rapid prototyping and development of image classification models.
191
+ - **Deep Learning Research**: To evaluate and benchmark the performance of various deep learning models, especially Convolutional [Neural Networks](https://www.ultralytics.com/glossary/neural-network-nn) (CNNs).
192
+
193
+ Explore the [Applications](#applications) section for detailed use cases.
ultralytics-main/docs/en/datasets/classify/imagewoof.md ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ comments: true
3
+ description: Explore the ImageWoof dataset, a challenging subset of ImageNet focusing on 10 dog breeds, designed to enhance image classification models. Learn more on Ultralytics Docs.
4
+ keywords: ImageWoof dataset, ImageNet subset, dog breeds, image classification, deep learning, machine learning, Ultralytics, training dataset, noisy labels
5
+ ---
6
+
7
+ # ImageWoof Dataset
8
+
9
+ The [ImageWoof](https://github.com/fastai/imagenette) dataset is a subset of the [ImageNet](imagenet.md) consisting of 10 classes that are challenging to classify, since they're all dog breeds. It was created as a more difficult task for [image classification](https://www.ultralytics.com/glossary/image-classification) algorithms to solve, aiming at encouraging development of more advanced models.
10
+
11
+ ## Key Features
12
+
13
+ - ImageWoof contains images of 10 different dog breeds: Australian terrier, Border terrier, Samoyed, Beagle, Shih-Tzu, English foxhound, Rhodesian ridgeback, Dingo, Golden retriever, and Old English sheepdog.
14
+ - The dataset provides images at various resolutions (full size, 320px, 160px), accommodating for different computational capabilities and research needs.
15
+ - It also includes a version with noisy labels, providing a more realistic scenario where labels might not always be reliable.
16
+
17
+ ## Dataset Structure
18
+
19
+ The ImageWoof dataset structure is based on the dog breed classes, with each breed having its own directory of images. Similar to other classification datasets, it follows a split-directory format with separate folders for training and validation sets.
20
+
21
+ ## Applications
22
+
23
+ The ImageWoof dataset is widely used for training and evaluating [deep learning](https://www.ultralytics.com/glossary/deep-learning-dl) models in image classification tasks, especially when it comes to more complex and similar classes. The dataset's challenge lies in the subtle differences between the dog breeds, pushing the limits of model's performance and generalization. It's particularly valuable for:
24
+
25
+ - Benchmarking classification model performance on fine-grained categories
26
+ - Testing model robustness against similar-looking classes
27
+ - Developing algorithms that can distinguish subtle visual differences
28
+ - Evaluating transfer learning capabilities from general to specific domains
29
+
30
+ ## Usage
31
+
32
+ To train a CNN model on the ImageWoof dataset for 100 [epochs](https://www.ultralytics.com/glossary/epoch) with an image size of 224x224, you can use the following code snippets. For a comprehensive list of available arguments, refer to the model [Training](../../modes/train.md) page.
33
+
34
+ !!! example "Train Example"
35
+
36
+ === "Python"
37
+
38
+ ```python
39
+ from ultralytics import YOLO
40
+
41
+ # Load a model
42
+ model = YOLO("yolo11n-cls.pt") # load a pretrained model (recommended for training)
43
+
44
+ # Train the model
45
+ results = model.train(data="imagewoof", epochs=100, imgsz=224)
46
+ ```
47
+
48
+ === "CLI"
49
+
50
+ ```bash
51
+ # Start training from a pretrained *.pt model
52
+ yolo classify train data=imagewoof model=yolo11n-cls.pt epochs=100 imgsz=224
53
+ ```
54
+
55
+ ## Dataset Variants
56
+
57
+ ImageWoof dataset comes in three different sizes to accommodate various research needs and computational capabilities:
58
+
59
+ 1. **Full Size (imagewoof)**: This is the original version of the ImageWoof dataset. It contains full-sized images and is ideal for final training and performance benchmarking.
60
+
61
+ 2. **Medium Size (imagewoof320)**: This version contains images resized to have a maximum edge length of 320 pixels. It's suitable for faster training without significantly sacrificing model performance.
62
+
63
+ 3. **Small Size (imagewoof160)**: This version contains images resized to have a maximum edge length of 160 pixels. It's designed for rapid prototyping and experimentation where training speed is a priority.
64
+
65
+ To use these variants in your training, simply replace 'imagewoof' in the dataset argument with 'imagewoof320' or 'imagewoof160'. For example:
66
+
67
+ !!! example
68
+
69
+ === "Python"
70
+
71
+ ```python
72
+ from ultralytics import YOLO
73
+
74
+ # Load a model
75
+ model = YOLO("yolo11n-cls.pt") # load a pretrained model (recommended for training)
76
+
77
+ # For medium-sized dataset
78
+ model.train(data="imagewoof320", epochs=100, imgsz=224)
79
+
80
+ # For small-sized dataset
81
+ model.train(data="imagewoof160", epochs=100, imgsz=224)
82
+ ```
83
+
84
+ === "CLI"
85
+
86
+ ```bash
87
+ # Load a pretrained model and train on the medium-sized dataset
88
+ yolo classify train model=yolo11n-cls.pt data=imagewoof320 epochs=100 imgsz=224
89
+ ```
90
+
91
+ It's important to note that using smaller images will likely yield lower performance in terms of classification accuracy. However, it's an excellent way to iterate quickly in the early stages of model development and prototyping.
92
+
93
+ ## Sample Images and Annotations
94
+
95
+ The ImageWoof dataset contains colorful images of various dog breeds, providing a challenging dataset for image classification tasks. Here are some examples of images from the dataset:
96
+
97
+ ![Dataset sample image](https://github.com/ultralytics/docs/releases/download/0/imagewoof-dataset-sample.avif)
98
+
99
+ The example showcases the subtle differences and similarities among the different dog breeds in the ImageWoof dataset, highlighting the complexity and difficulty of the classification task.
100
+
101
+ ## Citations and Acknowledgments
102
+
103
+ If you use the ImageWoof dataset in your research or development work, please make sure to acknowledge the creators of the dataset by linking to the [official dataset repository](https://github.com/fastai/imagenette).
104
+
105
+ We would like to acknowledge the [FastAI](https://www.fast.ai/) team for creating and maintaining the ImageWoof dataset as a valuable resource for the [machine learning](https://www.ultralytics.com/glossary/machine-learning-ml) and [computer vision](https://www.ultralytics.com/glossary/computer-vision-cv) research community. For more information about the ImageWoof dataset, visit the [ImageWoof dataset repository](https://github.com/fastai/imagenette).
106
+
107
+ ## FAQ
108
+
109
+ ### What is the ImageWoof dataset in Ultralytics?
110
+
111
+ The [ImageWoof](https://github.com/fastai/imagenette) dataset is a challenging subset of ImageNet focusing on 10 specific dog breeds. Created to push the limits of image classification models, it features breeds like Beagle, Shih-Tzu, and Golden Retriever. The dataset includes images at various resolutions (full size, 320px, 160px) and even noisy labels for more realistic training scenarios. This complexity makes ImageWoof ideal for developing more advanced deep learning models.
112
+
113
+ ### How can I train a model using the ImageWoof dataset with Ultralytics YOLO?
114
+
115
+ To train a [Convolutional Neural Network](https://www.ultralytics.com/glossary/convolutional-neural-network-cnn) (CNN) model on the ImageWoof dataset using Ultralytics YOLO for 100 epochs at an image size of 224x224, you can use the following code:
116
+
117
+ !!! example "Train Example"
118
+
119
+ === "Python"
120
+
121
+ ```python
122
+ from ultralytics import YOLO
123
+
124
+ model = YOLO("yolo11n-cls.pt") # Load a pretrained model
125
+ results = model.train(data="imagewoof", epochs=100, imgsz=224)
126
+ ```
127
+
128
+
129
+ === "CLI"
130
+
131
+ ```bash
132
+ yolo classify train data=imagewoof model=yolo11n-cls.pt epochs=100 imgsz=224
133
+ ```
134
+
135
+ For more details on available training arguments, refer to the [Training](../../modes/train.md) page.
136
+
137
+ ### What versions of the ImageWoof dataset are available?
138
+
139
+ The ImageWoof dataset comes in three sizes:
140
+
141
+ 1. **Full Size (imagewoof)**: Ideal for final training and benchmarking, containing full-sized images.
142
+ 2. **Medium Size (imagewoof320)**: Resized images with a maximum edge length of 320 pixels, suited for faster training.
143
+ 3. **Small Size (imagewoof160)**: Resized images with a maximum edge length of 160 pixels, perfect for rapid prototyping.
144
+
145
+ Use these versions by replacing 'imagewoof' in the dataset argument accordingly. Note, however, that smaller images may yield lower classification [accuracy](https://www.ultralytics.com/glossary/accuracy) but can be useful for quicker iterations.
146
+
147
+ ### How do noisy labels in the ImageWoof dataset benefit training?
148
+
149
+ Noisy labels in the ImageWoof dataset simulate real-world conditions where labels might not always be accurate. Training models with this data helps develop robustness and generalization in image classification tasks. This prepares the models to handle ambiguous or mislabeled data effectively, which is often encountered in practical applications.
150
+
151
+ ### What are the key challenges of using the ImageWoof dataset?
152
+
153
+ The primary challenge of the ImageWoof dataset lies in the subtle differences among the dog breeds it includes. Since it focuses on 10 closely related breeds, distinguishing between them requires more advanced and fine-tuned image classification models. This makes ImageWoof an excellent benchmark to test the capabilities and improvements of [deep learning](https://www.ultralytics.com/glossary/deep-learning-dl) models.
ultralytics-main/docs/en/datasets/classify/index.md ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ comments: true
3
+ description: Learn how to structure datasets for YOLO classification tasks. Detailed folder structure and usage examples for effective training.
4
+ keywords: YOLO, image classification, dataset structure, CIFAR-10, Ultralytics, machine learning, training data, model evaluation
5
+ ---
6
+
7
+ # Image Classification Datasets Overview
8
+
9
+ ## Dataset Structure for YOLO Classification Tasks
10
+
11
+ For [Ultralytics](https://www.ultralytics.com/) YOLO classification tasks, the dataset must be organized in a specific split-directory structure under the `root` directory to facilitate proper training, testing, and optional validation processes. This structure includes separate directories for training (`train`) and testing (`test`) phases, with an optional directory for validation (`val`).
12
+
13
+ Each of these directories should contain one subdirectory for each class in the dataset. The subdirectories are named after the corresponding class and contain all the images for that class. Ensure that each image file is named uniquely and stored in a common format such as JPEG or PNG.
14
+
15
+ ### Folder Structure Example
16
+
17
+ Consider the [CIFAR-10](cifar10.md) dataset as an example. The folder structure should look like this:
18
+
19
+ ```
20
+ cifar-10-/
21
+ |
22
+ |-- train/
23
+ | |-- airplane/
24
+ | | |-- 10008_airplane.png
25
+ | | |-- 10009_airplane.png
26
+ | | |-- ...
27
+ | |
28
+ | |-- automobile/
29
+ | | |-- 1000_automobile.png
30
+ | | |-- 1001_automobile.png
31
+ | | |-- ...
32
+ | |
33
+ | |-- bird/
34
+ | | |-- 10014_bird.png
35
+ | | |-- 10015_bird.png
36
+ | | |-- ...
37
+ | |
38
+ | |-- ...
39
+ |
40
+ |-- test/
41
+ | |-- airplane/
42
+ | | |-- 10_airplane.png
43
+ | | |-- 11_airplane.png
44
+ | | |-- ...
45
+ | |
46
+ | |-- automobile/
47
+ | | |-- 100_automobile.png
48
+ | | |-- 101_automobile.png
49
+ | | |-- ...
50
+ | |
51
+ | |-- bird/
52
+ | | |-- 1000_bird.png
53
+ | | |-- 1001_bird.png
54
+ | | |-- ...
55
+ | |
56
+ | |-- ...
57
+ |
58
+ |-- val/ (optional)
59
+ | |-- airplane/
60
+ | | |-- 105_airplane.png
61
+ | | |-- 106_airplane.png
62
+ | | |-- ...
63
+ | |
64
+ | |-- automobile/
65
+ | | |-- 102_automobile.png
66
+ | | |-- 103_automobile.png
67
+ | | |-- ...
68
+ | |
69
+ | |-- bird/
70
+ | | |-- 1045_bird.png
71
+ | | |-- 1046_bird.png
72
+ | | |-- ...
73
+ | |
74
+ | |-- ...
75
+ ```
76
+
77
+ This structured approach ensures that the model can effectively learn from well-organized classes during the training phase and accurately evaluate performance during testing and validation phases.
78
+
79
+ ## Usage
80
+
81
+ !!! example
82
+
83
+ === "Python"
84
+
85
+ ```python
86
+ from ultralytics import YOLO
87
+
88
+ # Load a model
89
+ model = YOLO("yolo11n-cls.pt") # load a pretrained model (recommended for training)
90
+
91
+ # Train the model
92
+ results = model.train(data="path/to/dataset", epochs=100, imgsz=640)
93
+ ```
94
+
95
+ === "CLI"
96
+
97
+ ```bash
98
+ # Start training from a pretrained *.pt model
99
+ yolo classify train data=path/to/data model=yolo11n-cls.pt epochs=100 imgsz=640
100
+ ```
101
+
102
+ !!! tip
103
+
104
+ Most built-in dataset names (for example `cifar10`, `imagenette`, or `mnist160`) will automatically download and cache the data the first time you reference them. Point `data` to a folder path only when you have curated a custom dataset.
105
+
106
+ ## Supported Datasets
107
+
108
+ Ultralytics supports the following datasets with automatic download:
109
+
110
+ - [Caltech 101](caltech101.md): A dataset containing images of 101 object categories for [image classification](https://www.ultralytics.com/glossary/image-classification) tasks.
111
+ - [Caltech 256](caltech256.md): An extended version of Caltech 101 with 256 object categories and more challenging images.
112
+ - [CIFAR-10](cifar10.md): A dataset of 60K 32x32 color images in 10 classes, with 6K images per class.
113
+ - [CIFAR-100](cifar100.md): An extended version of CIFAR-10 with 100 object categories and 600 images per class.
114
+ - [Fashion-MNIST](fashion-mnist.md): A dataset consisting of 70,000 grayscale images of 10 fashion categories for image classification tasks.
115
+ - [ImageNet](imagenet.md): A large-scale dataset for [object detection](https://www.ultralytics.com/glossary/object-detection) and image classification with over 14 million images and 20,000 categories.
116
+ - [ImageNet-10](imagenet10.md): A smaller subset of ImageNet with 10 categories for faster experimentation and testing.
117
+ - [Imagenette](imagenette.md): A smaller subset of ImageNet that contains 10 easily distinguishable classes for quicker training and testing.
118
+ - [Imagewoof](imagewoof.md): A more challenging subset of ImageNet containing 10 dog breed categories for image classification tasks.
119
+ - [MNIST](mnist.md): A dataset of 70,000 grayscale images of handwritten digits for image classification tasks.
120
+ - [MNIST160](mnist.md): First 8 images of each MNIST category from the MNIST dataset. Dataset contains 160 images total.
121
+
122
+ ### Adding your own dataset
123
+
124
+ If you have your own dataset and would like to use it for training classification models with Ultralytics YOLO, ensure that it follows the format specified above under "Dataset Structure" and then point your `data` argument to the dataset directory when initializing your training script.
125
+
126
+ ## FAQ
127
+
128
+ ### How do I structure my dataset for YOLO classification tasks?
129
+
130
+ To structure your dataset for Ultralytics YOLO classification tasks, you should follow a specific split-directory format. Organize your dataset into separate directories for `train`, `test`, and optionally `val`. Each of these directories should contain subdirectories named after each class, with the corresponding images inside. This facilitates smooth training and evaluation processes. For an example, consider the [CIFAR-10](cifar10.md) dataset format:
131
+
132
+ ```
133
+ cifar-10-/
134
+ |-- train/
135
+ | |-- airplane/
136
+ | |-- automobile/
137
+ | |-- bird/
138
+ | ...
139
+ |-- test/
140
+ | |-- airplane/
141
+ | |-- automobile/
142
+ | |-- bird/
143
+ | ...
144
+ |-- val/ (optional)
145
+ | |-- airplane/
146
+ | |-- automobile/
147
+ | |-- bird/
148
+ | ...
149
+ ```
150
+
151
+ For more details, visit the [Dataset Structure for YOLO Classification Tasks](#dataset-structure-for-yolo-classification-tasks) section.
152
+
153
+ ### What datasets are supported by Ultralytics YOLO for image classification?
154
+
155
+ Ultralytics YOLO supports automatic downloading of several datasets for image classification, including [Caltech 101](caltech101.md), [Caltech 256](caltech256.md), [CIFAR-10](cifar10.md), [CIFAR-100](cifar100.md), [Fashion-MNIST](fashion-mnist.md), [ImageNet](imagenet.md), [ImageNet-10](imagenet10.md), [Imagenette](imagenette.md), [Imagewoof](imagewoof.md), and [MNIST](mnist.md). These datasets are structured in a way that makes them easy to use with YOLO. Each dataset's page provides further details about its structure and applications.
156
+
157
+ ### How do I add my own dataset for YOLO image classification?
158
+
159
+ To use your own dataset with Ultralytics YOLO, ensure it follows the specified directory format required for the classification task, with separate `train`, `test`, and optionally `val` directories, and subdirectories for each class containing the respective images. Once your dataset is structured correctly, point the `data` argument to your dataset's root directory when initializing the training script. Here's an example in Python:
160
+
161
+ ```python
162
+ from ultralytics import YOLO
163
+
164
+ # Load a model
165
+ model = YOLO("yolo11n-cls.pt") # load a pretrained model (recommended for training)
166
+
167
+ # Train the model
168
+ results = model.train(data="path/to/your/dataset", epochs=100, imgsz=640)
169
+ ```
170
+
171
+ More details can be found in the [Adding your own dataset](#adding-your-own-dataset) section.
172
+
173
+ ### Why should I use Ultralytics YOLO for image classification?
174
+
175
+ Ultralytics YOLO offers several benefits for image classification, including:
176
+
177
+ - **Pretrained Models**: Load pretrained models like `yolo11n-cls.pt` to jump-start your training process.
178
+ - **Ease of Use**: Simple API and CLI commands for training and evaluation.
179
+ - **High Performance**: State-of-the-art [accuracy](https://www.ultralytics.com/glossary/accuracy) and speed, ideal for real-time applications.
180
+ - **Support for Multiple Datasets**: Seamless integration with various popular datasets like [CIFAR-10](cifar10.md), [ImageNet](imagenet.md), and more.
181
+ - **Community and Support**: Access to extensive documentation and an active community for troubleshooting and improvements.
182
+
183
+ For additional insights and real-world applications, you can explore [Ultralytics YOLO](https://www.ultralytics.com/yolo).
184
+
185
+ ### How can I train a model using Ultralytics YOLO?
186
+
187
+ Training a model using Ultralytics YOLO can be done easily in both Python and CLI. Here's an example:
188
+
189
+ !!! example
190
+
191
+ === "Python"
192
+
193
+ ```python
194
+ from ultralytics import YOLO
195
+
196
+ # Load a model
197
+ model = YOLO("yolo11n-cls.pt") # load a pretrained model
198
+
199
+ # Train the model
200
+ results = model.train(data="path/to/dataset", epochs=100, imgsz=640)
201
+ ```
202
+
203
+ === "CLI"
204
+
205
+ ```bash
206
+ # Start training from a pretrained *.pt model
207
+ yolo classify train data=path/to/data model=yolo11n-cls.pt epochs=100 imgsz=640
208
+ ```
209
+
210
+ These examples demonstrate the straightforward process of training a YOLO model using either approach. For more information, visit the [Usage](#usage) section and the [Train](https://docs.ultralytics.com/tasks/classify/#train) page for classification tasks.