Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

#21009 `ultralytics 8.3.154` Refactor `Validator` and `Metrics` classes

Merged
Ghost merged 1 commits into Ultralytics:main from ultralytics:validator-cleanup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
  1. # Ultralytics ๐Ÿš€ AGPL-3.0 License - https://ultralytics.com/license
  2. # Builds ultralytics/ultralytics:latest images on DockerHub https://hub.docker.com/r/ultralytics
  3. name: Publish Docker Images
  4. permissions:
  5. contents: read
  6. on:
  7. push:
  8. branches: [main]
  9. paths-ignore:
  10. - "docs/**"
  11. - "mkdocs.yml"
  12. workflow_dispatch:
  13. inputs:
  14. Dockerfile:
  15. type: boolean
  16. description: Dockerfile
  17. default: true
  18. Dockerfile-cpu:
  19. type: boolean
  20. description: Dockerfile-cpu
  21. default: true
  22. Dockerfile-arm64:
  23. type: boolean
  24. description: Dockerfile-arm64
  25. default: true
  26. Dockerfile-jetson-jetpack6:
  27. type: boolean
  28. description: Dockerfile-jetson-jetpack6
  29. default: true
  30. Dockerfile-jetson-jetpack5:
  31. type: boolean
  32. description: Dockerfile-jetson-jetpack5
  33. default: true
  34. Dockerfile-jetson-jetpack4:
  35. type: boolean
  36. description: Dockerfile-jetson-jetpack4
  37. default: true
  38. Dockerfile-python:
  39. type: boolean
  40. description: Dockerfile-python
  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. jobs:
  50. docker:
  51. if: github.repository == 'ultralytics/ultralytics'
  52. name: Push
  53. strategy:
  54. fail-fast: false
  55. max-parallel: 10
  56. matrix:
  57. include:
  58. - dockerfile: "Dockerfile"
  59. tags: "latest"
  60. platforms: "linux/amd64"
  61. runs_on: "ubuntu-latest"
  62. - dockerfile: "Dockerfile-cpu"
  63. tags: "latest-cpu"
  64. platforms: "linux/amd64"
  65. runs_on: "ubuntu-latest"
  66. - dockerfile: "Dockerfile-arm64"
  67. tags: "latest-arm64"
  68. platforms: "linux/arm64"
  69. runs_on: "ubuntu-24.04-arm"
  70. - dockerfile: "Dockerfile-jetson-jetpack6"
  71. tags: "latest-jetson-jetpack6"
  72. platforms: "linux/arm64"
  73. runs_on: "ubuntu-24.04-arm"
  74. - dockerfile: "Dockerfile-jetson-jetpack5"
  75. tags: "latest-jetson-jetpack5"
  76. platforms: "linux/arm64"
  77. runs_on: "ubuntu-24.04-arm"
  78. - dockerfile: "Dockerfile-jetson-jetpack4"
  79. tags: "latest-jetson-jetpack4"
  80. platforms: "linux/arm64"
  81. runs_on: "ubuntu-24.04-arm"
  82. - dockerfile: "Dockerfile-python"
  83. tags: "latest-python"
  84. platforms: "linux/amd64"
  85. runs_on: "ubuntu-latest"
  86. # - dockerfile: "Dockerfile-conda"
  87. # tags: "latest-conda"
  88. # platforms: "linux/amd64"
  89. runs-on: ${{ matrix.runs_on }}
  90. outputs:
  91. new_release: ${{ steps.check_tag.outputs.new_release }}
  92. steps:
  93. - name: Cleanup disk space
  94. uses: ultralytics/actions/cleanup-disk@main
  95. - name: Checkout repo
  96. uses: actions/checkout@v4
  97. with:
  98. fetch-depth: 0 # copy full .git directory to access full git history in Docker images
  99. - name: Set up Docker Buildx
  100. uses: docker/setup-buildx-action@v3
  101. - name: Login to Docker Hub
  102. uses: docker/login-action@v3
  103. with:
  104. username: ${{ secrets.DOCKERHUB_USERNAME }}
  105. password: ${{ secrets.DOCKERHUB_TOKEN }}
  106. - name: Login to GHCR
  107. uses: docker/login-action@v3
  108. with:
  109. registry: ghcr.io
  110. username: ${{ github.repository_owner }}
  111. password: ${{ secrets._GITHUB_TOKEN }}
  112. - name: Retrieve Ultralytics version
  113. id: get_version
  114. run: |
  115. VERSION=$(grep "^__version__ =" ultralytics/__init__.py | awk -F'"' '{print $2}')
  116. echo "Retrieved Ultralytics version: $VERSION"
  117. echo "version=$VERSION" >> $GITHUB_OUTPUT
  118. VERSION_TAG=$(echo "${{ matrix.tags }}" | sed "s/latest/${VERSION}/")
  119. echo "Intended version tag: $VERSION_TAG"
  120. echo "version_tag=$VERSION_TAG" >> $GITHUB_OUTPUT
  121. - name: Check if version tag exists on DockerHub
  122. id: check_tag
  123. run: |
  124. RESPONSE=$(curl -s https://hub.docker.com/v2/repositories/ultralytics/ultralytics/tags/$VERSION_TAG)
  125. MESSAGE=$(echo $RESPONSE | jq -r '.message')
  126. if [[ "$MESSAGE" == "null" ]]; then
  127. echo "Tag $VERSION_TAG already exists on DockerHub."
  128. echo "new_release=false" >> $GITHUB_OUTPUT
  129. elif [[ "$MESSAGE" == *"404"* ]]; then
  130. echo "Tag $VERSION_TAG does not exist on DockerHub."
  131. echo "new_release=true" >> $GITHUB_OUTPUT
  132. else
  133. echo "Unexpected response from DockerHub. Please check manually."
  134. echo "new_release=false" >> $GITHUB_OUTPUT
  135. fi
  136. env:
  137. VERSION_TAG: ${{ steps.get_version.outputs.version_tag }}
  138. - name: Build Image
  139. if: github.event_name == 'push' || github.event.inputs[matrix.dockerfile] == 'true'
  140. uses: ultralytics/actions/retry@main
  141. with:
  142. timeout_minutes: 120
  143. retry_delay_seconds: 60
  144. retries: 2
  145. run: |
  146. docker build \
  147. --platform ${{ matrix.platforms }} \
  148. --label "org.opencontainers.image.source=https://github.com/ultralytics/ultralytics" \
  149. --label "org.opencontainers.image.description=Ultralytics image" \
  150. --label "org.opencontainers.image.licenses=AGPL-3.0-or-later" \
  151. -f docker/${{ matrix.dockerfile }} \
  152. -t ultralytics/ultralytics:${{ matrix.tags }} \
  153. -t ultralytics/ultralytics:${{ steps.get_version.outputs.version_tag }} \
  154. -t ghcr.io/ultralytics/ultralytics:${{ matrix.tags }} \
  155. -t ghcr.io/ultralytics/ultralytics:${{ steps.get_version.outputs.version_tag }} \
  156. .
  157. - name: Check Environment
  158. if: (github.event_name == 'push' || github.event.inputs[matrix.dockerfile] == 'true') && (matrix.platforms == 'linux/amd64' || matrix.platforms == 'linux/arm64') && matrix.dockerfile != 'Dockerfile-conda'
  159. run: docker run ultralytics/ultralytics:${{ matrix.tags }} /bin/bash -c "yolo checks && uv pip list"
  160. - name: Run Tests
  161. if: (github.event_name == 'push' || github.event.inputs[matrix.dockerfile] == 'true') && (matrix.platforms == 'linux/amd64' || matrix.platforms == 'linux/arm64') && matrix.dockerfile != 'Dockerfile-conda'
  162. run: docker run ultralytics/ultralytics:${{ matrix.tags }} /bin/bash -c "pip install pytest && pytest tests"
  163. - name: Run Benchmarks
  164. # WARNING: Dockerfile (GPU) error on TF.js export 'module 'numpy' has no attribute 'object'.
  165. 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' # Images for Jetson not supported on GitHub CI runners
  166. run: docker run ultralytics/ultralytics:${{ matrix.tags }} yolo benchmark model=yolo11n.pt imgsz=160 verbose=0.309
  167. - name: Push Docker Image with Ultralytics version tag
  168. if: (github.event_name == 'push' || (github.event.inputs[matrix.dockerfile] == 'true' && github.event.inputs.push == 'true')) && steps.check_tag.outputs.new_release == 'true' && matrix.dockerfile != 'Dockerfile-conda'
  169. uses: ultralytics/actions/retry@main
  170. with:
  171. timeout_minutes: 15
  172. retry_delay_seconds: 300
  173. retries: 2
  174. run: |
  175. t="ultralytics/ultralytics:${{ steps.get_version.outputs.version_tag }}"
  176. docker push $t
  177. docker push ghcr.io/$t
  178. - name: Build and Push Additional Images (latest-runner and latest-jupyter)
  179. if: github.event_name == 'push' || (github.event.inputs[matrix.dockerfile] == 'true' && github.event.inputs.push == 'true')
  180. uses: ultralytics/actions/retry@main
  181. with:
  182. timeout_minutes: 15
  183. retry_delay_seconds: 300
  184. retries: 2
  185. run: |
  186. t="ultralytics/ultralytics:${{ matrix.tags }}"
  187. docker push $t
  188. docker push ghcr.io/$t
  189. if [[ "${{ matrix.tags }}" == "latest" ]]; then
  190. t="ultralytics/ultralytics:latest-runner"
  191. docker build -f docker/Dockerfile-runner -t $t -t ghcr.io/$t \
  192. --label "org.opencontainers.image.source=https://github.com/ultralytics/ultralytics" \
  193. --label "org.opencontainers.image.description=Ultralytics runner image" \
  194. --label "org.opencontainers.image.licenses=AGPL-3.0-or-later" \
  195. .
  196. docker push $t
  197. docker push ghcr.io/$t
  198. fi
  199. if [[ "${{ matrix.tags }}" == "latest-python" ]]; then
  200. t="ultralytics/ultralytics:latest-jupyter"
  201. v="ultralytics/ultralytics:${{ steps.get_version.outputs.version }}-jupyter"
  202. docker build -f docker/Dockerfile-jupyter -t $t -t ghcr.io/$t -t $v -t ghcr.io/$v \
  203. --label "org.opencontainers.image.source=https://github.com/ultralytics/ultralytics" \
  204. --label "org.opencontainers.image.description=Ultralytics Jupyter image" \
  205. --label "org.opencontainers.image.licenses=AGPL-3.0-or-later" \
  206. .
  207. docker push $t
  208. docker push ghcr.io/$t
  209. if [[ "${{ steps.check_tag_dockerhub.outputs.new_release }}" == "true" ]]; then
  210. docker push $v
  211. docker push ghcr.io/$v
  212. fi
  213. fi
  214. trigger-actions:
  215. runs-on: ubuntu-latest
  216. needs: docker
  217. # Only trigger actions on new Ultralytics releases
  218. if: success() && github.repository == 'ultralytics/ultralytics' && github.event_name == 'push' && needs.docker.outputs.new_release == 'true'
  219. steps:
  220. - name: Trigger Additional GitHub Actions
  221. env:
  222. GH_TOKEN: ${{ secrets._GITHUB_TOKEN }}
  223. run: |
  224. sleep 60
  225. gh workflow run deploy_cloud_run.yml \
  226. --repo ultralytics/assistant \
  227. --ref main
  228. notify:
  229. runs-on: ubuntu-latest
  230. needs: [docker, trigger-actions]
  231. if: always()
  232. steps:
  233. - name: Check for failure and notify
  234. if: needs.docker.result == 'failure' && github.repository == 'ultralytics/ultralytics' && github.event_name == 'push' && github.run_attempt == '1'
  235. uses: slackapi/slack-github-action@v2.1.0
  236. with:
  237. webhook-type: incoming-webhook
  238. webhook: ${{ secrets.SLACK_WEBHOOK_URL_YOLO }}
  239. payload: |
  240. 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"
Discard
Tip!

Press p or to see the previous file or, n or to see the next file