Sompote commited on
Commit
12e6fed
·
verified ·
1 Parent(s): a2e00a2

Upload 392 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 +3 -0
  2. LICENSE +661 -0
  3. README.md +134 -12
  4. app.py +692 -0
  5. inference.py +453 -0
  6. packages.txt +2 -0
  7. pyproject.toml +186 -0
  8. requirements.txt +35 -3
  9. run.sh +44 -0
  10. streamlit_app.py +599 -0
  11. ultralytics/__init__.py +29 -0
  12. ultralytics/__pycache__/__init__.cpython-311.pyc +0 -0
  13. ultralytics/assets/bus.jpg +3 -0
  14. ultralytics/assets/zidane.jpg +0 -0
  15. ultralytics/cfg/__init__.py +1025 -0
  16. ultralytics/cfg/__pycache__/__init__.cpython-311.pyc +0 -0
  17. ultralytics/cfg/datasets/Argoverse.yaml +75 -0
  18. ultralytics/cfg/datasets/DOTAv1.5.yaml +37 -0
  19. ultralytics/cfg/datasets/DOTAv1.yaml +36 -0
  20. ultralytics/cfg/datasets/GlobalWheat2020.yaml +54 -0
  21. ultralytics/cfg/datasets/ImageNet.yaml +2025 -0
  22. ultralytics/cfg/datasets/Objects365.yaml +443 -0
  23. ultralytics/cfg/datasets/SKU-110K.yaml +58 -0
  24. ultralytics/cfg/datasets/VOC.yaml +100 -0
  25. ultralytics/cfg/datasets/VisDrone.yaml +73 -0
  26. ultralytics/cfg/datasets/african-wildlife.yaml +25 -0
  27. ultralytics/cfg/datasets/brain-tumor.yaml +23 -0
  28. ultralytics/cfg/datasets/carparts-seg.yaml +44 -0
  29. ultralytics/cfg/datasets/coco-pose.yaml +39 -0
  30. ultralytics/cfg/datasets/coco.yaml +115 -0
  31. ultralytics/cfg/datasets/coco128-seg.yaml +101 -0
  32. ultralytics/cfg/datasets/coco128.yaml +101 -0
  33. ultralytics/cfg/datasets/coco8-pose.yaml +26 -0
  34. ultralytics/cfg/datasets/coco8-seg.yaml +101 -0
  35. ultralytics/cfg/datasets/coco8.yaml +101 -0
  36. ultralytics/cfg/datasets/crack-seg.yaml +22 -0
  37. ultralytics/cfg/datasets/dog-pose.yaml +24 -0
  38. ultralytics/cfg/datasets/dota8.yaml +35 -0
  39. ultralytics/cfg/datasets/hand-keypoints.yaml +26 -0
  40. ultralytics/cfg/datasets/lvis.yaml +1236 -0
  41. ultralytics/cfg/datasets/medical-pills.yaml +22 -0
  42. ultralytics/cfg/datasets/open-images-v7.yaml +661 -0
  43. ultralytics/cfg/datasets/package-seg.yaml +22 -0
  44. ultralytics/cfg/datasets/signature.yaml +21 -0
  45. ultralytics/cfg/datasets/tiger-pose.yaml +25 -0
  46. ultralytics/cfg/datasets/xView.yaml +153 -0
  47. ultralytics/cfg/default.yaml +130 -0
  48. ultralytics/cfg/models/11/yolo11-cls-resnet18.yaml +24 -0
  49. ultralytics/cfg/models/11/yolo11-cls.yaml +33 -0
  50. ultralytics/cfg/models/11/yolo11-obb.yaml +50 -0
.gitattributes CHANGED
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ ultralytics/assets/bus.jpg filter=lfs diff=lfs merge=lfs -text
37
+ ultralytics/data/__pycache__/augment.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
38
+ ultralytics/nn/modules/__pycache__/block.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
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
637
+ by 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/>.
README.md CHANGED
@@ -1,19 +1,141 @@
1
  ---
2
- title: Tunnel Defext
3
- emoji: 🚀
4
- colorFrom: red
5
  colorTo: red
6
- sdk: docker
7
- app_port: 8501
8
- tags:
9
- - streamlit
10
  pinned: false
11
- short_description: Tunnel segment defect
12
  ---
13
 
14
- # Welcome to Streamlit!
15
 
16
- Edit `/src/streamlit_app.py` to customize this app to your heart's desire. :heart:
17
 
18
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
19
- forums](https://discuss.streamlit.io).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: Tunnel Crack Detection
3
+ emoji: 🔍
4
+ colorFrom: blue
5
  colorTo: red
6
+ sdk: streamlit
7
+ sdk_version: 1.28.0
8
+ app_file: app.py
 
9
  pinned: false
10
+ license: agpl-3.0
11
  ---
12
 
13
+ # 🔍 Tunnel Crack Detection
14
 
15
+ A state-of-the-art web application for detecting cracks and defects in tunnel infrastructure using YOLOv12-DINO deep learning model. Deployed on Hugging Face Spaces for easy access and sharing.
16
 
17
+ ## Features
18
+
19
+ - 🔍 **Real-time crack detection** using YOLOv12-DINO
20
+ - 🖼️ **Interactive web interface** built with Streamlit
21
+ - 📊 **Detailed analysis** with charts and detection tables
22
+ - 📁 **Large file support** (up to 5GB model weights)
23
+ - 📈 **Detection history** and results export
24
+ - 🎯 **Configurable parameters** (confidence, IoU thresholds)
25
+
26
+ ## 🚀 Quick Start
27
+
28
+ This application is deployed on Hugging Face Spaces. Simply:
29
+
30
+ 1. **Upload your YOLOv12-DINO model weights** (.pt file) using the sidebar
31
+ 2. **Upload a tunnel image** for analysis
32
+ 3. **Click "Analyze for Cracks"** to get instant results!
33
+
34
+ ## 🛠️ Local Setup
35
+
36
+ ### Prerequisites
37
+
38
+ - Python 3.8 or higher
39
+ - YOLOv12-DINO trained model weights (.pt file)
40
+
41
+ ### Installation
42
+
43
+ 1. **Clone or navigate to the project directory:**
44
+ ```bash
45
+ cd /Users/sompoteyouwai/env/deploy_tunnel_crack
46
+ ```
47
+
48
+ 2. **Create a virtual environment (recommended):**
49
+ ```bash
50
+ python -m venv venv
51
+ source venv/bin/activate # On Windows: venv\Scripts\activate
52
+ ```
53
+
54
+ 3. **Install dependencies:**
55
+ ```bash
56
+ pip install -r requirements.txt
57
+ ```
58
+
59
+ ### Running the Application
60
+
61
+ 1. **Start the Streamlit app:**
62
+ ```bash
63
+ streamlit run streamlit_app.py
64
+ ```
65
+
66
+ 2. **Open your browser** and navigate to `http://localhost:8501`
67
+
68
+ 3. **Load the model:**
69
+ - If the default model exists at `/Users/sompoteyouwai/env/model_weight/segment_defect.pt`, click "Load Default Model"
70
+ - Alternatively, upload your own model weights (.pt file)
71
+
72
+ 4. **Upload an image** and click "Detect Cracks" to analyze
73
+
74
+ ## Usage
75
+
76
+ ### Model Loading
77
+ - **Default Model**: The app automatically detects if the default model is available
78
+ - **Custom Model**: Upload your own YOLOv12-DINO trained weights
79
+ - **Device Selection**: Choose between CPU, CUDA (GPU), or MPS (Apple Silicon)
80
+
81
+ ### Detection Parameters
82
+ - **Confidence Threshold**: Minimum confidence score for detections (0.01-1.0)
83
+ - **IoU Threshold**: Intersection over Union threshold for Non-Maximum Suppression (0.01-1.0)
84
+ - **Image Size**: Input resolution for the model (320-1280 pixels)
85
+
86
+ ### Results
87
+ - **Annotated Images**: View detected cracks with bounding boxes
88
+ - **Detection Summary**: Count and classification of detected defects
89
+ - **Interactive Charts**: Pie charts and confidence distributions
90
+ - **Detailed Table**: Exportable CSV with detection coordinates and metadata
91
+ - **History**: Track multiple detection sessions
92
+
93
+ ## File Structure
94
+
95
+ ```
96
+ deploy_tunnel_crack/
97
+ ├── streamlit_app.py # Main Streamlit application
98
+ ├── inference.py # YOLOv12-DINO inference engine
99
+ ├── requirements.txt # Python dependencies
100
+ ├── README.md # This file
101
+ └── run.sh # Quick start script
102
+ ```
103
+
104
+ ## Model Information
105
+
106
+ The application expects a YOLOv12-DINO model trained for crack/defect detection. The default model path is:
107
+ ```
108
+ /Users/sompoteyouwai/env/model_weight/segment_defect.pt
109
+ ```
110
+
111
+ ### Supported Model Features:
112
+ - Object detection and segmentation
113
+ - Multiple defect classes
114
+ - Configurable inference parameters
115
+ - GPU acceleration support
116
+
117
+ ## Troubleshooting
118
+
119
+ ### Common Issues:
120
+
121
+ 1. **Model not found**: Ensure the model file exists at the specified path or upload a custom model
122
+ 2. **CUDA errors**: Install appropriate PyTorch version for your GPU
123
+ 3. **Memory issues**: Reduce image size or use CPU device for large images
124
+ 4. **Import errors**: Ensure all dependencies are installed: `pip install -r requirements.txt`
125
+
126
+ ### Performance Tips:
127
+ - Use GPU (CUDA/MPS) for faster inference
128
+ - Optimize image size based on your hardware capabilities
129
+ - Adjust confidence threshold to filter false positives
130
+
131
+ ## Development
132
+
133
+ To modify or extend the application:
134
+
135
+ 1. **Streamlit App**: Edit `streamlit_app.py` for UI changes
136
+ 2. **Inference Engine**: Modify `inference.py` for model-related changes
137
+ 3. **Dependencies**: Update `requirements.txt` for new packages
138
+
139
+ ## License
140
+
141
+ This project is for tunnel infrastructure monitoring and maintenance applications.
app.py ADDED
@@ -0,0 +1,692 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Tunnel Crack Detection - Hugging Face Spaces App
4
+
5
+ A Streamlit-based web interface for tunnel crack detection using YOLOv12-DINO.
6
+ Deployed on Hugging Face Spaces for easy access and sharing.
7
+ """
8
+
9
+ import streamlit as st
10
+ import cv2
11
+ import numpy as np
12
+ import pandas as pd
13
+ from pathlib import Path
14
+ import tempfile
15
+ import os
16
+ import sys
17
+ from typing import Dict, List, Tuple
18
+ import time
19
+ from PIL import Image
20
+ import plotly.express as px
21
+ import plotly.graph_objects as go
22
+ import requests
23
+ from io import BytesIO
24
+
25
+ # Add the current directory to the Python path
26
+ current_dir = Path(__file__).parent
27
+ sys.path.insert(0, str(current_dir))
28
+
29
+ try:
30
+ from inference import YOLOInference
31
+ except ImportError as e:
32
+ st.error(f"Error importing inference module: {e}")
33
+ st.stop()
34
+
35
+ # Page configuration
36
+ st.set_page_config(
37
+ page_title="🔍 Tunnel Crack Detection",
38
+ page_icon="🔍",
39
+ layout="wide",
40
+ initial_sidebar_state="expanded"
41
+ )
42
+
43
+ # Custom CSS for better styling
44
+ st.markdown("""
45
+ <style>
46
+ .main-header {
47
+ font-size: 3rem;
48
+ color: #1e88e5;
49
+ text-align: center;
50
+ margin-bottom: 2rem;
51
+ text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
52
+ }
53
+ .sub-header {
54
+ text-align: center;
55
+ color: #666;
56
+ margin-bottom: 3rem;
57
+ font-size: 1.2rem;
58
+ }
59
+ .metric-card {
60
+ background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
61
+ padding: 1.5rem;
62
+ border-radius: 1rem;
63
+ margin: 0.5rem 0;
64
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
65
+ }
66
+ .detection-box {
67
+ border: 2px solid #1e88e5;
68
+ border-radius: 1rem;
69
+ padding: 1.5rem;
70
+ margin: 1rem 0;
71
+ background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
72
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
73
+ }
74
+ .success-box {
75
+ border: 2px solid #4caf50;
76
+ border-radius: 1rem;
77
+ padding: 1.5rem;
78
+ margin: 1rem 0;
79
+ background: linear-gradient(135deg, #f1f8e9 0%, #dcedc8 100%);
80
+ box-shadow: 0 4px 8px rgba(76, 175, 80, 0.2);
81
+ }
82
+ .error-box {
83
+ border: 2px solid #f44336;
84
+ border-radius: 1rem;
85
+ padding: 1.5rem;
86
+ margin: 1rem 0;
87
+ background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
88
+ box-shadow: 0 4px 8px rgba(244, 67, 54, 0.2);
89
+ }
90
+ .warning-box {
91
+ border: 2px solid #ff9800;
92
+ border-radius: 1rem;
93
+ padding: 1.5rem;
94
+ margin: 1rem 0;
95
+ background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
96
+ box-shadow: 0 4px 8px rgba(255, 152, 0, 0.2);
97
+ }
98
+ .info-box {
99
+ border: 2px solid #2196f3;
100
+ border-radius: 1rem;
101
+ padding: 1.5rem;
102
+ margin: 1rem 0;
103
+ background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
104
+ box-shadow: 0 4px 8px rgba(33, 150, 243, 0.2);
105
+ }
106
+ .stButton > button {
107
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
108
+ color: white;
109
+ border: none;
110
+ border-radius: 0.5rem;
111
+ padding: 0.5rem 2rem;
112
+ font-weight: bold;
113
+ transition: all 0.3s ease;
114
+ }
115
+ .stButton > button:hover {
116
+ transform: translateY(-2px);
117
+ box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
118
+ }
119
+ .sidebar .stSelectbox > div > div {
120
+ background-color: #f8f9fa;
121
+ }
122
+ </style>
123
+ """, unsafe_allow_html=True)
124
+
125
+ # Initialize session state
126
+ if 'model_loaded' not in st.session_state:
127
+ st.session_state.model_loaded = False
128
+ if 'model_instance' not in st.session_state:
129
+ st.session_state.model_instance = None
130
+ if 'detection_history' not in st.session_state:
131
+ st.session_state.detection_history = []
132
+
133
+ # Model download URL (you'll need to replace this with actual model URL or use HF Hub)
134
+ MODEL_URL = "https://huggingface.co/spaces/YOUR_USERNAME/tunnel-crack-detection/resolve/main/segment_defect.pt"
135
+
136
+ @st.cache_resource
137
+ def download_model():
138
+ """Download model from Hugging Face Hub or URL."""
139
+ model_path = "segment_defect.pt"
140
+
141
+ if not os.path.exists(model_path):
142
+ st.info("🔄 Downloading model weights... This may take a few minutes.")
143
+ try:
144
+ # Try to download from URL (you may need to adjust this)
145
+ # For HF Spaces, you might want to use huggingface_hub library
146
+ response = requests.get(MODEL_URL, stream=True)
147
+ response.raise_for_status()
148
+
149
+ with open(model_path, 'wb') as f:
150
+ for chunk in response.iter_content(chunk_size=8192):
151
+ f.write(chunk)
152
+
153
+ st.success("✅ Model downloaded successfully!")
154
+ except Exception as e:
155
+ st.error(f"❌ Failed to download model: {e}")
156
+ return None
157
+
158
+ return model_path
159
+
160
+ def load_model(weights_path: str, device: str = "cpu") -> Tuple[bool, str]:
161
+ """Load the YOLO model with specified weights."""
162
+ try:
163
+ if not Path(weights_path).exists():
164
+ return False, f"❌ Model file not found: {weights_path}"
165
+
166
+ with st.spinner("🚀 Loading tunnel crack detection model..."):
167
+ st.session_state.model_instance = YOLOInference(
168
+ weights=weights_path,
169
+ conf=0.25,
170
+ iou=0.7,
171
+ imgsz=640,
172
+ device=device,
173
+ verbose=True
174
+ )
175
+
176
+ st.session_state.model_loaded = True
177
+
178
+ # Get model information
179
+ model_info = f"✅ Model loaded successfully\n"
180
+ model_info += f"📋 Task: {st.session_state.model_instance.model.task}\n"
181
+
182
+ if hasattr(st.session_state.model_instance.model.model, 'names'):
183
+ class_names = list(st.session_state.model_instance.model.model.names.values())
184
+ model_info += f"🏷️ Classes ({len(class_names)}): {', '.join(class_names)}"
185
+
186
+ return True, model_info
187
+
188
+ except Exception as e:
189
+ return False, f"❌ Error loading model: {str(e)}"
190
+
191
+ def perform_detection(
192
+ image: np.ndarray,
193
+ conf_threshold: float,
194
+ iou_threshold: float,
195
+ image_size: int
196
+ ) -> Tuple[np.ndarray, Dict, str]:
197
+ """Perform crack detection using the loaded model."""
198
+
199
+ if st.session_state.model_instance is None:
200
+ return None, {}, "❌ No model loaded"
201
+
202
+ try:
203
+ # Update model parameters
204
+ st.session_state.model_instance.conf = conf_threshold
205
+ st.session_state.model_instance.iou = iou_threshold
206
+ st.session_state.model_instance.imgsz = image_size
207
+
208
+ # Save image to temporary file
209
+ with tempfile.NamedTemporaryFile(suffix='.jpg', delete=False) as tmp_file:
210
+ # Convert RGB to BGR for OpenCV
211
+ image_bgr = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
212
+ cv2.imwrite(tmp_file.name, image_bgr)
213
+ tmp_path = tmp_file.name
214
+
215
+ start_time = time.time()
216
+
217
+ try:
218
+ # Use the exact same method as inference.py
219
+ results = st.session_state.model_instance.predict_single(
220
+ source=tmp_path,
221
+ save=False,
222
+ show=False,
223
+ save_txt=False,
224
+ save_conf=False,
225
+ save_crop=False,
226
+ output_dir=None
227
+ )
228
+
229
+ inference_time = time.time() - start_time
230
+
231
+ if not results:
232
+ return image, {}, "❌ No results returned from model"
233
+
234
+ result = results[0]
235
+
236
+ # Get annotated image
237
+ annotated_img = result.plot()
238
+ annotated_img = cv2.cvtColor(annotated_img, cv2.COLOR_BGR2RGB)
239
+
240
+ # Process detection results
241
+ detection_data = process_detection_results(result, inference_time)
242
+
243
+ # Generate summary text
244
+ summary_text = generate_detection_summary(result, detection_data, inference_time)
245
+
246
+ return annotated_img, detection_data, summary_text
247
+
248
+ finally:
249
+ # Clean up temporary file
250
+ if os.path.exists(tmp_path):
251
+ os.unlink(tmp_path)
252
+
253
+ except Exception as e:
254
+ return None, {}, f"❌ Error during detection: {str(e)}"
255
+
256
+ def process_detection_results(result, inference_time: float) -> Dict:
257
+ """Process detection results into structured data."""
258
+
259
+ if result.boxes is None or len(result.boxes) == 0:
260
+ return {
261
+ 'total_detections': 0,
262
+ 'class_counts': {},
263
+ 'detections': [],
264
+ 'inference_time': inference_time
265
+ }
266
+
267
+ detections = result.boxes
268
+
269
+ # Get class names
270
+ if hasattr(st.session_state.model_instance.model.model, 'names'):
271
+ class_names = st.session_state.model_instance.model.model.names
272
+ else:
273
+ class_names = getattr(result, 'names', {i: f"Class_{i}" for i in range(100)})
274
+
275
+ # Process each detection
276
+ detection_list = []
277
+ class_counts = {}
278
+
279
+ for i, (box, conf, cls) in enumerate(zip(detections.xyxy, detections.conf, detections.cls)):
280
+ cls_id = int(cls)
281
+ cls_name = class_names.get(cls_id, f"Class_{cls_id}")
282
+ confidence = float(conf)
283
+
284
+ x1, y1, x2, y2 = box.tolist()
285
+
286
+ detection_list.append({
287
+ 'id': i + 1,
288
+ 'class': cls_name,
289
+ 'confidence': confidence,
290
+ 'x1': int(x1),
291
+ 'y1': int(y1),
292
+ 'x2': int(x2),
293
+ 'y2': int(y2),
294
+ 'width': int(x2 - x1),
295
+ 'height': int(y2 - y1),
296
+ 'area': int((x2 - x1) * (y2 - y1))
297
+ })
298
+
299
+ class_counts[cls_name] = class_counts.get(cls_name, 0) + 1
300
+
301
+ return {
302
+ 'total_detections': len(detection_list),
303
+ 'class_counts': class_counts,
304
+ 'detections': detection_list,
305
+ 'inference_time': inference_time
306
+ }
307
+
308
+ def generate_detection_summary(result, detection_data: Dict, inference_time: float) -> str:
309
+ """Generate detection summary text."""
310
+
311
+ total_detections = detection_data['total_detections']
312
+
313
+ if total_detections == 0:
314
+ return "🔍 No cracks or defects detected in the image."
315
+
316
+ summary = f"✅ **Detection Results:**\n\n"
317
+ summary += f"📊 **Images processed:** 1\n"
318
+ summary += f"📊 **Total detections:** {total_detections}\n"
319
+ summary += f"⏱️ **Inference time:** {inference_time:.3f}s\n\n"
320
+
321
+ summary += "📋 **Detections by class:**\n"
322
+ for cls_name, count in sorted(detection_data['class_counts'].items()):
323
+ summary += f" • {cls_name}: {count}\n"
324
+
325
+ return summary
326
+
327
+ def create_detection_chart(detection_data: Dict):
328
+ """Create interactive charts for detection results."""
329
+
330
+ if detection_data['total_detections'] == 0:
331
+ st.info("📊 No detections to visualize")
332
+ return
333
+
334
+ col1, col2 = st.columns(2)
335
+
336
+ with col1:
337
+ # Class distribution pie chart
338
+ class_counts = detection_data['class_counts']
339
+
340
+ fig_pie = px.pie(
341
+ values=list(class_counts.values()),
342
+ names=list(class_counts.keys()),
343
+ title="🥧 Detection Distribution by Class",
344
+ color_discrete_sequence=px.colors.qualitative.Set3
345
+ )
346
+ fig_pie.update_layout(height=400)
347
+
348
+ st.plotly_chart(fig_pie, use_container_width=True)
349
+
350
+ with col2:
351
+ # Confidence distribution
352
+ confidences = [det['confidence'] for det in detection_data['detections']]
353
+ classes = [det['class'] for det in detection_data['detections']]
354
+
355
+ fig_conf = px.box(
356
+ x=classes,
357
+ y=confidences,
358
+ title="📈 Confidence Distribution by Class",
359
+ color=classes
360
+ )
361
+ fig_conf.update_layout(height=400)
362
+ fig_conf.update_xaxes(title="Class")
363
+ fig_conf.update_yaxes(title="Confidence Score")
364
+
365
+ st.plotly_chart(fig_conf, use_container_width=True)
366
+
367
+ def create_detection_table(detection_data: Dict):
368
+ """Create detailed detection table."""
369
+
370
+ if detection_data['total_detections'] == 0:
371
+ st.info("📋 No detections to display")
372
+ return
373
+
374
+ # Convert to DataFrame
375
+ df = pd.DataFrame(detection_data['detections'])
376
+
377
+ # Format confidence as percentage
378
+ df['confidence_pct'] = df['confidence'].apply(lambda x: f"{x:.1%}")
379
+
380
+ # Reorder columns for better display
381
+ display_columns = ['id', 'class', 'confidence_pct', 'x1', 'y1', 'x2', 'y2', 'width', 'height', 'area']
382
+ df_display = df[display_columns].copy()
383
+
384
+ # Rename columns for better readability
385
+ df_display.columns = ['ID', 'Class', 'Confidence', 'X1', 'Y1', 'X2', 'Y2', 'Width', 'Height', 'Area']
386
+
387
+ st.dataframe(df_display, use_container_width=True, height=300)
388
+
389
+ # Download button for results
390
+ csv = df_display.to_csv(index=False)
391
+ st.download_button(
392
+ label="📥 Download Detection Results (CSV)",
393
+ data=csv,
394
+ file_name=f"crack_detection_results_{int(time.time())}.csv",
395
+ mime="text/csv",
396
+ use_container_width=True
397
+ )
398
+
399
+ def main():
400
+ """Main Streamlit application."""
401
+
402
+ # Header
403
+ st.markdown('<h1 class="main-header">🔍 Tunnel Crack Detection</h1>', unsafe_allow_html=True)
404
+ st.markdown('<p class="sub-header">AI-powered crack and defect detection for tunnel infrastructure using YOLOv12-DINO</p>', unsafe_allow_html=True)
405
+
406
+ # Info about the model
407
+ st.markdown("""
408
+ <div class="info-box">
409
+ <h4>🤖 About This Model</h4>
410
+ <p>This application uses YOLOv12-DINO, a state-of-the-art deep learning model that combines:</p>
411
+ <ul>
412
+ <li><strong>YOLOv12</strong>: Latest version of the YOLO object detection architecture</li>
413
+ <li><strong>DINOv3</strong>: Vision Transformer backbone for enhanced feature extraction</li>
414
+ <li><strong>Specialized Training</strong>: Fine-tuned specifically for tunnel crack and defect detection</li>
415
+ </ul>
416
+ <p><em>Perfect for infrastructure monitoring and maintenance applications!</em></p>
417
+ </div>
418
+ """, unsafe_allow_html=True)
419
+
420
+ # Auto-load model on startup
421
+ if not st.session_state.model_loaded:
422
+ with st.spinner("🔄 Initializing model..."):
423
+ # For HF Spaces, you might want to have the model pre-loaded or use a different approach
424
+ # model_path = download_model()
425
+ # if model_path:
426
+ # success, message = load_model(model_path, "cpu")
427
+ # if success:
428
+ # st.success("🚀 Model ready for inference!")
429
+ pass
430
+
431
+ # Sidebar for configuration
432
+ with st.sidebar:
433
+ st.header("🛠️ Configuration")
434
+
435
+ # Model loading section
436
+ st.subheader("📁 Model")
437
+
438
+ if not st.session_state.model_loaded:
439
+ st.markdown('<div class="warning-box">⚠️ Upload a model to get started</div>', unsafe_allow_html=True)
440
+
441
+ uploaded_file = st.file_uploader(
442
+ "Upload Model Weights (.pt file)",
443
+ type=['pt'],
444
+ help="Upload your trained YOLOv12-DINO model weights",
445
+ label_visibility="visible"
446
+ )
447
+
448
+ if uploaded_file is not None:
449
+ # Show file info
450
+ file_size_mb = uploaded_file.size / (1024 * 1024)
451
+ st.success(f"📁 File uploaded: {uploaded_file.name} ({file_size_mb:.1f} MB)")
452
+
453
+ if st.button("🚀 Load Model", type="primary"):
454
+ # Show progress for file processing
455
+ progress_bar = st.progress(0)
456
+ status_text = st.empty()
457
+
458
+ try:
459
+ # Save uploaded file temporarily
460
+ status_text.text("💾 Processing uploaded file...")
461
+ progress_bar.progress(25)
462
+
463
+ with tempfile.NamedTemporaryFile(delete=False, suffix='.pt') as tmp_file:
464
+ tmp_file.write(uploaded_file.read())
465
+ tmp_path = tmp_file.name
466
+
467
+ progress_bar.progress(50)
468
+ status_text.text("🚀 Loading model...")
469
+
470
+ success, message = load_model(tmp_path, "cpu")
471
+
472
+ progress_bar.progress(100)
473
+ status_text.text("✅ Model loading complete!")
474
+
475
+ if success:
476
+ st.success(message)
477
+ st.rerun()
478
+ else:
479
+ st.error(message)
480
+
481
+ # Clean up progress indicators
482
+ time.sleep(1)
483
+ progress_bar.empty()
484
+ status_text.empty()
485
+
486
+ except Exception as e:
487
+ st.error(f"❌ Error processing file: {str(e)}")
488
+ progress_bar.empty()
489
+ status_text.empty()
490
+ else:
491
+ st.markdown('<div class="success-box">✅ Model loaded and ready!</div>', unsafe_allow_html=True)
492
+
493
+ # Detection parameters
494
+ st.subheader("⚙️ Detection Parameters")
495
+
496
+ conf_threshold = st.slider(
497
+ "Confidence Threshold",
498
+ min_value=0.01,
499
+ max_value=1.0,
500
+ value=0.25,
501
+ step=0.01,
502
+ help="Minimum confidence for detection"
503
+ )
504
+
505
+ iou_threshold = st.slider(
506
+ "IoU Threshold",
507
+ min_value=0.01,
508
+ max_value=1.0,
509
+ value=0.7,
510
+ step=0.01,
511
+ help="IoU threshold for Non-Maximum Suppression"
512
+ )
513
+
514
+ image_size = st.selectbox(
515
+ "Image Size",
516
+ options=[320, 416, 512, 640, 832, 1024],
517
+ index=3,
518
+ help="Input image size for model"
519
+ )
520
+
521
+ # Statistics
522
+ if st.session_state.detection_history:
523
+ st.subheader("📊 Session Stats")
524
+ total_detections = sum([h['detections'] for h in st.session_state.detection_history])
525
+ st.metric("Images Processed", len(st.session_state.detection_history))
526
+ st.metric("Total Detections", total_detections)
527
+
528
+ # Main content area
529
+ col1, col2 = st.columns([1, 1])
530
+
531
+ with col1:
532
+ st.header("🖼️ Input Image")
533
+
534
+ # Image upload
535
+ image_file = st.file_uploader(
536
+ "Upload Image for Analysis",
537
+ type=['jpg', 'jpeg', 'png', 'bmp'],
538
+ help="Upload a tunnel image for crack detection"
539
+ )
540
+
541
+ if image_file is not None:
542
+ # Load and display image
543
+ try:
544
+ image = Image.open(image_file)
545
+ image_np = np.array(image)
546
+
547
+ # Display image
548
+ st.image(image, caption="📷 Input Image", use_column_width=True)
549
+
550
+ # Image info
551
+ st.info(f"📊 Image size: {image.width} × {image.height} pixels")
552
+
553
+ except Exception as e:
554
+ st.error(f"❌ Error loading image: {str(e)}")
555
+ return
556
+
557
+ # Detection button
558
+ detect_button = st.button(
559
+ "🔍 Analyze for Cracks",
560
+ type="primary",
561
+ disabled=not st.session_state.model_loaded,
562
+ use_container_width=True
563
+ )
564
+
565
+ if detect_button:
566
+ if st.session_state.model_loaded:
567
+ with st.spinner("🔍 Analyzing image for cracks and defects..."):
568
+ annotated_img, detection_data, summary_text = perform_detection(
569
+ image_np, conf_threshold, iou_threshold, image_size
570
+ )
571
+
572
+ # Store results in session state
573
+ st.session_state.last_detection = {
574
+ 'annotated_img': annotated_img,
575
+ 'detection_data': detection_data,
576
+ 'summary_text': summary_text,
577
+ 'timestamp': time.time()
578
+ }
579
+
580
+ # Add to history
581
+ st.session_state.detection_history.append({
582
+ 'filename': image_file.name,
583
+ 'detections': detection_data['total_detections'],
584
+ 'timestamp': time.time()
585
+ })
586
+
587
+ st.rerun()
588
+ else:
589
+ st.error("❌ Please upload and load a model first")
590
+ else:
591
+ st.markdown("""
592
+ <div class="info-box">
593
+ <h4>🚀 Get Started</h4>
594
+ <ol>
595
+ <li>Upload your YOLOv12-DINO model weights in the sidebar</li>
596
+ <li>Upload a tunnel image above</li>
597
+ <li>Click "Analyze for Cracks" to detect defects</li>
598
+ </ol>
599
+ </div>
600
+ """, unsafe_allow_html=True)
601
+
602
+ with col2:
603
+ st.header("🎯 Detection Results")
604
+
605
+ if 'last_detection' in st.session_state:
606
+ detection_result = st.session_state.last_detection
607
+
608
+ # Display annotated image
609
+ if detection_result['annotated_img'] is not None:
610
+ try:
611
+ st.image(
612
+ detection_result['annotated_img'],
613
+ caption="🎯 Detection Results",
614
+ use_column_width=True
615
+ )
616
+ except Exception as e:
617
+ st.error(f"Error displaying result image: {str(e)}")
618
+
619
+ # Display summary
620
+ st.markdown(f'<div class="detection-box">{detection_result["summary_text"]}</div>',
621
+ unsafe_allow_html=True)
622
+
623
+ else:
624
+ st.markdown("""
625
+ <div class="info-box">
626
+ <h4>📊 Results will appear here</h4>
627
+ <p>Upload an image and click 'Analyze for Cracks' to see detection results with:</p>
628
+ <ul>
629
+ <li>🎯 Annotated image with detected cracks</li>
630
+ <li>📊 Detection statistics and confidence scores</li>
631
+ <li>📋 Detailed analysis tables</li>
632
+ <li>📈 Interactive charts and visualizations</li>
633
+ </ul>
634
+ </div>
635
+ """, unsafe_allow_html=True)
636
+
637
+ # Additional tabs for detailed analysis
638
+ if 'last_detection' in st.session_state and st.session_state.last_detection['detection_data']['total_detections'] > 0:
639
+
640
+ st.markdown("---")
641
+ st.header("📊 Detailed Analysis")
642
+
643
+ tab1, tab2, tab3 = st.tabs(["📈 Visualizations", "📋 Detection Table", "📜 Session History"])
644
+
645
+ with tab1:
646
+ create_detection_chart(st.session_state.last_detection['detection_data'])
647
+
648
+ with tab2:
649
+ create_detection_table(st.session_state.last_detection['detection_data'])
650
+
651
+ with tab3:
652
+ if st.session_state.detection_history:
653
+ st.subheader("📜 Analysis History")
654
+ history_df = pd.DataFrame(st.session_state.detection_history)
655
+ history_df['timestamp'] = pd.to_datetime(history_df['timestamp'], unit='s')
656
+ history_df.columns = ['Filename', 'Detections', 'Timestamp']
657
+
658
+ st.dataframe(history_df, use_container_width=True, height=300)
659
+
660
+ col1, col2 = st.columns(2)
661
+ with col1:
662
+ if st.button("🗑️ Clear History", use_container_width=True):
663
+ st.session_state.detection_history = []
664
+ st.rerun()
665
+ with col2:
666
+ if len(st.session_state.detection_history) > 0:
667
+ csv = history_df.to_csv(index=False)
668
+ st.download_button(
669
+ label="📥 Download History",
670
+ data=csv,
671
+ file_name=f"detection_history_{int(time.time())}.csv",
672
+ mime="text/csv",
673
+ use_container_width=True
674
+ )
675
+ else:
676
+ st.info("📜 No analysis history yet. Start by uploading and analyzing images!")
677
+
678
+ # Footer
679
+ st.markdown("---")
680
+ st.markdown("""
681
+ <div style='text-align: center; color: #666; padding: 2rem;'>
682
+ <h4>🔍 Tunnel Crack Detection System</h4>
683
+ <p>
684
+ Powered by <strong>YOLOv12-DINO</strong> • Built with <strong>Streamlit</strong> •
685
+ Deployed on <strong>🤗 Hugging Face Spaces</strong>
686
+ </p>
687
+ <p><em>Advanced AI for Infrastructure Monitoring and Maintenance</em></p>
688
+ </div>
689
+ """, unsafe_allow_html=True)
690
+
691
+ if __name__ == "__main__":
692
+ main()
inference.py ADDED
@@ -0,0 +1,453 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ YOLOv12-DINO Inference Script
4
+
5
+ This script performs object detection on images using trained YOLOv12-DINO model weights.
6
+ It can process single images, image directories, or image lists and generate annotated outputs.
7
+
8
+ Usage:
9
+ python inference.py --weights path/to/model.pt --source path/to/images --output path/to/output
10
+ python inference.py --weights runs/detect/train/weights/best.pt --source test_images/ --output results/
11
+ python inference.py --weights best.pt --source image.jpg --conf 0.5 --iou 0.7 --save --show
12
+
13
+ Features:
14
+ - Supports multiple input formats (single image, directory, image list)
15
+ - Configurable confidence and IoU thresholds
16
+ - Optional visualization and saving of annotated images
17
+ - Batch processing for efficient inference
18
+ - Support for various image formats (jpg, png, bmp, etc.)
19
+ """
20
+
21
+ import argparse
22
+ import os
23
+ import sys
24
+ from pathlib import Path
25
+ from typing import List, Union
26
+ import time
27
+
28
+ # Add the current directory to the Python path
29
+ current_dir = Path(__file__).parent
30
+ sys.path.insert(0, str(current_dir))
31
+
32
+ try:
33
+ from ultralytics import YOLO
34
+ from ultralytics.utils import LOGGER, colorstr
35
+ from ultralytics.utils.checks import check_file, check_imgsz
36
+ from ultralytics.utils.files import increment_path
37
+ except ImportError as e:
38
+ print(f"Error importing ultralytics: {e}")
39
+ print("Please ensure ultralytics is properly installed")
40
+ sys.exit(1)
41
+
42
+
43
+ class YOLOInference:
44
+ """YOLOv12-DINO inference class for object detection on images."""
45
+
46
+ def __init__(
47
+ self,
48
+ weights: Union[str, Path],
49
+ conf: float = 0.25,
50
+ iou: float = 0.7,
51
+ imgsz: int = 640,
52
+ device: str = "",
53
+ verbose: bool = True
54
+ ):
55
+ """
56
+ Initialize the YOLOv12-DINO inference model.
57
+
58
+ Args:
59
+ weights (str | Path): Path to the trained model weights (.pt file)
60
+ conf (float): Confidence threshold for detection (0.0-1.0)
61
+ iou (float): IoU threshold for Non-Maximum Suppression (0.0-1.0)
62
+ imgsz (int): Input image size for inference
63
+ device (str): Device to run inference on ('cpu', 'cuda', 'mps', etc.)
64
+ verbose (bool): Enable verbose output
65
+ """
66
+ self.weights = Path(weights)
67
+ self.conf = conf
68
+ self.iou = iou
69
+ self.imgsz = check_imgsz(imgsz)
70
+ self.device = device
71
+ self.verbose = verbose
72
+
73
+ # Validate weights file
74
+ if not self.weights.exists():
75
+ raise FileNotFoundError(f"Model weights not found: {self.weights}")
76
+
77
+ # Load model
78
+ if self.verbose:
79
+ LOGGER.info(f"Loading YOLOv12-DINO model from {self.weights}")
80
+
81
+ self.model = YOLO(str(self.weights), verbose=self.verbose)
82
+
83
+ if self.verbose:
84
+ LOGGER.info(f"Model loaded successfully")
85
+ LOGGER.info(f"Model task: {self.model.task}")
86
+ if hasattr(self.model.model, 'names'):
87
+ LOGGER.info(f"Classes: {list(self.model.model.names.values())}")
88
+
89
+ def predict_single(
90
+ self,
91
+ source: Union[str, Path],
92
+ save: bool = False,
93
+ show: bool = False,
94
+ save_txt: bool = False,
95
+ save_conf: bool = False,
96
+ save_crop: bool = False,
97
+ output_dir: Union[str, Path] = None
98
+ ):
99
+ """
100
+ Perform inference on a single image source.
101
+
102
+ Args:
103
+ source (str | Path): Path to image file
104
+ save (bool): Save annotated images
105
+ show (bool): Display results
106
+ save_txt (bool): Save detection results to txt files
107
+ save_conf (bool): Save confidence scores in txt files
108
+ save_crop (bool): Save cropped detection images
109
+ output_dir (str | Path): Output directory for saved results
110
+
111
+ Returns:
112
+ List of Results objects containing detection results
113
+ """
114
+ # Prepare prediction arguments
115
+ predict_args = {
116
+ 'source': str(source),
117
+ 'conf': self.conf,
118
+ 'iou': self.iou,
119
+ 'imgsz': self.imgsz,
120
+ 'save': save,
121
+ 'show': show,
122
+ 'save_txt': save_txt,
123
+ 'save_conf': save_conf,
124
+ 'save_crop': save_crop,
125
+ 'verbose': self.verbose
126
+ }
127
+
128
+ if self.device:
129
+ predict_args['device'] = self.device
130
+
131
+ if output_dir:
132
+ predict_args['project'] = str(Path(output_dir).parent)
133
+ predict_args['name'] = Path(output_dir).name
134
+
135
+ # Run inference
136
+ results = self.model.predict(**predict_args)
137
+ return results
138
+
139
+ def predict_batch(
140
+ self,
141
+ source_dir: Union[str, Path],
142
+ save: bool = True,
143
+ show: bool = False,
144
+ save_txt: bool = False,
145
+ save_conf: bool = False,
146
+ save_crop: bool = False,
147
+ output_dir: Union[str, Path] = None,
148
+ extensions: tuple = ('.jpg', '.jpeg', '.png', '.bmp', '.tiff', '.tif')
149
+ ):
150
+ """
151
+ Perform batch inference on all images in a directory.
152
+
153
+ Args:
154
+ source_dir (str | Path): Directory containing images
155
+ save (bool): Save annotated images
156
+ show (bool): Display results
157
+ save_txt (bool): Save detection results to txt files
158
+ save_conf (bool): Save confidence scores in txt files
159
+ save_crop (bool): Save cropped detection images
160
+ output_dir (str | Path): Output directory for saved results
161
+ extensions (tuple): Supported image file extensions
162
+
163
+ Returns:
164
+ List of Results objects containing detection results for all images
165
+ """
166
+ source_dir = Path(source_dir)
167
+ if not source_dir.exists():
168
+ raise FileNotFoundError(f"Source directory not found: {source_dir}")
169
+
170
+ # Find all image files
171
+ image_files = []
172
+ for ext in extensions:
173
+ image_files.extend(source_dir.glob(f"*{ext}"))
174
+ image_files.extend(source_dir.glob(f"*{ext.upper()}"))
175
+
176
+ if not image_files:
177
+ raise ValueError(f"No images found in {source_dir} with extensions {extensions}")
178
+
179
+ if self.verbose:
180
+ LOGGER.info(f"Found {len(image_files)} images in {source_dir}")
181
+
182
+ # Prepare prediction arguments
183
+ predict_args = {
184
+ 'source': str(source_dir),
185
+ 'conf': self.conf,
186
+ 'iou': self.iou,
187
+ 'imgsz': self.imgsz,
188
+ 'save': save,
189
+ 'show': show,
190
+ 'save_txt': save_txt,
191
+ 'save_conf': save_conf,
192
+ 'save_crop': save_crop,
193
+ 'verbose': self.verbose
194
+ }
195
+
196
+ if self.device:
197
+ predict_args['device'] = self.device
198
+
199
+ if output_dir:
200
+ predict_args['project'] = str(Path(output_dir).parent)
201
+ predict_args['name'] = Path(output_dir).name
202
+
203
+ # Run batch inference
204
+ results = self.model.predict(**predict_args)
205
+ return results
206
+
207
+ def predict_from_list(
208
+ self,
209
+ image_list: List[Union[str, Path]],
210
+ save: bool = True,
211
+ show: bool = False,
212
+ save_txt: bool = False,
213
+ save_conf: bool = False,
214
+ save_crop: bool = False,
215
+ output_dir: Union[str, Path] = None
216
+ ):
217
+ """
218
+ Perform inference on a list of image paths.
219
+
220
+ Args:
221
+ image_list (List[str | Path]): List of image file paths
222
+ save (bool): Save annotated images
223
+ show (bool): Display results
224
+ save_txt (bool): Save detection results to txt files
225
+ save_conf (bool): Save confidence scores in txt files
226
+ save_crop (bool): Save cropped detection images
227
+ output_dir (str | Path): Output directory for saved results
228
+
229
+ Returns:
230
+ List of Results objects containing detection results for all images
231
+ """
232
+ all_results = []
233
+
234
+ for image_path in image_list:
235
+ if not Path(image_path).exists():
236
+ LOGGER.warning(f"Image not found: {image_path}")
237
+ continue
238
+
239
+ results = self.predict_single(
240
+ source=image_path,
241
+ save=save,
242
+ show=show,
243
+ save_txt=save_txt,
244
+ save_conf=save_conf,
245
+ save_crop=save_crop,
246
+ output_dir=output_dir
247
+ )
248
+ all_results.extend(results)
249
+
250
+ return all_results
251
+
252
+ def print_results_summary(self, results, source_info: str = ""):
253
+ """Print a summary of detection results."""
254
+ if not results:
255
+ LOGGER.info(f"No results to display{f' for {source_info}' if source_info else ''}")
256
+ return
257
+
258
+ total_detections = sum(len(r.boxes) if r.boxes is not None else 0 for r in results)
259
+
260
+ if self.verbose:
261
+ LOGGER.info(f"\n{colorstr('Results Summary')}{f' for {source_info}' if source_info else ''}:")
262
+ LOGGER.info(f" Images processed: {len(results)}")
263
+ LOGGER.info(f" Total detections: {total_detections}")
264
+
265
+ if hasattr(self.model.model, 'names') and total_detections > 0:
266
+ # Count detections per class
267
+ class_counts = {}
268
+ for result in results:
269
+ if result.boxes is not None:
270
+ for cls in result.boxes.cls:
271
+ cls_name = self.model.model.names[int(cls)]
272
+ class_counts[cls_name] = class_counts.get(cls_name, 0) + 1
273
+
274
+ LOGGER.info(" Detections by class:")
275
+ for cls_name, count in sorted(class_counts.items()):
276
+ LOGGER.info(f" {cls_name}: {count}")
277
+
278
+
279
+ def parse_arguments():
280
+ """Parse command line arguments."""
281
+ parser = argparse.ArgumentParser(
282
+ description="YOLOv12-DINO Inference Script",
283
+ formatter_class=argparse.RawDescriptionHelpFormatter,
284
+ epilog="""
285
+ Examples:
286
+ # Single image inference
287
+ python inference.py --weights best.pt --source image.jpg --save --show
288
+
289
+ # Batch inference on directory
290
+ python inference.py --weights runs/detect/train/weights/best.pt --source test_images/ --output results/
291
+
292
+ # Custom thresholds and save options
293
+ python inference.py --weights model.pt --source images/ --conf 0.5 --iou 0.7 --save-txt --save-crop
294
+ """
295
+ )
296
+
297
+ parser.add_argument(
298
+ '--weights', '-w',
299
+ type=str,
300
+ required=True,
301
+ help='Path to trained model weights (.pt file)'
302
+ )
303
+
304
+ parser.add_argument(
305
+ '--source', '-s',
306
+ type=str,
307
+ required=True,
308
+ help='Source for inference (image file, directory, or list of images)'
309
+ )
310
+
311
+ parser.add_argument(
312
+ '--output', '-o',
313
+ type=str,
314
+ default=None,
315
+ help='Output directory for results (default: runs/detect/predict)'
316
+ )
317
+
318
+ parser.add_argument(
319
+ '--conf',
320
+ type=float,
321
+ default=0.25,
322
+ help='Confidence threshold for detection (default: 0.25)'
323
+ )
324
+
325
+ parser.add_argument(
326
+ '--iou',
327
+ type=float,
328
+ default=0.7,
329
+ help='IoU threshold for NMS (default: 0.7)'
330
+ )
331
+
332
+ parser.add_argument(
333
+ '--imgsz',
334
+ type=int,
335
+ default=640,
336
+ help='Input image size (default: 640)'
337
+ )
338
+
339
+ parser.add_argument(
340
+ '--device',
341
+ type=str,
342
+ default='',
343
+ help='Device to run on (cpu, cuda, mps, etc.) (default: auto-detect)'
344
+ )
345
+
346
+ parser.add_argument(
347
+ '--save',
348
+ action='store_true',
349
+ help='Save annotated images'
350
+ )
351
+
352
+ parser.add_argument(
353
+ '--show',
354
+ action='store_true',
355
+ help='Display results'
356
+ )
357
+
358
+ parser.add_argument(
359
+ '--save-txt',
360
+ action='store_true',
361
+ help='Save detection results to txt files'
362
+ )
363
+
364
+ parser.add_argument(
365
+ '--save-conf',
366
+ action='store_true',
367
+ help='Save confidence scores in txt files'
368
+ )
369
+
370
+ parser.add_argument(
371
+ '--save-crop',
372
+ action='store_true',
373
+ help='Save cropped detection images'
374
+ )
375
+
376
+ parser.add_argument(
377
+ '--verbose', '-v',
378
+ action='store_true',
379
+ default=True,
380
+ help='Enable verbose output'
381
+ )
382
+
383
+ return parser.parse_args()
384
+
385
+
386
+ def main():
387
+ """Main inference function."""
388
+ args = parse_arguments()
389
+
390
+ try:
391
+ # Initialize inference model
392
+ inference = YOLOInference(
393
+ weights=args.weights,
394
+ conf=args.conf,
395
+ iou=args.iou,
396
+ imgsz=args.imgsz,
397
+ device=args.device,
398
+ verbose=args.verbose
399
+ )
400
+
401
+ # Determine source type and run inference
402
+ source_path = Path(args.source)
403
+ start_time = time.time()
404
+
405
+ if source_path.is_file():
406
+ # Single image inference
407
+ if args.verbose:
408
+ LOGGER.info(f"Running inference on single image: {source_path}")
409
+
410
+ results = inference.predict_single(
411
+ source=source_path,
412
+ save=args.save,
413
+ show=args.show,
414
+ save_txt=args.save_txt,
415
+ save_conf=args.save_conf,
416
+ save_crop=args.save_crop,
417
+ output_dir=args.output
418
+ )
419
+
420
+ inference.print_results_summary(results, str(source_path))
421
+
422
+ elif source_path.is_dir():
423
+ # Directory batch inference
424
+ if args.verbose:
425
+ LOGGER.info(f"Running batch inference on directory: {source_path}")
426
+
427
+ results = inference.predict_batch(
428
+ source_dir=source_path,
429
+ save=args.save,
430
+ show=args.show,
431
+ save_txt=args.save_txt,
432
+ save_conf=args.save_conf,
433
+ save_crop=args.save_crop,
434
+ output_dir=args.output
435
+ )
436
+
437
+ inference.print_results_summary(results, str(source_path))
438
+
439
+ else:
440
+ raise FileNotFoundError(f"Source not found: {source_path}")
441
+
442
+ # Print timing information
443
+ end_time = time.time()
444
+ if args.verbose:
445
+ LOGGER.info(f"\nInference completed in {end_time - start_time:.2f} seconds")
446
+
447
+ except Exception as e:
448
+ LOGGER.error(f"Error during inference: {e}")
449
+ sys.exit(1)
450
+
451
+
452
+ if __name__ == "__main__":
453
+ main()
packages.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ libgl1-mesa-glx
2
+ libglib2.0-0
pyproject.toml ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Overview:
4
+ # This pyproject.toml file manages the build, packaging, and distribution of the Ultralytics library.
5
+ # It defines essential project metadata, dependencies, and settings used to develop and deploy the library.
6
+
7
+ # Key Sections:
8
+ # - [build-system]: Specifies the build requirements and backend (e.g., setuptools, wheel).
9
+ # - [project]: Includes details like name, version, description, authors, dependencies and more.
10
+ # - [project.optional-dependencies]: Provides additional, optional packages for extended features.
11
+ # - [tool.*]: Configures settings for various tools (pytest, yapf, etc.) used in the project.
12
+
13
+ # Installation:
14
+ # The Ultralytics library can be installed using the command: 'pip install ultralytics'
15
+ # For development purposes, you can install the package in editable mode with: 'pip install -e .'
16
+ # This approach allows for real-time code modifications without the need for re-installation.
17
+
18
+ # Documentation:
19
+ # For comprehensive documentation and usage instructions, visit: https://docs.ultralytics.com
20
+
21
+ [build-system]
22
+ requires = ["setuptools>=70.0.0", "wheel"]
23
+ build-backend = "setuptools.build_meta"
24
+
25
+ # Project settings -----------------------------------------------------------------------------------------------------
26
+ [project]
27
+ name = "ultralytics"
28
+ dynamic = ["version"]
29
+ description = "Ultralytics YOLO 🚀 for SOTA object detection, multi-object tracking, instance segmentation, pose estimation and image classification."
30
+ readme = "README.md"
31
+ requires-python = ">=3.8"
32
+ license = { "text" = "AGPL-3.0" }
33
+ keywords = ["machine-learning", "deep-learning", "computer-vision", "ML", "DL", "AI", "YOLO", "YOLOv3", "YOLOv5", "YOLOv8", "YOLOv9", "YOLOv10", "YOLO11", "HUB", "Ultralytics"]
34
+ authors = [
35
+ { name = "Glenn Jocher", email = "[email protected]" },
36
+ { name = "Jing Qiu", email = "[email protected]" },
37
+ ]
38
+ maintainers = [
39
+ { name = "Ultralytics", email = "[email protected]" },
40
+ ]
41
+ classifiers = [
42
+ "Development Status :: 4 - Beta",
43
+ "Intended Audience :: Developers",
44
+ "Intended Audience :: Education",
45
+ "Intended Audience :: Science/Research",
46
+ "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
47
+ "Programming Language :: Python :: 3",
48
+ "Programming Language :: Python :: 3.8",
49
+ "Programming Language :: Python :: 3.9",
50
+ "Programming Language :: Python :: 3.10",
51
+ "Programming Language :: Python :: 3.11",
52
+ "Programming Language :: Python :: 3.12",
53
+ "Topic :: Software Development",
54
+ "Topic :: Scientific/Engineering",
55
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
56
+ "Topic :: Scientific/Engineering :: Image Recognition",
57
+ "Operating System :: POSIX :: Linux",
58
+ "Operating System :: MacOS",
59
+ "Operating System :: Microsoft :: Windows",
60
+ ]
61
+
62
+ # Required dependencies ------------------------------------------------------------------------------------------------
63
+ dependencies = [
64
+ "numpy>=1.23.0",
65
+ "numpy<2.0.0; sys_platform == 'darwin'", # macOS OpenVINO errors https://github.com/ultralytics/ultralytics/pull/17221
66
+ "matplotlib>=3.3.0",
67
+ "opencv-python>=4.6.0",
68
+ "pillow>=7.1.2",
69
+ "pyyaml>=5.3.1",
70
+ "requests>=2.23.0",
71
+ "scipy>=1.4.1",
72
+ "torch>=1.8.0",
73
+ "torch>=1.8.0,!=2.4.0; sys_platform == 'win32'", # Windows CPU errors w/ 2.4.0 https://github.com/ultralytics/ultralytics/issues/15049
74
+ "torchvision>=0.9.0",
75
+ "tqdm>=4.64.0", # progress bars
76
+ "psutil", # system utilization
77
+ "py-cpuinfo", # display CPU info
78
+ "pandas>=1.1.4",
79
+ "seaborn>=0.11.0", # plotting
80
+ "ultralytics-thop>=2.0.0", # FLOPs computation https://github.com/ultralytics/thop
81
+ ]
82
+
83
+ # Optional dependencies ------------------------------------------------------------------------------------------------
84
+ [project.optional-dependencies]
85
+ dev = [
86
+ "ipython",
87
+ "pytest",
88
+ "pytest-cov",
89
+ "coverage[toml]",
90
+ "mkdocs>=1.6.0",
91
+ "mkdocs-material>=9.5.9",
92
+ "mkdocstrings[python]",
93
+ "mkdocs-redirects", # 301 redirects
94
+ "mkdocs-ultralytics-plugin>=0.1.8", # for meta descriptions and images, dates and authors
95
+ "mkdocs-macros-plugin>=1.0.5" # duplicating content (i.e. export tables) in multiple places
96
+ ]
97
+ export = [
98
+ "onnx>=1.12.0", # ONNX export
99
+ "coremltools>=7.0; platform_system != 'Windows' and python_version <= '3.11'", # CoreML supported on macOS and Linux
100
+ "scikit-learn>=1.3.2; platform_system != 'Windows' and python_version <= '3.11'", # CoreML k-means quantization
101
+ "openvino>=2024.0.0", # OpenVINO export
102
+ "tensorflow>=2.0.0", # TF bug https://github.com/ultralytics/ultralytics/issues/5161
103
+ "tensorflowjs>=3.9.0", # TF.js export, automatically installs tensorflow
104
+ "tensorstore>=0.1.63; platform_machine == 'aarch64' and python_version >= '3.9'", # for TF Raspberry Pi exports
105
+ "keras", # not installed automatically by tensorflow>=2.16
106
+ "flatbuffers>=23.5.26,<100; platform_machine == 'aarch64'", # update old 'flatbuffers' included inside tensorflow package
107
+ "numpy==1.23.5; platform_machine == 'aarch64'", # fix error: `np.bool` was a deprecated alias for the builtin `bool` when using TensorRT models on NVIDIA Jetson
108
+ "h5py!=3.11.0; platform_machine == 'aarch64'", # fix h5py build issues due to missing aarch64 wheels in 3.11 release
109
+ ]
110
+ solutions = [
111
+ "shapely>=2.0.0", # shapely for point and polygon data matching
112
+ "streamlit", # for live inference on web browser i.e `yolo streamlit-predict`
113
+ ]
114
+ logging = [
115
+ "comet", # https://docs.ultralytics.com/integrations/comet/
116
+ "tensorboard>=2.13.0",
117
+ "dvclive>=2.12.0",
118
+ ]
119
+ extra = [
120
+ "hub-sdk>=0.0.12", # Ultralytics HUB
121
+ "ipython", # interactive notebook
122
+ "albumentations>=1.4.6", # training augmentations
123
+ "pycocotools>=2.0.7", # COCO mAP
124
+ ]
125
+
126
+ [project.urls]
127
+ "Homepage" = "https://ultralytics.com"
128
+ "Source" = "https://github.com/ultralytics/ultralytics"
129
+ "Documentation" = "https://docs.ultralytics.com"
130
+ "Bug Reports" = "https://github.com/ultralytics/ultralytics/issues"
131
+ "Changelog" = "https://github.com/ultralytics/ultralytics/releases"
132
+
133
+ [project.scripts]
134
+ yolo = "ultralytics.cfg:entrypoint"
135
+ ultralytics = "ultralytics.cfg:entrypoint"
136
+
137
+ # Tools settings -------------------------------------------------------------------------------------------------------
138
+ [tool.setuptools] # configuration specific to the `setuptools` build backend.
139
+ packages = { find = { where = ["."], include = ["ultralytics", "ultralytics.*"] } }
140
+ package-data = { "ultralytics" = ["**/*.yaml", "../tests/*.py"], "ultralytics.assets" = ["*.jpg"] }
141
+
142
+ [tool.setuptools.dynamic]
143
+ version = { attr = "ultralytics.__version__" }
144
+
145
+ [tool.pytest.ini_options]
146
+ addopts = "--doctest-modules --durations=30 --color=yes"
147
+ markers = [
148
+ "slow: skip slow tests unless --slow is set",
149
+ ]
150
+ norecursedirs = [".git", "dist", "build"]
151
+
152
+ [tool.coverage.run]
153
+ source = ["ultralytics/"]
154
+ data_file = "tests/.coverage"
155
+ omit = ["ultralytics/utils/callbacks/*"]
156
+
157
+ [tool.isort]
158
+ line_length = 120
159
+ multi_line_output = 0
160
+
161
+ [tool.yapf]
162
+ based_on_style = "pep8"
163
+ spaces_before_comment = 2
164
+ column_limit = 120
165
+ coalesce_brackets = true
166
+ spaces_around_power_operator = true
167
+ space_between_ending_comma_and_closing_bracket = true
168
+ split_before_closing_bracket = false
169
+ split_before_first_argument = false
170
+
171
+ [tool.ruff]
172
+ line-length = 120
173
+
174
+ [tool.ruff.format]
175
+ docstring-code-format = true
176
+
177
+ [tool.docformatter]
178
+ wrap-summaries = 120
179
+ wrap-descriptions = 120
180
+ pre-summary-newline = true
181
+ close-quotes-on-newline = true
182
+ in-place = true
183
+
184
+ [tool.codespell]
185
+ ignore-words-list = "crate,nd,ned,strack,dota,ane,segway,fo,gool,winn,commend,bloc,nam,afterall"
186
+ skip = '*.pt,*.pth,*.torchscript,*.onnx,*.tflite,*.pb,*.bin,*.param,*.mlmodel,*.engine,*.npy,*.data*,*.csv,*pnnx*,*venv*,*translat*,__pycache__*,*.ico,*.jpg,*.png,*.mp4,*.mov,/runs,/.git,./docs/??/*.md,./docs/mkdocs_??.yml'
requirements.txt CHANGED
@@ -1,3 +1,35 @@
1
- altair
2
- pandas
3
- streamlit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Core ML and Computer Vision
2
+ torch>=2.0.0
3
+ torchvision>=0.15.0
4
+ ultralytics>=8.0.0
5
+ transformers>=4.30.0
6
+
7
+ # Streamlit and Web Interface
8
+ streamlit>=1.28.0
9
+ plotly>=5.15.0
10
+
11
+ # Image Processing and Utilities
12
+ opencv-python-headless>=4.8.0
13
+ Pillow>=9.5.0
14
+ numpy>=1.23.0,<2.0.0
15
+
16
+ # Data Processing and Analysis
17
+ pandas>=2.0.0
18
+ matplotlib>=3.3.0
19
+ seaborn>=0.11.0
20
+
21
+ # Additional Dependencies for YOLOv12-DINO
22
+ PyYAML>=5.3.1
23
+ scipy>=1.4.1
24
+ tqdm>=4.64.0
25
+ psutil
26
+ py-cpuinfo
27
+ requests>=2.23.0
28
+ ultralytics-thop>=2.0.0
29
+
30
+ # Hugging Face Integration
31
+ huggingface_hub
32
+
33
+ # Optional: For enhanced performance on GPU
34
+ # flash-attn>=2.7.0
35
+ # timm>=1.0.14
run.sh ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Tunnel Crack Detection App Launcher
4
+ echo "🔍 Starting Tunnel Crack Detection App..."
5
+
6
+ # Check if virtual environment exists
7
+ if [ -d "venv" ]; then
8
+ echo "📦 Activating virtual environment..."
9
+ source venv/bin/activate
10
+ else
11
+ echo "⚠️ Virtual environment not found. Consider creating one:"
12
+ echo " python -m venv venv"
13
+ echo " source venv/bin/activate"
14
+ echo " pip install -r requirements.txt"
15
+ echo ""
16
+ fi
17
+
18
+ # Check if default model exists
19
+ DEFAULT_MODEL="/Users/sompoteyouwai/env/model_weight/segment_defect.pt"
20
+ if [ -f "$DEFAULT_MODEL" ]; then
21
+ echo "✅ Default model found: $DEFAULT_MODEL"
22
+ else
23
+ echo "⚠️ Default model not found at: $DEFAULT_MODEL"
24
+ echo " You can still upload a custom model through the web interface"
25
+ fi
26
+
27
+ # Check if requirements are installed
28
+ echo "🔧 Checking dependencies..."
29
+ python -c "import streamlit, torch, ultralytics" 2>/dev/null
30
+ if [ $? -eq 0 ]; then
31
+ echo "✅ Dependencies verified"
32
+ else
33
+ echo "❌ Missing dependencies. Installing..."
34
+ pip install -r requirements.txt
35
+ fi
36
+
37
+ echo ""
38
+ echo "🚀 Launching Streamlit app..."
39
+ echo "📱 Open your browser to: http://localhost:8501"
40
+ echo "⏹️ Press Ctrl+C to stop the server"
41
+ echo ""
42
+
43
+ # Launch Streamlit
44
+ streamlit run streamlit_app.py --server.port 8501 --server.address localhost
streamlit_app.py ADDED
@@ -0,0 +1,599 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Tunnel Crack Detection Streamlit App
4
+
5
+ A Streamlit-based web interface for tunnel crack detection using YOLOv12-DINO.
6
+ Upload images and get real-time crack detection results with interactive controls.
7
+ """
8
+
9
+ import streamlit as st
10
+ import cv2
11
+ import numpy as np
12
+ import pandas as pd
13
+ from pathlib import Path
14
+ import tempfile
15
+ import os
16
+ import sys
17
+ from typing import Dict, List, Tuple
18
+ import time
19
+ from PIL import Image
20
+ import plotly.express as px
21
+ import plotly.graph_objects as go
22
+
23
+ # Add the current directory to the Python path
24
+ current_dir = Path(__file__).parent
25
+ sys.path.insert(0, str(current_dir))
26
+
27
+ try:
28
+ from inference import YOLOInference
29
+ except ImportError as e:
30
+ st.error(f"Error importing inference module: {e}")
31
+ st.stop()
32
+
33
+ # Page configuration
34
+ st.set_page_config(
35
+ page_title="Tunnel Crack Detection",
36
+ page_icon="🔍",
37
+ layout="wide",
38
+ initial_sidebar_state="expanded"
39
+ )
40
+
41
+ # Configure large file uploads
42
+ import streamlit.web.bootstrap
43
+ try:
44
+ # Set large upload size (5GB in MB)
45
+ if hasattr(st, '_config'):
46
+ st._config.set_option('server.maxUploadSize', 5000)
47
+ else:
48
+ # For newer Streamlit versions
49
+ from streamlit import config
50
+ config.set_option('server.maxUploadSize', 5000)
51
+ config.set_option('server.maxMessageSize', 5000)
52
+ except Exception:
53
+ pass
54
+
55
+ # Set environment variable for large files (5GB in MB)
56
+ os.environ['STREAMLIT_SERVER_MAX_UPLOAD_SIZE'] = '5000'
57
+
58
+ # Custom CSS for better styling
59
+ st.markdown("""
60
+ <style>
61
+ .main-header {
62
+ font-size: 3rem;
63
+ color: #1e88e5;
64
+ text-align: center;
65
+ margin-bottom: 2rem;
66
+ }
67
+ .metric-card {
68
+ background-color: #f0f2f6;
69
+ padding: 1rem;
70
+ border-radius: 0.5rem;
71
+ margin: 0.5rem 0;
72
+ }
73
+ .detection-box {
74
+ border: 2px solid #1e88e5;
75
+ border-radius: 0.5rem;
76
+ padding: 1rem;
77
+ margin: 1rem 0;
78
+ background-color: #f8f9fa;
79
+ }
80
+ .success-box {
81
+ border: 2px solid #4caf50;
82
+ border-radius: 0.5rem;
83
+ padding: 1rem;
84
+ margin: 1rem 0;
85
+ background-color: #f1f8e9;
86
+ }
87
+ .error-box {
88
+ border: 2px solid #f44336;
89
+ border-radius: 0.5rem;
90
+ padding: 1rem;
91
+ margin: 1rem 0;
92
+ background-color: #ffebee;
93
+ }
94
+ .warning-box {
95
+ border: 2px solid #ff9800;
96
+ border-radius: 0.5rem;
97
+ padding: 1rem;
98
+ margin: 1rem 0;
99
+ background-color: #fff3e0;
100
+ }
101
+ </style>
102
+ """, unsafe_allow_html=True)
103
+
104
+ # Initialize session state
105
+ if 'model_loaded' not in st.session_state:
106
+ st.session_state.model_loaded = False
107
+ if 'model_instance' not in st.session_state:
108
+ st.session_state.model_instance = None
109
+ if 'detection_history' not in st.session_state:
110
+ st.session_state.detection_history = []
111
+
112
+ # Default model weight path
113
+ DEFAULT_WEIGHTS_PATH = "/Users/sompoteyouwai/env/model_weight/segment_defect.pt"
114
+
115
+ def load_model(weights_path: str, device: str = "cpu") -> Tuple[bool, str]:
116
+ """Load the YOLO model with specified weights."""
117
+ try:
118
+ if not Path(weights_path).exists():
119
+ return False, f"❌ Model file not found: {weights_path}"
120
+
121
+ with st.spinner("Loading tunnel crack detection model..."):
122
+ st.session_state.model_instance = YOLOInference(
123
+ weights=weights_path,
124
+ conf=0.25,
125
+ iou=0.7,
126
+ imgsz=640,
127
+ device=device,
128
+ verbose=True
129
+ )
130
+
131
+ st.session_state.model_loaded = True
132
+
133
+ # Get model information
134
+ model_info = f"✅ Model loaded successfully\n"
135
+ model_info += f"📋 Task: {st.session_state.model_instance.model.task}\n"
136
+
137
+ if hasattr(st.session_state.model_instance.model.model, 'names'):
138
+ class_names = list(st.session_state.model_instance.model.model.names.values())
139
+ model_info += f"🏷️ Classes ({len(class_names)}): {', '.join(class_names)}"
140
+
141
+ return True, model_info
142
+
143
+ except Exception as e:
144
+ return False, f"❌ Error loading model: {str(e)}"
145
+
146
+ def perform_detection(
147
+ image: np.ndarray,
148
+ conf_threshold: float,
149
+ iou_threshold: float,
150
+ image_size: int
151
+ ) -> Tuple[np.ndarray, Dict, str]:
152
+ """Perform crack detection using the loaded model."""
153
+
154
+ if st.session_state.model_instance is None:
155
+ return None, {}, "❌ No model loaded"
156
+
157
+ try:
158
+ # Update model parameters
159
+ st.session_state.model_instance.conf = conf_threshold
160
+ st.session_state.model_instance.iou = iou_threshold
161
+ st.session_state.model_instance.imgsz = image_size
162
+
163
+ # Save image to temporary file
164
+ with tempfile.NamedTemporaryFile(suffix='.jpg', delete=False) as tmp_file:
165
+ # Convert RGB to BGR for OpenCV
166
+ image_bgr = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
167
+ cv2.imwrite(tmp_file.name, image_bgr)
168
+ tmp_path = tmp_file.name
169
+
170
+ start_time = time.time()
171
+
172
+ try:
173
+ # Use the exact same method as inference.py
174
+ results = st.session_state.model_instance.predict_single(
175
+ source=tmp_path,
176
+ save=False,
177
+ show=False,
178
+ save_txt=False,
179
+ save_conf=False,
180
+ save_crop=False,
181
+ output_dir=None
182
+ )
183
+
184
+ inference_time = time.time() - start_time
185
+
186
+ if not results:
187
+ return image, {}, "❌ No results returned from model"
188
+
189
+ result = results[0]
190
+
191
+ # Get annotated image
192
+ annotated_img = result.plot()
193
+ annotated_img = cv2.cvtColor(annotated_img, cv2.COLOR_BGR2RGB)
194
+
195
+ # Process detection results
196
+ detection_data = process_detection_results(result, inference_time)
197
+
198
+ # Generate summary text
199
+ summary_text = generate_detection_summary(result, detection_data, inference_time)
200
+
201
+ return annotated_img, detection_data, summary_text
202
+
203
+ finally:
204
+ # Clean up temporary file
205
+ if os.path.exists(tmp_path):
206
+ os.unlink(tmp_path)
207
+
208
+ except Exception as e:
209
+ return None, {}, f"❌ Error during detection: {str(e)}"
210
+
211
+ def process_detection_results(result, inference_time: float) -> Dict:
212
+ """Process detection results into structured data."""
213
+
214
+ if result.boxes is None or len(result.boxes) == 0:
215
+ return {
216
+ 'total_detections': 0,
217
+ 'class_counts': {},
218
+ 'detections': [],
219
+ 'inference_time': inference_time
220
+ }
221
+
222
+ detections = result.boxes
223
+
224
+ # Get class names
225
+ if hasattr(st.session_state.model_instance.model.model, 'names'):
226
+ class_names = st.session_state.model_instance.model.model.names
227
+ else:
228
+ class_names = getattr(result, 'names', {i: f"Class_{i}" for i in range(100)})
229
+
230
+ # Process each detection
231
+ detection_list = []
232
+ class_counts = {}
233
+
234
+ for i, (box, conf, cls) in enumerate(zip(detections.xyxy, detections.conf, detections.cls)):
235
+ cls_id = int(cls)
236
+ cls_name = class_names.get(cls_id, f"Class_{cls_id}")
237
+ confidence = float(conf)
238
+
239
+ x1, y1, x2, y2 = box.tolist()
240
+
241
+ detection_list.append({
242
+ 'id': i + 1,
243
+ 'class': cls_name,
244
+ 'confidence': confidence,
245
+ 'x1': int(x1),
246
+ 'y1': int(y1),
247
+ 'x2': int(x2),
248
+ 'y2': int(y2),
249
+ 'width': int(x2 - x1),
250
+ 'height': int(y2 - y1),
251
+ 'area': int((x2 - x1) * (y2 - y1))
252
+ })
253
+
254
+ class_counts[cls_name] = class_counts.get(cls_name, 0) + 1
255
+
256
+ return {
257
+ 'total_detections': len(detection_list),
258
+ 'class_counts': class_counts,
259
+ 'detections': detection_list,
260
+ 'inference_time': inference_time
261
+ }
262
+
263
+ def generate_detection_summary(result, detection_data: Dict, inference_time: float) -> str:
264
+ """Generate detection summary text."""
265
+
266
+ total_detections = detection_data['total_detections']
267
+
268
+ if total_detections == 0:
269
+ return "🔍 No cracks or defects detected in the image."
270
+
271
+ summary = f"✅ **Detection Results:**\n\n"
272
+ summary += f"📊 **Images processed:** 1\n"
273
+ summary += f"📊 **Total detections:** {total_detections}\n"
274
+ summary += f"⏱️ **Inference time:** {inference_time:.3f}s\n\n"
275
+
276
+ summary += "📋 **Detections by class:**\n"
277
+ for cls_name, count in sorted(detection_data['class_counts'].items()):
278
+ summary += f" • {cls_name}: {count}\n"
279
+
280
+ return summary
281
+
282
+ def create_detection_chart(detection_data: Dict):
283
+ """Create interactive charts for detection results."""
284
+
285
+ if detection_data['total_detections'] == 0:
286
+ st.info("No detections to visualize")
287
+ return
288
+
289
+ # Class distribution pie chart
290
+ class_counts = detection_data['class_counts']
291
+
292
+ fig_pie = px.pie(
293
+ values=list(class_counts.values()),
294
+ names=list(class_counts.keys()),
295
+ title="Detection Distribution by Class",
296
+ color_discrete_sequence=px.colors.qualitative.Set3
297
+ )
298
+ fig_pie.update_layout(height=400)
299
+
300
+ st.plotly_chart(fig_pie, use_container_width=True)
301
+
302
+ # Confidence distribution
303
+ confidences = [det['confidence'] for det in detection_data['detections']]
304
+ classes = [det['class'] for det in detection_data['detections']]
305
+
306
+ fig_conf = px.box(
307
+ x=classes,
308
+ y=confidences,
309
+ title="Confidence Distribution by Class",
310
+ color=classes
311
+ )
312
+ fig_conf.update_layout(height=400)
313
+ fig_conf.update_xaxes(title="Class")
314
+ fig_conf.update_yaxes(title="Confidence Score")
315
+
316
+ st.plotly_chart(fig_conf, use_container_width=True)
317
+
318
+ def create_detection_table(detection_data: Dict):
319
+ """Create detailed detection table."""
320
+
321
+ if detection_data['total_detections'] == 0:
322
+ st.info("No detections to display")
323
+ return
324
+
325
+ # Convert to DataFrame
326
+ df = pd.DataFrame(detection_data['detections'])
327
+
328
+ # Format confidence as percentage
329
+ df['confidence_pct'] = df['confidence'].apply(lambda x: f"{x:.1%}")
330
+
331
+ # Reorder columns for better display
332
+ display_columns = ['id', 'class', 'confidence_pct', 'x1', 'y1', 'x2', 'y2', 'width', 'height', 'area']
333
+ df_display = df[display_columns].copy()
334
+
335
+ # Rename columns for better readability
336
+ df_display.columns = ['ID', 'Class', 'Confidence', 'X1', 'Y1', 'X2', 'Y2', 'Width', 'Height', 'Area']
337
+
338
+ st.dataframe(df_display, use_container_width=True)
339
+
340
+ # Download button for results
341
+ csv = df_display.to_csv(index=False)
342
+ st.download_button(
343
+ label="📥 Download Detection Results (CSV)",
344
+ data=csv,
345
+ file_name=f"crack_detection_results_{int(time.time())}.csv",
346
+ mime="text/csv"
347
+ )
348
+
349
+ def main():
350
+ """Main Streamlit application."""
351
+
352
+ # Header
353
+ st.markdown('<h1 class="main-header">🔍 Tunnel Crack Detection</h1>', unsafe_allow_html=True)
354
+ st.markdown("**AI-powered crack and defect detection for tunnel infrastructure using YOLOv12-DINO**")
355
+
356
+ # Sidebar for model configuration
357
+ with st.sidebar:
358
+ st.header("🛠️ Model Configuration")
359
+
360
+ # Model loading section
361
+ st.subheader("📁 Load Model")
362
+
363
+ # Check if default model exists
364
+ default_exists = Path(DEFAULT_WEIGHTS_PATH).exists()
365
+
366
+ if default_exists:
367
+ st.success(f"✅ Default model found: `segment_defect.pt`")
368
+ if st.button("🚀 Load Default Model", type="primary"):
369
+ device = st.selectbox(
370
+ "Device",
371
+ options=["cpu", "cuda", "mps"],
372
+ index=0,
373
+ help="Select computation device",
374
+ key="device_default"
375
+ )
376
+ success, message = load_model(DEFAULT_WEIGHTS_PATH, device)
377
+ if success:
378
+ st.success(message)
379
+ else:
380
+ st.error(message)
381
+ else:
382
+ st.markdown(f'<div class="warning-box">⚠️ Default model not found at:<br><code>{DEFAULT_WEIGHTS_PATH}</code></div>',
383
+ unsafe_allow_html=True)
384
+
385
+ st.markdown("---")
386
+
387
+ # Alternative model upload
388
+ st.info("💡 **Alternative:** Upload a custom model (up to 5GB)")
389
+ uploaded_file = st.file_uploader(
390
+ "Upload Model Weights (.pt file)",
391
+ type=['pt'],
392
+ help="Upload your trained YOLOv12-DINO model weights",
393
+ label_visibility="visible"
394
+ )
395
+
396
+ device = st.selectbox(
397
+ "Device",
398
+ options=["cpu", "cuda", "mps"],
399
+ index=0,
400
+ help="Select computation device",
401
+ key="device_upload"
402
+ )
403
+
404
+ if uploaded_file is not None:
405
+ # Show file info
406
+ file_size_mb = uploaded_file.size / (1024 * 1024)
407
+ st.success(f"📁 File uploaded: {uploaded_file.name} ({file_size_mb:.1f} MB)")
408
+
409
+ if st.button("🔄 Load Uploaded Model", type="secondary"):
410
+ # Show progress for large file processing
411
+ progress_bar = st.progress(0)
412
+ status_text = st.empty()
413
+
414
+ try:
415
+ # Save uploaded file temporarily with progress indication
416
+ status_text.text("💾 Saving uploaded file...")
417
+ progress_bar.progress(25)
418
+
419
+ with tempfile.NamedTemporaryFile(delete=False, suffix='.pt') as tmp_file:
420
+ tmp_file.write(uploaded_file.read())
421
+ tmp_path = tmp_file.name
422
+
423
+ progress_bar.progress(50)
424
+ status_text.text("🚀 Loading model...")
425
+
426
+ success, message = load_model(tmp_path, device)
427
+
428
+ progress_bar.progress(100)
429
+ status_text.text("✅ Model loading complete!")
430
+
431
+ if success:
432
+ st.success(message)
433
+ else:
434
+ st.error(message)
435
+
436
+ # Clean up progress indicators
437
+ time.sleep(1)
438
+ progress_bar.empty()
439
+ status_text.empty()
440
+
441
+ except Exception as e:
442
+ st.error(f"❌ Error processing file: {str(e)}")
443
+ progress_bar.empty()
444
+ status_text.empty()
445
+
446
+ # Detection parameters
447
+ st.subheader("⚙️ Detection Parameters")
448
+
449
+ conf_threshold = st.slider(
450
+ "Confidence Threshold",
451
+ min_value=0.01,
452
+ max_value=1.0,
453
+ value=0.25,
454
+ step=0.01,
455
+ help="Minimum confidence for detection"
456
+ )
457
+
458
+ iou_threshold = st.slider(
459
+ "IoU Threshold",
460
+ min_value=0.01,
461
+ max_value=1.0,
462
+ value=0.7,
463
+ step=0.01,
464
+ help="IoU threshold for Non-Maximum Suppression"
465
+ )
466
+
467
+ image_size = st.selectbox(
468
+ "Image Size",
469
+ options=[320, 416, 512, 640, 832, 1024, 1280],
470
+ index=3,
471
+ help="Input image size for model"
472
+ )
473
+
474
+ # Model status
475
+ if st.session_state.model_loaded:
476
+ st.markdown('<div class="success-box">✅ Model loaded and ready</div>', unsafe_allow_html=True)
477
+ else:
478
+ st.markdown('<div class="warning-box">⚠️ Please load a model first</div>', unsafe_allow_html=True)
479
+
480
+ # Main content area
481
+ col1, col2 = st.columns([1, 1])
482
+
483
+ with col1:
484
+ st.header("🖼️ Input Image")
485
+
486
+ # Image upload
487
+ image_file = st.file_uploader(
488
+ "Upload Image",
489
+ type=['jpg', 'jpeg', 'png', 'bmp'],
490
+ help="Upload a tunnel image for crack detection"
491
+ )
492
+
493
+ if image_file is not None:
494
+ # Load and display image
495
+ try:
496
+ image = Image.open(image_file)
497
+ image_np = np.array(image)
498
+
499
+ # Display image
500
+ st.image(image, caption="Input Image", width=None)
501
+
502
+ # Image info
503
+ st.info(f"📊 Image size: {image.width} × {image.height} pixels")
504
+
505
+ except Exception as e:
506
+ st.error(f"❌ Error loading image: {str(e)}")
507
+ return
508
+
509
+ # Detection button
510
+ if st.button("🔍 Detect Cracks", type="primary", disabled=not st.session_state.model_loaded):
511
+ if st.session_state.model_loaded:
512
+ with st.spinner("Analyzing image for cracks and defects..."):
513
+ annotated_img, detection_data, summary_text = perform_detection(
514
+ image_np, conf_threshold, iou_threshold, image_size
515
+ )
516
+
517
+ # Store results in session state
518
+ st.session_state.last_detection = {
519
+ 'annotated_img': annotated_img,
520
+ 'detection_data': detection_data,
521
+ 'summary_text': summary_text,
522
+ 'timestamp': time.time()
523
+ }
524
+
525
+ # Add to history
526
+ st.session_state.detection_history.append({
527
+ 'filename': image_file.name,
528
+ 'detections': detection_data['total_detections'],
529
+ 'timestamp': time.time()
530
+ })
531
+ else:
532
+ st.error("❌ Please load a model first")
533
+
534
+ with col2:
535
+ st.header("🎯 Detection Results")
536
+
537
+ if 'last_detection' in st.session_state:
538
+ detection_result = st.session_state.last_detection
539
+
540
+ # Display annotated image
541
+ if detection_result['annotated_img'] is not None:
542
+ try:
543
+ st.image(
544
+ detection_result['annotated_img'],
545
+ caption="Crack Detection Results",
546
+ width=None
547
+ )
548
+ except Exception as e:
549
+ st.error(f"Error displaying result image: {str(e)}")
550
+
551
+ # Display summary
552
+ st.markdown(f'<div class="detection-box">{detection_result["summary_text"]}</div>',
553
+ unsafe_allow_html=True)
554
+
555
+ else:
556
+ st.info("🔍 Upload an image and click 'Detect Cracks' to see results")
557
+
558
+ # Additional tabs for detailed analysis
559
+ if 'last_detection' in st.session_state and st.session_state.last_detection['detection_data']['total_detections'] > 0:
560
+
561
+ st.header("📊 Detailed Analysis")
562
+
563
+ tab1, tab2, tab3 = st.tabs(["📈 Charts", "📋 Detection Table", "📜 History"])
564
+
565
+ with tab1:
566
+ create_detection_chart(st.session_state.last_detection['detection_data'])
567
+
568
+ with tab2:
569
+ create_detection_table(st.session_state.last_detection['detection_data'])
570
+
571
+ with tab3:
572
+ if st.session_state.detection_history:
573
+ history_df = pd.DataFrame(st.session_state.detection_history)
574
+ history_df['timestamp'] = pd.to_datetime(history_df['timestamp'], unit='s')
575
+ history_df.columns = ['Filename', 'Detections', 'Timestamp']
576
+
577
+ st.dataframe(history_df, use_container_width=True)
578
+
579
+ # Clear history button
580
+ if st.button("🗑️ Clear History"):
581
+ st.session_state.detection_history = []
582
+ st.rerun()
583
+ else:
584
+ st.info("No detection history yet")
585
+
586
+ # Footer
587
+ st.markdown("---")
588
+ st.markdown(
589
+ """
590
+ <div style='text-align: center; color: #666; padding: 1rem;'>
591
+ 🔍 <strong>Tunnel Crack Detection System</strong> |
592
+ Powered by <strong>Streamlit</strong> + <strong>YOLOv12-DINO</strong>
593
+ </div>
594
+ """,
595
+ unsafe_allow_html=True
596
+ )
597
+
598
+ if __name__ == "__main__":
599
+ main()
ultralytics/__init__.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ __version__ = "8.3.63"
4
+
5
+ import os
6
+
7
+ # Set ENV variables (place before imports)
8
+ if not os.environ.get("OMP_NUM_THREADS"):
9
+ os.environ["OMP_NUM_THREADS"] = "1" # default for reduced CPU utilization during training
10
+
11
+ from ultralytics.models import NAS, RTDETR, SAM, YOLO, FastSAM, YOLOWorld
12
+ from ultralytics.utils import ASSETS, SETTINGS
13
+ from ultralytics.utils.checks import check_yolo as checks
14
+ from ultralytics.utils.downloads import download
15
+
16
+ settings = SETTINGS
17
+ __all__ = (
18
+ "__version__",
19
+ "ASSETS",
20
+ "YOLO",
21
+ "YOLOWorld",
22
+ "NAS",
23
+ "SAM",
24
+ "FastSAM",
25
+ "RTDETR",
26
+ "checks",
27
+ "download",
28
+ "settings",
29
+ )
ultralytics/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (890 Bytes). View file
 
ultralytics/assets/bus.jpg ADDED

Git LFS Details

  • SHA256: c02019c4979c191eb739ddd944445ef408dad5679acab6fd520ef9d434bfbc63
  • Pointer size: 131 Bytes
  • Size of remote file: 137 kB
ultralytics/assets/zidane.jpg ADDED
ultralytics/cfg/__init__.py ADDED
@@ -0,0 +1,1025 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ import shutil
4
+ import subprocess
5
+ import sys
6
+ from pathlib import Path
7
+ from types import SimpleNamespace
8
+ from typing import Dict, List, Union
9
+
10
+ import cv2
11
+
12
+ from ultralytics.utils import (
13
+ ASSETS,
14
+ DEFAULT_CFG,
15
+ DEFAULT_CFG_DICT,
16
+ DEFAULT_CFG_PATH,
17
+ DEFAULT_SOL_DICT,
18
+ IS_VSCODE,
19
+ LOGGER,
20
+ RANK,
21
+ ROOT,
22
+ RUNS_DIR,
23
+ SETTINGS,
24
+ SETTINGS_FILE,
25
+ TESTS_RUNNING,
26
+ IterableSimpleNamespace,
27
+ __version__,
28
+ checks,
29
+ colorstr,
30
+ deprecation_warn,
31
+ vscode_msg,
32
+ yaml_load,
33
+ yaml_print,
34
+ )
35
+
36
+ # Define valid solutions
37
+ SOLUTION_MAP = {
38
+ "count": ("ObjectCounter", "count"),
39
+ "heatmap": ("Heatmap", "generate_heatmap"),
40
+ "queue": ("QueueManager", "process_queue"),
41
+ "speed": ("SpeedEstimator", "estimate_speed"),
42
+ "workout": ("AIGym", "monitor"),
43
+ "analytics": ("Analytics", "process_data"),
44
+ "trackzone": ("TrackZone", "trackzone"),
45
+ "inference": ("Inference", "inference"),
46
+ "help": None,
47
+ }
48
+
49
+ # Define valid tasks and modes
50
+ MODES = {"train", "val", "predict", "export", "track", "benchmark"}
51
+ TASKS = {"detect", "segment", "classify", "pose", "obb"}
52
+ TASK2DATA = {
53
+ "detect": "coco8.yaml",
54
+ "segment": "coco8-seg.yaml",
55
+ "classify": "imagenet10",
56
+ "pose": "coco8-pose.yaml",
57
+ "obb": "dota8.yaml",
58
+ }
59
+ TASK2MODEL = {
60
+ "detect": "yolo11n.pt",
61
+ "segment": "yolo11n-seg.pt",
62
+ "classify": "yolo11n-cls.pt",
63
+ "pose": "yolo11n-pose.pt",
64
+ "obb": "yolo11n-obb.pt",
65
+ }
66
+ TASK2METRIC = {
67
+ "detect": "metrics/mAP50-95(B)",
68
+ "segment": "metrics/mAP50-95(M)",
69
+ "classify": "metrics/accuracy_top1",
70
+ "pose": "metrics/mAP50-95(P)",
71
+ "obb": "metrics/mAP50-95(B)",
72
+ }
73
+ MODELS = {TASK2MODEL[task] for task in TASKS}
74
+
75
+ ARGV = sys.argv or ["", ""] # sometimes sys.argv = []
76
+ SOLUTIONS_HELP_MSG = f"""
77
+ Arguments received: {str(["yolo"] + ARGV[1:])}. Ultralytics 'yolo solutions' usage overview:
78
+
79
+ yolo solutions SOLUTION ARGS
80
+
81
+ Where SOLUTION (optional) is one of {list(SOLUTION_MAP.keys())[:-1]}
82
+ ARGS (optional) are any number of custom 'arg=value' pairs like 'show_in=True' that override defaults
83
+ at https://docs.ultralytics.com/usage/cfg
84
+
85
+ 1. Call object counting solution
86
+ yolo solutions count source="path/to/video/file.mp4" region=[(20, 400), (1080, 400), (1080, 360), (20, 360)]
87
+
88
+ 2. Call heatmaps solution
89
+ yolo solutions heatmap colormap=cv2.COLORMAP_PARULA model=yolo11n.pt
90
+
91
+ 3. Call queue management solution
92
+ yolo solutions queue region=[(20, 400), (1080, 400), (1080, 360), (20, 360)] model=yolo11n.pt
93
+
94
+ 4. Call workouts monitoring solution for push-ups
95
+ yolo solutions workout model=yolo11n-pose.pt kpts=[6, 8, 10]
96
+
97
+ 5. Generate analytical graphs
98
+ yolo solutions analytics analytics_type="pie"
99
+
100
+ 6. Track objects within specific zones
101
+ yolo solutions trackzone source="path/to/video/file.mp4" region=[(150, 150), (1130, 150), (1130, 570), (150, 570)]
102
+
103
+ 7. Streamlit real-time webcam inference GUI
104
+ yolo streamlit-predict
105
+ """
106
+ CLI_HELP_MSG = f"""
107
+ Arguments received: {str(["yolo"] + ARGV[1:])}. Ultralytics 'yolo' commands use the following syntax:
108
+
109
+ yolo TASK MODE ARGS
110
+
111
+ Where TASK (optional) is one of {TASKS}
112
+ MODE (required) is one of {MODES}
113
+ ARGS (optional) are any number of custom 'arg=value' pairs like 'imgsz=320' that override defaults.
114
+ See all ARGS at https://docs.ultralytics.com/usage/cfg or with 'yolo cfg'
115
+
116
+ 1. Train a detection model for 10 epochs with an initial learning_rate of 0.01
117
+ yolo train data=coco8.yaml model=yolo11n.pt epochs=10 lr0=0.01
118
+
119
+ 2. Predict a YouTube video using a pretrained segmentation model at image size 320:
120
+ yolo predict model=yolo11n-seg.pt source='https://youtu.be/LNwODJXcvt4' imgsz=320
121
+
122
+ 3. Val a pretrained detection model at batch-size 1 and image size 640:
123
+ yolo val model=yolo11n.pt data=coco8.yaml batch=1 imgsz=640
124
+
125
+ 4. Export a YOLO11n classification model to ONNX format at image size 224 by 128 (no TASK required)
126
+ yolo export model=yolo11n-cls.pt format=onnx imgsz=224,128
127
+
128
+ 5. Ultralytics solutions usage
129
+ yolo solutions count or in {list(SOLUTION_MAP.keys())[1:-1]} source="path/to/video/file.mp4"
130
+
131
+ 6. Run special commands:
132
+ yolo help
133
+ yolo checks
134
+ yolo version
135
+ yolo settings
136
+ yolo copy-cfg
137
+ yolo cfg
138
+ yolo solutions help
139
+
140
+ Docs: https://docs.ultralytics.com
141
+ Solutions: https://docs.ultralytics.com/solutions/
142
+ Community: https://community.ultralytics.com
143
+ GitHub: https://github.com/ultralytics/ultralytics
144
+ """
145
+
146
+ # Define keys for arg type checks
147
+ CFG_FLOAT_KEYS = { # integer or float arguments, i.e. x=2 and x=2.0
148
+ "warmup_epochs",
149
+ "box",
150
+ "cls",
151
+ "dfl",
152
+ "degrees",
153
+ "shear",
154
+ "time",
155
+ "workspace",
156
+ "batch",
157
+ }
158
+ CFG_FRACTION_KEYS = { # fractional float arguments with 0.0<=values<=1.0
159
+ "dropout",
160
+ "lr0",
161
+ "lrf",
162
+ "momentum",
163
+ "weight_decay",
164
+ "warmup_momentum",
165
+ "warmup_bias_lr",
166
+ "hsv_h",
167
+ "hsv_s",
168
+ "hsv_v",
169
+ "translate",
170
+ "scale",
171
+ "perspective",
172
+ "flipud",
173
+ "fliplr",
174
+ "bgr",
175
+ "mosaic",
176
+ "mixup",
177
+ "copy_paste",
178
+ "conf",
179
+ "iou",
180
+ "fraction",
181
+ }
182
+ CFG_INT_KEYS = { # integer-only arguments
183
+ "epochs",
184
+ "patience",
185
+ "workers",
186
+ "seed",
187
+ "close_mosaic",
188
+ "mask_ratio",
189
+ "max_det",
190
+ "vid_stride",
191
+ "line_width",
192
+ "nbs",
193
+ "save_period",
194
+ }
195
+ CFG_BOOL_KEYS = { # boolean-only arguments
196
+ "save",
197
+ "exist_ok",
198
+ "verbose",
199
+ "deterministic",
200
+ "single_cls",
201
+ "rect",
202
+ "cos_lr",
203
+ "overlap_mask",
204
+ "val",
205
+ "save_json",
206
+ "save_hybrid",
207
+ "half",
208
+ "dnn",
209
+ "plots",
210
+ "show",
211
+ "save_txt",
212
+ "save_conf",
213
+ "save_crop",
214
+ "save_frames",
215
+ "show_labels",
216
+ "show_conf",
217
+ "visualize",
218
+ "augment",
219
+ "agnostic_nms",
220
+ "retina_masks",
221
+ "show_boxes",
222
+ "keras",
223
+ "optimize",
224
+ "int8",
225
+ "dynamic",
226
+ "simplify",
227
+ "nms",
228
+ "profile",
229
+ "multi_scale",
230
+ }
231
+
232
+
233
+ def cfg2dict(cfg):
234
+ """
235
+ Converts a configuration object to a dictionary.
236
+
237
+ Args:
238
+ cfg (str | Path | Dict | SimpleNamespace): Configuration object to be converted. Can be a file path,
239
+ a string, a dictionary, or a SimpleNamespace object.
240
+
241
+ Returns:
242
+ (Dict): Configuration object in dictionary format.
243
+
244
+ Examples:
245
+ Convert a YAML file path to a dictionary:
246
+ >>> config_dict = cfg2dict("config.yaml")
247
+
248
+ Convert a SimpleNamespace to a dictionary:
249
+ >>> from types import SimpleNamespace
250
+ >>> config_sn = SimpleNamespace(param1="value1", param2="value2")
251
+ >>> config_dict = cfg2dict(config_sn)
252
+
253
+ Pass through an already existing dictionary:
254
+ >>> config_dict = cfg2dict({"param1": "value1", "param2": "value2"})
255
+
256
+ Notes:
257
+ - If cfg is a path or string, it's loaded as YAML and converted to a dictionary.
258
+ - If cfg is a SimpleNamespace object, it's converted to a dictionary using vars().
259
+ - If cfg is already a dictionary, it's returned unchanged.
260
+ """
261
+ if isinstance(cfg, (str, Path)):
262
+ cfg = yaml_load(cfg) # load dict
263
+ elif isinstance(cfg, SimpleNamespace):
264
+ cfg = vars(cfg) # convert to dict
265
+ return cfg
266
+
267
+
268
+ def get_cfg(cfg: Union[str, Path, Dict, SimpleNamespace] = DEFAULT_CFG_DICT, overrides: Dict = None):
269
+ """
270
+ Load and merge configuration data from a file or dictionary, with optional overrides.
271
+
272
+ Args:
273
+ cfg (str | Path | Dict | SimpleNamespace): Configuration data source. Can be a file path, dictionary, or
274
+ SimpleNamespace object.
275
+ overrides (Dict | None): Dictionary containing key-value pairs to override the base configuration.
276
+
277
+ Returns:
278
+ (SimpleNamespace): Namespace containing the merged configuration arguments.
279
+
280
+ Examples:
281
+ >>> from ultralytics.cfg import get_cfg
282
+ >>> config = get_cfg() # Load default configuration
283
+ >>> config_with_overrides = get_cfg("path/to/config.yaml", overrides={"epochs": 50, "batch_size": 16})
284
+
285
+ Notes:
286
+ - If both `cfg` and `overrides` are provided, the values in `overrides` will take precedence.
287
+ - Special handling ensures alignment and correctness of the configuration, such as converting numeric
288
+ `project` and `name` to strings and validating configuration keys and values.
289
+ - The function performs type and value checks on the configuration data.
290
+ """
291
+ cfg = cfg2dict(cfg)
292
+
293
+ # Merge overrides
294
+ if overrides:
295
+ overrides = cfg2dict(overrides)
296
+ if "save_dir" not in cfg:
297
+ overrides.pop("save_dir", None) # special override keys to ignore
298
+ check_dict_alignment(cfg, overrides)
299
+ cfg = {**cfg, **overrides} # merge cfg and overrides dicts (prefer overrides)
300
+
301
+ # Special handling for numeric project/name
302
+ for k in "project", "name":
303
+ if k in cfg and isinstance(cfg[k], (int, float)):
304
+ cfg[k] = str(cfg[k])
305
+ if cfg.get("name") == "model": # assign model to 'name' arg
306
+ cfg["name"] = str(cfg.get("model", "")).split(".")[0]
307
+ LOGGER.warning(f"WARNING ⚠️ 'name=model' automatically updated to 'name={cfg['name']}'.")
308
+
309
+ # Type and Value checks
310
+ check_cfg(cfg)
311
+
312
+ # Return instance
313
+ return IterableSimpleNamespace(**cfg)
314
+
315
+
316
+ def check_cfg(cfg, hard=True):
317
+ """
318
+ Checks configuration argument types and values for the Ultralytics library.
319
+
320
+ This function validates the types and values of configuration arguments, ensuring correctness and converting
321
+ them if necessary. It checks for specific key types defined in global variables such as CFG_FLOAT_KEYS,
322
+ CFG_FRACTION_KEYS, CFG_INT_KEYS, and CFG_BOOL_KEYS.
323
+
324
+ Args:
325
+ cfg (Dict): Configuration dictionary to validate.
326
+ hard (bool): If True, raises exceptions for invalid types and values; if False, attempts to convert them.
327
+
328
+ Examples:
329
+ >>> config = {
330
+ ... "epochs": 50, # valid integer
331
+ ... "lr0": 0.01, # valid float
332
+ ... "momentum": 1.2, # invalid float (out of 0.0-1.0 range)
333
+ ... "save": "true", # invalid bool
334
+ ... }
335
+ >>> check_cfg(config, hard=False)
336
+ >>> print(config)
337
+ {'epochs': 50, 'lr0': 0.01, 'momentum': 1.2, 'save': False} # corrected 'save' key
338
+
339
+ Notes:
340
+ - The function modifies the input dictionary in-place.
341
+ - None values are ignored as they may be from optional arguments.
342
+ - Fraction keys are checked to be within the range [0.0, 1.0].
343
+ """
344
+ for k, v in cfg.items():
345
+ if v is not None: # None values may be from optional args
346
+ if k in CFG_FLOAT_KEYS and not isinstance(v, (int, float)):
347
+ if hard:
348
+ raise TypeError(
349
+ f"'{k}={v}' is of invalid type {type(v).__name__}. "
350
+ f"Valid '{k}' types are int (i.e. '{k}=0') or float (i.e. '{k}=0.5')"
351
+ )
352
+ cfg[k] = float(v)
353
+ elif k in CFG_FRACTION_KEYS:
354
+ if not isinstance(v, (int, float)):
355
+ if hard:
356
+ raise TypeError(
357
+ f"'{k}={v}' is of invalid type {type(v).__name__}. "
358
+ f"Valid '{k}' types are int (i.e. '{k}=0') or float (i.e. '{k}=0.5')"
359
+ )
360
+ cfg[k] = v = float(v)
361
+ if not (0.0 <= v <= 1.0):
362
+ raise ValueError(f"'{k}={v}' is an invalid value. Valid '{k}' values are between 0.0 and 1.0.")
363
+ elif k in CFG_INT_KEYS and not isinstance(v, int):
364
+ if hard:
365
+ raise TypeError(
366
+ f"'{k}={v}' is of invalid type {type(v).__name__}. '{k}' must be an int (i.e. '{k}=8')"
367
+ )
368
+ cfg[k] = int(v)
369
+ elif k in CFG_BOOL_KEYS and not isinstance(v, bool):
370
+ if hard:
371
+ raise TypeError(
372
+ f"'{k}={v}' is of invalid type {type(v).__name__}. "
373
+ f"'{k}' must be a bool (i.e. '{k}=True' or '{k}=False')"
374
+ )
375
+ cfg[k] = bool(v)
376
+
377
+
378
+ def get_save_dir(args, name=None):
379
+ """
380
+ Returns the directory path for saving outputs, derived from arguments or default settings.
381
+
382
+ Args:
383
+ args (SimpleNamespace): Namespace object containing configurations such as 'project', 'name', 'task',
384
+ 'mode', and 'save_dir'.
385
+ name (str | None): Optional name for the output directory. If not provided, it defaults to 'args.name'
386
+ or the 'args.mode'.
387
+
388
+ Returns:
389
+ (Path): Directory path where outputs should be saved.
390
+
391
+ Examples:
392
+ >>> from types import SimpleNamespace
393
+ >>> args = SimpleNamespace(project="my_project", task="detect", mode="train", exist_ok=True)
394
+ >>> save_dir = get_save_dir(args)
395
+ >>> print(save_dir)
396
+ my_project/detect/train
397
+ """
398
+ if getattr(args, "save_dir", None):
399
+ save_dir = args.save_dir
400
+ else:
401
+ from ultralytics.utils.files import increment_path
402
+
403
+ project = args.project or (ROOT.parent / "tests/tmp/runs" if TESTS_RUNNING else RUNS_DIR) / args.task
404
+ name = name or args.name or f"{args.mode}"
405
+ save_dir = increment_path(Path(project) / name, exist_ok=args.exist_ok if RANK in {-1, 0} else True)
406
+
407
+ return Path(save_dir)
408
+
409
+
410
+ def _handle_deprecation(custom):
411
+ """
412
+ Handles deprecated configuration keys by mapping them to current equivalents with deprecation warnings.
413
+
414
+ Args:
415
+ custom (Dict): Configuration dictionary potentially containing deprecated keys.
416
+
417
+ Examples:
418
+ >>> custom_config = {"boxes": True, "hide_labels": "False", "line_thickness": 2}
419
+ >>> _handle_deprecation(custom_config)
420
+ >>> print(custom_config)
421
+ {'show_boxes': True, 'show_labels': True, 'line_width': 2}
422
+
423
+ Notes:
424
+ This function modifies the input dictionary in-place, replacing deprecated keys with their current
425
+ equivalents. It also handles value conversions where necessary, such as inverting boolean values for
426
+ 'hide_labels' and 'hide_conf'.
427
+ """
428
+ for key in custom.copy().keys():
429
+ if key == "boxes":
430
+ deprecation_warn(key, "show_boxes")
431
+ custom["show_boxes"] = custom.pop("boxes")
432
+ if key == "hide_labels":
433
+ deprecation_warn(key, "show_labels")
434
+ custom["show_labels"] = custom.pop("hide_labels") == "False"
435
+ if key == "hide_conf":
436
+ deprecation_warn(key, "show_conf")
437
+ custom["show_conf"] = custom.pop("hide_conf") == "False"
438
+ if key == "line_thickness":
439
+ deprecation_warn(key, "line_width")
440
+ custom["line_width"] = custom.pop("line_thickness")
441
+ if key == "label_smoothing":
442
+ deprecation_warn(key)
443
+ custom.pop("label_smoothing")
444
+
445
+ return custom
446
+
447
+
448
+ def check_dict_alignment(base: Dict, custom: Dict, e=None):
449
+ """
450
+ Checks alignment between custom and base configuration dictionaries, handling deprecated keys and providing error
451
+ messages for mismatched keys.
452
+
453
+ Args:
454
+ base (Dict): The base configuration dictionary containing valid keys.
455
+ custom (Dict): The custom configuration dictionary to be checked for alignment.
456
+ e (Exception | None): Optional error instance passed by the calling function.
457
+
458
+ Raises:
459
+ SystemExit: If mismatched keys are found between the custom and base dictionaries.
460
+
461
+ Examples:
462
+ >>> base_cfg = {"epochs": 50, "lr0": 0.01, "batch_size": 16}
463
+ >>> custom_cfg = {"epoch": 100, "lr": 0.02, "batch_size": 32}
464
+ >>> try:
465
+ ... check_dict_alignment(base_cfg, custom_cfg)
466
+ ... except SystemExit:
467
+ ... print("Mismatched keys found")
468
+
469
+ Notes:
470
+ - Suggests corrections for mismatched keys based on similarity to valid keys.
471
+ - Automatically replaces deprecated keys in the custom configuration with updated equivalents.
472
+ - Prints detailed error messages for each mismatched key to help users correct their configurations.
473
+ """
474
+ custom = _handle_deprecation(custom)
475
+ base_keys, custom_keys = (set(x.keys()) for x in (base, custom))
476
+ if mismatched := [k for k in custom_keys if k not in base_keys]:
477
+ from difflib import get_close_matches
478
+
479
+ string = ""
480
+ for x in mismatched:
481
+ matches = get_close_matches(x, base_keys) # key list
482
+ matches = [f"{k}={base[k]}" if base.get(k) is not None else k for k in matches]
483
+ match_str = f"Similar arguments are i.e. {matches}." if matches else ""
484
+ string += f"'{colorstr('red', 'bold', x)}' is not a valid YOLO argument. {match_str}\n"
485
+ raise SyntaxError(string + CLI_HELP_MSG) from e
486
+
487
+
488
+ def merge_equals_args(args: List[str]) -> List[str]:
489
+ """
490
+ Merges arguments around isolated '=' in a list of strings and joins fragments with brackets.
491
+
492
+ This function handles the following cases:
493
+ 1. ['arg', '=', 'val'] becomes ['arg=val']
494
+ 2. ['arg=', 'val'] becomes ['arg=val']
495
+ 3. ['arg', '=val'] becomes ['arg=val']
496
+ 4. Joins fragments with brackets, e.g., ['imgsz=[3,', '640,', '640]'] becomes ['imgsz=[3,640,640]']
497
+
498
+ Args:
499
+ args (List[str]): A list of strings where each element represents an argument or fragment.
500
+
501
+ Returns:
502
+ List[str]: A list of strings where the arguments around isolated '=' are merged and fragments with brackets are joined.
503
+
504
+ Examples:
505
+ >>> args = ["arg1", "=", "value", "arg2=", "value2", "arg3", "=value3", "imgsz=[3,", "640,", "640]"]
506
+ >>> merge_and_join_args(args)
507
+ ['arg1=value', 'arg2=value2', 'arg3=value3', 'imgsz=[3,640,640]']
508
+ """
509
+ new_args = []
510
+ current = ""
511
+ depth = 0
512
+
513
+ i = 0
514
+ while i < len(args):
515
+ arg = args[i]
516
+
517
+ # Handle equals sign merging
518
+ if arg == "=" and 0 < i < len(args) - 1: # merge ['arg', '=', 'val']
519
+ new_args[-1] += f"={args[i + 1]}"
520
+ i += 2
521
+ continue
522
+ elif arg.endswith("=") and i < len(args) - 1 and "=" not in args[i + 1]: # merge ['arg=', 'val']
523
+ new_args.append(f"{arg}{args[i + 1]}")
524
+ i += 2
525
+ continue
526
+ elif arg.startswith("=") and i > 0: # merge ['arg', '=val']
527
+ new_args[-1] += arg
528
+ i += 1
529
+ continue
530
+
531
+ # Handle bracket joining
532
+ depth += arg.count("[") - arg.count("]")
533
+ current += arg
534
+ if depth == 0:
535
+ new_args.append(current)
536
+ current = ""
537
+
538
+ i += 1
539
+
540
+ # Append any remaining current string
541
+ if current:
542
+ new_args.append(current)
543
+
544
+ return new_args
545
+
546
+
547
+ def handle_yolo_hub(args: List[str]) -> None:
548
+ """
549
+ Handles Ultralytics HUB command-line interface (CLI) commands for authentication.
550
+
551
+ This function processes Ultralytics HUB CLI commands such as login and logout. It should be called when executing a
552
+ script with arguments related to HUB authentication.
553
+
554
+ Args:
555
+ args (List[str]): A list of command line arguments. The first argument should be either 'login'
556
+ or 'logout'. For 'login', an optional second argument can be the API key.
557
+
558
+ Examples:
559
+ ```bash
560
+ yolo login YOUR_API_KEY
561
+ ```
562
+
563
+ Notes:
564
+ - The function imports the 'hub' module from ultralytics to perform login and logout operations.
565
+ - For the 'login' command, if no API key is provided, an empty string is passed to the login function.
566
+ - The 'logout' command does not require any additional arguments.
567
+ """
568
+ from ultralytics import hub
569
+
570
+ if args[0] == "login":
571
+ key = args[1] if len(args) > 1 else ""
572
+ # Log in to Ultralytics HUB using the provided API key
573
+ hub.login(key)
574
+ elif args[0] == "logout":
575
+ # Log out from Ultralytics HUB
576
+ hub.logout()
577
+
578
+
579
+ def handle_yolo_settings(args: List[str]) -> None:
580
+ """
581
+ Handles YOLO settings command-line interface (CLI) commands.
582
+
583
+ This function processes YOLO settings CLI commands such as reset and updating individual settings. It should be
584
+ called when executing a script with arguments related to YOLO settings management.
585
+
586
+ Args:
587
+ args (List[str]): A list of command line arguments for YOLO settings management.
588
+
589
+ Examples:
590
+ >>> handle_yolo_settings(["reset"]) # Reset YOLO settings
591
+ >>> handle_yolo_settings(["default_cfg_path=yolo11n.yaml"]) # Update a specific setting
592
+
593
+ Notes:
594
+ - If no arguments are provided, the function will display the current settings.
595
+ - The 'reset' command will delete the existing settings file and create new default settings.
596
+ - Other arguments are treated as key-value pairs to update specific settings.
597
+ - The function will check for alignment between the provided settings and the existing ones.
598
+ - After processing, the updated settings will be displayed.
599
+ - For more information on handling YOLO settings, visit:
600
+ https://docs.ultralytics.com/quickstart/#ultralytics-settings
601
+ """
602
+ url = "https://docs.ultralytics.com/quickstart/#ultralytics-settings" # help URL
603
+ try:
604
+ if any(args):
605
+ if args[0] == "reset":
606
+ SETTINGS_FILE.unlink() # delete the settings file
607
+ SETTINGS.reset() # create new settings
608
+ LOGGER.info("Settings reset successfully") # inform the user that settings have been reset
609
+ else: # save a new setting
610
+ new = dict(parse_key_value_pair(a) for a in args)
611
+ check_dict_alignment(SETTINGS, new)
612
+ SETTINGS.update(new)
613
+
614
+ print(SETTINGS) # print the current settings
615
+ LOGGER.info(f"💡 Learn more about Ultralytics Settings at {url}")
616
+ except Exception as e:
617
+ LOGGER.warning(f"WARNING ⚠️ settings error: '{e}'. Please see {url} for help.")
618
+
619
+
620
+ def handle_yolo_solutions(args: List[str]) -> None:
621
+ """
622
+ Processes YOLO solutions arguments and runs the specified computer vision solutions pipeline.
623
+
624
+ Args:
625
+ args (List[str]): Command-line arguments for configuring and running the Ultralytics YOLO
626
+ solutions: https://docs.ultralytics.com/solutions/, It can include solution name, source,
627
+ and other configuration parameters.
628
+
629
+ Returns:
630
+ None: The function processes video frames and saves the output but doesn't return any value.
631
+
632
+ Examples:
633
+ Run people counting solution with default settings:
634
+ >>> handle_yolo_solutions(["count"])
635
+
636
+ Run analytics with custom configuration:
637
+ >>> handle_yolo_solutions(["analytics", "conf=0.25", "source=path/to/video/file.mp4"])
638
+
639
+ Run inference with custom configuration, requires Streamlit version 1.29.0 or higher.
640
+ >>> handle_yolo_solutions(["inference", "model=yolo11n.pt"])
641
+
642
+ Notes:
643
+ - Default configurations are merged from DEFAULT_SOL_DICT and DEFAULT_CFG_DICT
644
+ - Arguments can be provided in the format 'key=value' or as boolean flags
645
+ - Available solutions are defined in SOLUTION_MAP with their respective classes and methods
646
+ - If an invalid solution is provided, defaults to 'count' solution
647
+ - Output videos are saved in 'runs/solution/{solution_name}' directory
648
+ - For 'analytics' solution, frame numbers are tracked for generating analytical graphs
649
+ - Video processing can be interrupted by pressing 'q'
650
+ - Processes video frames sequentially and saves output in .avi format
651
+ - If no source is specified, downloads and uses a default sample video\
652
+ - The inference solution will be launched using the 'streamlit run' command.
653
+ - The Streamlit app file is located in the Ultralytics package directory.
654
+ """
655
+ full_args_dict = {**DEFAULT_SOL_DICT, **DEFAULT_CFG_DICT} # arguments dictionary
656
+ overrides = {}
657
+
658
+ # check dictionary alignment
659
+ for arg in merge_equals_args(args):
660
+ arg = arg.lstrip("-").rstrip(",")
661
+ if "=" in arg:
662
+ try:
663
+ k, v = parse_key_value_pair(arg)
664
+ overrides[k] = v
665
+ except (NameError, SyntaxError, ValueError, AssertionError) as e:
666
+ check_dict_alignment(full_args_dict, {arg: ""}, e)
667
+ elif arg in full_args_dict and isinstance(full_args_dict.get(arg), bool):
668
+ overrides[arg] = True
669
+ check_dict_alignment(full_args_dict, overrides) # dict alignment
670
+
671
+ # Get solution name
672
+ if args and args[0] in SOLUTION_MAP:
673
+ if args[0] != "help":
674
+ s_n = args.pop(0) # Extract the solution name directly
675
+ else:
676
+ LOGGER.info(SOLUTIONS_HELP_MSG)
677
+ else:
678
+ LOGGER.warning(
679
+ f"⚠️ No valid solution provided. Using default 'count'. Available: {', '.join(SOLUTION_MAP.keys())}"
680
+ )
681
+ s_n = "count" # Default solution if none provided
682
+
683
+ if args and args[0] == "help": # Add check for return if user call `yolo solutions help`
684
+ return
685
+
686
+ if s_n == "inference":
687
+ checks.check_requirements("streamlit>=1.29.0")
688
+ LOGGER.info("💡 Loading Ultralytics live inference app...")
689
+ subprocess.run(
690
+ [ # Run subprocess with Streamlit custom argument
691
+ "streamlit",
692
+ "run",
693
+ str(ROOT / "solutions/streamlit_inference.py"),
694
+ "--server.headless",
695
+ "true",
696
+ overrides.pop("model", "yolo11n.pt"),
697
+ ]
698
+ )
699
+ else:
700
+ cls, method = SOLUTION_MAP[s_n] # solution class name, method name and default source
701
+
702
+ from ultralytics import solutions # import ultralytics solutions
703
+
704
+ solution = getattr(solutions, cls)(IS_CLI=True, **overrides) # get solution class i.e ObjectCounter
705
+ process = getattr(
706
+ solution, method
707
+ ) # get specific function of class for processing i.e, count from ObjectCounter
708
+
709
+ cap = cv2.VideoCapture(solution.CFG["source"]) # read the video file
710
+
711
+ # extract width, height and fps of the video file, create save directory and initialize video writer
712
+ import os # for directory creation
713
+ from pathlib import Path
714
+
715
+ from ultralytics.utils.files import increment_path # for output directory path update
716
+
717
+ w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))
718
+ if s_n == "analytics": # analytical graphs follow fixed shape for output i.e w=1920, h=1080
719
+ w, h = 1920, 1080
720
+ save_dir = increment_path(Path("runs") / "solutions" / "exp", exist_ok=False)
721
+ save_dir.mkdir(parents=True, exist_ok=True) # create the output directory
722
+ vw = cv2.VideoWriter(os.path.join(save_dir, "solution.avi"), cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h))
723
+
724
+ try: # Process video frames
725
+ f_n = 0 # frame number, required for analytical graphs
726
+ while cap.isOpened():
727
+ success, frame = cap.read()
728
+ if not success:
729
+ break
730
+ frame = process(frame, f_n := f_n + 1) if s_n == "analytics" else process(frame)
731
+ vw.write(frame)
732
+ if cv2.waitKey(1) & 0xFF == ord("q"):
733
+ break
734
+ finally:
735
+ cap.release()
736
+
737
+
738
+ def parse_key_value_pair(pair: str = "key=value"):
739
+ """
740
+ Parses a key-value pair string into separate key and value components.
741
+
742
+ Args:
743
+ pair (str): A string containing a key-value pair in the format "key=value".
744
+
745
+ Returns:
746
+ key (str): The parsed key.
747
+ value (str): The parsed value.
748
+
749
+ Raises:
750
+ AssertionError: If the value is missing or empty.
751
+
752
+ Examples:
753
+ >>> key, value = parse_key_value_pair("model=yolo11n.pt")
754
+ >>> print(f"Key: {key}, Value: {value}")
755
+ Key: model, Value: yolo11n.pt
756
+
757
+ >>> key, value = parse_key_value_pair("epochs=100")
758
+ >>> print(f"Key: {key}, Value: {value}")
759
+ Key: epochs, Value: 100
760
+
761
+ Notes:
762
+ - The function splits the input string on the first '=' character.
763
+ - Leading and trailing whitespace is removed from both key and value.
764
+ - An assertion error is raised if the value is empty after stripping.
765
+ """
766
+ k, v = pair.split("=", 1) # split on first '=' sign
767
+ k, v = k.strip(), v.strip() # remove spaces
768
+ assert v, f"missing '{k}' value"
769
+ return k, smart_value(v)
770
+
771
+
772
+ def smart_value(v):
773
+ """
774
+ Converts a string representation of a value to its appropriate Python type.
775
+
776
+ This function attempts to convert a given string into a Python object of the most appropriate type. It handles
777
+ conversions to None, bool, int, float, and other types that can be evaluated safely.
778
+
779
+ Args:
780
+ v (str): The string representation of the value to be converted.
781
+
782
+ Returns:
783
+ (Any): The converted value. The type can be None, bool, int, float, or the original string if no conversion
784
+ is applicable.
785
+
786
+ Examples:
787
+ >>> smart_value("42")
788
+ 42
789
+ >>> smart_value("3.14")
790
+ 3.14
791
+ >>> smart_value("True")
792
+ True
793
+ >>> smart_value("None")
794
+ None
795
+ >>> smart_value("some_string")
796
+ 'some_string'
797
+
798
+ Notes:
799
+ - The function uses a case-insensitive comparison for boolean and None values.
800
+ - For other types, it attempts to use Python's eval() function, which can be unsafe if used on untrusted input.
801
+ - If no conversion is possible, the original string is returned.
802
+ """
803
+ v_lower = v.lower()
804
+ if v_lower == "none":
805
+ return None
806
+ elif v_lower == "true":
807
+ return True
808
+ elif v_lower == "false":
809
+ return False
810
+ else:
811
+ try:
812
+ return eval(v)
813
+ except Exception:
814
+ return v
815
+
816
+
817
+ def entrypoint(debug=""):
818
+ """
819
+ Ultralytics entrypoint function for parsing and executing command-line arguments.
820
+
821
+ This function serves as the main entry point for the Ultralytics CLI, parsing command-line arguments and
822
+ executing the corresponding tasks such as training, validation, prediction, exporting models, and more.
823
+
824
+ Args:
825
+ debug (str): Space-separated string of command-line arguments for debugging purposes.
826
+
827
+ Examples:
828
+ Train a detection model for 10 epochs with an initial learning_rate of 0.01:
829
+ >>> entrypoint("train data=coco8.yaml model=yolo11n.pt epochs=10 lr0=0.01")
830
+
831
+ Predict a YouTube video using a pretrained segmentation model at image size 320:
832
+ >>> entrypoint("predict model=yolo11n-seg.pt source='https://youtu.be/LNwODJXcvt4' imgsz=320")
833
+
834
+ Validate a pretrained detection model at batch-size 1 and image size 640:
835
+ >>> entrypoint("val model=yolo11n.pt data=coco8.yaml batch=1 imgsz=640")
836
+
837
+ Notes:
838
+ - If no arguments are passed, the function will display the usage help message.
839
+ - For a list of all available commands and their arguments, see the provided help messages and the
840
+ Ultralytics documentation at https://docs.ultralytics.com.
841
+ """
842
+ args = (debug.split(" ") if debug else ARGV)[1:]
843
+ if not args: # no arguments passed
844
+ LOGGER.info(CLI_HELP_MSG)
845
+ return
846
+
847
+ special = {
848
+ "help": lambda: LOGGER.info(CLI_HELP_MSG),
849
+ "checks": checks.collect_system_info,
850
+ "version": lambda: LOGGER.info(__version__),
851
+ "settings": lambda: handle_yolo_settings(args[1:]),
852
+ "cfg": lambda: yaml_print(DEFAULT_CFG_PATH),
853
+ "hub": lambda: handle_yolo_hub(args[1:]),
854
+ "login": lambda: handle_yolo_hub(args),
855
+ "logout": lambda: handle_yolo_hub(args),
856
+ "copy-cfg": copy_default_cfg,
857
+ "solutions": lambda: handle_yolo_solutions(args[1:]),
858
+ }
859
+ full_args_dict = {**DEFAULT_CFG_DICT, **{k: None for k in TASKS}, **{k: None for k in MODES}, **special}
860
+
861
+ # Define common misuses of special commands, i.e. -h, -help, --help
862
+ special.update({k[0]: v for k, v in special.items()}) # singular
863
+ special.update({k[:-1]: v for k, v in special.items() if len(k) > 1 and k.endswith("s")}) # singular
864
+ special = {**special, **{f"-{k}": v for k, v in special.items()}, **{f"--{k}": v for k, v in special.items()}}
865
+
866
+ overrides = {} # basic overrides, i.e. imgsz=320
867
+ for a in merge_equals_args(args): # merge spaces around '=' sign
868
+ if a.startswith("--"):
869
+ LOGGER.warning(f"WARNING ⚠️ argument '{a}' does not require leading dashes '--', updating to '{a[2:]}'.")
870
+ a = a[2:]
871
+ if a.endswith(","):
872
+ LOGGER.warning(f"WARNING ⚠️ argument '{a}' does not require trailing comma ',', updating to '{a[:-1]}'.")
873
+ a = a[:-1]
874
+ if "=" in a:
875
+ try:
876
+ k, v = parse_key_value_pair(a)
877
+ if k == "cfg" and v is not None: # custom.yaml passed
878
+ LOGGER.info(f"Overriding {DEFAULT_CFG_PATH} with {v}")
879
+ overrides = {k: val for k, val in yaml_load(checks.check_yaml(v)).items() if k != "cfg"}
880
+ else:
881
+ overrides[k] = v
882
+ except (NameError, SyntaxError, ValueError, AssertionError) as e:
883
+ check_dict_alignment(full_args_dict, {a: ""}, e)
884
+
885
+ elif a in TASKS:
886
+ overrides["task"] = a
887
+ elif a in MODES:
888
+ overrides["mode"] = a
889
+ elif a.lower() in special:
890
+ special[a.lower()]()
891
+ return
892
+ elif a in DEFAULT_CFG_DICT and isinstance(DEFAULT_CFG_DICT[a], bool):
893
+ overrides[a] = True # auto-True for default bool args, i.e. 'yolo show' sets show=True
894
+ elif a in DEFAULT_CFG_DICT:
895
+ raise SyntaxError(
896
+ f"'{colorstr('red', 'bold', a)}' is a valid YOLO argument but is missing an '=' sign "
897
+ f"to set its value, i.e. try '{a}={DEFAULT_CFG_DICT[a]}'\n{CLI_HELP_MSG}"
898
+ )
899
+ else:
900
+ check_dict_alignment(full_args_dict, {a: ""})
901
+
902
+ # Check keys
903
+ check_dict_alignment(full_args_dict, overrides)
904
+
905
+ # Mode
906
+ mode = overrides.get("mode")
907
+ if mode is None:
908
+ mode = DEFAULT_CFG.mode or "predict"
909
+ LOGGER.warning(f"WARNING ⚠️ 'mode' argument is missing. Valid modes are {MODES}. Using default 'mode={mode}'.")
910
+ elif mode not in MODES:
911
+ raise ValueError(f"Invalid 'mode={mode}'. Valid modes are {MODES}.\n{CLI_HELP_MSG}")
912
+
913
+ # Task
914
+ task = overrides.pop("task", None)
915
+ if task:
916
+ if task == "classify" and mode == "track":
917
+ raise ValueError(
918
+ f"❌ Classification doesn't support 'mode=track'. Valid modes for classification are"
919
+ f" {MODES - {'track'}}.\n{CLI_HELP_MSG}"
920
+ )
921
+ elif task not in TASKS:
922
+ if task == "track":
923
+ LOGGER.warning(
924
+ "WARNING ⚠️ invalid 'task=track', setting 'task=detect' and 'mode=track'. Valid tasks are {TASKS}.\n{CLI_HELP_MSG}."
925
+ )
926
+ task, mode = "detect", "track"
927
+ else:
928
+ raise ValueError(f"Invalid 'task={task}'. Valid tasks are {TASKS}.\n{CLI_HELP_MSG}")
929
+ if "model" not in overrides:
930
+ overrides["model"] = TASK2MODEL[task]
931
+
932
+ # Model
933
+ model = overrides.pop("model", DEFAULT_CFG.model)
934
+ if model is None:
935
+ model = "yolo11n.pt"
936
+ LOGGER.warning(f"WARNING ⚠️ 'model' argument is missing. Using default 'model={model}'.")
937
+ overrides["model"] = model
938
+ stem = Path(model).stem.lower()
939
+ if "rtdetr" in stem: # guess architecture
940
+ from ultralytics import RTDETR
941
+
942
+ model = RTDETR(model) # no task argument
943
+ elif "fastsam" in stem:
944
+ from ultralytics import FastSAM
945
+
946
+ model = FastSAM(model)
947
+ elif "sam_" in stem or "sam2_" in stem or "sam2.1_" in stem:
948
+ from ultralytics import SAM
949
+
950
+ model = SAM(model)
951
+ else:
952
+ from ultralytics import YOLO
953
+
954
+ model = YOLO(model, task=task)
955
+ if isinstance(overrides.get("pretrained"), str):
956
+ model.load(overrides["pretrained"])
957
+
958
+ # Task Update
959
+ if task != model.task:
960
+ if task:
961
+ LOGGER.warning(
962
+ f"WARNING ⚠️ conflicting 'task={task}' passed with 'task={model.task}' model. "
963
+ f"Ignoring 'task={task}' and updating to 'task={model.task}' to match model."
964
+ )
965
+ task = model.task
966
+
967
+ # Mode
968
+ if mode in {"predict", "track"} and "source" not in overrides:
969
+ overrides["source"] = (
970
+ "https://ultralytics.com/images/boats.jpg" if task == "obb" else DEFAULT_CFG.source or ASSETS
971
+ )
972
+ LOGGER.warning(f"WARNING ⚠️ 'source' argument is missing. Using default 'source={overrides['source']}'.")
973
+ elif mode in {"train", "val"}:
974
+ if "data" not in overrides and "resume" not in overrides:
975
+ overrides["data"] = DEFAULT_CFG.data or TASK2DATA.get(task or DEFAULT_CFG.task, DEFAULT_CFG.data)
976
+ LOGGER.warning(f"WARNING ⚠️ 'data' argument is missing. Using default 'data={overrides['data']}'.")
977
+ elif mode == "export":
978
+ if "format" not in overrides:
979
+ overrides["format"] = DEFAULT_CFG.format or "torchscript"
980
+ LOGGER.warning(f"WARNING ⚠️ 'format' argument is missing. Using default 'format={overrides['format']}'.")
981
+
982
+ # Run command in python
983
+ getattr(model, mode)(**overrides) # default args from model
984
+
985
+ # Show help
986
+ LOGGER.info(f"💡 Learn more at https://docs.ultralytics.com/modes/{mode}")
987
+
988
+ # Recommend VS Code extension
989
+ if IS_VSCODE and SETTINGS.get("vscode_msg", True):
990
+ LOGGER.info(vscode_msg())
991
+
992
+
993
+ # Special modes --------------------------------------------------------------------------------------------------------
994
+ def copy_default_cfg():
995
+ """
996
+ Copies the default configuration file and creates a new one with '_copy' appended to its name.
997
+
998
+ This function duplicates the existing default configuration file (DEFAULT_CFG_PATH) and saves it
999
+ with '_copy' appended to its name in the current working directory. It provides a convenient way
1000
+ to create a custom configuration file based on the default settings.
1001
+
1002
+ Examples:
1003
+ >>> copy_default_cfg()
1004
+ # Output: default.yaml copied to /path/to/current/directory/default_copy.yaml
1005
+ # Example YOLO command with this new custom cfg:
1006
+ # yolo cfg='/path/to/current/directory/default_copy.yaml' imgsz=320 batch=8
1007
+
1008
+ Notes:
1009
+ - The new configuration file is created in the current working directory.
1010
+ - After copying, the function prints a message with the new file's location and an example
1011
+ YOLO command demonstrating how to use the new configuration file.
1012
+ - This function is useful for users who want to modify the default configuration without
1013
+ altering the original file.
1014
+ """
1015
+ new_file = Path.cwd() / DEFAULT_CFG_PATH.name.replace(".yaml", "_copy.yaml")
1016
+ shutil.copy2(DEFAULT_CFG_PATH, new_file)
1017
+ LOGGER.info(
1018
+ f"{DEFAULT_CFG_PATH} copied to {new_file}\n"
1019
+ f"Example YOLO command with this new custom cfg:\n yolo cfg='{new_file}' imgsz=320 batch=8"
1020
+ )
1021
+
1022
+
1023
+ if __name__ == "__main__":
1024
+ # Example: entrypoint(debug='yolo predict model=yolo11n.pt')
1025
+ entrypoint(debug="")
ultralytics/cfg/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (49.9 kB). View file
 
ultralytics/cfg/datasets/Argoverse.yaml ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Argoverse-HD dataset (ring-front-center camera) https://www.cs.cmu.edu/~mengtial/proj/streaming/ by Argo AI
4
+ # Documentation: https://docs.ultralytics.com/datasets/detect/argoverse/
5
+ # Example usage: yolo train data=Argoverse.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── Argoverse ← downloads here (31.5 GB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/Argoverse # dataset root dir
13
+ train: Argoverse-1.1/images/train/ # train images (relative to 'path') 39384 images
14
+ val: Argoverse-1.1/images/val/ # val images (relative to 'path') 15062 images
15
+ test: Argoverse-1.1/images/test/ # test images (optional) https://eval.ai/web/challenges/challenge-page/800/overview
16
+
17
+ # Classes
18
+ names:
19
+ 0: person
20
+ 1: bicycle
21
+ 2: car
22
+ 3: motorcycle
23
+ 4: bus
24
+ 5: truck
25
+ 6: traffic_light
26
+ 7: stop_sign
27
+
28
+ # Download script/URL (optional) ---------------------------------------------------------------------------------------
29
+ download: |
30
+ import json
31
+ from tqdm import tqdm
32
+ from ultralytics.utils.downloads import download
33
+ from pathlib import Path
34
+
35
+ def argoverse2yolo(set):
36
+ labels = {}
37
+ a = json.load(open(set, "rb"))
38
+ for annot in tqdm(a['annotations'], desc=f"Converting {set} to YOLOv5 format..."):
39
+ img_id = annot['image_id']
40
+ img_name = a['images'][img_id]['name']
41
+ img_label_name = f'{img_name[:-3]}txt'
42
+
43
+ cls = annot['category_id'] # instance class id
44
+ x_center, y_center, width, height = annot['bbox']
45
+ x_center = (x_center + width / 2) / 1920.0 # offset and scale
46
+ y_center = (y_center + height / 2) / 1200.0 # offset and scale
47
+ width /= 1920.0 # scale
48
+ height /= 1200.0 # scale
49
+
50
+ img_dir = set.parents[2] / 'Argoverse-1.1' / 'labels' / a['seq_dirs'][a['images'][annot['image_id']]['sid']]
51
+ if not img_dir.exists():
52
+ img_dir.mkdir(parents=True, exist_ok=True)
53
+
54
+ k = str(img_dir / img_label_name)
55
+ if k not in labels:
56
+ labels[k] = []
57
+ labels[k].append(f"{cls} {x_center} {y_center} {width} {height}\n")
58
+
59
+ for k in labels:
60
+ with open(k, "w") as f:
61
+ f.writelines(labels[k])
62
+
63
+
64
+ # Download 'https://argoverse-hd.s3.us-east-2.amazonaws.com/Argoverse-HD-Full.zip' (deprecated S3 link)
65
+ dir = Path(yaml['path']) # dataset root dir
66
+ urls = ['https://drive.google.com/file/d/1st9qW3BeIwQsnR0t8mRpvbsSWIo16ACi/view?usp=drive_link']
67
+ print("\n\nWARNING: Argoverse dataset MUST be downloaded manually, autodownload will NOT work.")
68
+ print(f"WARNING: Manually download Argoverse dataset '{urls[0]}' to '{dir}' and re-run your command.\n\n")
69
+ # download(urls, dir=dir)
70
+
71
+ # Convert
72
+ annotations_dir = 'Argoverse-HD/annotations/'
73
+ (dir / 'Argoverse-1.1' / 'tracking').rename(dir / 'Argoverse-1.1' / 'images') # rename 'tracking' to 'images'
74
+ for d in "train.json", "val.json":
75
+ argoverse2yolo(dir / annotations_dir / d) # convert Argoverse annotations to YOLO labels
ultralytics/cfg/datasets/DOTAv1.5.yaml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # DOTA 1.5 dataset https://captain-whu.github.io/DOTA/index.html for object detection in aerial images by Wuhan University
4
+ # Documentation: https://docs.ultralytics.com/datasets/obb/dota-v2/
5
+ # Example usage: yolo train model=yolov8n-obb.pt data=DOTAv1.5.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── dota1.5 ← downloads here (2GB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/DOTAv1.5 # dataset root dir
13
+ train: images/train # train images (relative to 'path') 1411 images
14
+ val: images/val # val images (relative to 'path') 458 images
15
+ test: images/test # test images (optional) 937 images
16
+
17
+ # Classes for DOTA 1.5
18
+ names:
19
+ 0: plane
20
+ 1: ship
21
+ 2: storage tank
22
+ 3: baseball diamond
23
+ 4: tennis court
24
+ 5: basketball court
25
+ 6: ground track field
26
+ 7: harbor
27
+ 8: bridge
28
+ 9: large vehicle
29
+ 10: small vehicle
30
+ 11: helicopter
31
+ 12: roundabout
32
+ 13: soccer ball field
33
+ 14: swimming pool
34
+ 15: container crane
35
+
36
+ # Download script/URL (optional)
37
+ download: https://github.com/ultralytics/assets/releases/download/v0.0.0/DOTAv1.5.zip
ultralytics/cfg/datasets/DOTAv1.yaml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # DOTA 1.0 dataset https://captain-whu.github.io/DOTA/index.html for object detection in aerial images by Wuhan University
4
+ # Documentation: https://docs.ultralytics.com/datasets/obb/dota-v2/
5
+ # Example usage: yolo train model=yolov8n-obb.pt data=DOTAv1.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── dota1 ← downloads here (2GB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/DOTAv1 # dataset root dir
13
+ train: images/train # train images (relative to 'path') 1411 images
14
+ val: images/val # val images (relative to 'path') 458 images
15
+ test: images/test # test images (optional) 937 images
16
+
17
+ # Classes for DOTA 1.0
18
+ names:
19
+ 0: plane
20
+ 1: ship
21
+ 2: storage tank
22
+ 3: baseball diamond
23
+ 4: tennis court
24
+ 5: basketball court
25
+ 6: ground track field
26
+ 7: harbor
27
+ 8: bridge
28
+ 9: large vehicle
29
+ 10: small vehicle
30
+ 11: helicopter
31
+ 12: roundabout
32
+ 13: soccer ball field
33
+ 14: swimming pool
34
+
35
+ # Download script/URL (optional)
36
+ download: https://github.com/ultralytics/assets/releases/download/v0.0.0/DOTAv1.zip
ultralytics/cfg/datasets/GlobalWheat2020.yaml ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Global Wheat 2020 dataset https://www.global-wheat.com/ by University of Saskatchewan
4
+ # Documentation: https://docs.ultralytics.com/datasets/detect/globalwheat2020/
5
+ # Example usage: yolo train data=GlobalWheat2020.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── GlobalWheat2020 ← downloads here (7.0 GB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/GlobalWheat2020 # dataset root dir
13
+ train: # train images (relative to 'path') 3422 images
14
+ - images/arvalis_1
15
+ - images/arvalis_2
16
+ - images/arvalis_3
17
+ - images/ethz_1
18
+ - images/rres_1
19
+ - images/inrae_1
20
+ - images/usask_1
21
+ val: # val images (relative to 'path') 748 images (WARNING: train set contains ethz_1)
22
+ - images/ethz_1
23
+ test: # test images (optional) 1276 images
24
+ - images/utokyo_1
25
+ - images/utokyo_2
26
+ - images/nau_1
27
+ - images/uq_1
28
+
29
+ # Classes
30
+ names:
31
+ 0: wheat_head
32
+
33
+ # Download script/URL (optional) ---------------------------------------------------------------------------------------
34
+ download: |
35
+ from ultralytics.utils.downloads import download
36
+ from pathlib import Path
37
+
38
+ # Download
39
+ dir = Path(yaml['path']) # dataset root dir
40
+ urls = ['https://zenodo.org/record/4298502/files/global-wheat-codalab-official.zip',
41
+ 'https://github.com/ultralytics/assets/releases/download/v0.0.0/GlobalWheat2020_labels.zip']
42
+ download(urls, dir=dir)
43
+
44
+ # Make Directories
45
+ for p in 'annotations', 'images', 'labels':
46
+ (dir / p).mkdir(parents=True, exist_ok=True)
47
+
48
+ # Move
49
+ for p in 'arvalis_1', 'arvalis_2', 'arvalis_3', 'ethz_1', 'rres_1', 'inrae_1', 'usask_1', \
50
+ 'utokyo_1', 'utokyo_2', 'nau_1', 'uq_1':
51
+ (dir / 'global-wheat-codalab-official' / p).rename(dir / 'images' / p) # move to /images
52
+ f = (dir / 'global-wheat-codalab-official' / p).with_suffix('.json') # json file
53
+ if f.exists():
54
+ f.rename((dir / 'annotations' / p).with_suffix('.json')) # move to /annotations
ultralytics/cfg/datasets/ImageNet.yaml ADDED
@@ -0,0 +1,2025 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # ImageNet-1k dataset https://www.image-net.org/index.php by Stanford University
4
+ # Simplified class names from https://github.com/anishathalye/imagenet-simple-labels
5
+ # Documentation: https://docs.ultralytics.com/datasets/classify/imagenet/
6
+ # Example usage: yolo train task=classify data=imagenet
7
+ # parent
8
+ # ├── ultralytics
9
+ # └── datasets
10
+ # └── imagenet ← downloads here (144 GB)
11
+
12
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
13
+ path: ../datasets/imagenet # dataset root dir
14
+ train: train # train images (relative to 'path') 1281167 images
15
+ val: val # val images (relative to 'path') 50000 images
16
+ test: # test images (optional)
17
+
18
+ # Classes
19
+ names:
20
+ 0: tench
21
+ 1: goldfish
22
+ 2: great white shark
23
+ 3: tiger shark
24
+ 4: hammerhead shark
25
+ 5: electric ray
26
+ 6: stingray
27
+ 7: cock
28
+ 8: hen
29
+ 9: ostrich
30
+ 10: brambling
31
+ 11: goldfinch
32
+ 12: house finch
33
+ 13: junco
34
+ 14: indigo bunting
35
+ 15: American robin
36
+ 16: bulbul
37
+ 17: jay
38
+ 18: magpie
39
+ 19: chickadee
40
+ 20: American dipper
41
+ 21: kite
42
+ 22: bald eagle
43
+ 23: vulture
44
+ 24: great grey owl
45
+ 25: fire salamander
46
+ 26: smooth newt
47
+ 27: newt
48
+ 28: spotted salamander
49
+ 29: axolotl
50
+ 30: American bullfrog
51
+ 31: tree frog
52
+ 32: tailed frog
53
+ 33: loggerhead sea turtle
54
+ 34: leatherback sea turtle
55
+ 35: mud turtle
56
+ 36: terrapin
57
+ 37: box turtle
58
+ 38: banded gecko
59
+ 39: green iguana
60
+ 40: Carolina anole
61
+ 41: desert grassland whiptail lizard
62
+ 42: agama
63
+ 43: frilled-necked lizard
64
+ 44: alligator lizard
65
+ 45: Gila monster
66
+ 46: European green lizard
67
+ 47: chameleon
68
+ 48: Komodo dragon
69
+ 49: Nile crocodile
70
+ 50: American alligator
71
+ 51: triceratops
72
+ 52: worm snake
73
+ 53: ring-necked snake
74
+ 54: eastern hog-nosed snake
75
+ 55: smooth green snake
76
+ 56: kingsnake
77
+ 57: garter snake
78
+ 58: water snake
79
+ 59: vine snake
80
+ 60: night snake
81
+ 61: boa constrictor
82
+ 62: African rock python
83
+ 63: Indian cobra
84
+ 64: green mamba
85
+ 65: sea snake
86
+ 66: Saharan horned viper
87
+ 67: eastern diamondback rattlesnake
88
+ 68: sidewinder
89
+ 69: trilobite
90
+ 70: harvestman
91
+ 71: scorpion
92
+ 72: yellow garden spider
93
+ 73: barn spider
94
+ 74: European garden spider
95
+ 75: southern black widow
96
+ 76: tarantula
97
+ 77: wolf spider
98
+ 78: tick
99
+ 79: centipede
100
+ 80: black grouse
101
+ 81: ptarmigan
102
+ 82: ruffed grouse
103
+ 83: prairie grouse
104
+ 84: peacock
105
+ 85: quail
106
+ 86: partridge
107
+ 87: grey parrot
108
+ 88: macaw
109
+ 89: sulphur-crested cockatoo
110
+ 90: lorikeet
111
+ 91: coucal
112
+ 92: bee eater
113
+ 93: hornbill
114
+ 94: hummingbird
115
+ 95: jacamar
116
+ 96: toucan
117
+ 97: duck
118
+ 98: red-breasted merganser
119
+ 99: goose
120
+ 100: black swan
121
+ 101: tusker
122
+ 102: echidna
123
+ 103: platypus
124
+ 104: wallaby
125
+ 105: koala
126
+ 106: wombat
127
+ 107: jellyfish
128
+ 108: sea anemone
129
+ 109: brain coral
130
+ 110: flatworm
131
+ 111: nematode
132
+ 112: conch
133
+ 113: snail
134
+ 114: slug
135
+ 115: sea slug
136
+ 116: chiton
137
+ 117: chambered nautilus
138
+ 118: Dungeness crab
139
+ 119: rock crab
140
+ 120: fiddler crab
141
+ 121: red king crab
142
+ 122: American lobster
143
+ 123: spiny lobster
144
+ 124: crayfish
145
+ 125: hermit crab
146
+ 126: isopod
147
+ 127: white stork
148
+ 128: black stork
149
+ 129: spoonbill
150
+ 130: flamingo
151
+ 131: little blue heron
152
+ 132: great egret
153
+ 133: bittern
154
+ 134: crane (bird)
155
+ 135: limpkin
156
+ 136: common gallinule
157
+ 137: American coot
158
+ 138: bustard
159
+ 139: ruddy turnstone
160
+ 140: dunlin
161
+ 141: common redshank
162
+ 142: dowitcher
163
+ 143: oystercatcher
164
+ 144: pelican
165
+ 145: king penguin
166
+ 146: albatross
167
+ 147: grey whale
168
+ 148: killer whale
169
+ 149: dugong
170
+ 150: sea lion
171
+ 151: Chihuahua
172
+ 152: Japanese Chin
173
+ 153: Maltese
174
+ 154: Pekingese
175
+ 155: Shih Tzu
176
+ 156: King Charles Spaniel
177
+ 157: Papillon
178
+ 158: toy terrier
179
+ 159: Rhodesian Ridgeback
180
+ 160: Afghan Hound
181
+ 161: Basset Hound
182
+ 162: Beagle
183
+ 163: Bloodhound
184
+ 164: Bluetick Coonhound
185
+ 165: Black and Tan Coonhound
186
+ 166: Treeing Walker Coonhound
187
+ 167: English foxhound
188
+ 168: Redbone Coonhound
189
+ 169: borzoi
190
+ 170: Irish Wolfhound
191
+ 171: Italian Greyhound
192
+ 172: Whippet
193
+ 173: Ibizan Hound
194
+ 174: Norwegian Elkhound
195
+ 175: Otterhound
196
+ 176: Saluki
197
+ 177: Scottish Deerhound
198
+ 178: Weimaraner
199
+ 179: Staffordshire Bull Terrier
200
+ 180: American Staffordshire Terrier
201
+ 181: Bedlington Terrier
202
+ 182: Border Terrier
203
+ 183: Kerry Blue Terrier
204
+ 184: Irish Terrier
205
+ 185: Norfolk Terrier
206
+ 186: Norwich Terrier
207
+ 187: Yorkshire Terrier
208
+ 188: Wire Fox Terrier
209
+ 189: Lakeland Terrier
210
+ 190: Sealyham Terrier
211
+ 191: Airedale Terrier
212
+ 192: Cairn Terrier
213
+ 193: Australian Terrier
214
+ 194: Dandie Dinmont Terrier
215
+ 195: Boston Terrier
216
+ 196: Miniature Schnauzer
217
+ 197: Giant Schnauzer
218
+ 198: Standard Schnauzer
219
+ 199: Scottish Terrier
220
+ 200: Tibetan Terrier
221
+ 201: Australian Silky Terrier
222
+ 202: Soft-coated Wheaten Terrier
223
+ 203: West Highland White Terrier
224
+ 204: Lhasa Apso
225
+ 205: Flat-Coated Retriever
226
+ 206: Curly-coated Retriever
227
+ 207: Golden Retriever
228
+ 208: Labrador Retriever
229
+ 209: Chesapeake Bay Retriever
230
+ 210: German Shorthaired Pointer
231
+ 211: Vizsla
232
+ 212: English Setter
233
+ 213: Irish Setter
234
+ 214: Gordon Setter
235
+ 215: Brittany
236
+ 216: Clumber Spaniel
237
+ 217: English Springer Spaniel
238
+ 218: Welsh Springer Spaniel
239
+ 219: Cocker Spaniels
240
+ 220: Sussex Spaniel
241
+ 221: Irish Water Spaniel
242
+ 222: Kuvasz
243
+ 223: Schipperke
244
+ 224: Groenendael
245
+ 225: Malinois
246
+ 226: Briard
247
+ 227: Australian Kelpie
248
+ 228: Komondor
249
+ 229: Old English Sheepdog
250
+ 230: Shetland Sheepdog
251
+ 231: collie
252
+ 232: Border Collie
253
+ 233: Bouvier des Flandres
254
+ 234: Rottweiler
255
+ 235: German Shepherd Dog
256
+ 236: Dobermann
257
+ 237: Miniature Pinscher
258
+ 238: Greater Swiss Mountain Dog
259
+ 239: Bernese Mountain Dog
260
+ 240: Appenzeller Sennenhund
261
+ 241: Entlebucher Sennenhund
262
+ 242: Boxer
263
+ 243: Bullmastiff
264
+ 244: Tibetan Mastiff
265
+ 245: French Bulldog
266
+ 246: Great Dane
267
+ 247: St. Bernard
268
+ 248: husky
269
+ 249: Alaskan Malamute
270
+ 250: Siberian Husky
271
+ 251: Dalmatian
272
+ 252: Affenpinscher
273
+ 253: Basenji
274
+ 254: pug
275
+ 255: Leonberger
276
+ 256: Newfoundland
277
+ 257: Pyrenean Mountain Dog
278
+ 258: Samoyed
279
+ 259: Pomeranian
280
+ 260: Chow Chow
281
+ 261: Keeshond
282
+ 262: Griffon Bruxellois
283
+ 263: Pembroke Welsh Corgi
284
+ 264: Cardigan Welsh Corgi
285
+ 265: Toy Poodle
286
+ 266: Miniature Poodle
287
+ 267: Standard Poodle
288
+ 268: Mexican hairless dog
289
+ 269: grey wolf
290
+ 270: Alaskan tundra wolf
291
+ 271: red wolf
292
+ 272: coyote
293
+ 273: dingo
294
+ 274: dhole
295
+ 275: African wild dog
296
+ 276: hyena
297
+ 277: red fox
298
+ 278: kit fox
299
+ 279: Arctic fox
300
+ 280: grey fox
301
+ 281: tabby cat
302
+ 282: tiger cat
303
+ 283: Persian cat
304
+ 284: Siamese cat
305
+ 285: Egyptian Mau
306
+ 286: cougar
307
+ 287: lynx
308
+ 288: leopard
309
+ 289: snow leopard
310
+ 290: jaguar
311
+ 291: lion
312
+ 292: tiger
313
+ 293: cheetah
314
+ 294: brown bear
315
+ 295: American black bear
316
+ 296: polar bear
317
+ 297: sloth bear
318
+ 298: mongoose
319
+ 299: meerkat
320
+ 300: tiger beetle
321
+ 301: ladybug
322
+ 302: ground beetle
323
+ 303: longhorn beetle
324
+ 304: leaf beetle
325
+ 305: dung beetle
326
+ 306: rhinoceros beetle
327
+ 307: weevil
328
+ 308: fly
329
+ 309: bee
330
+ 310: ant
331
+ 311: grasshopper
332
+ 312: cricket
333
+ 313: stick insect
334
+ 314: cockroach
335
+ 315: mantis
336
+ 316: cicada
337
+ 317: leafhopper
338
+ 318: lacewing
339
+ 319: dragonfly
340
+ 320: damselfly
341
+ 321: red admiral
342
+ 322: ringlet
343
+ 323: monarch butterfly
344
+ 324: small white
345
+ 325: sulphur butterfly
346
+ 326: gossamer-winged butterfly
347
+ 327: starfish
348
+ 328: sea urchin
349
+ 329: sea cucumber
350
+ 330: cottontail rabbit
351
+ 331: hare
352
+ 332: Angora rabbit
353
+ 333: hamster
354
+ 334: porcupine
355
+ 335: fox squirrel
356
+ 336: marmot
357
+ 337: beaver
358
+ 338: guinea pig
359
+ 339: common sorrel
360
+ 340: zebra
361
+ 341: pig
362
+ 342: wild boar
363
+ 343: warthog
364
+ 344: hippopotamus
365
+ 345: ox
366
+ 346: water buffalo
367
+ 347: bison
368
+ 348: ram
369
+ 349: bighorn sheep
370
+ 350: Alpine ibex
371
+ 351: hartebeest
372
+ 352: impala
373
+ 353: gazelle
374
+ 354: dromedary
375
+ 355: llama
376
+ 356: weasel
377
+ 357: mink
378
+ 358: European polecat
379
+ 359: black-footed ferret
380
+ 360: otter
381
+ 361: skunk
382
+ 362: badger
383
+ 363: armadillo
384
+ 364: three-toed sloth
385
+ 365: orangutan
386
+ 366: gorilla
387
+ 367: chimpanzee
388
+ 368: gibbon
389
+ 369: siamang
390
+ 370: guenon
391
+ 371: patas monkey
392
+ 372: baboon
393
+ 373: macaque
394
+ 374: langur
395
+ 375: black-and-white colobus
396
+ 376: proboscis monkey
397
+ 377: marmoset
398
+ 378: white-headed capuchin
399
+ 379: howler monkey
400
+ 380: titi
401
+ 381: Geoffroy's spider monkey
402
+ 382: common squirrel monkey
403
+ 383: ring-tailed lemur
404
+ 384: indri
405
+ 385: Asian elephant
406
+ 386: African bush elephant
407
+ 387: red panda
408
+ 388: giant panda
409
+ 389: snoek
410
+ 390: eel
411
+ 391: coho salmon
412
+ 392: rock beauty
413
+ 393: clownfish
414
+ 394: sturgeon
415
+ 395: garfish
416
+ 396: lionfish
417
+ 397: pufferfish
418
+ 398: abacus
419
+ 399: abaya
420
+ 400: academic gown
421
+ 401: accordion
422
+ 402: acoustic guitar
423
+ 403: aircraft carrier
424
+ 404: airliner
425
+ 405: airship
426
+ 406: altar
427
+ 407: ambulance
428
+ 408: amphibious vehicle
429
+ 409: analog clock
430
+ 410: apiary
431
+ 411: apron
432
+ 412: waste container
433
+ 413: assault rifle
434
+ 414: backpack
435
+ 415: bakery
436
+ 416: balance beam
437
+ 417: balloon
438
+ 418: ballpoint pen
439
+ 419: Band-Aid
440
+ 420: banjo
441
+ 421: baluster
442
+ 422: barbell
443
+ 423: barber chair
444
+ 424: barbershop
445
+ 425: barn
446
+ 426: barometer
447
+ 427: barrel
448
+ 428: wheelbarrow
449
+ 429: baseball
450
+ 430: basketball
451
+ 431: bassinet
452
+ 432: bassoon
453
+ 433: swimming cap
454
+ 434: bath towel
455
+ 435: bathtub
456
+ 436: station wagon
457
+ 437: lighthouse
458
+ 438: beaker
459
+ 439: military cap
460
+ 440: beer bottle
461
+ 441: beer glass
462
+ 442: bell-cot
463
+ 443: bib
464
+ 444: tandem bicycle
465
+ 445: bikini
466
+ 446: ring binder
467
+ 447: binoculars
468
+ 448: birdhouse
469
+ 449: boathouse
470
+ 450: bobsleigh
471
+ 451: bolo tie
472
+ 452: poke bonnet
473
+ 453: bookcase
474
+ 454: bookstore
475
+ 455: bottle cap
476
+ 456: bow
477
+ 457: bow tie
478
+ 458: brass
479
+ 459: bra
480
+ 460: breakwater
481
+ 461: breastplate
482
+ 462: broom
483
+ 463: bucket
484
+ 464: buckle
485
+ 465: bulletproof vest
486
+ 466: high-speed train
487
+ 467: butcher shop
488
+ 468: taxicab
489
+ 469: cauldron
490
+ 470: candle
491
+ 471: cannon
492
+ 472: canoe
493
+ 473: can opener
494
+ 474: cardigan
495
+ 475: car mirror
496
+ 476: carousel
497
+ 477: tool kit
498
+ 478: carton
499
+ 479: car wheel
500
+ 480: automated teller machine
501
+ 481: cassette
502
+ 482: cassette player
503
+ 483: castle
504
+ 484: catamaran
505
+ 485: CD player
506
+ 486: cello
507
+ 487: mobile phone
508
+ 488: chain
509
+ 489: chain-link fence
510
+ 490: chain mail
511
+ 491: chainsaw
512
+ 492: chest
513
+ 493: chiffonier
514
+ 494: chime
515
+ 495: china cabinet
516
+ 496: Christmas stocking
517
+ 497: church
518
+ 498: movie theater
519
+ 499: cleaver
520
+ 500: cliff dwelling
521
+ 501: cloak
522
+ 502: clogs
523
+ 503: cocktail shaker
524
+ 504: coffee mug
525
+ 505: coffeemaker
526
+ 506: coil
527
+ 507: combination lock
528
+ 508: computer keyboard
529
+ 509: confectionery store
530
+ 510: container ship
531
+ 511: convertible
532
+ 512: corkscrew
533
+ 513: cornet
534
+ 514: cowboy boot
535
+ 515: cowboy hat
536
+ 516: cradle
537
+ 517: crane (machine)
538
+ 518: crash helmet
539
+ 519: crate
540
+ 520: infant bed
541
+ 521: Crock Pot
542
+ 522: croquet ball
543
+ 523: crutch
544
+ 524: cuirass
545
+ 525: dam
546
+ 526: desk
547
+ 527: desktop computer
548
+ 528: rotary dial telephone
549
+ 529: diaper
550
+ 530: digital clock
551
+ 531: digital watch
552
+ 532: dining table
553
+ 533: dishcloth
554
+ 534: dishwasher
555
+ 535: disc brake
556
+ 536: dock
557
+ 537: dog sled
558
+ 538: dome
559
+ 539: doormat
560
+ 540: drilling rig
561
+ 541: drum
562
+ 542: drumstick
563
+ 543: dumbbell
564
+ 544: Dutch oven
565
+ 545: electric fan
566
+ 546: electric guitar
567
+ 547: electric locomotive
568
+ 548: entertainment center
569
+ 549: envelope
570
+ 550: espresso machine
571
+ 551: face powder
572
+ 552: feather boa
573
+ 553: filing cabinet
574
+ 554: fireboat
575
+ 555: fire engine
576
+ 556: fire screen sheet
577
+ 557: flagpole
578
+ 558: flute
579
+ 559: folding chair
580
+ 560: football helmet
581
+ 561: forklift
582
+ 562: fountain
583
+ 563: fountain pen
584
+ 564: four-poster bed
585
+ 565: freight car
586
+ 566: French horn
587
+ 567: frying pan
588
+ 568: fur coat
589
+ 569: garbage truck
590
+ 570: gas mask
591
+ 571: gas pump
592
+ 572: goblet
593
+ 573: go-kart
594
+ 574: golf ball
595
+ 575: golf cart
596
+ 576: gondola
597
+ 577: gong
598
+ 578: gown
599
+ 579: grand piano
600
+ 580: greenhouse
601
+ 581: grille
602
+ 582: grocery store
603
+ 583: guillotine
604
+ 584: barrette
605
+ 585: hair spray
606
+ 586: half-track
607
+ 587: hammer
608
+ 588: hamper
609
+ 589: hair dryer
610
+ 590: hand-held computer
611
+ 591: handkerchief
612
+ 592: hard disk drive
613
+ 593: harmonica
614
+ 594: harp
615
+ 595: harvester
616
+ 596: hatchet
617
+ 597: holster
618
+ 598: home theater
619
+ 599: honeycomb
620
+ 600: hook
621
+ 601: hoop skirt
622
+ 602: horizontal bar
623
+ 603: horse-drawn vehicle
624
+ 604: hourglass
625
+ 605: iPod
626
+ 606: clothes iron
627
+ 607: jack-o'-lantern
628
+ 608: jeans
629
+ 609: jeep
630
+ 610: T-shirt
631
+ 611: jigsaw puzzle
632
+ 612: pulled rickshaw
633
+ 613: joystick
634
+ 614: kimono
635
+ 615: knee pad
636
+ 616: knot
637
+ 617: lab coat
638
+ 618: ladle
639
+ 619: lampshade
640
+ 620: laptop computer
641
+ 621: lawn mower
642
+ 622: lens cap
643
+ 623: paper knife
644
+ 624: library
645
+ 625: lifeboat
646
+ 626: lighter
647
+ 627: limousine
648
+ 628: ocean liner
649
+ 629: lipstick
650
+ 630: slip-on shoe
651
+ 631: lotion
652
+ 632: speaker
653
+ 633: loupe
654
+ 634: sawmill
655
+ 635: magnetic compass
656
+ 636: mail bag
657
+ 637: mailbox
658
+ 638: tights
659
+ 639: tank suit
660
+ 640: manhole cover
661
+ 641: maraca
662
+ 642: marimba
663
+ 643: mask
664
+ 644: match
665
+ 645: maypole
666
+ 646: maze
667
+ 647: measuring cup
668
+ 648: medicine chest
669
+ 649: megalith
670
+ 650: microphone
671
+ 651: microwave oven
672
+ 652: military uniform
673
+ 653: milk can
674
+ 654: minibus
675
+ 655: miniskirt
676
+ 656: minivan
677
+ 657: missile
678
+ 658: mitten
679
+ 659: mixing bowl
680
+ 660: mobile home
681
+ 661: Model T
682
+ 662: modem
683
+ 663: monastery
684
+ 664: monitor
685
+ 665: moped
686
+ 666: mortar
687
+ 667: square academic cap
688
+ 668: mosque
689
+ 669: mosquito net
690
+ 670: scooter
691
+ 671: mountain bike
692
+ 672: tent
693
+ 673: computer mouse
694
+ 674: mousetrap
695
+ 675: moving van
696
+ 676: muzzle
697
+ 677: nail
698
+ 678: neck brace
699
+ 679: necklace
700
+ 680: nipple
701
+ 681: notebook computer
702
+ 682: obelisk
703
+ 683: oboe
704
+ 684: ocarina
705
+ 685: odometer
706
+ 686: oil filter
707
+ 687: organ
708
+ 688: oscilloscope
709
+ 689: overskirt
710
+ 690: bullock cart
711
+ 691: oxygen mask
712
+ 692: packet
713
+ 693: paddle
714
+ 694: paddle wheel
715
+ 695: padlock
716
+ 696: paintbrush
717
+ 697: pajamas
718
+ 698: palace
719
+ 699: pan flute
720
+ 700: paper towel
721
+ 701: parachute
722
+ 702: parallel bars
723
+ 703: park bench
724
+ 704: parking meter
725
+ 705: passenger car
726
+ 706: patio
727
+ 707: payphone
728
+ 708: pedestal
729
+ 709: pencil case
730
+ 710: pencil sharpener
731
+ 711: perfume
732
+ 712: Petri dish
733
+ 713: photocopier
734
+ 714: plectrum
735
+ 715: Pickelhaube
736
+ 716: picket fence
737
+ 717: pickup truck
738
+ 718: pier
739
+ 719: piggy bank
740
+ 720: pill bottle
741
+ 721: pillow
742
+ 722: ping-pong ball
743
+ 723: pinwheel
744
+ 724: pirate ship
745
+ 725: pitcher
746
+ 726: hand plane
747
+ 727: planetarium
748
+ 728: plastic bag
749
+ 729: plate rack
750
+ 730: plow
751
+ 731: plunger
752
+ 732: Polaroid camera
753
+ 733: pole
754
+ 734: police van
755
+ 735: poncho
756
+ 736: billiard table
757
+ 737: soda bottle
758
+ 738: pot
759
+ 739: potter's wheel
760
+ 740: power drill
761
+ 741: prayer rug
762
+ 742: printer
763
+ 743: prison
764
+ 744: projectile
765
+ 745: projector
766
+ 746: hockey puck
767
+ 747: punching bag
768
+ 748: purse
769
+ 749: quill
770
+ 750: quilt
771
+ 751: race car
772
+ 752: racket
773
+ 753: radiator
774
+ 754: radio
775
+ 755: radio telescope
776
+ 756: rain barrel
777
+ 757: recreational vehicle
778
+ 758: reel
779
+ 759: reflex camera
780
+ 760: refrigerator
781
+ 761: remote control
782
+ 762: restaurant
783
+ 763: revolver
784
+ 764: rifle
785
+ 765: rocking chair
786
+ 766: rotisserie
787
+ 767: eraser
788
+ 768: rugby ball
789
+ 769: ruler
790
+ 770: running shoe
791
+ 771: safe
792
+ 772: safety pin
793
+ 773: salt shaker
794
+ 774: sandal
795
+ 775: sarong
796
+ 776: saxophone
797
+ 777: scabbard
798
+ 778: weighing scale
799
+ 779: school bus
800
+ 780: schooner
801
+ 781: scoreboard
802
+ 782: CRT screen
803
+ 783: screw
804
+ 784: screwdriver
805
+ 785: seat belt
806
+ 786: sewing machine
807
+ 787: shield
808
+ 788: shoe store
809
+ 789: shoji
810
+ 790: shopping basket
811
+ 791: shopping cart
812
+ 792: shovel
813
+ 793: shower cap
814
+ 794: shower curtain
815
+ 795: ski
816
+ 796: ski mask
817
+ 797: sleeping bag
818
+ 798: slide rule
819
+ 799: sliding door
820
+ 800: slot machine
821
+ 801: snorkel
822
+ 802: snowmobile
823
+ 803: snowplow
824
+ 804: soap dispenser
825
+ 805: soccer ball
826
+ 806: sock
827
+ 807: solar thermal collector
828
+ 808: sombrero
829
+ 809: soup bowl
830
+ 810: space bar
831
+ 811: space heater
832
+ 812: space shuttle
833
+ 813: spatula
834
+ 814: motorboat
835
+ 815: spider web
836
+ 816: spindle
837
+ 817: sports car
838
+ 818: spotlight
839
+ 819: stage
840
+ 820: steam locomotive
841
+ 821: through arch bridge
842
+ 822: steel drum
843
+ 823: stethoscope
844
+ 824: scarf
845
+ 825: stone wall
846
+ 826: stopwatch
847
+ 827: stove
848
+ 828: strainer
849
+ 829: tram
850
+ 830: stretcher
851
+ 831: couch
852
+ 832: stupa
853
+ 833: submarine
854
+ 834: suit
855
+ 835: sundial
856
+ 836: sunglass
857
+ 837: sunglasses
858
+ 838: sunscreen
859
+ 839: suspension bridge
860
+ 840: mop
861
+ 841: sweatshirt
862
+ 842: swimsuit
863
+ 843: swing
864
+ 844: switch
865
+ 845: syringe
866
+ 846: table lamp
867
+ 847: tank
868
+ 848: tape player
869
+ 849: teapot
870
+ 850: teddy bear
871
+ 851: television
872
+ 852: tennis ball
873
+ 853: thatched roof
874
+ 854: front curtain
875
+ 855: thimble
876
+ 856: threshing machine
877
+ 857: throne
878
+ 858: tile roof
879
+ 859: toaster
880
+ 860: tobacco shop
881
+ 861: toilet seat
882
+ 862: torch
883
+ 863: totem pole
884
+ 864: tow truck
885
+ 865: toy store
886
+ 866: tractor
887
+ 867: semi-trailer truck
888
+ 868: tray
889
+ 869: trench coat
890
+ 870: tricycle
891
+ 871: trimaran
892
+ 872: tripod
893
+ 873: triumphal arch
894
+ 874: trolleybus
895
+ 875: trombone
896
+ 876: tub
897
+ 877: turnstile
898
+ 878: typewriter keyboard
899
+ 879: umbrella
900
+ 880: unicycle
901
+ 881: upright piano
902
+ 882: vacuum cleaner
903
+ 883: vase
904
+ 884: vault
905
+ 885: velvet
906
+ 886: vending machine
907
+ 887: vestment
908
+ 888: viaduct
909
+ 889: violin
910
+ 890: volleyball
911
+ 891: waffle iron
912
+ 892: wall clock
913
+ 893: wallet
914
+ 894: wardrobe
915
+ 895: military aircraft
916
+ 896: sink
917
+ 897: washing machine
918
+ 898: water bottle
919
+ 899: water jug
920
+ 900: water tower
921
+ 901: whiskey jug
922
+ 902: whistle
923
+ 903: wig
924
+ 904: window screen
925
+ 905: window shade
926
+ 906: Windsor tie
927
+ 907: wine bottle
928
+ 908: wing
929
+ 909: wok
930
+ 910: wooden spoon
931
+ 911: wool
932
+ 912: split-rail fence
933
+ 913: shipwreck
934
+ 914: yawl
935
+ 915: yurt
936
+ 916: website
937
+ 917: comic book
938
+ 918: crossword
939
+ 919: traffic sign
940
+ 920: traffic light
941
+ 921: dust jacket
942
+ 922: menu
943
+ 923: plate
944
+ 924: guacamole
945
+ 925: consomme
946
+ 926: hot pot
947
+ 927: trifle
948
+ 928: ice cream
949
+ 929: ice pop
950
+ 930: baguette
951
+ 931: bagel
952
+ 932: pretzel
953
+ 933: cheeseburger
954
+ 934: hot dog
955
+ 935: mashed potato
956
+ 936: cabbage
957
+ 937: broccoli
958
+ 938: cauliflower
959
+ 939: zucchini
960
+ 940: spaghetti squash
961
+ 941: acorn squash
962
+ 942: butternut squash
963
+ 943: cucumber
964
+ 944: artichoke
965
+ 945: bell pepper
966
+ 946: cardoon
967
+ 947: mushroom
968
+ 948: Granny Smith
969
+ 949: strawberry
970
+ 950: orange
971
+ 951: lemon
972
+ 952: fig
973
+ 953: pineapple
974
+ 954: banana
975
+ 955: jackfruit
976
+ 956: custard apple
977
+ 957: pomegranate
978
+ 958: hay
979
+ 959: carbonara
980
+ 960: chocolate syrup
981
+ 961: dough
982
+ 962: meatloaf
983
+ 963: pizza
984
+ 964: pot pie
985
+ 965: burrito
986
+ 966: red wine
987
+ 967: espresso
988
+ 968: cup
989
+ 969: eggnog
990
+ 970: alp
991
+ 971: bubble
992
+ 972: cliff
993
+ 973: coral reef
994
+ 974: geyser
995
+ 975: lakeshore
996
+ 976: promontory
997
+ 977: shoal
998
+ 978: seashore
999
+ 979: valley
1000
+ 980: volcano
1001
+ 981: baseball player
1002
+ 982: bridegroom
1003
+ 983: scuba diver
1004
+ 984: rapeseed
1005
+ 985: daisy
1006
+ 986: yellow lady's slipper
1007
+ 987: corn
1008
+ 988: acorn
1009
+ 989: rose hip
1010
+ 990: horse chestnut seed
1011
+ 991: coral fungus
1012
+ 992: agaric
1013
+ 993: gyromitra
1014
+ 994: stinkhorn mushroom
1015
+ 995: earth star
1016
+ 996: hen-of-the-woods
1017
+ 997: bolete
1018
+ 998: ear
1019
+ 999: toilet paper
1020
+
1021
+ # Imagenet class codes to human-readable names
1022
+ map:
1023
+ n01440764: tench
1024
+ n01443537: goldfish
1025
+ n01484850: great_white_shark
1026
+ n01491361: tiger_shark
1027
+ n01494475: hammerhead
1028
+ n01496331: electric_ray
1029
+ n01498041: stingray
1030
+ n01514668: cock
1031
+ n01514859: hen
1032
+ n01518878: ostrich
1033
+ n01530575: brambling
1034
+ n01531178: goldfinch
1035
+ n01532829: house_finch
1036
+ n01534433: junco
1037
+ n01537544: indigo_bunting
1038
+ n01558993: robin
1039
+ n01560419: bulbul
1040
+ n01580077: jay
1041
+ n01582220: magpie
1042
+ n01592084: chickadee
1043
+ n01601694: water_ouzel
1044
+ n01608432: kite
1045
+ n01614925: bald_eagle
1046
+ n01616318: vulture
1047
+ n01622779: great_grey_owl
1048
+ n01629819: European_fire_salamander
1049
+ n01630670: common_newt
1050
+ n01631663: eft
1051
+ n01632458: spotted_salamander
1052
+ n01632777: axolotl
1053
+ n01641577: bullfrog
1054
+ n01644373: tree_frog
1055
+ n01644900: tailed_frog
1056
+ n01664065: loggerhead
1057
+ n01665541: leatherback_turtle
1058
+ n01667114: mud_turtle
1059
+ n01667778: terrapin
1060
+ n01669191: box_turtle
1061
+ n01675722: banded_gecko
1062
+ n01677366: common_iguana
1063
+ n01682714: American_chameleon
1064
+ n01685808: whiptail
1065
+ n01687978: agama
1066
+ n01688243: frilled_lizard
1067
+ n01689811: alligator_lizard
1068
+ n01692333: Gila_monster
1069
+ n01693334: green_lizard
1070
+ n01694178: African_chameleon
1071
+ n01695060: Komodo_dragon
1072
+ n01697457: African_crocodile
1073
+ n01698640: American_alligator
1074
+ n01704323: triceratops
1075
+ n01728572: thunder_snake
1076
+ n01728920: ringneck_snake
1077
+ n01729322: hognose_snake
1078
+ n01729977: green_snake
1079
+ n01734418: king_snake
1080
+ n01735189: garter_snake
1081
+ n01737021: water_snake
1082
+ n01739381: vine_snake
1083
+ n01740131: night_snake
1084
+ n01742172: boa_constrictor
1085
+ n01744401: rock_python
1086
+ n01748264: Indian_cobra
1087
+ n01749939: green_mamba
1088
+ n01751748: sea_snake
1089
+ n01753488: horned_viper
1090
+ n01755581: diamondback
1091
+ n01756291: sidewinder
1092
+ n01768244: trilobite
1093
+ n01770081: harvestman
1094
+ n01770393: scorpion
1095
+ n01773157: black_and_gold_garden_spider
1096
+ n01773549: barn_spider
1097
+ n01773797: garden_spider
1098
+ n01774384: black_widow
1099
+ n01774750: tarantula
1100
+ n01775062: wolf_spider
1101
+ n01776313: tick
1102
+ n01784675: centipede
1103
+ n01795545: black_grouse
1104
+ n01796340: ptarmigan
1105
+ n01797886: ruffed_grouse
1106
+ n01798484: prairie_chicken
1107
+ n01806143: peacock
1108
+ n01806567: quail
1109
+ n01807496: partridge
1110
+ n01817953: African_grey
1111
+ n01818515: macaw
1112
+ n01819313: sulphur-crested_cockatoo
1113
+ n01820546: lorikeet
1114
+ n01824575: coucal
1115
+ n01828970: bee_eater
1116
+ n01829413: hornbill
1117
+ n01833805: hummingbird
1118
+ n01843065: jacamar
1119
+ n01843383: toucan
1120
+ n01847000: drake
1121
+ n01855032: red-breasted_merganser
1122
+ n01855672: goose
1123
+ n01860187: black_swan
1124
+ n01871265: tusker
1125
+ n01872401: echidna
1126
+ n01873310: platypus
1127
+ n01877812: wallaby
1128
+ n01882714: koala
1129
+ n01883070: wombat
1130
+ n01910747: jellyfish
1131
+ n01914609: sea_anemone
1132
+ n01917289: brain_coral
1133
+ n01924916: flatworm
1134
+ n01930112: nematode
1135
+ n01943899: conch
1136
+ n01944390: snail
1137
+ n01945685: slug
1138
+ n01950731: sea_slug
1139
+ n01955084: chiton
1140
+ n01968897: chambered_nautilus
1141
+ n01978287: Dungeness_crab
1142
+ n01978455: rock_crab
1143
+ n01980166: fiddler_crab
1144
+ n01981276: king_crab
1145
+ n01983481: American_lobster
1146
+ n01984695: spiny_lobster
1147
+ n01985128: crayfish
1148
+ n01986214: hermit_crab
1149
+ n01990800: isopod
1150
+ n02002556: white_stork
1151
+ n02002724: black_stork
1152
+ n02006656: spoonbill
1153
+ n02007558: flamingo
1154
+ n02009229: little_blue_heron
1155
+ n02009912: American_egret
1156
+ n02011460: bittern
1157
+ n02012849: crane_(bird)
1158
+ n02013706: limpkin
1159
+ n02017213: European_gallinule
1160
+ n02018207: American_coot
1161
+ n02018795: bustard
1162
+ n02025239: ruddy_turnstone
1163
+ n02027492: red-backed_sandpiper
1164
+ n02028035: redshank
1165
+ n02033041: dowitcher
1166
+ n02037110: oystercatcher
1167
+ n02051845: pelican
1168
+ n02056570: king_penguin
1169
+ n02058221: albatross
1170
+ n02066245: grey_whale
1171
+ n02071294: killer_whale
1172
+ n02074367: dugong
1173
+ n02077923: sea_lion
1174
+ n02085620: Chihuahua
1175
+ n02085782: Japanese_spaniel
1176
+ n02085936: Maltese_dog
1177
+ n02086079: Pekinese
1178
+ n02086240: Shih-Tzu
1179
+ n02086646: Blenheim_spaniel
1180
+ n02086910: papillon
1181
+ n02087046: toy_terrier
1182
+ n02087394: Rhodesian_ridgeback
1183
+ n02088094: Afghan_hound
1184
+ n02088238: basset
1185
+ n02088364: beagle
1186
+ n02088466: bloodhound
1187
+ n02088632: bluetick
1188
+ n02089078: black-and-tan_coonhound
1189
+ n02089867: Walker_hound
1190
+ n02089973: English_foxhound
1191
+ n02090379: redbone
1192
+ n02090622: borzoi
1193
+ n02090721: Irish_wolfhound
1194
+ n02091032: Italian_greyhound
1195
+ n02091134: whippet
1196
+ n02091244: Ibizan_hound
1197
+ n02091467: Norwegian_elkhound
1198
+ n02091635: otterhound
1199
+ n02091831: Saluki
1200
+ n02092002: Scottish_deerhound
1201
+ n02092339: Weimaraner
1202
+ n02093256: Staffordshire_bullterrier
1203
+ n02093428: American_Staffordshire_terrier
1204
+ n02093647: Bedlington_terrier
1205
+ n02093754: Border_terrier
1206
+ n02093859: Kerry_blue_terrier
1207
+ n02093991: Irish_terrier
1208
+ n02094114: Norfolk_terrier
1209
+ n02094258: Norwich_terrier
1210
+ n02094433: Yorkshire_terrier
1211
+ n02095314: wire-haired_fox_terrier
1212
+ n02095570: Lakeland_terrier
1213
+ n02095889: Sealyham_terrier
1214
+ n02096051: Airedale
1215
+ n02096177: cairn
1216
+ n02096294: Australian_terrier
1217
+ n02096437: Dandie_Dinmont
1218
+ n02096585: Boston_bull
1219
+ n02097047: miniature_schnauzer
1220
+ n02097130: giant_schnauzer
1221
+ n02097209: standard_schnauzer
1222
+ n02097298: Scotch_terrier
1223
+ n02097474: Tibetan_terrier
1224
+ n02097658: silky_terrier
1225
+ n02098105: soft-coated_wheaten_terrier
1226
+ n02098286: West_Highland_white_terrier
1227
+ n02098413: Lhasa
1228
+ n02099267: flat-coated_retriever
1229
+ n02099429: curly-coated_retriever
1230
+ n02099601: golden_retriever
1231
+ n02099712: Labrador_retriever
1232
+ n02099849: Chesapeake_Bay_retriever
1233
+ n02100236: German_short-haired_pointer
1234
+ n02100583: vizsla
1235
+ n02100735: English_setter
1236
+ n02100877: Irish_setter
1237
+ n02101006: Gordon_setter
1238
+ n02101388: Brittany_spaniel
1239
+ n02101556: clumber
1240
+ n02102040: English_springer
1241
+ n02102177: Welsh_springer_spaniel
1242
+ n02102318: cocker_spaniel
1243
+ n02102480: Sussex_spaniel
1244
+ n02102973: Irish_water_spaniel
1245
+ n02104029: kuvasz
1246
+ n02104365: schipperke
1247
+ n02105056: groenendael
1248
+ n02105162: malinois
1249
+ n02105251: briard
1250
+ n02105412: kelpie
1251
+ n02105505: komondor
1252
+ n02105641: Old_English_sheepdog
1253
+ n02105855: Shetland_sheepdog
1254
+ n02106030: collie
1255
+ n02106166: Border_collie
1256
+ n02106382: Bouvier_des_Flandres
1257
+ n02106550: Rottweiler
1258
+ n02106662: German_shepherd
1259
+ n02107142: Doberman
1260
+ n02107312: miniature_pinscher
1261
+ n02107574: Greater_Swiss_Mountain_dog
1262
+ n02107683: Bernese_mountain_dog
1263
+ n02107908: Appenzeller
1264
+ n02108000: EntleBucher
1265
+ n02108089: boxer
1266
+ n02108422: bull_mastiff
1267
+ n02108551: Tibetan_mastiff
1268
+ n02108915: French_bulldog
1269
+ n02109047: Great_Dane
1270
+ n02109525: Saint_Bernard
1271
+ n02109961: Eskimo_dog
1272
+ n02110063: malamute
1273
+ n02110185: Siberian_husky
1274
+ n02110341: dalmatian
1275
+ n02110627: affenpinscher
1276
+ n02110806: basenji
1277
+ n02110958: pug
1278
+ n02111129: Leonberg
1279
+ n02111277: Newfoundland
1280
+ n02111500: Great_Pyrenees
1281
+ n02111889: Samoyed
1282
+ n02112018: Pomeranian
1283
+ n02112137: chow
1284
+ n02112350: keeshond
1285
+ n02112706: Brabancon_griffon
1286
+ n02113023: Pembroke
1287
+ n02113186: Cardigan
1288
+ n02113624: toy_poodle
1289
+ n02113712: miniature_poodle
1290
+ n02113799: standard_poodle
1291
+ n02113978: Mexican_hairless
1292
+ n02114367: timber_wolf
1293
+ n02114548: white_wolf
1294
+ n02114712: red_wolf
1295
+ n02114855: coyote
1296
+ n02115641: dingo
1297
+ n02115913: dhole
1298
+ n02116738: African_hunting_dog
1299
+ n02117135: hyena
1300
+ n02119022: red_fox
1301
+ n02119789: kit_fox
1302
+ n02120079: Arctic_fox
1303
+ n02120505: grey_fox
1304
+ n02123045: tabby
1305
+ n02123159: tiger_cat
1306
+ n02123394: Persian_cat
1307
+ n02123597: Siamese_cat
1308
+ n02124075: Egyptian_cat
1309
+ n02125311: cougar
1310
+ n02127052: lynx
1311
+ n02128385: leopard
1312
+ n02128757: snow_leopard
1313
+ n02128925: jaguar
1314
+ n02129165: lion
1315
+ n02129604: tiger
1316
+ n02130308: cheetah
1317
+ n02132136: brown_bear
1318
+ n02133161: American_black_bear
1319
+ n02134084: ice_bear
1320
+ n02134418: sloth_bear
1321
+ n02137549: mongoose
1322
+ n02138441: meerkat
1323
+ n02165105: tiger_beetle
1324
+ n02165456: ladybug
1325
+ n02167151: ground_beetle
1326
+ n02168699: long-horned_beetle
1327
+ n02169497: leaf_beetle
1328
+ n02172182: dung_beetle
1329
+ n02174001: rhinoceros_beetle
1330
+ n02177972: weevil
1331
+ n02190166: fly
1332
+ n02206856: bee
1333
+ n02219486: ant
1334
+ n02226429: grasshopper
1335
+ n02229544: cricket
1336
+ n02231487: walking_stick
1337
+ n02233338: cockroach
1338
+ n02236044: mantis
1339
+ n02256656: cicada
1340
+ n02259212: leafhopper
1341
+ n02264363: lacewing
1342
+ n02268443: dragonfly
1343
+ n02268853: damselfly
1344
+ n02276258: admiral
1345
+ n02277742: ringlet
1346
+ n02279972: monarch
1347
+ n02280649: cabbage_butterfly
1348
+ n02281406: sulphur_butterfly
1349
+ n02281787: lycaenid
1350
+ n02317335: starfish
1351
+ n02319095: sea_urchin
1352
+ n02321529: sea_cucumber
1353
+ n02325366: wood_rabbit
1354
+ n02326432: hare
1355
+ n02328150: Angora
1356
+ n02342885: hamster
1357
+ n02346627: porcupine
1358
+ n02356798: fox_squirrel
1359
+ n02361337: marmot
1360
+ n02363005: beaver
1361
+ n02364673: guinea_pig
1362
+ n02389026: sorrel
1363
+ n02391049: zebra
1364
+ n02395406: hog
1365
+ n02396427: wild_boar
1366
+ n02397096: warthog
1367
+ n02398521: hippopotamus
1368
+ n02403003: ox
1369
+ n02408429: water_buffalo
1370
+ n02410509: bison
1371
+ n02412080: ram
1372
+ n02415577: bighorn
1373
+ n02417914: ibex
1374
+ n02422106: hartebeest
1375
+ n02422699: impala
1376
+ n02423022: gazelle
1377
+ n02437312: Arabian_camel
1378
+ n02437616: llama
1379
+ n02441942: weasel
1380
+ n02442845: mink
1381
+ n02443114: polecat
1382
+ n02443484: black-footed_ferret
1383
+ n02444819: otter
1384
+ n02445715: skunk
1385
+ n02447366: badger
1386
+ n02454379: armadillo
1387
+ n02457408: three-toed_sloth
1388
+ n02480495: orangutan
1389
+ n02480855: gorilla
1390
+ n02481823: chimpanzee
1391
+ n02483362: gibbon
1392
+ n02483708: siamang
1393
+ n02484975: guenon
1394
+ n02486261: patas
1395
+ n02486410: baboon
1396
+ n02487347: macaque
1397
+ n02488291: langur
1398
+ n02488702: colobus
1399
+ n02489166: proboscis_monkey
1400
+ n02490219: marmoset
1401
+ n02492035: capuchin
1402
+ n02492660: howler_monkey
1403
+ n02493509: titi
1404
+ n02493793: spider_monkey
1405
+ n02494079: squirrel_monkey
1406
+ n02497673: Madagascar_cat
1407
+ n02500267: indri
1408
+ n02504013: Indian_elephant
1409
+ n02504458: African_elephant
1410
+ n02509815: lesser_panda
1411
+ n02510455: giant_panda
1412
+ n02514041: barracouta
1413
+ n02526121: eel
1414
+ n02536864: coho
1415
+ n02606052: rock_beauty
1416
+ n02607072: anemone_fish
1417
+ n02640242: sturgeon
1418
+ n02641379: gar
1419
+ n02643566: lionfish
1420
+ n02655020: puffer
1421
+ n02666196: abacus
1422
+ n02667093: abaya
1423
+ n02669723: academic_gown
1424
+ n02672831: accordion
1425
+ n02676566: acoustic_guitar
1426
+ n02687172: aircraft_carrier
1427
+ n02690373: airliner
1428
+ n02692877: airship
1429
+ n02699494: altar
1430
+ n02701002: ambulance
1431
+ n02704792: amphibian
1432
+ n02708093: analog_clock
1433
+ n02727426: apiary
1434
+ n02730930: apron
1435
+ n02747177: ashcan
1436
+ n02749479: assault_rifle
1437
+ n02769748: backpack
1438
+ n02776631: bakery
1439
+ n02777292: balance_beam
1440
+ n02782093: balloon
1441
+ n02783161: ballpoint
1442
+ n02786058: Band_Aid
1443
+ n02787622: banjo
1444
+ n02788148: bannister
1445
+ n02790996: barbell
1446
+ n02791124: barber_chair
1447
+ n02791270: barbershop
1448
+ n02793495: barn
1449
+ n02794156: barometer
1450
+ n02795169: barrel
1451
+ n02797295: barrow
1452
+ n02799071: baseball
1453
+ n02802426: basketball
1454
+ n02804414: bassinet
1455
+ n02804610: bassoon
1456
+ n02807133: bathing_cap
1457
+ n02808304: bath_towel
1458
+ n02808440: bathtub
1459
+ n02814533: beach_wagon
1460
+ n02814860: beacon
1461
+ n02815834: beaker
1462
+ n02817516: bearskin
1463
+ n02823428: beer_bottle
1464
+ n02823750: beer_glass
1465
+ n02825657: bell_cote
1466
+ n02834397: bib
1467
+ n02835271: bicycle-built-for-two
1468
+ n02837789: bikini
1469
+ n02840245: binder
1470
+ n02841315: binoculars
1471
+ n02843684: birdhouse
1472
+ n02859443: boathouse
1473
+ n02860847: bobsled
1474
+ n02865351: bolo_tie
1475
+ n02869837: bonnet
1476
+ n02870880: bookcase
1477
+ n02871525: bookshop
1478
+ n02877765: bottlecap
1479
+ n02879718: bow
1480
+ n02883205: bow_tie
1481
+ n02892201: brass
1482
+ n02892767: brassiere
1483
+ n02894605: breakwater
1484
+ n02895154: breastplate
1485
+ n02906734: broom
1486
+ n02909870: bucket
1487
+ n02910353: buckle
1488
+ n02916936: bulletproof_vest
1489
+ n02917067: bullet_train
1490
+ n02927161: butcher_shop
1491
+ n02930766: cab
1492
+ n02939185: caldron
1493
+ n02948072: candle
1494
+ n02950826: cannon
1495
+ n02951358: canoe
1496
+ n02951585: can_opener
1497
+ n02963159: cardigan
1498
+ n02965783: car_mirror
1499
+ n02966193: carousel
1500
+ n02966687: carpenter's_kit
1501
+ n02971356: carton
1502
+ n02974003: car_wheel
1503
+ n02977058: cash_machine
1504
+ n02978881: cassette
1505
+ n02979186: cassette_player
1506
+ n02980441: castle
1507
+ n02981792: catamaran
1508
+ n02988304: CD_player
1509
+ n02992211: cello
1510
+ n02992529: cellular_telephone
1511
+ n02999410: chain
1512
+ n03000134: chainlink_fence
1513
+ n03000247: chain_mail
1514
+ n03000684: chain_saw
1515
+ n03014705: chest
1516
+ n03016953: chiffonier
1517
+ n03017168: chime
1518
+ n03018349: china_cabinet
1519
+ n03026506: Christmas_stocking
1520
+ n03028079: church
1521
+ n03032252: cinema
1522
+ n03041632: cleaver
1523
+ n03042490: cliff_dwelling
1524
+ n03045698: cloak
1525
+ n03047690: clog
1526
+ n03062245: cocktail_shaker
1527
+ n03063599: coffee_mug
1528
+ n03063689: coffeepot
1529
+ n03065424: coil
1530
+ n03075370: combination_lock
1531
+ n03085013: computer_keyboard
1532
+ n03089624: confectionery
1533
+ n03095699: container_ship
1534
+ n03100240: convertible
1535
+ n03109150: corkscrew
1536
+ n03110669: cornet
1537
+ n03124043: cowboy_boot
1538
+ n03124170: cowboy_hat
1539
+ n03125729: cradle
1540
+ n03126707: crane_(machine)
1541
+ n03127747: crash_helmet
1542
+ n03127925: crate
1543
+ n03131574: crib
1544
+ n03133878: Crock_Pot
1545
+ n03134739: croquet_ball
1546
+ n03141823: crutch
1547
+ n03146219: cuirass
1548
+ n03160309: dam
1549
+ n03179701: desk
1550
+ n03180011: desktop_computer
1551
+ n03187595: dial_telephone
1552
+ n03188531: diaper
1553
+ n03196217: digital_clock
1554
+ n03197337: digital_watch
1555
+ n03201208: dining_table
1556
+ n03207743: dishrag
1557
+ n03207941: dishwasher
1558
+ n03208938: disk_brake
1559
+ n03216828: dock
1560
+ n03218198: dogsled
1561
+ n03220513: dome
1562
+ n03223299: doormat
1563
+ n03240683: drilling_platform
1564
+ n03249569: drum
1565
+ n03250847: drumstick
1566
+ n03255030: dumbbell
1567
+ n03259280: Dutch_oven
1568
+ n03271574: electric_fan
1569
+ n03272010: electric_guitar
1570
+ n03272562: electric_locomotive
1571
+ n03290653: entertainment_center
1572
+ n03291819: envelope
1573
+ n03297495: espresso_maker
1574
+ n03314780: face_powder
1575
+ n03325584: feather_boa
1576
+ n03337140: file
1577
+ n03344393: fireboat
1578
+ n03345487: fire_engine
1579
+ n03347037: fire_screen
1580
+ n03355925: flagpole
1581
+ n03372029: flute
1582
+ n03376595: folding_chair
1583
+ n03379051: football_helmet
1584
+ n03384352: forklift
1585
+ n03388043: fountain
1586
+ n03388183: fountain_pen
1587
+ n03388549: four-poster
1588
+ n03393912: freight_car
1589
+ n03394916: French_horn
1590
+ n03400231: frying_pan
1591
+ n03404251: fur_coat
1592
+ n03417042: garbage_truck
1593
+ n03424325: gasmask
1594
+ n03425413: gas_pump
1595
+ n03443371: goblet
1596
+ n03444034: go-kart
1597
+ n03445777: golf_ball
1598
+ n03445924: golfcart
1599
+ n03447447: gondola
1600
+ n03447721: gong
1601
+ n03450230: gown
1602
+ n03452741: grand_piano
1603
+ n03457902: greenhouse
1604
+ n03459775: grille
1605
+ n03461385: grocery_store
1606
+ n03467068: guillotine
1607
+ n03476684: hair_slide
1608
+ n03476991: hair_spray
1609
+ n03478589: half_track
1610
+ n03481172: hammer
1611
+ n03482405: hamper
1612
+ n03483316: hand_blower
1613
+ n03485407: hand-held_computer
1614
+ n03485794: handkerchief
1615
+ n03492542: hard_disc
1616
+ n03494278: harmonica
1617
+ n03495258: harp
1618
+ n03496892: harvester
1619
+ n03498962: hatchet
1620
+ n03527444: holster
1621
+ n03529860: home_theater
1622
+ n03530642: honeycomb
1623
+ n03532672: hook
1624
+ n03534580: hoopskirt
1625
+ n03535780: horizontal_bar
1626
+ n03538406: horse_cart
1627
+ n03544143: hourglass
1628
+ n03584254: iPod
1629
+ n03584829: iron
1630
+ n03590841: jack-o'-lantern
1631
+ n03594734: jean
1632
+ n03594945: jeep
1633
+ n03595614: jersey
1634
+ n03598930: jigsaw_puzzle
1635
+ n03599486: jinrikisha
1636
+ n03602883: joystick
1637
+ n03617480: kimono
1638
+ n03623198: knee_pad
1639
+ n03627232: knot
1640
+ n03630383: lab_coat
1641
+ n03633091: ladle
1642
+ n03637318: lampshade
1643
+ n03642806: laptop
1644
+ n03649909: lawn_mower
1645
+ n03657121: lens_cap
1646
+ n03658185: letter_opener
1647
+ n03661043: library
1648
+ n03662601: lifeboat
1649
+ n03666591: lighter
1650
+ n03670208: limousine
1651
+ n03673027: liner
1652
+ n03676483: lipstick
1653
+ n03680355: Loafer
1654
+ n03690938: lotion
1655
+ n03691459: loudspeaker
1656
+ n03692522: loupe
1657
+ n03697007: lumbermill
1658
+ n03706229: magnetic_compass
1659
+ n03709823: mailbag
1660
+ n03710193: mailbox
1661
+ n03710637: maillot_(tights)
1662
+ n03710721: maillot_(tank_suit)
1663
+ n03717622: manhole_cover
1664
+ n03720891: maraca
1665
+ n03721384: marimba
1666
+ n03724870: mask
1667
+ n03729826: matchstick
1668
+ n03733131: maypole
1669
+ n03733281: maze
1670
+ n03733805: measuring_cup
1671
+ n03742115: medicine_chest
1672
+ n03743016: megalith
1673
+ n03759954: microphone
1674
+ n03761084: microwave
1675
+ n03763968: military_uniform
1676
+ n03764736: milk_can
1677
+ n03769881: minibus
1678
+ n03770439: miniskirt
1679
+ n03770679: minivan
1680
+ n03773504: missile
1681
+ n03775071: mitten
1682
+ n03775546: mixing_bowl
1683
+ n03776460: mobile_home
1684
+ n03777568: Model_T
1685
+ n03777754: modem
1686
+ n03781244: monastery
1687
+ n03782006: monitor
1688
+ n03785016: moped
1689
+ n03786901: mortar
1690
+ n03787032: mortarboard
1691
+ n03788195: mosque
1692
+ n03788365: mosquito_net
1693
+ n03791053: motor_scooter
1694
+ n03792782: mountain_bike
1695
+ n03792972: mountain_tent
1696
+ n03793489: mouse
1697
+ n03794056: mousetrap
1698
+ n03796401: moving_van
1699
+ n03803284: muzzle
1700
+ n03804744: nail
1701
+ n03814639: neck_brace
1702
+ n03814906: necklace
1703
+ n03825788: nipple
1704
+ n03832673: notebook
1705
+ n03837869: obelisk
1706
+ n03838899: oboe
1707
+ n03840681: ocarina
1708
+ n03841143: odometer
1709
+ n03843555: oil_filter
1710
+ n03854065: organ
1711
+ n03857828: oscilloscope
1712
+ n03866082: overskirt
1713
+ n03868242: oxcart
1714
+ n03868863: oxygen_mask
1715
+ n03871628: packet
1716
+ n03873416: paddle
1717
+ n03874293: paddlewheel
1718
+ n03874599: padlock
1719
+ n03876231: paintbrush
1720
+ n03877472: pajama
1721
+ n03877845: palace
1722
+ n03884397: panpipe
1723
+ n03887697: paper_towel
1724
+ n03888257: parachute
1725
+ n03888605: parallel_bars
1726
+ n03891251: park_bench
1727
+ n03891332: parking_meter
1728
+ n03895866: passenger_car
1729
+ n03899768: patio
1730
+ n03902125: pay-phone
1731
+ n03903868: pedestal
1732
+ n03908618: pencil_box
1733
+ n03908714: pencil_sharpener
1734
+ n03916031: perfume
1735
+ n03920288: Petri_dish
1736
+ n03924679: photocopier
1737
+ n03929660: pick
1738
+ n03929855: pickelhaube
1739
+ n03930313: picket_fence
1740
+ n03930630: pickup
1741
+ n03933933: pier
1742
+ n03935335: piggy_bank
1743
+ n03937543: pill_bottle
1744
+ n03938244: pillow
1745
+ n03942813: ping-pong_ball
1746
+ n03944341: pinwheel
1747
+ n03947888: pirate
1748
+ n03950228: pitcher
1749
+ n03954731: plane
1750
+ n03956157: planetarium
1751
+ n03958227: plastic_bag
1752
+ n03961711: plate_rack
1753
+ n03967562: plow
1754
+ n03970156: plunger
1755
+ n03976467: Polaroid_camera
1756
+ n03976657: pole
1757
+ n03977966: police_van
1758
+ n03980874: poncho
1759
+ n03982430: pool_table
1760
+ n03983396: pop_bottle
1761
+ n03991062: pot
1762
+ n03992509: potter's_wheel
1763
+ n03995372: power_drill
1764
+ n03998194: prayer_rug
1765
+ n04004767: printer
1766
+ n04005630: prison
1767
+ n04008634: projectile
1768
+ n04009552: projector
1769
+ n04019541: puck
1770
+ n04023962: punching_bag
1771
+ n04026417: purse
1772
+ n04033901: quill
1773
+ n04033995: quilt
1774
+ n04037443: racer
1775
+ n04039381: racket
1776
+ n04040759: radiator
1777
+ n04041544: radio
1778
+ n04044716: radio_telescope
1779
+ n04049303: rain_barrel
1780
+ n04065272: recreational_vehicle
1781
+ n04067472: reel
1782
+ n04069434: reflex_camera
1783
+ n04070727: refrigerator
1784
+ n04074963: remote_control
1785
+ n04081281: restaurant
1786
+ n04086273: revolver
1787
+ n04090263: rifle
1788
+ n04099969: rocking_chair
1789
+ n04111531: rotisserie
1790
+ n04116512: rubber_eraser
1791
+ n04118538: rugby_ball
1792
+ n04118776: rule
1793
+ n04120489: running_shoe
1794
+ n04125021: safe
1795
+ n04127249: safety_pin
1796
+ n04131690: saltshaker
1797
+ n04133789: sandal
1798
+ n04136333: sarong
1799
+ n04141076: sax
1800
+ n04141327: scabbard
1801
+ n04141975: scale
1802
+ n04146614: school_bus
1803
+ n04147183: schooner
1804
+ n04149813: scoreboard
1805
+ n04152593: screen
1806
+ n04153751: screw
1807
+ n04154565: screwdriver
1808
+ n04162706: seat_belt
1809
+ n04179913: sewing_machine
1810
+ n04192698: shield
1811
+ n04200800: shoe_shop
1812
+ n04201297: shoji
1813
+ n04204238: shopping_basket
1814
+ n04204347: shopping_cart
1815
+ n04208210: shovel
1816
+ n04209133: shower_cap
1817
+ n04209239: shower_curtain
1818
+ n04228054: ski
1819
+ n04229816: ski_mask
1820
+ n04235860: sleeping_bag
1821
+ n04238763: slide_rule
1822
+ n04239074: sliding_door
1823
+ n04243546: slot
1824
+ n04251144: snorkel
1825
+ n04252077: snowmobile
1826
+ n04252225: snowplow
1827
+ n04254120: soap_dispenser
1828
+ n04254680: soccer_ball
1829
+ n04254777: sock
1830
+ n04258138: solar_dish
1831
+ n04259630: sombrero
1832
+ n04263257: soup_bowl
1833
+ n04264628: space_bar
1834
+ n04265275: space_heater
1835
+ n04266014: space_shuttle
1836
+ n04270147: spatula
1837
+ n04273569: speedboat
1838
+ n04275548: spider_web
1839
+ n04277352: spindle
1840
+ n04285008: sports_car
1841
+ n04286575: spotlight
1842
+ n04296562: stage
1843
+ n04310018: steam_locomotive
1844
+ n04311004: steel_arch_bridge
1845
+ n04311174: steel_drum
1846
+ n04317175: stethoscope
1847
+ n04325704: stole
1848
+ n04326547: stone_wall
1849
+ n04328186: stopwatch
1850
+ n04330267: stove
1851
+ n04332243: strainer
1852
+ n04335435: streetcar
1853
+ n04336792: stretcher
1854
+ n04344873: studio_couch
1855
+ n04346328: stupa
1856
+ n04347754: submarine
1857
+ n04350905: suit
1858
+ n04355338: sundial
1859
+ n04355933: sunglass
1860
+ n04356056: sunglasses
1861
+ n04357314: sunscreen
1862
+ n04366367: suspension_bridge
1863
+ n04367480: swab
1864
+ n04370456: sweatshirt
1865
+ n04371430: swimming_trunks
1866
+ n04371774: swing
1867
+ n04372370: switch
1868
+ n04376876: syringe
1869
+ n04380533: table_lamp
1870
+ n04389033: tank
1871
+ n04392985: tape_player
1872
+ n04398044: teapot
1873
+ n04399382: teddy
1874
+ n04404412: television
1875
+ n04409515: tennis_ball
1876
+ n04417672: thatch
1877
+ n04418357: theater_curtain
1878
+ n04423845: thimble
1879
+ n04428191: thresher
1880
+ n04429376: throne
1881
+ n04435653: tile_roof
1882
+ n04442312: toaster
1883
+ n04443257: tobacco_shop
1884
+ n04447861: toilet_seat
1885
+ n04456115: torch
1886
+ n04458633: totem_pole
1887
+ n04461696: tow_truck
1888
+ n04462240: toyshop
1889
+ n04465501: tractor
1890
+ n04467665: trailer_truck
1891
+ n04476259: tray
1892
+ n04479046: trench_coat
1893
+ n04482393: tricycle
1894
+ n04483307: trimaran
1895
+ n04485082: tripod
1896
+ n04486054: triumphal_arch
1897
+ n04487081: trolleybus
1898
+ n04487394: trombone
1899
+ n04493381: tub
1900
+ n04501370: turnstile
1901
+ n04505470: typewriter_keyboard
1902
+ n04507155: umbrella
1903
+ n04509417: unicycle
1904
+ n04515003: upright
1905
+ n04517823: vacuum
1906
+ n04522168: vase
1907
+ n04523525: vault
1908
+ n04525038: velvet
1909
+ n04525305: vending_machine
1910
+ n04532106: vestment
1911
+ n04532670: viaduct
1912
+ n04536866: violin
1913
+ n04540053: volleyball
1914
+ n04542943: waffle_iron
1915
+ n04548280: wall_clock
1916
+ n04548362: wallet
1917
+ n04550184: wardrobe
1918
+ n04552348: warplane
1919
+ n04553703: washbasin
1920
+ n04554684: washer
1921
+ n04557648: water_bottle
1922
+ n04560804: water_jug
1923
+ n04562935: water_tower
1924
+ n04579145: whiskey_jug
1925
+ n04579432: whistle
1926
+ n04584207: wig
1927
+ n04589890: window_screen
1928
+ n04590129: window_shade
1929
+ n04591157: Windsor_tie
1930
+ n04591713: wine_bottle
1931
+ n04592741: wing
1932
+ n04596742: wok
1933
+ n04597913: wooden_spoon
1934
+ n04599235: wool
1935
+ n04604644: worm_fence
1936
+ n04606251: wreck
1937
+ n04612504: yawl
1938
+ n04613696: yurt
1939
+ n06359193: web_site
1940
+ n06596364: comic_book
1941
+ n06785654: crossword_puzzle
1942
+ n06794110: street_sign
1943
+ n06874185: traffic_light
1944
+ n07248320: book_jacket
1945
+ n07565083: menu
1946
+ n07579787: plate
1947
+ n07583066: guacamole
1948
+ n07584110: consomme
1949
+ n07590611: hot_pot
1950
+ n07613480: trifle
1951
+ n07614500: ice_cream
1952
+ n07615774: ice_lolly
1953
+ n07684084: French_loaf
1954
+ n07693725: bagel
1955
+ n07695742: pretzel
1956
+ n07697313: cheeseburger
1957
+ n07697537: hotdog
1958
+ n07711569: mashed_potato
1959
+ n07714571: head_cabbage
1960
+ n07714990: broccoli
1961
+ n07715103: cauliflower
1962
+ n07716358: zucchini
1963
+ n07716906: spaghetti_squash
1964
+ n07717410: acorn_squash
1965
+ n07717556: butternut_squash
1966
+ n07718472: cucumber
1967
+ n07718747: artichoke
1968
+ n07720875: bell_pepper
1969
+ n07730033: cardoon
1970
+ n07734744: mushroom
1971
+ n07742313: Granny_Smith
1972
+ n07745940: strawberry
1973
+ n07747607: orange
1974
+ n07749582: lemon
1975
+ n07753113: fig
1976
+ n07753275: pineapple
1977
+ n07753592: banana
1978
+ n07754684: jackfruit
1979
+ n07760859: custard_apple
1980
+ n07768694: pomegranate
1981
+ n07802026: hay
1982
+ n07831146: carbonara
1983
+ n07836838: chocolate_sauce
1984
+ n07860988: dough
1985
+ n07871810: meat_loaf
1986
+ n07873807: pizza
1987
+ n07875152: potpie
1988
+ n07880968: burrito
1989
+ n07892512: red_wine
1990
+ n07920052: espresso
1991
+ n07930864: cup
1992
+ n07932039: eggnog
1993
+ n09193705: alp
1994
+ n09229709: bubble
1995
+ n09246464: cliff
1996
+ n09256479: coral_reef
1997
+ n09288635: geyser
1998
+ n09332890: lakeside
1999
+ n09399592: promontory
2000
+ n09421951: sandbar
2001
+ n09428293: seashore
2002
+ n09468604: valley
2003
+ n09472597: volcano
2004
+ n09835506: ballplayer
2005
+ n10148035: groom
2006
+ n10565667: scuba_diver
2007
+ n11879895: rapeseed
2008
+ n11939491: daisy
2009
+ n12057211: yellow_lady's_slipper
2010
+ n12144580: corn
2011
+ n12267677: acorn
2012
+ n12620546: hip
2013
+ n12768682: buckeye
2014
+ n12985857: coral_fungus
2015
+ n12998815: agaric
2016
+ n13037406: gyromitra
2017
+ n13040303: stinkhorn
2018
+ n13044778: earthstar
2019
+ n13052670: hen-of-the-woods
2020
+ n13054560: bolete
2021
+ n13133613: ear
2022
+ n15075141: toilet_tissue
2023
+
2024
+ # Download script/URL (optional)
2025
+ download: yolo/data/scripts/get_imagenet.sh
ultralytics/cfg/datasets/Objects365.yaml ADDED
@@ -0,0 +1,443 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Objects365 dataset https://www.objects365.org/ by Megvii
4
+ # Documentation: https://docs.ultralytics.com/datasets/detect/objects365/
5
+ # Example usage: yolo train data=Objects365.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── Objects365 ← downloads here (712 GB = 367G data + 345G zips)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/Objects365 # dataset root dir
13
+ train: images/train # train images (relative to 'path') 1742289 images
14
+ val: images/val # val images (relative to 'path') 80000 images
15
+ test: # test images (optional)
16
+
17
+ # Classes
18
+ names:
19
+ 0: Person
20
+ 1: Sneakers
21
+ 2: Chair
22
+ 3: Other Shoes
23
+ 4: Hat
24
+ 5: Car
25
+ 6: Lamp
26
+ 7: Glasses
27
+ 8: Bottle
28
+ 9: Desk
29
+ 10: Cup
30
+ 11: Street Lights
31
+ 12: Cabinet/shelf
32
+ 13: Handbag/Satchel
33
+ 14: Bracelet
34
+ 15: Plate
35
+ 16: Picture/Frame
36
+ 17: Helmet
37
+ 18: Book
38
+ 19: Gloves
39
+ 20: Storage box
40
+ 21: Boat
41
+ 22: Leather Shoes
42
+ 23: Flower
43
+ 24: Bench
44
+ 25: Potted Plant
45
+ 26: Bowl/Basin
46
+ 27: Flag
47
+ 28: Pillow
48
+ 29: Boots
49
+ 30: Vase
50
+ 31: Microphone
51
+ 32: Necklace
52
+ 33: Ring
53
+ 34: SUV
54
+ 35: Wine Glass
55
+ 36: Belt
56
+ 37: Monitor/TV
57
+ 38: Backpack
58
+ 39: Umbrella
59
+ 40: Traffic Light
60
+ 41: Speaker
61
+ 42: Watch
62
+ 43: Tie
63
+ 44: Trash bin Can
64
+ 45: Slippers
65
+ 46: Bicycle
66
+ 47: Stool
67
+ 48: Barrel/bucket
68
+ 49: Van
69
+ 50: Couch
70
+ 51: Sandals
71
+ 52: Basket
72
+ 53: Drum
73
+ 54: Pen/Pencil
74
+ 55: Bus
75
+ 56: Wild Bird
76
+ 57: High Heels
77
+ 58: Motorcycle
78
+ 59: Guitar
79
+ 60: Carpet
80
+ 61: Cell Phone
81
+ 62: Bread
82
+ 63: Camera
83
+ 64: Canned
84
+ 65: Truck
85
+ 66: Traffic cone
86
+ 67: Cymbal
87
+ 68: Lifesaver
88
+ 69: Towel
89
+ 70: Stuffed Toy
90
+ 71: Candle
91
+ 72: Sailboat
92
+ 73: Laptop
93
+ 74: Awning
94
+ 75: Bed
95
+ 76: Faucet
96
+ 77: Tent
97
+ 78: Horse
98
+ 79: Mirror
99
+ 80: Power outlet
100
+ 81: Sink
101
+ 82: Apple
102
+ 83: Air Conditioner
103
+ 84: Knife
104
+ 85: Hockey Stick
105
+ 86: Paddle
106
+ 87: Pickup Truck
107
+ 88: Fork
108
+ 89: Traffic Sign
109
+ 90: Balloon
110
+ 91: Tripod
111
+ 92: Dog
112
+ 93: Spoon
113
+ 94: Clock
114
+ 95: Pot
115
+ 96: Cow
116
+ 97: Cake
117
+ 98: Dining Table
118
+ 99: Sheep
119
+ 100: Hanger
120
+ 101: Blackboard/Whiteboard
121
+ 102: Napkin
122
+ 103: Other Fish
123
+ 104: Orange/Tangerine
124
+ 105: Toiletry
125
+ 106: Keyboard
126
+ 107: Tomato
127
+ 108: Lantern
128
+ 109: Machinery Vehicle
129
+ 110: Fan
130
+ 111: Green Vegetables
131
+ 112: Banana
132
+ 113: Baseball Glove
133
+ 114: Airplane
134
+ 115: Mouse
135
+ 116: Train
136
+ 117: Pumpkin
137
+ 118: Soccer
138
+ 119: Skiboard
139
+ 120: Luggage
140
+ 121: Nightstand
141
+ 122: Tea pot
142
+ 123: Telephone
143
+ 124: Trolley
144
+ 125: Head Phone
145
+ 126: Sports Car
146
+ 127: Stop Sign
147
+ 128: Dessert
148
+ 129: Scooter
149
+ 130: Stroller
150
+ 131: Crane
151
+ 132: Remote
152
+ 133: Refrigerator
153
+ 134: Oven
154
+ 135: Lemon
155
+ 136: Duck
156
+ 137: Baseball Bat
157
+ 138: Surveillance Camera
158
+ 139: Cat
159
+ 140: Jug
160
+ 141: Broccoli
161
+ 142: Piano
162
+ 143: Pizza
163
+ 144: Elephant
164
+ 145: Skateboard
165
+ 146: Surfboard
166
+ 147: Gun
167
+ 148: Skating and Skiing shoes
168
+ 149: Gas stove
169
+ 150: Donut
170
+ 151: Bow Tie
171
+ 152: Carrot
172
+ 153: Toilet
173
+ 154: Kite
174
+ 155: Strawberry
175
+ 156: Other Balls
176
+ 157: Shovel
177
+ 158: Pepper
178
+ 159: Computer Box
179
+ 160: Toilet Paper
180
+ 161: Cleaning Products
181
+ 162: Chopsticks
182
+ 163: Microwave
183
+ 164: Pigeon
184
+ 165: Baseball
185
+ 166: Cutting/chopping Board
186
+ 167: Coffee Table
187
+ 168: Side Table
188
+ 169: Scissors
189
+ 170: Marker
190
+ 171: Pie
191
+ 172: Ladder
192
+ 173: Snowboard
193
+ 174: Cookies
194
+ 175: Radiator
195
+ 176: Fire Hydrant
196
+ 177: Basketball
197
+ 178: Zebra
198
+ 179: Grape
199
+ 180: Giraffe
200
+ 181: Potato
201
+ 182: Sausage
202
+ 183: Tricycle
203
+ 184: Violin
204
+ 185: Egg
205
+ 186: Fire Extinguisher
206
+ 187: Candy
207
+ 188: Fire Truck
208
+ 189: Billiards
209
+ 190: Converter
210
+ 191: Bathtub
211
+ 192: Wheelchair
212
+ 193: Golf Club
213
+ 194: Briefcase
214
+ 195: Cucumber
215
+ 196: Cigar/Cigarette
216
+ 197: Paint Brush
217
+ 198: Pear
218
+ 199: Heavy Truck
219
+ 200: Hamburger
220
+ 201: Extractor
221
+ 202: Extension Cord
222
+ 203: Tong
223
+ 204: Tennis Racket
224
+ 205: Folder
225
+ 206: American Football
226
+ 207: earphone
227
+ 208: Mask
228
+ 209: Kettle
229
+ 210: Tennis
230
+ 211: Ship
231
+ 212: Swing
232
+ 213: Coffee Machine
233
+ 214: Slide
234
+ 215: Carriage
235
+ 216: Onion
236
+ 217: Green beans
237
+ 218: Projector
238
+ 219: Frisbee
239
+ 220: Washing Machine/Drying Machine
240
+ 221: Chicken
241
+ 222: Printer
242
+ 223: Watermelon
243
+ 224: Saxophone
244
+ 225: Tissue
245
+ 226: Toothbrush
246
+ 227: Ice cream
247
+ 228: Hot-air balloon
248
+ 229: Cello
249
+ 230: French Fries
250
+ 231: Scale
251
+ 232: Trophy
252
+ 233: Cabbage
253
+ 234: Hot dog
254
+ 235: Blender
255
+ 236: Peach
256
+ 237: Rice
257
+ 238: Wallet/Purse
258
+ 239: Volleyball
259
+ 240: Deer
260
+ 241: Goose
261
+ 242: Tape
262
+ 243: Tablet
263
+ 244: Cosmetics
264
+ 245: Trumpet
265
+ 246: Pineapple
266
+ 247: Golf Ball
267
+ 248: Ambulance
268
+ 249: Parking meter
269
+ 250: Mango
270
+ 251: Key
271
+ 252: Hurdle
272
+ 253: Fishing Rod
273
+ 254: Medal
274
+ 255: Flute
275
+ 256: Brush
276
+ 257: Penguin
277
+ 258: Megaphone
278
+ 259: Corn
279
+ 260: Lettuce
280
+ 261: Garlic
281
+ 262: Swan
282
+ 263: Helicopter
283
+ 264: Green Onion
284
+ 265: Sandwich
285
+ 266: Nuts
286
+ 267: Speed Limit Sign
287
+ 268: Induction Cooker
288
+ 269: Broom
289
+ 270: Trombone
290
+ 271: Plum
291
+ 272: Rickshaw
292
+ 273: Goldfish
293
+ 274: Kiwi fruit
294
+ 275: Router/modem
295
+ 276: Poker Card
296
+ 277: Toaster
297
+ 278: Shrimp
298
+ 279: Sushi
299
+ 280: Cheese
300
+ 281: Notepaper
301
+ 282: Cherry
302
+ 283: Pliers
303
+ 284: CD
304
+ 285: Pasta
305
+ 286: Hammer
306
+ 287: Cue
307
+ 288: Avocado
308
+ 289: Hami melon
309
+ 290: Flask
310
+ 291: Mushroom
311
+ 292: Screwdriver
312
+ 293: Soap
313
+ 294: Recorder
314
+ 295: Bear
315
+ 296: Eggplant
316
+ 297: Board Eraser
317
+ 298: Coconut
318
+ 299: Tape Measure/Ruler
319
+ 300: Pig
320
+ 301: Showerhead
321
+ 302: Globe
322
+ 303: Chips
323
+ 304: Steak
324
+ 305: Crosswalk Sign
325
+ 306: Stapler
326
+ 307: Camel
327
+ 308: Formula 1
328
+ 309: Pomegranate
329
+ 310: Dishwasher
330
+ 311: Crab
331
+ 312: Hoverboard
332
+ 313: Meatball
333
+ 314: Rice Cooker
334
+ 315: Tuba
335
+ 316: Calculator
336
+ 317: Papaya
337
+ 318: Antelope
338
+ 319: Parrot
339
+ 320: Seal
340
+ 321: Butterfly
341
+ 322: Dumbbell
342
+ 323: Donkey
343
+ 324: Lion
344
+ 325: Urinal
345
+ 326: Dolphin
346
+ 327: Electric Drill
347
+ 328: Hair Dryer
348
+ 329: Egg tart
349
+ 330: Jellyfish
350
+ 331: Treadmill
351
+ 332: Lighter
352
+ 333: Grapefruit
353
+ 334: Game board
354
+ 335: Mop
355
+ 336: Radish
356
+ 337: Baozi
357
+ 338: Target
358
+ 339: French
359
+ 340: Spring Rolls
360
+ 341: Monkey
361
+ 342: Rabbit
362
+ 343: Pencil Case
363
+ 344: Yak
364
+ 345: Red Cabbage
365
+ 346: Binoculars
366
+ 347: Asparagus
367
+ 348: Barbell
368
+ 349: Scallop
369
+ 350: Noddles
370
+ 351: Comb
371
+ 352: Dumpling
372
+ 353: Oyster
373
+ 354: Table Tennis paddle
374
+ 355: Cosmetics Brush/Eyeliner Pencil
375
+ 356: Chainsaw
376
+ 357: Eraser
377
+ 358: Lobster
378
+ 359: Durian
379
+ 360: Okra
380
+ 361: Lipstick
381
+ 362: Cosmetics Mirror
382
+ 363: Curling
383
+ 364: Table Tennis
384
+
385
+ # Download script/URL (optional) ---------------------------------------------------------------------------------------
386
+ download: |
387
+ from tqdm import tqdm
388
+
389
+ from ultralytics.utils.checks import check_requirements
390
+ from ultralytics.utils.downloads import download
391
+ from ultralytics.utils.ops import xyxy2xywhn
392
+
393
+ import numpy as np
394
+ from pathlib import Path
395
+
396
+ check_requirements(('pycocotools>=2.0',))
397
+ from pycocotools.coco import COCO
398
+
399
+ # Make Directories
400
+ dir = Path(yaml['path']) # dataset root dir
401
+ for p in 'images', 'labels':
402
+ (dir / p).mkdir(parents=True, exist_ok=True)
403
+ for q in 'train', 'val':
404
+ (dir / p / q).mkdir(parents=True, exist_ok=True)
405
+
406
+ # Train, Val Splits
407
+ for split, patches in [('train', 50 + 1), ('val', 43 + 1)]:
408
+ print(f"Processing {split} in {patches} patches ...")
409
+ images, labels = dir / 'images' / split, dir / 'labels' / split
410
+
411
+ # Download
412
+ url = f"https://dorc.ks3-cn-beijing.ksyun.com/data-set/2020Objects365%E6%95%B0%E6%8D%AE%E9%9B%86/{split}/"
413
+ if split == 'train':
414
+ download([f'{url}zhiyuan_objv2_{split}.tar.gz'], dir=dir) # annotations json
415
+ download([f'{url}patch{i}.tar.gz' for i in range(patches)], dir=images, curl=True, threads=8)
416
+ elif split == 'val':
417
+ download([f'{url}zhiyuan_objv2_{split}.json'], dir=dir) # annotations json
418
+ download([f'{url}images/v1/patch{i}.tar.gz' for i in range(15 + 1)], dir=images, curl=True, threads=8)
419
+ download([f'{url}images/v2/patch{i}.tar.gz' for i in range(16, patches)], dir=images, curl=True, threads=8)
420
+
421
+ # Move
422
+ for f in tqdm(images.rglob('*.jpg'), desc=f'Moving {split} images'):
423
+ f.rename(images / f.name) # move to /images/{split}
424
+
425
+ # Labels
426
+ coco = COCO(dir / f'zhiyuan_objv2_{split}.json')
427
+ names = [x["name"] for x in coco.loadCats(coco.getCatIds())]
428
+ for cid, cat in enumerate(names):
429
+ catIds = coco.getCatIds(catNms=[cat])
430
+ imgIds = coco.getImgIds(catIds=catIds)
431
+ for im in tqdm(coco.loadImgs(imgIds), desc=f'Class {cid + 1}/{len(names)} {cat}'):
432
+ width, height = im["width"], im["height"]
433
+ path = Path(im["file_name"]) # image filename
434
+ try:
435
+ with open(labels / path.with_suffix('.txt').name, 'a') as file:
436
+ annIds = coco.getAnnIds(imgIds=im["id"], catIds=catIds, iscrowd=None)
437
+ for a in coco.loadAnns(annIds):
438
+ x, y, w, h = a['bbox'] # bounding box in xywh (xy top-left corner)
439
+ xyxy = np.array([x, y, x + w, y + h])[None] # pixels(1,4)
440
+ x, y, w, h = xyxy2xywhn(xyxy, w=width, h=height, clip=True)[0] # normalized and clipped
441
+ file.write(f"{cid} {x:.5f} {y:.5f} {w:.5f} {h:.5f}\n")
442
+ except Exception as e:
443
+ print(e)
ultralytics/cfg/datasets/SKU-110K.yaml ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # SKU-110K retail items dataset https://github.com/eg4000/SKU110K_CVPR19 by Trax Retail
4
+ # Documentation: https://docs.ultralytics.com/datasets/detect/sku-110k/
5
+ # Example usage: yolo train data=SKU-110K.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── SKU-110K ← downloads here (13.6 GB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/SKU-110K # dataset root dir
13
+ train: train.txt # train images (relative to 'path') 8219 images
14
+ val: val.txt # val images (relative to 'path') 588 images
15
+ test: test.txt # test images (optional) 2936 images
16
+
17
+ # Classes
18
+ names:
19
+ 0: object
20
+
21
+ # Download script/URL (optional) ---------------------------------------------------------------------------------------
22
+ download: |
23
+ import shutil
24
+ from pathlib import Path
25
+
26
+ import numpy as np
27
+ import pandas as pd
28
+ from tqdm import tqdm
29
+
30
+ from ultralytics.utils.downloads import download
31
+ from ultralytics.utils.ops import xyxy2xywh
32
+
33
+ # Download
34
+ dir = Path(yaml['path']) # dataset root dir
35
+ parent = Path(dir.parent) # download dir
36
+ urls = ['http://trax-geometry.s3.amazonaws.com/cvpr_challenge/SKU110K_fixed.tar.gz']
37
+ download(urls, dir=parent)
38
+
39
+ # Rename directories
40
+ if dir.exists():
41
+ shutil.rmtree(dir)
42
+ (parent / 'SKU110K_fixed').rename(dir) # rename dir
43
+ (dir / 'labels').mkdir(parents=True, exist_ok=True) # create labels dir
44
+
45
+ # Convert labels
46
+ names = 'image', 'x1', 'y1', 'x2', 'y2', 'class', 'image_width', 'image_height' # column names
47
+ for d in 'annotations_train.csv', 'annotations_val.csv', 'annotations_test.csv':
48
+ x = pd.read_csv(dir / 'annotations' / d, names=names).values # annotations
49
+ images, unique_images = x[:, 0], np.unique(x[:, 0])
50
+ with open((dir / d).with_suffix('.txt').__str__().replace('annotations_', ''), 'w') as f:
51
+ f.writelines(f'./images/{s}\n' for s in unique_images)
52
+ for im in tqdm(unique_images, desc=f'Converting {dir / d}'):
53
+ cls = 0 # single-class dataset
54
+ with open((dir / 'labels' / im).with_suffix('.txt'), 'a') as f:
55
+ for r in x[images == im]:
56
+ w, h = r[6], r[7] # image width, height
57
+ xywh = xyxy2xywh(np.array([[r[1] / w, r[2] / h, r[3] / w, r[4] / h]]))[0] # instance
58
+ f.write(f"{cls} {xywh[0]:.5f} {xywh[1]:.5f} {xywh[2]:.5f} {xywh[3]:.5f}\n") # write label
ultralytics/cfg/datasets/VOC.yaml ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # PASCAL VOC dataset http://host.robots.ox.ac.uk/pascal/VOC by University of Oxford
4
+ # Documentation: # Documentation: https://docs.ultralytics.com/datasets/detect/voc/
5
+ # Example usage: yolo train data=VOC.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── VOC ← downloads here (2.8 GB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/VOC
13
+ train: # train images (relative to 'path') 16551 images
14
+ - images/train2012
15
+ - images/train2007
16
+ - images/val2012
17
+ - images/val2007
18
+ val: # val images (relative to 'path') 4952 images
19
+ - images/test2007
20
+ test: # test images (optional)
21
+ - images/test2007
22
+
23
+ # Classes
24
+ names:
25
+ 0: aeroplane
26
+ 1: bicycle
27
+ 2: bird
28
+ 3: boat
29
+ 4: bottle
30
+ 5: bus
31
+ 6: car
32
+ 7: cat
33
+ 8: chair
34
+ 9: cow
35
+ 10: diningtable
36
+ 11: dog
37
+ 12: horse
38
+ 13: motorbike
39
+ 14: person
40
+ 15: pottedplant
41
+ 16: sheep
42
+ 17: sofa
43
+ 18: train
44
+ 19: tvmonitor
45
+
46
+ # Download script/URL (optional) ---------------------------------------------------------------------------------------
47
+ download: |
48
+ import xml.etree.ElementTree as ET
49
+
50
+ from tqdm import tqdm
51
+ from ultralytics.utils.downloads import download
52
+ from pathlib import Path
53
+
54
+ def convert_label(path, lb_path, year, image_id):
55
+ def convert_box(size, box):
56
+ dw, dh = 1. / size[0], 1. / size[1]
57
+ x, y, w, h = (box[0] + box[1]) / 2.0 - 1, (box[2] + box[3]) / 2.0 - 1, box[1] - box[0], box[3] - box[2]
58
+ return x * dw, y * dh, w * dw, h * dh
59
+
60
+ in_file = open(path / f'VOC{year}/Annotations/{image_id}.xml')
61
+ out_file = open(lb_path, 'w')
62
+ tree = ET.parse(in_file)
63
+ root = tree.getroot()
64
+ size = root.find('size')
65
+ w = int(size.find('width').text)
66
+ h = int(size.find('height').text)
67
+
68
+ names = list(yaml['names'].values()) # names list
69
+ for obj in root.iter('object'):
70
+ cls = obj.find('name').text
71
+ if cls in names and int(obj.find('difficult').text) != 1:
72
+ xmlbox = obj.find('bndbox')
73
+ bb = convert_box((w, h), [float(xmlbox.find(x).text) for x in ('xmin', 'xmax', 'ymin', 'ymax')])
74
+ cls_id = names.index(cls) # class id
75
+ out_file.write(" ".join(str(a) for a in (cls_id, *bb)) + '\n')
76
+
77
+
78
+ # Download
79
+ dir = Path(yaml['path']) # dataset root dir
80
+ url = 'https://github.com/ultralytics/assets/releases/download/v0.0.0/'
81
+ urls = [f'{url}VOCtrainval_06-Nov-2007.zip', # 446MB, 5012 images
82
+ f'{url}VOCtest_06-Nov-2007.zip', # 438MB, 4953 images
83
+ f'{url}VOCtrainval_11-May-2012.zip'] # 1.95GB, 17126 images
84
+ download(urls, dir=dir / 'images', curl=True, threads=3, exist_ok=True) # download and unzip over existing paths (required)
85
+
86
+ # Convert
87
+ path = dir / 'images/VOCdevkit'
88
+ for year, image_set in ('2012', 'train'), ('2012', 'val'), ('2007', 'train'), ('2007', 'val'), ('2007', 'test'):
89
+ imgs_path = dir / 'images' / f'{image_set}{year}'
90
+ lbs_path = dir / 'labels' / f'{image_set}{year}'
91
+ imgs_path.mkdir(exist_ok=True, parents=True)
92
+ lbs_path.mkdir(exist_ok=True, parents=True)
93
+
94
+ with open(path / f'VOC{year}/ImageSets/Main/{image_set}.txt') as f:
95
+ image_ids = f.read().strip().split()
96
+ for id in tqdm(image_ids, desc=f'{image_set}{year}'):
97
+ f = path / f'VOC{year}/JPEGImages/{id}.jpg' # old img path
98
+ lb_path = (lbs_path / f.name).with_suffix('.txt') # new label path
99
+ f.rename(imgs_path / f.name) # move image
100
+ convert_label(path, lb_path, year, id) # convert labels to YOLO format
ultralytics/cfg/datasets/VisDrone.yaml ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # VisDrone2019-DET dataset https://github.com/VisDrone/VisDrone-Dataset by Tianjin University
4
+ # Documentation: https://docs.ultralytics.com/datasets/detect/visdrone/
5
+ # Example usage: yolo train data=VisDrone.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── VisDrone ← downloads here (2.3 GB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/VisDrone # dataset root dir
13
+ train: VisDrone2019-DET-train/images # train images (relative to 'path') 6471 images
14
+ val: VisDrone2019-DET-val/images # val images (relative to 'path') 548 images
15
+ test: VisDrone2019-DET-test-dev/images # test images (optional) 1610 images
16
+
17
+ # Classes
18
+ names:
19
+ 0: pedestrian
20
+ 1: people
21
+ 2: bicycle
22
+ 3: car
23
+ 4: van
24
+ 5: truck
25
+ 6: tricycle
26
+ 7: awning-tricycle
27
+ 8: bus
28
+ 9: motor
29
+
30
+ # Download script/URL (optional) ---------------------------------------------------------------------------------------
31
+ download: |
32
+ import os
33
+ from pathlib import Path
34
+
35
+ from ultralytics.utils.downloads import download
36
+
37
+ def visdrone2yolo(dir):
38
+ from PIL import Image
39
+ from tqdm import tqdm
40
+
41
+ def convert_box(size, box):
42
+ # Convert VisDrone box to YOLO xywh box
43
+ dw = 1. / size[0]
44
+ dh = 1. / size[1]
45
+ return (box[0] + box[2] / 2) * dw, (box[1] + box[3] / 2) * dh, box[2] * dw, box[3] * dh
46
+
47
+ (dir / 'labels').mkdir(parents=True, exist_ok=True) # make labels directory
48
+ pbar = tqdm((dir / 'annotations').glob('*.txt'), desc=f'Converting {dir}')
49
+ for f in pbar:
50
+ img_size = Image.open((dir / 'images' / f.name).with_suffix('.jpg')).size
51
+ lines = []
52
+ with open(f, 'r') as file: # read annotation.txt
53
+ for row in [x.split(',') for x in file.read().strip().splitlines()]:
54
+ if row[4] == '0': # VisDrone 'ignored regions' class 0
55
+ continue
56
+ cls = int(row[5]) - 1
57
+ box = convert_box(img_size, tuple(map(int, row[:4])))
58
+ lines.append(f"{cls} {' '.join(f'{x:.6f}' for x in box)}\n")
59
+ with open(str(f).replace(f'{os.sep}annotations{os.sep}', f'{os.sep}labels{os.sep}'), 'w') as fl:
60
+ fl.writelines(lines) # write label.txt
61
+
62
+
63
+ # Download
64
+ dir = Path(yaml['path']) # dataset root dir
65
+ urls = ['https://github.com/ultralytics/assets/releases/download/v0.0.0/VisDrone2019-DET-train.zip',
66
+ 'https://github.com/ultralytics/assets/releases/download/v0.0.0/VisDrone2019-DET-val.zip',
67
+ 'https://github.com/ultralytics/assets/releases/download/v0.0.0/VisDrone2019-DET-test-dev.zip',
68
+ 'https://github.com/ultralytics/assets/releases/download/v0.0.0/VisDrone2019-DET-test-challenge.zip']
69
+ download(urls, dir=dir, curl=True, threads=4)
70
+
71
+ # Convert
72
+ for d in 'VisDrone2019-DET-train', 'VisDrone2019-DET-val', 'VisDrone2019-DET-test-dev':
73
+ visdrone2yolo(dir / d) # convert VisDrone annotations to YOLO labels
ultralytics/cfg/datasets/african-wildlife.yaml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # African-wildlife dataset by Ultralytics
4
+ # Documentation: https://docs.ultralytics.com/datasets/detect/african-wildlife/
5
+ # Example usage: yolo train data=african-wildlife.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── african-wildlife ← downloads here (100 MB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/african-wildlife # dataset root dir
13
+ train: train/images # train images (relative to 'path') 1052 images
14
+ val: valid/images # val images (relative to 'path') 225 images
15
+ test: test/images # test images (relative to 'path') 227 images
16
+
17
+ # Classes
18
+ names:
19
+ 0: buffalo
20
+ 1: elephant
21
+ 2: rhino
22
+ 3: zebra
23
+
24
+ # Download script/URL (optional)
25
+ download: https://github.com/ultralytics/assets/releases/download/v0.0.0/african-wildlife.zip
ultralytics/cfg/datasets/brain-tumor.yaml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Brain-tumor dataset by Ultralytics
4
+ # Documentation: https://docs.ultralytics.com/datasets/detect/brain-tumor/
5
+ # Example usage: yolo train data=brain-tumor.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── brain-tumor ← downloads here (4.05 MB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/brain-tumor # dataset root dir
13
+ train: train/images # train images (relative to 'path') 893 images
14
+ val: valid/images # val images (relative to 'path') 223 images
15
+ test: # test images (relative to 'path')
16
+
17
+ # Classes
18
+ names:
19
+ 0: negative
20
+ 1: positive
21
+
22
+ # Download script/URL (optional)
23
+ download: https://github.com/ultralytics/assets/releases/download/v0.0.0/brain-tumor.zip
ultralytics/cfg/datasets/carparts-seg.yaml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Carparts-seg dataset by Ultralytics
4
+ # Documentation: https://docs.ultralytics.com/datasets/segment/carparts-seg/
5
+ # Example usage: yolo train data=carparts-seg.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── carparts-seg ← downloads here (132 MB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/carparts-seg # dataset root dir
13
+ train: train/images # train images (relative to 'path') 3516 images
14
+ val: valid/images # val images (relative to 'path') 276 images
15
+ test: test/images # test images (relative to 'path') 401 images
16
+
17
+ # Classes
18
+ names:
19
+ 0: back_bumper
20
+ 1: back_door
21
+ 2: back_glass
22
+ 3: back_left_door
23
+ 4: back_left_light
24
+ 5: back_light
25
+ 6: back_right_door
26
+ 7: back_right_light
27
+ 8: front_bumper
28
+ 9: front_door
29
+ 10: front_glass
30
+ 11: front_left_door
31
+ 12: front_left_light
32
+ 13: front_light
33
+ 14: front_right_door
34
+ 15: front_right_light
35
+ 16: hood
36
+ 17: left_mirror
37
+ 18: object
38
+ 19: right_mirror
39
+ 20: tailgate
40
+ 21: trunk
41
+ 22: wheel
42
+
43
+ # Download script/URL (optional)
44
+ download: https://github.com/ultralytics/assets/releases/download/v0.0.0/carparts-seg.zip
ultralytics/cfg/datasets/coco-pose.yaml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # COCO 2017 Keypoints dataset https://cocodataset.org by Microsoft
4
+ # Documentation: https://docs.ultralytics.com/datasets/pose/coco/
5
+ # Example usage: yolo train data=coco-pose.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── coco-pose ← downloads here (20.1 GB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/coco-pose # dataset root dir
13
+ train: train2017.txt # train images (relative to 'path') 56599 images
14
+ val: val2017.txt # val images (relative to 'path') 2346 images
15
+ test: test-dev2017.txt # 20288 of 40670 images, submit to https://codalab.lisn.upsaclay.fr/competitions/7403
16
+
17
+ # Keypoints
18
+ kpt_shape: [17, 3] # number of keypoints, number of dims (2 for x,y or 3 for x,y,visible)
19
+ flip_idx: [0, 2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15]
20
+
21
+ # Classes
22
+ names:
23
+ 0: person
24
+
25
+ # Download script/URL (optional)
26
+ download: |
27
+ from ultralytics.utils.downloads import download
28
+ from pathlib import Path
29
+
30
+ # Download labels
31
+ dir = Path(yaml['path']) # dataset root dir
32
+ url = 'https://github.com/ultralytics/assets/releases/download/v0.0.0/'
33
+ urls = [url + 'coco2017labels-pose.zip'] # labels
34
+ download(urls, dir=dir.parent)
35
+ # Download data
36
+ urls = ['http://images.cocodataset.org/zips/train2017.zip', # 19G, 118k images
37
+ 'http://images.cocodataset.org/zips/val2017.zip', # 1G, 5k images
38
+ 'http://images.cocodataset.org/zips/test2017.zip'] # 7G, 41k images (optional)
39
+ download(urls, dir=dir / 'images', threads=3)
ultralytics/cfg/datasets/coco.yaml ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # COCO 2017 dataset https://cocodataset.org by Microsoft
4
+ # Documentation: https://docs.ultralytics.com/datasets/detect/coco/
5
+ # Example usage: yolo train data=coco.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── coco ← downloads here (20.1 GB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ..datasets/coco # dataset root dir
13
+ train: train2017.txt # train images (relative to 'path') 118287 images
14
+ val: val2017.txt # val images (relative to 'path') 5000 images
15
+ test: test-dev2017.txt # 20288 of 40670 images, submit to https://competitions.codalab.org/competitions/20794
16
+
17
+ # Classes
18
+ names:
19
+ 0: person
20
+ 1: bicycle
21
+ 2: car
22
+ 3: motorcycle
23
+ 4: airplane
24
+ 5: bus
25
+ 6: train
26
+ 7: truck
27
+ 8: boat
28
+ 9: traffic light
29
+ 10: fire hydrant
30
+ 11: stop sign
31
+ 12: parking meter
32
+ 13: bench
33
+ 14: bird
34
+ 15: cat
35
+ 16: dog
36
+ 17: horse
37
+ 18: sheep
38
+ 19: cow
39
+ 20: elephant
40
+ 21: bear
41
+ 22: zebra
42
+ 23: giraffe
43
+ 24: backpack
44
+ 25: umbrella
45
+ 26: handbag
46
+ 27: tie
47
+ 28: suitcase
48
+ 29: frisbee
49
+ 30: skis
50
+ 31: snowboard
51
+ 32: sports ball
52
+ 33: kite
53
+ 34: baseball bat
54
+ 35: baseball glove
55
+ 36: skateboard
56
+ 37: surfboard
57
+ 38: tennis racket
58
+ 39: bottle
59
+ 40: wine glass
60
+ 41: cup
61
+ 42: fork
62
+ 43: knife
63
+ 44: spoon
64
+ 45: bowl
65
+ 46: banana
66
+ 47: apple
67
+ 48: sandwich
68
+ 49: orange
69
+ 50: broccoli
70
+ 51: carrot
71
+ 52: hot dog
72
+ 53: pizza
73
+ 54: donut
74
+ 55: cake
75
+ 56: chair
76
+ 57: couch
77
+ 58: potted plant
78
+ 59: bed
79
+ 60: dining table
80
+ 61: toilet
81
+ 62: tv
82
+ 63: laptop
83
+ 64: mouse
84
+ 65: remote
85
+ 66: keyboard
86
+ 67: cell phone
87
+ 68: microwave
88
+ 69: oven
89
+ 70: toaster
90
+ 71: sink
91
+ 72: refrigerator
92
+ 73: book
93
+ 74: clock
94
+ 75: vase
95
+ 76: scissors
96
+ 77: teddy bear
97
+ 78: hair drier
98
+ 79: toothbrush
99
+
100
+ # Download script/URL (optional)
101
+ download: |
102
+ from ultralytics.utils.downloads import download
103
+ from pathlib import Path
104
+
105
+ # Download labels
106
+ segments = True # segment or box labels
107
+ dir = Path(yaml['path']) # dataset root dir
108
+ url = 'https://github.com/ultralytics/assets/releases/download/v0.0.0/'
109
+ urls = [url + ('coco2017labels-segments.zip' if segments else 'coco2017labels.zip')] # labels
110
+ download(urls, dir=dir.parent)
111
+ # Download data
112
+ urls = ['http://images.cocodataset.org/zips/train2017.zip', # 19G, 118k images
113
+ 'http://images.cocodataset.org/zips/val2017.zip', # 1G, 5k images
114
+ 'http://images.cocodataset.org/zips/test2017.zip'] # 7G, 41k images (optional)
115
+ download(urls, dir=dir / 'images', threads=3)
ultralytics/cfg/datasets/coco128-seg.yaml ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # COCO128-seg dataset https://www.kaggle.com/datasets/ultralytics/coco128 (first 128 images from COCO train2017) by Ultralytics
4
+ # Documentation: https://docs.ultralytics.com/datasets/segment/coco/
5
+ # Example usage: yolo train data=coco128.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── coco128-seg ← downloads here (7 MB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/coco128-seg # dataset root dir
13
+ train: images/train2017 # train images (relative to 'path') 128 images
14
+ val: images/train2017 # val images (relative to 'path') 128 images
15
+ test: # test images (optional)
16
+
17
+ # Classes
18
+ names:
19
+ 0: person
20
+ 1: bicycle
21
+ 2: car
22
+ 3: motorcycle
23
+ 4: airplane
24
+ 5: bus
25
+ 6: train
26
+ 7: truck
27
+ 8: boat
28
+ 9: traffic light
29
+ 10: fire hydrant
30
+ 11: stop sign
31
+ 12: parking meter
32
+ 13: bench
33
+ 14: bird
34
+ 15: cat
35
+ 16: dog
36
+ 17: horse
37
+ 18: sheep
38
+ 19: cow
39
+ 20: elephant
40
+ 21: bear
41
+ 22: zebra
42
+ 23: giraffe
43
+ 24: backpack
44
+ 25: umbrella
45
+ 26: handbag
46
+ 27: tie
47
+ 28: suitcase
48
+ 29: frisbee
49
+ 30: skis
50
+ 31: snowboard
51
+ 32: sports ball
52
+ 33: kite
53
+ 34: baseball bat
54
+ 35: baseball glove
55
+ 36: skateboard
56
+ 37: surfboard
57
+ 38: tennis racket
58
+ 39: bottle
59
+ 40: wine glass
60
+ 41: cup
61
+ 42: fork
62
+ 43: knife
63
+ 44: spoon
64
+ 45: bowl
65
+ 46: banana
66
+ 47: apple
67
+ 48: sandwich
68
+ 49: orange
69
+ 50: broccoli
70
+ 51: carrot
71
+ 52: hot dog
72
+ 53: pizza
73
+ 54: donut
74
+ 55: cake
75
+ 56: chair
76
+ 57: couch
77
+ 58: potted plant
78
+ 59: bed
79
+ 60: dining table
80
+ 61: toilet
81
+ 62: tv
82
+ 63: laptop
83
+ 64: mouse
84
+ 65: remote
85
+ 66: keyboard
86
+ 67: cell phone
87
+ 68: microwave
88
+ 69: oven
89
+ 70: toaster
90
+ 71: sink
91
+ 72: refrigerator
92
+ 73: book
93
+ 74: clock
94
+ 75: vase
95
+ 76: scissors
96
+ 77: teddy bear
97
+ 78: hair drier
98
+ 79: toothbrush
99
+
100
+ # Download script/URL (optional)
101
+ download: https://github.com/ultralytics/assets/releases/download/v0.0.0/coco128-seg.zip
ultralytics/cfg/datasets/coco128.yaml ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # COCO128 dataset https://www.kaggle.com/datasets/ultralytics/coco128 (first 128 images from COCO train2017) by Ultralytics
4
+ # Documentation: https://docs.ultralytics.com/datasets/detect/coco/
5
+ # Example usage: yolo train data=coco128.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── coco128 ← downloads here (7 MB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/coco128 # dataset root dir
13
+ train: images/train2017 # train images (relative to 'path') 128 images
14
+ val: images/train2017 # val images (relative to 'path') 128 images
15
+ test: # test images (optional)
16
+
17
+ # Classes
18
+ names:
19
+ 0: person
20
+ 1: bicycle
21
+ 2: car
22
+ 3: motorcycle
23
+ 4: airplane
24
+ 5: bus
25
+ 6: train
26
+ 7: truck
27
+ 8: boat
28
+ 9: traffic light
29
+ 10: fire hydrant
30
+ 11: stop sign
31
+ 12: parking meter
32
+ 13: bench
33
+ 14: bird
34
+ 15: cat
35
+ 16: dog
36
+ 17: horse
37
+ 18: sheep
38
+ 19: cow
39
+ 20: elephant
40
+ 21: bear
41
+ 22: zebra
42
+ 23: giraffe
43
+ 24: backpack
44
+ 25: umbrella
45
+ 26: handbag
46
+ 27: tie
47
+ 28: suitcase
48
+ 29: frisbee
49
+ 30: skis
50
+ 31: snowboard
51
+ 32: sports ball
52
+ 33: kite
53
+ 34: baseball bat
54
+ 35: baseball glove
55
+ 36: skateboard
56
+ 37: surfboard
57
+ 38: tennis racket
58
+ 39: bottle
59
+ 40: wine glass
60
+ 41: cup
61
+ 42: fork
62
+ 43: knife
63
+ 44: spoon
64
+ 45: bowl
65
+ 46: banana
66
+ 47: apple
67
+ 48: sandwich
68
+ 49: orange
69
+ 50: broccoli
70
+ 51: carrot
71
+ 52: hot dog
72
+ 53: pizza
73
+ 54: donut
74
+ 55: cake
75
+ 56: chair
76
+ 57: couch
77
+ 58: potted plant
78
+ 59: bed
79
+ 60: dining table
80
+ 61: toilet
81
+ 62: tv
82
+ 63: laptop
83
+ 64: mouse
84
+ 65: remote
85
+ 66: keyboard
86
+ 67: cell phone
87
+ 68: microwave
88
+ 69: oven
89
+ 70: toaster
90
+ 71: sink
91
+ 72: refrigerator
92
+ 73: book
93
+ 74: clock
94
+ 75: vase
95
+ 76: scissors
96
+ 77: teddy bear
97
+ 78: hair drier
98
+ 79: toothbrush
99
+
100
+ # Download script/URL (optional)
101
+ download: https://github.com/ultralytics/assets/releases/download/v0.0.0/coco128.zip
ultralytics/cfg/datasets/coco8-pose.yaml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # COCO8-pose dataset (first 8 images from COCO train2017) by Ultralytics
4
+ # Documentation: https://docs.ultralytics.com/datasets/pose/coco8-pose/
5
+ # Example usage: yolo train data=coco8-pose.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── coco8-pose ← downloads here (1 MB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/coco8-pose # dataset root dir
13
+ train: images/train # train images (relative to 'path') 4 images
14
+ val: images/val # val images (relative to 'path') 4 images
15
+ test: # test images (optional)
16
+
17
+ # Keypoints
18
+ kpt_shape: [17, 3] # number of keypoints, number of dims (2 for x,y or 3 for x,y,visible)
19
+ flip_idx: [0, 2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15]
20
+
21
+ # Classes
22
+ names:
23
+ 0: person
24
+
25
+ # Download script/URL (optional)
26
+ download: https://github.com/ultralytics/assets/releases/download/v0.0.0/coco8-pose.zip
ultralytics/cfg/datasets/coco8-seg.yaml ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # COCO8-seg dataset (first 8 images from COCO train2017) by Ultralytics
4
+ # Documentation: https://docs.ultralytics.com/datasets/segment/coco8-seg/
5
+ # Example usage: yolo train data=coco8-seg.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── coco8-seg ← downloads here (1 MB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/coco8-seg # dataset root dir
13
+ train: images/train # train images (relative to 'path') 4 images
14
+ val: images/val # val images (relative to 'path') 4 images
15
+ test: # test images (optional)
16
+
17
+ # Classes
18
+ names:
19
+ 0: person
20
+ 1: bicycle
21
+ 2: car
22
+ 3: motorcycle
23
+ 4: airplane
24
+ 5: bus
25
+ 6: train
26
+ 7: truck
27
+ 8: boat
28
+ 9: traffic light
29
+ 10: fire hydrant
30
+ 11: stop sign
31
+ 12: parking meter
32
+ 13: bench
33
+ 14: bird
34
+ 15: cat
35
+ 16: dog
36
+ 17: horse
37
+ 18: sheep
38
+ 19: cow
39
+ 20: elephant
40
+ 21: bear
41
+ 22: zebra
42
+ 23: giraffe
43
+ 24: backpack
44
+ 25: umbrella
45
+ 26: handbag
46
+ 27: tie
47
+ 28: suitcase
48
+ 29: frisbee
49
+ 30: skis
50
+ 31: snowboard
51
+ 32: sports ball
52
+ 33: kite
53
+ 34: baseball bat
54
+ 35: baseball glove
55
+ 36: skateboard
56
+ 37: surfboard
57
+ 38: tennis racket
58
+ 39: bottle
59
+ 40: wine glass
60
+ 41: cup
61
+ 42: fork
62
+ 43: knife
63
+ 44: spoon
64
+ 45: bowl
65
+ 46: banana
66
+ 47: apple
67
+ 48: sandwich
68
+ 49: orange
69
+ 50: broccoli
70
+ 51: carrot
71
+ 52: hot dog
72
+ 53: pizza
73
+ 54: donut
74
+ 55: cake
75
+ 56: chair
76
+ 57: couch
77
+ 58: potted plant
78
+ 59: bed
79
+ 60: dining table
80
+ 61: toilet
81
+ 62: tv
82
+ 63: laptop
83
+ 64: mouse
84
+ 65: remote
85
+ 66: keyboard
86
+ 67: cell phone
87
+ 68: microwave
88
+ 69: oven
89
+ 70: toaster
90
+ 71: sink
91
+ 72: refrigerator
92
+ 73: book
93
+ 74: clock
94
+ 75: vase
95
+ 76: scissors
96
+ 77: teddy bear
97
+ 78: hair drier
98
+ 79: toothbrush
99
+
100
+ # Download script/URL (optional)
101
+ download: https://github.com/ultralytics/assets/releases/download/v0.0.0/coco8-seg.zip
ultralytics/cfg/datasets/coco8.yaml ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # COCO8 dataset (first 8 images from COCO train2017) by Ultralytics
4
+ # Documentation: https://docs.ultralytics.com/datasets/detect/coco8/
5
+ # Example usage: yolo train data=coco8.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── coco8 ← downloads here (1 MB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/coco8 # dataset root dir
13
+ train: images/train # train images (relative to 'path') 4 images
14
+ val: images/val # val images (relative to 'path') 4 images
15
+ test: # test images (optional)
16
+
17
+ # Classes
18
+ names:
19
+ 0: person
20
+ 1: bicycle
21
+ 2: car
22
+ 3: motorcycle
23
+ 4: airplane
24
+ 5: bus
25
+ 6: train
26
+ 7: truck
27
+ 8: boat
28
+ 9: traffic light
29
+ 10: fire hydrant
30
+ 11: stop sign
31
+ 12: parking meter
32
+ 13: bench
33
+ 14: bird
34
+ 15: cat
35
+ 16: dog
36
+ 17: horse
37
+ 18: sheep
38
+ 19: cow
39
+ 20: elephant
40
+ 21: bear
41
+ 22: zebra
42
+ 23: giraffe
43
+ 24: backpack
44
+ 25: umbrella
45
+ 26: handbag
46
+ 27: tie
47
+ 28: suitcase
48
+ 29: frisbee
49
+ 30: skis
50
+ 31: snowboard
51
+ 32: sports ball
52
+ 33: kite
53
+ 34: baseball bat
54
+ 35: baseball glove
55
+ 36: skateboard
56
+ 37: surfboard
57
+ 38: tennis racket
58
+ 39: bottle
59
+ 40: wine glass
60
+ 41: cup
61
+ 42: fork
62
+ 43: knife
63
+ 44: spoon
64
+ 45: bowl
65
+ 46: banana
66
+ 47: apple
67
+ 48: sandwich
68
+ 49: orange
69
+ 50: broccoli
70
+ 51: carrot
71
+ 52: hot dog
72
+ 53: pizza
73
+ 54: donut
74
+ 55: cake
75
+ 56: chair
76
+ 57: couch
77
+ 58: potted plant
78
+ 59: bed
79
+ 60: dining table
80
+ 61: toilet
81
+ 62: tv
82
+ 63: laptop
83
+ 64: mouse
84
+ 65: remote
85
+ 66: keyboard
86
+ 67: cell phone
87
+ 68: microwave
88
+ 69: oven
89
+ 70: toaster
90
+ 71: sink
91
+ 72: refrigerator
92
+ 73: book
93
+ 74: clock
94
+ 75: vase
95
+ 76: scissors
96
+ 77: teddy bear
97
+ 78: hair drier
98
+ 79: toothbrush
99
+
100
+ # Download script/URL (optional)
101
+ download: https://github.com/ultralytics/assets/releases/download/v0.0.0/coco8.zip
ultralytics/cfg/datasets/crack-seg.yaml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Crack-seg dataset by Ultralytics
4
+ # Documentation: https://docs.ultralytics.com/datasets/segment/crack-seg/
5
+ # Example usage: yolo train data=crack-seg.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── crack-seg ← downloads here (91.2 MB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/crack-seg # dataset root dir
13
+ train: train/images # train images (relative to 'path') 3717 images
14
+ val: valid/images # val images (relative to 'path') 112 images
15
+ test: test/images # test images (relative to 'path') 200 images
16
+
17
+ # Classes
18
+ names:
19
+ 0: crack
20
+
21
+ # Download script/URL (optional)
22
+ download: https://github.com/ultralytics/assets/releases/download/v0.0.0/crack-seg.zip
ultralytics/cfg/datasets/dog-pose.yaml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Dogs dataset http://vision.stanford.edu/aditya86/ImageNetDogs/ by Stanford
4
+ # Documentation: https://docs.ultralytics.com/datasets/pose/dog-pose/
5
+ # Example usage: yolo train data=dog-pose.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── dog-pose ← downloads here (337 MB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/dog-pose # dataset root dir
13
+ train: train # train images (relative to 'path') 6773 images
14
+ val: val # val images (relative to 'path') 1703 images
15
+
16
+ # Keypoints
17
+ kpt_shape: [24, 3] # number of keypoints, number of dims (2 for x,y or 3 for x,y,visible)
18
+
19
+ # Classes
20
+ names:
21
+ 0: dog
22
+
23
+ # Download script/URL (optional)
24
+ download: https://github.com/ultralytics/assets/releases/download/v0.0.0/dog-pose.zip
ultralytics/cfg/datasets/dota8.yaml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # DOTA8 dataset 8 images from split DOTAv1 dataset by Ultralytics
4
+ # Documentation: https://docs.ultralytics.com/datasets/obb/dota8/
5
+ # Example usage: yolo train model=yolov8n-obb.pt data=dota8.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── dota8 ← downloads here (1MB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/dota8 # dataset root dir
13
+ train: images/train # train images (relative to 'path') 4 images
14
+ val: images/val # val images (relative to 'path') 4 images
15
+
16
+ # Classes for DOTA 1.0
17
+ names:
18
+ 0: plane
19
+ 1: ship
20
+ 2: storage tank
21
+ 3: baseball diamond
22
+ 4: tennis court
23
+ 5: basketball court
24
+ 6: ground track field
25
+ 7: harbor
26
+ 8: bridge
27
+ 9: large vehicle
28
+ 10: small vehicle
29
+ 11: helicopter
30
+ 12: roundabout
31
+ 13: soccer ball field
32
+ 14: swimming pool
33
+
34
+ # Download script/URL (optional)
35
+ download: https://github.com/ultralytics/assets/releases/download/v0.0.0/dota8.zip
ultralytics/cfg/datasets/hand-keypoints.yaml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Hand Keypoints dataset by Ultralytics
4
+ # Documentation: https://docs.ultralytics.com/datasets/pose/hand-keypoints/
5
+ # Example usage: yolo train data=hand-keypoints.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── hand-keypoints ← downloads here (369 MB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/hand-keypoints # dataset root dir
13
+ train: train # train images (relative to 'path') 18776 images
14
+ val: val # val images (relative to 'path') 7992 images
15
+
16
+ # Keypoints
17
+ kpt_shape: [21, 3] # number of keypoints, number of dims (2 for x,y or 3 for x,y,visible)
18
+ flip_idx:
19
+ [0, 1, 2, 4, 3, 10, 11, 12, 13, 14, 5, 6, 7, 8, 9, 15, 16, 17, 18, 19, 20]
20
+
21
+ # Classes
22
+ names:
23
+ 0: hand
24
+
25
+ # Download script/URL (optional)
26
+ download: https://github.com/ultralytics/assets/releases/download/v0.0.0/hand-keypoints.zip
ultralytics/cfg/datasets/lvis.yaml ADDED
@@ -0,0 +1,1236 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # LVIS dataset http://www.lvisdataset.org by Facebook AI Research.
4
+ # Documentation: https://docs.ultralytics.com/datasets/detect/lvis/
5
+ # Example usage: yolo train data=lvis.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── lvis ← downloads here (20.1 GB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/lvis # dataset root dir
13
+ train: train.txt # train images (relative to 'path') 100170 images
14
+ val: val.txt # val images (relative to 'path') 19809 images
15
+ minival: minival.txt # minival images (relative to 'path') 5000 images
16
+
17
+ names:
18
+ 0: aerosol can/spray can
19
+ 1: air conditioner
20
+ 2: airplane/aeroplane
21
+ 3: alarm clock
22
+ 4: alcohol/alcoholic beverage
23
+ 5: alligator/gator
24
+ 6: almond
25
+ 7: ambulance
26
+ 8: amplifier
27
+ 9: anklet/ankle bracelet
28
+ 10: antenna/aerial/transmitting aerial
29
+ 11: apple
30
+ 12: applesauce
31
+ 13: apricot
32
+ 14: apron
33
+ 15: aquarium/fish tank
34
+ 16: arctic/arctic type of shoe/galosh/golosh/rubber/rubber type of shoe/gumshoe
35
+ 17: armband
36
+ 18: armchair
37
+ 19: armoire
38
+ 20: armor/armour
39
+ 21: artichoke
40
+ 22: trash can/garbage can/wastebin/dustbin/trash barrel/trash bin
41
+ 23: ashtray
42
+ 24: asparagus
43
+ 25: atomizer/atomiser/spray/sprayer/nebulizer/nebuliser
44
+ 26: avocado
45
+ 27: award/accolade
46
+ 28: awning
47
+ 29: ax/axe
48
+ 30: baboon
49
+ 31: baby buggy/baby carriage/perambulator/pram/stroller
50
+ 32: basketball backboard
51
+ 33: backpack/knapsack/packsack/rucksack/haversack
52
+ 34: handbag/purse/pocketbook
53
+ 35: suitcase/baggage/luggage
54
+ 36: bagel/beigel
55
+ 37: bagpipe
56
+ 38: baguet/baguette
57
+ 39: bait/lure
58
+ 40: ball
59
+ 41: ballet skirt/tutu
60
+ 42: balloon
61
+ 43: bamboo
62
+ 44: banana
63
+ 45: Band Aid
64
+ 46: bandage
65
+ 47: bandanna/bandana
66
+ 48: banjo
67
+ 49: banner/streamer
68
+ 50: barbell
69
+ 51: barge
70
+ 52: barrel/cask
71
+ 53: barrette
72
+ 54: barrow/garden cart/lawn cart/wheelbarrow
73
+ 55: baseball base
74
+ 56: baseball
75
+ 57: baseball bat
76
+ 58: baseball cap/jockey cap/golf cap
77
+ 59: baseball glove/baseball mitt
78
+ 60: basket/handbasket
79
+ 61: basketball
80
+ 62: bass horn/sousaphone/tuba
81
+ 63: bat/bat animal
82
+ 64: bath mat
83
+ 65: bath towel
84
+ 66: bathrobe
85
+ 67: bathtub/bathing tub
86
+ 68: batter/batter food
87
+ 69: battery
88
+ 70: beachball
89
+ 71: bead
90
+ 72: bean curd/tofu
91
+ 73: beanbag
92
+ 74: beanie/beany
93
+ 75: bear
94
+ 76: bed
95
+ 77: bedpan
96
+ 78: bedspread/bedcover/bed covering/counterpane/spread
97
+ 79: cow
98
+ 80: beef/beef food/boeuf/boeuf food
99
+ 81: beeper/pager
100
+ 82: beer bottle
101
+ 83: beer can
102
+ 84: beetle
103
+ 85: bell
104
+ 86: bell pepper/capsicum
105
+ 87: belt
106
+ 88: belt buckle
107
+ 89: bench
108
+ 90: beret
109
+ 91: bib
110
+ 92: Bible
111
+ 93: bicycle/bike/bike bicycle
112
+ 94: visor/vizor
113
+ 95: billboard
114
+ 96: binder/ring-binder
115
+ 97: binoculars/field glasses/opera glasses
116
+ 98: bird
117
+ 99: birdfeeder
118
+ 100: birdbath
119
+ 101: birdcage
120
+ 102: birdhouse
121
+ 103: birthday cake
122
+ 104: birthday card
123
+ 105: pirate flag
124
+ 106: black sheep
125
+ 107: blackberry
126
+ 108: blackboard/chalkboard
127
+ 109: blanket
128
+ 110: blazer/sport jacket/sport coat/sports jacket/sports coat
129
+ 111: blender/liquidizer/liquidiser
130
+ 112: blimp
131
+ 113: blinker/flasher
132
+ 114: blouse
133
+ 115: blueberry
134
+ 116: gameboard
135
+ 117: boat/ship/ship boat
136
+ 118: bob/bobber/bobfloat
137
+ 119: bobbin/spool/reel
138
+ 120: bobby pin/hairgrip
139
+ 121: boiled egg/coddled egg
140
+ 122: bolo tie/bolo/bola tie/bola
141
+ 123: deadbolt
142
+ 124: bolt
143
+ 125: bonnet
144
+ 126: book
145
+ 127: bookcase
146
+ 128: booklet/brochure/leaflet/pamphlet
147
+ 129: bookmark/bookmarker
148
+ 130: boom microphone/microphone boom
149
+ 131: boot
150
+ 132: bottle
151
+ 133: bottle opener
152
+ 134: bouquet
153
+ 135: bow/bow weapon
154
+ 136: bow/bow decorative ribbons
155
+ 137: bow-tie/bowtie
156
+ 138: bowl
157
+ 139: pipe bowl
158
+ 140: bowler hat/bowler/derby hat/derby/plug hat
159
+ 141: bowling ball
160
+ 142: box
161
+ 143: boxing glove
162
+ 144: suspenders
163
+ 145: bracelet/bangle
164
+ 146: brass plaque
165
+ 147: brassiere/bra/bandeau
166
+ 148: bread-bin/breadbox
167
+ 149: bread
168
+ 150: breechcloth/breechclout/loincloth
169
+ 151: bridal gown/wedding gown/wedding dress
170
+ 152: briefcase
171
+ 153: broccoli
172
+ 154: broach
173
+ 155: broom
174
+ 156: brownie
175
+ 157: brussels sprouts
176
+ 158: bubble gum
177
+ 159: bucket/pail
178
+ 160: horse buggy
179
+ 161: horned cow
180
+ 162: bulldog
181
+ 163: bulldozer/dozer
182
+ 164: bullet train
183
+ 165: bulletin board/notice board
184
+ 166: bulletproof vest
185
+ 167: bullhorn/megaphone
186
+ 168: bun/roll
187
+ 169: bunk bed
188
+ 170: buoy
189
+ 171: burrito
190
+ 172: bus/bus vehicle/autobus/charabanc/double-decker/motorbus/motorcoach
191
+ 173: business card
192
+ 174: butter
193
+ 175: butterfly
194
+ 176: button
195
+ 177: cab/cab taxi/taxi/taxicab
196
+ 178: cabana
197
+ 179: cabin car/caboose
198
+ 180: cabinet
199
+ 181: locker/storage locker
200
+ 182: cake
201
+ 183: calculator
202
+ 184: calendar
203
+ 185: calf
204
+ 186: camcorder
205
+ 187: camel
206
+ 188: camera
207
+ 189: camera lens
208
+ 190: camper/camper vehicle/camping bus/motor home
209
+ 191: can/tin can
210
+ 192: can opener/tin opener
211
+ 193: candle/candlestick
212
+ 194: candle holder
213
+ 195: candy bar
214
+ 196: candy cane
215
+ 197: walking cane
216
+ 198: canister/canister
217
+ 199: canoe
218
+ 200: cantaloup/cantaloupe
219
+ 201: canteen
220
+ 202: cap/cap headwear
221
+ 203: bottle cap/cap/cap container lid
222
+ 204: cape
223
+ 205: cappuccino/coffee cappuccino
224
+ 206: car/car automobile/auto/auto automobile/automobile
225
+ 207: railcar/railcar part of a train/railway car/railway car part of a train/railroad car/railroad car part of a train
226
+ 208: elevator car
227
+ 209: car battery/automobile battery
228
+ 210: identity card
229
+ 211: card
230
+ 212: cardigan
231
+ 213: cargo ship/cargo vessel
232
+ 214: carnation
233
+ 215: horse carriage
234
+ 216: carrot
235
+ 217: tote bag
236
+ 218: cart
237
+ 219: carton
238
+ 220: cash register/register/register for cash transactions
239
+ 221: casserole
240
+ 222: cassette
241
+ 223: cast/plaster cast/plaster bandage
242
+ 224: cat
243
+ 225: cauliflower
244
+ 226: cayenne/cayenne spice/cayenne pepper/cayenne pepper spice/red pepper/red pepper spice
245
+ 227: CD player
246
+ 228: celery
247
+ 229: cellular telephone/cellular phone/cellphone/mobile phone/smart phone
248
+ 230: chain mail/ring mail/chain armor/chain armour/ring armor/ring armour
249
+ 231: chair
250
+ 232: chaise longue/chaise/daybed
251
+ 233: chalice
252
+ 234: chandelier
253
+ 235: chap
254
+ 236: checkbook/chequebook
255
+ 237: checkerboard
256
+ 238: cherry
257
+ 239: chessboard
258
+ 240: chicken/chicken animal
259
+ 241: chickpea/garbanzo
260
+ 242: chili/chili vegetable/chili pepper/chili pepper vegetable/chilli/chilli vegetable/chilly/chilly vegetable/chile/chile vegetable
261
+ 243: chime/gong
262
+ 244: chinaware
263
+ 245: crisp/crisp potato chip/potato chip
264
+ 246: poker chip
265
+ 247: chocolate bar
266
+ 248: chocolate cake
267
+ 249: chocolate milk
268
+ 250: chocolate mousse
269
+ 251: choker/collar/neckband
270
+ 252: chopping board/cutting board/chopping block
271
+ 253: chopstick
272
+ 254: Christmas tree
273
+ 255: slide
274
+ 256: cider/cyder
275
+ 257: cigar box
276
+ 258: cigarette
277
+ 259: cigarette case/cigarette pack
278
+ 260: cistern/water tank
279
+ 261: clarinet
280
+ 262: clasp
281
+ 263: cleansing agent/cleanser/cleaner
282
+ 264: cleat/cleat for securing rope
283
+ 265: clementine
284
+ 266: clip
285
+ 267: clipboard
286
+ 268: clippers/clippers for plants
287
+ 269: cloak
288
+ 270: clock/timepiece/timekeeper
289
+ 271: clock tower
290
+ 272: clothes hamper/laundry basket/clothes basket
291
+ 273: clothespin/clothes peg
292
+ 274: clutch bag
293
+ 275: coaster
294
+ 276: coat
295
+ 277: coat hanger/clothes hanger/dress hanger
296
+ 278: coatrack/hatrack
297
+ 279: cock/rooster
298
+ 280: cockroach
299
+ 281: cocoa/cocoa beverage/hot chocolate/hot chocolate beverage/drinking chocolate
300
+ 282: coconut/cocoanut
301
+ 283: coffee maker/coffee machine
302
+ 284: coffee table/cocktail table
303
+ 285: coffeepot
304
+ 286: coil
305
+ 287: coin
306
+ 288: colander/cullender
307
+ 289: coleslaw/slaw
308
+ 290: coloring material/colouring material
309
+ 291: combination lock
310
+ 292: pacifier/teething ring
311
+ 293: comic book
312
+ 294: compass
313
+ 295: computer keyboard/keyboard/keyboard computer
314
+ 296: condiment
315
+ 297: cone/traffic cone
316
+ 298: control/controller
317
+ 299: convertible/convertible automobile
318
+ 300: sofa bed
319
+ 301: cooker
320
+ 302: cookie/cooky/biscuit/biscuit cookie
321
+ 303: cooking utensil
322
+ 304: cooler/cooler for food/ice chest
323
+ 305: cork/cork bottle plug/bottle cork
324
+ 306: corkboard
325
+ 307: corkscrew/bottle screw
326
+ 308: edible corn/corn/maize
327
+ 309: cornbread
328
+ 310: cornet/horn/trumpet
329
+ 311: cornice/valance/valance board/pelmet
330
+ 312: cornmeal
331
+ 313: corset/girdle
332
+ 314: costume
333
+ 315: cougar/puma/catamount/mountain lion/panther
334
+ 316: coverall
335
+ 317: cowbell
336
+ 318: cowboy hat/ten-gallon hat
337
+ 319: crab/crab animal
338
+ 320: crabmeat
339
+ 321: cracker
340
+ 322: crape/crepe/French pancake
341
+ 323: crate
342
+ 324: crayon/wax crayon
343
+ 325: cream pitcher
344
+ 326: crescent roll/croissant
345
+ 327: crib/cot
346
+ 328: crock pot/earthenware jar
347
+ 329: crossbar
348
+ 330: crouton
349
+ 331: crow
350
+ 332: crowbar/wrecking bar/pry bar
351
+ 333: crown
352
+ 334: crucifix
353
+ 335: cruise ship/cruise liner
354
+ 336: police cruiser/patrol car/police car/squad car
355
+ 337: crumb
356
+ 338: crutch
357
+ 339: cub/cub animal
358
+ 340: cube/square block
359
+ 341: cucumber/cuke
360
+ 342: cufflink
361
+ 343: cup
362
+ 344: trophy cup
363
+ 345: cupboard/closet
364
+ 346: cupcake
365
+ 347: hair curler/hair roller/hair crimper
366
+ 348: curling iron
367
+ 349: curtain/drapery
368
+ 350: cushion
369
+ 351: cylinder
370
+ 352: cymbal
371
+ 353: dagger
372
+ 354: dalmatian
373
+ 355: dartboard
374
+ 356: date/date fruit
375
+ 357: deck chair/beach chair
376
+ 358: deer/cervid
377
+ 359: dental floss/floss
378
+ 360: desk
379
+ 361: detergent
380
+ 362: diaper
381
+ 363: diary/journal
382
+ 364: die/dice
383
+ 365: dinghy/dory/rowboat
384
+ 366: dining table
385
+ 367: tux/tuxedo
386
+ 368: dish
387
+ 369: dish antenna
388
+ 370: dishrag/dishcloth
389
+ 371: dishtowel/tea towel
390
+ 372: dishwasher/dishwashing machine
391
+ 373: dishwasher detergent/dishwashing detergent/dishwashing liquid/dishsoap
392
+ 374: dispenser
393
+ 375: diving board
394
+ 376: Dixie cup/paper cup
395
+ 377: dog
396
+ 378: dog collar
397
+ 379: doll
398
+ 380: dollar/dollar bill/one dollar bill
399
+ 381: dollhouse/doll's house
400
+ 382: dolphin
401
+ 383: domestic ass/donkey
402
+ 384: doorknob/doorhandle
403
+ 385: doormat/welcome mat
404
+ 386: doughnut/donut
405
+ 387: dove
406
+ 388: dragonfly
407
+ 389: drawer
408
+ 390: underdrawers/boxers/boxershorts
409
+ 391: dress/frock
410
+ 392: dress hat/high hat/opera hat/silk hat/top hat
411
+ 393: dress suit
412
+ 394: dresser
413
+ 395: drill
414
+ 396: drone
415
+ 397: dropper/eye dropper
416
+ 398: drum/drum musical instrument
417
+ 399: drumstick
418
+ 400: duck
419
+ 401: duckling
420
+ 402: duct tape
421
+ 403: duffel bag/duffle bag/duffel/duffle
422
+ 404: dumbbell
423
+ 405: dumpster
424
+ 406: dustpan
425
+ 407: eagle
426
+ 408: earphone/earpiece/headphone
427
+ 409: earplug
428
+ 410: earring
429
+ 411: easel
430
+ 412: eclair
431
+ 413: eel
432
+ 414: egg/eggs
433
+ 415: egg roll/spring roll
434
+ 416: egg yolk/yolk/yolk egg
435
+ 417: eggbeater/eggwhisk
436
+ 418: eggplant/aubergine
437
+ 419: electric chair
438
+ 420: refrigerator
439
+ 421: elephant
440
+ 422: elk/moose
441
+ 423: envelope
442
+ 424: eraser
443
+ 425: escargot
444
+ 426: eyepatch
445
+ 427: falcon
446
+ 428: fan
447
+ 429: faucet/spigot/tap
448
+ 430: fedora
449
+ 431: ferret
450
+ 432: Ferris wheel
451
+ 433: ferry/ferryboat
452
+ 434: fig/fig fruit
453
+ 435: fighter jet/fighter aircraft/attack aircraft
454
+ 436: figurine
455
+ 437: file cabinet/filing cabinet
456
+ 438: file/file tool
457
+ 439: fire alarm/smoke alarm
458
+ 440: fire engine/fire truck
459
+ 441: fire extinguisher/extinguisher
460
+ 442: fire hose
461
+ 443: fireplace
462
+ 444: fireplug/fire hydrant/hydrant
463
+ 445: first-aid kit
464
+ 446: fish
465
+ 447: fish/fish food
466
+ 448: fishbowl/goldfish bowl
467
+ 449: fishing rod/fishing pole
468
+ 450: flag
469
+ 451: flagpole/flagstaff
470
+ 452: flamingo
471
+ 453: flannel
472
+ 454: flap
473
+ 455: flash/flashbulb
474
+ 456: flashlight/torch
475
+ 457: fleece
476
+ 458: flip-flop/flip-flop sandal
477
+ 459: flipper/flipper footwear/fin/fin footwear
478
+ 460: flower arrangement/floral arrangement
479
+ 461: flute glass/champagne flute
480
+ 462: foal
481
+ 463: folding chair
482
+ 464: food processor
483
+ 465: football/football American
484
+ 466: football helmet
485
+ 467: footstool/footrest
486
+ 468: fork
487
+ 469: forklift
488
+ 470: freight car
489
+ 471: French toast
490
+ 472: freshener/air freshener
491
+ 473: frisbee
492
+ 474: frog/toad/toad frog
493
+ 475: fruit juice
494
+ 476: frying pan/frypan/skillet
495
+ 477: fudge
496
+ 478: funnel
497
+ 479: futon
498
+ 480: gag/muzzle
499
+ 481: garbage
500
+ 482: garbage truck
501
+ 483: garden hose
502
+ 484: gargle/mouthwash
503
+ 485: gargoyle
504
+ 486: garlic/ail
505
+ 487: gasmask/respirator/gas helmet
506
+ 488: gazelle
507
+ 489: gelatin/jelly
508
+ 490: gemstone
509
+ 491: generator
510
+ 492: giant panda/panda/panda bear
511
+ 493: gift wrap
512
+ 494: ginger/gingerroot
513
+ 495: giraffe
514
+ 496: cincture/sash/waistband/waistcloth
515
+ 497: glass/glass drink container/drinking glass
516
+ 498: globe
517
+ 499: glove
518
+ 500: goat
519
+ 501: goggles
520
+ 502: goldfish
521
+ 503: golf club/golf-club
522
+ 504: golfcart
523
+ 505: gondola/gondola boat
524
+ 506: goose
525
+ 507: gorilla
526
+ 508: gourd
527
+ 509: grape
528
+ 510: grater
529
+ 511: gravestone/headstone/tombstone
530
+ 512: gravy boat/gravy holder
531
+ 513: green bean
532
+ 514: green onion/spring onion/scallion
533
+ 515: griddle
534
+ 516: grill/grille/grillwork/radiator grille
535
+ 517: grits/hominy grits
536
+ 518: grizzly/grizzly bear
537
+ 519: grocery bag
538
+ 520: guitar
539
+ 521: gull/seagull
540
+ 522: gun
541
+ 523: hairbrush
542
+ 524: hairnet
543
+ 525: hairpin
544
+ 526: halter top
545
+ 527: ham/jambon/gammon
546
+ 528: hamburger/beefburger/burger
547
+ 529: hammer
548
+ 530: hammock
549
+ 531: hamper
550
+ 532: hamster
551
+ 533: hair dryer
552
+ 534: hand glass/hand mirror
553
+ 535: hand towel/face towel
554
+ 536: handcart/pushcart/hand truck
555
+ 537: handcuff
556
+ 538: handkerchief
557
+ 539: handle/grip/handgrip
558
+ 540: handsaw/carpenter's saw
559
+ 541: hardback book/hardcover book
560
+ 542: harmonium/organ/organ musical instrument/reed organ/reed organ musical instrument
561
+ 543: hat
562
+ 544: hatbox
563
+ 545: veil
564
+ 546: headband
565
+ 547: headboard
566
+ 548: headlight/headlamp
567
+ 549: headscarf
568
+ 550: headset
569
+ 551: headstall/headstall for horses/headpiece/headpiece for horses
570
+ 552: heart
571
+ 553: heater/warmer
572
+ 554: helicopter
573
+ 555: helmet
574
+ 556: heron
575
+ 557: highchair/feeding chair
576
+ 558: hinge
577
+ 559: hippopotamus
578
+ 560: hockey stick
579
+ 561: hog/pig
580
+ 562: home plate/home plate baseball/home base/home base baseball
581
+ 563: honey
582
+ 564: fume hood/exhaust hood
583
+ 565: hook
584
+ 566: hookah/narghile/nargileh/sheesha/shisha/water pipe
585
+ 567: hornet
586
+ 568: horse
587
+ 569: hose/hosepipe
588
+ 570: hot-air balloon
589
+ 571: hotplate
590
+ 572: hot sauce
591
+ 573: hourglass
592
+ 574: houseboat
593
+ 575: hummingbird
594
+ 576: hummus/humus/hommos/hoummos/humous
595
+ 577: polar bear
596
+ 578: icecream
597
+ 579: popsicle
598
+ 580: ice maker
599
+ 581: ice pack/ice bag
600
+ 582: ice skate
601
+ 583: igniter/ignitor/lighter
602
+ 584: inhaler/inhalator
603
+ 585: iPod
604
+ 586: iron/iron for clothing/smoothing iron/smoothing iron for clothing
605
+ 587: ironing board
606
+ 588: jacket
607
+ 589: jam
608
+ 590: jar
609
+ 591: jean/blue jean/denim
610
+ 592: jeep/landrover
611
+ 593: jelly bean/jelly egg
612
+ 594: jersey/T-shirt/tee shirt
613
+ 595: jet plane/jet-propelled plane
614
+ 596: jewel/gem/precious stone
615
+ 597: jewelry/jewellery
616
+ 598: joystick
617
+ 599: jumpsuit
618
+ 600: kayak
619
+ 601: keg
620
+ 602: kennel/doghouse
621
+ 603: kettle/boiler
622
+ 604: key
623
+ 605: keycard
624
+ 606: kilt
625
+ 607: kimono
626
+ 608: kitchen sink
627
+ 609: kitchen table
628
+ 610: kite
629
+ 611: kitten/kitty
630
+ 612: kiwi fruit
631
+ 613: knee pad
632
+ 614: knife
633
+ 615: knitting needle
634
+ 616: knob
635
+ 617: knocker/knocker on a door/doorknocker
636
+ 618: koala/koala bear
637
+ 619: lab coat/laboratory coat
638
+ 620: ladder
639
+ 621: ladle
640
+ 622: ladybug/ladybeetle/ladybird beetle
641
+ 623: lamb/lamb animal
642
+ 624: lamb-chop/lambchop
643
+ 625: lamp
644
+ 626: lamppost
645
+ 627: lampshade
646
+ 628: lantern
647
+ 629: lanyard/laniard
648
+ 630: laptop computer/notebook computer
649
+ 631: lasagna/lasagne
650
+ 632: latch
651
+ 633: lawn mower
652
+ 634: leather
653
+ 635: legging/legging clothing/leging/leging clothing/leg covering
654
+ 636: Lego/Lego set
655
+ 637: legume
656
+ 638: lemon
657
+ 639: lemonade
658
+ 640: lettuce
659
+ 641: license plate/numberplate
660
+ 642: life buoy/lifesaver/life belt/life ring
661
+ 643: life jacket/life vest
662
+ 644: lightbulb
663
+ 645: lightning rod/lightning conductor
664
+ 646: lime
665
+ 647: limousine
666
+ 648: lion
667
+ 649: lip balm
668
+ 650: liquor/spirits/hard liquor/liqueur/cordial
669
+ 651: lizard
670
+ 652: log
671
+ 653: lollipop
672
+ 654: speaker/speaker stereo equipment
673
+ 655: loveseat
674
+ 656: machine gun
675
+ 657: magazine
676
+ 658: magnet
677
+ 659: mail slot
678
+ 660: mailbox/mailbox at home/letter box/letter box at home
679
+ 661: mallard
680
+ 662: mallet
681
+ 663: mammoth
682
+ 664: manatee
683
+ 665: mandarin orange
684
+ 666: manager/through
685
+ 667: manhole
686
+ 668: map
687
+ 669: marker
688
+ 670: martini
689
+ 671: mascot
690
+ 672: mashed potato
691
+ 673: masher
692
+ 674: mask/facemask
693
+ 675: mast
694
+ 676: mat/mat gym equipment/gym mat
695
+ 677: matchbox
696
+ 678: mattress
697
+ 679: measuring cup
698
+ 680: measuring stick/ruler/ruler measuring stick/measuring rod
699
+ 681: meatball
700
+ 682: medicine
701
+ 683: melon
702
+ 684: microphone
703
+ 685: microscope
704
+ 686: microwave oven
705
+ 687: milestone/milepost
706
+ 688: milk
707
+ 689: milk can
708
+ 690: milkshake
709
+ 691: minivan
710
+ 692: mint candy
711
+ 693: mirror
712
+ 694: mitten
713
+ 695: mixer/mixer kitchen tool/stand mixer
714
+ 696: money
715
+ 697: monitor/monitor computer equipment
716
+ 698: monkey
717
+ 699: motor
718
+ 700: motor scooter/scooter
719
+ 701: motor vehicle/automotive vehicle
720
+ 702: motorcycle
721
+ 703: mound/mound baseball/pitcher's mound
722
+ 704: mouse/mouse computer equipment/computer mouse
723
+ 705: mousepad
724
+ 706: muffin
725
+ 707: mug
726
+ 708: mushroom
727
+ 709: music stool/piano stool
728
+ 710: musical instrument/instrument/instrument musical
729
+ 711: nailfile
730
+ 712: napkin/table napkin/serviette
731
+ 713: neckerchief
732
+ 714: necklace
733
+ 715: necktie/tie/tie necktie
734
+ 716: needle
735
+ 717: nest
736
+ 718: newspaper/paper/paper newspaper
737
+ 719: newsstand
738
+ 720: nightshirt/nightwear/sleepwear/nightclothes
739
+ 721: nosebag/nosebag for animals/feedbag
740
+ 722: noseband/noseband for animals/nosepiece/nosepiece for animals
741
+ 723: notebook
742
+ 724: notepad
743
+ 725: nut
744
+ 726: nutcracker
745
+ 727: oar
746
+ 728: octopus/octopus food
747
+ 729: octopus/octopus animal
748
+ 730: oil lamp/kerosene lamp/kerosine lamp
749
+ 731: olive oil
750
+ 732: omelet/omelette
751
+ 733: onion
752
+ 734: orange/orange fruit
753
+ 735: orange juice
754
+ 736: ostrich
755
+ 737: ottoman/pouf/pouffe/hassock
756
+ 738: oven
757
+ 739: overalls/overalls clothing
758
+ 740: owl
759
+ 741: packet
760
+ 742: inkpad/inking pad/stamp pad
761
+ 743: pad
762
+ 744: paddle/boat paddle
763
+ 745: padlock
764
+ 746: paintbrush
765
+ 747: painting
766
+ 748: pajamas/pyjamas
767
+ 749: palette/pallet
768
+ 750: pan/pan for cooking/cooking pan
769
+ 751: pan/pan metal container
770
+ 752: pancake
771
+ 753: pantyhose
772
+ 754: papaya
773
+ 755: paper plate
774
+ 756: paper towel
775
+ 757: paperback book/paper-back book/softback book/soft-cover book
776
+ 758: paperweight
777
+ 759: parachute
778
+ 760: parakeet/parrakeet/parroket/paraquet/paroquet/parroquet
779
+ 761: parasail/parasail sports
780
+ 762: parasol/sunshade
781
+ 763: parchment
782
+ 764: parka/anorak
783
+ 765: parking meter
784
+ 766: parrot
785
+ 767: passenger car/passenger car part of a train/coach/coach part of a train
786
+ 768: passenger ship
787
+ 769: passport
788
+ 770: pastry
789
+ 771: patty/patty food
790
+ 772: pea/pea food
791
+ 773: peach
792
+ 774: peanut butter
793
+ 775: pear
794
+ 776: peeler/peeler tool for fruit and vegetables
795
+ 777: wooden leg/pegleg
796
+ 778: pegboard
797
+ 779: pelican
798
+ 780: pen
799
+ 781: pencil
800
+ 782: pencil box/pencil case
801
+ 783: pencil sharpener
802
+ 784: pendulum
803
+ 785: penguin
804
+ 786: pennant
805
+ 787: penny/penny coin
806
+ 788: pepper/peppercorn
807
+ 789: pepper mill/pepper grinder
808
+ 790: perfume
809
+ 791: persimmon
810
+ 792: person/baby/child/boy/girl/man/woman/human
811
+ 793: pet
812
+ 794: pew/pew church bench/church bench
813
+ 795: phonebook/telephone book/telephone directory
814
+ 796: phonograph record/phonograph recording/record/record phonograph recording
815
+ 797: piano
816
+ 798: pickle
817
+ 799: pickup truck
818
+ 800: pie
819
+ 801: pigeon
820
+ 802: piggy bank/penny bank
821
+ 803: pillow
822
+ 804: pin/pin non jewelry
823
+ 805: pineapple
824
+ 806: pinecone
825
+ 807: ping-pong ball
826
+ 808: pinwheel
827
+ 809: tobacco pipe
828
+ 810: pipe/piping
829
+ 811: pistol/handgun
830
+ 812: pita/pita bread/pocket bread
831
+ 813: pitcher/pitcher vessel for liquid/ewer
832
+ 814: pitchfork
833
+ 815: pizza
834
+ 816: place mat
835
+ 817: plate
836
+ 818: platter
837
+ 819: playpen
838
+ 820: pliers/plyers
839
+ 821: plow/plow farm equipment/plough/plough farm equipment
840
+ 822: plume
841
+ 823: pocket watch
842
+ 824: pocketknife
843
+ 825: poker/poker fire stirring tool/stove poker/fire hook
844
+ 826: pole/post
845
+ 827: polo shirt/sport shirt
846
+ 828: poncho
847
+ 829: pony
848
+ 830: pool table/billiard table/snooker table
849
+ 831: pop/pop soda/soda/soda pop/tonic/soft drink
850
+ 832: postbox/postbox public/mailbox/mailbox public
851
+ 833: postcard/postal card/mailing-card
852
+ 834: poster/placard
853
+ 835: pot
854
+ 836: flowerpot
855
+ 837: potato
856
+ 838: potholder
857
+ 839: pottery/clayware
858
+ 840: pouch
859
+ 841: power shovel/excavator/digger
860
+ 842: prawn/shrimp
861
+ 843: pretzel
862
+ 844: printer/printing machine
863
+ 845: projectile/projectile weapon/missile
864
+ 846: projector
865
+ 847: propeller/propellor
866
+ 848: prune
867
+ 849: pudding
868
+ 850: puffer/puffer fish/pufferfish/blowfish/globefish
869
+ 851: puffin
870
+ 852: pug-dog
871
+ 853: pumpkin
872
+ 854: puncher
873
+ 855: puppet/marionette
874
+ 856: puppy
875
+ 857: quesadilla
876
+ 858: quiche
877
+ 859: quilt/comforter
878
+ 860: rabbit
879
+ 861: race car/racing car
880
+ 862: racket/racquet
881
+ 863: radar
882
+ 864: radiator
883
+ 865: radio receiver/radio set/radio/tuner/tuner radio
884
+ 866: radish/daikon
885
+ 867: raft
886
+ 868: rag doll
887
+ 869: raincoat/waterproof jacket
888
+ 870: ram/ram animal
889
+ 871: raspberry
890
+ 872: rat
891
+ 873: razorblade
892
+ 874: reamer/reamer juicer/juicer/juice reamer
893
+ 875: rearview mirror
894
+ 876: receipt
895
+ 877: recliner/reclining chair/lounger/lounger chair
896
+ 878: record player/phonograph/phonograph record player/turntable
897
+ 879: reflector
898
+ 880: remote control
899
+ 881: rhinoceros
900
+ 882: rib/rib food
901
+ 883: rifle
902
+ 884: ring
903
+ 885: river boat
904
+ 886: road map
905
+ 887: robe
906
+ 888: rocking chair
907
+ 889: rodent
908
+ 890: roller skate
909
+ 891: Rollerblade
910
+ 892: rolling pin
911
+ 893: root beer
912
+ 894: router/router computer equipment
913
+ 895: rubber band/elastic band
914
+ 896: runner/runner carpet
915
+ 897: plastic bag/paper bag
916
+ 898: saddle/saddle on an animal
917
+ 899: saddle blanket/saddlecloth/horse blanket
918
+ 900: saddlebag
919
+ 901: safety pin
920
+ 902: sail
921
+ 903: salad
922
+ 904: salad plate/salad bowl
923
+ 905: salami
924
+ 906: salmon/salmon fish
925
+ 907: salmon/salmon food
926
+ 908: salsa
927
+ 909: saltshaker
928
+ 910: sandal/sandal type of shoe
929
+ 911: sandwich
930
+ 912: satchel
931
+ 913: saucepan
932
+ 914: saucer
933
+ 915: sausage
934
+ 916: sawhorse/sawbuck
935
+ 917: saxophone
936
+ 918: scale/scale measuring instrument
937
+ 919: scarecrow/strawman
938
+ 920: scarf
939
+ 921: school bus
940
+ 922: scissors
941
+ 923: scoreboard
942
+ 924: scraper
943
+ 925: screwdriver
944
+ 926: scrubbing brush
945
+ 927: sculpture
946
+ 928: seabird/seafowl
947
+ 929: seahorse
948
+ 930: seaplane/hydroplane
949
+ 931: seashell
950
+ 932: sewing machine
951
+ 933: shaker
952
+ 934: shampoo
953
+ 935: shark
954
+ 936: sharpener
955
+ 937: Sharpie
956
+ 938: shaver/shaver electric/electric shaver/electric razor
957
+ 939: shaving cream/shaving soap
958
+ 940: shawl
959
+ 941: shears
960
+ 942: sheep
961
+ 943: shepherd dog/sheepdog
962
+ 944: sherbert/sherbet
963
+ 945: shield
964
+ 946: shirt
965
+ 947: shoe/sneaker/sneaker type of shoe/tennis shoe
966
+ 948: shopping bag
967
+ 949: shopping cart
968
+ 950: short pants/shorts/shorts clothing/trunks/trunks clothing
969
+ 951: shot glass
970
+ 952: shoulder bag
971
+ 953: shovel
972
+ 954: shower head
973
+ 955: shower cap
974
+ 956: shower curtain
975
+ 957: shredder/shredder for paper
976
+ 958: signboard
977
+ 959: silo
978
+ 960: sink
979
+ 961: skateboard
980
+ 962: skewer
981
+ 963: ski
982
+ 964: ski boot
983
+ 965: ski parka/ski jacket
984
+ 966: ski pole
985
+ 967: skirt
986
+ 968: skullcap
987
+ 969: sled/sledge/sleigh
988
+ 970: sleeping bag
989
+ 971: sling/sling bandage/triangular bandage
990
+ 972: slipper/slipper footwear/carpet slipper/carpet slipper footwear
991
+ 973: smoothie
992
+ 974: snake/serpent
993
+ 975: snowboard
994
+ 976: snowman
995
+ 977: snowmobile
996
+ 978: soap
997
+ 979: soccer ball
998
+ 980: sock
999
+ 981: sofa/couch/lounge
1000
+ 982: softball
1001
+ 983: solar array/solar battery/solar panel
1002
+ 984: sombrero
1003
+ 985: soup
1004
+ 986: soup bowl
1005
+ 987: soupspoon
1006
+ 988: sour cream/soured cream
1007
+ 989: soya milk/soybean milk/soymilk
1008
+ 990: space shuttle
1009
+ 991: sparkler/sparkler fireworks
1010
+ 992: spatula
1011
+ 993: spear/lance
1012
+ 994: spectacles/specs/eyeglasses/glasses
1013
+ 995: spice rack
1014
+ 996: spider
1015
+ 997: crawfish/crayfish
1016
+ 998: sponge
1017
+ 999: spoon
1018
+ 1000: sportswear/athletic wear/activewear
1019
+ 1001: spotlight
1020
+ 1002: squid/squid food/calamari/calamary
1021
+ 1003: squirrel
1022
+ 1004: stagecoach
1023
+ 1005: stapler/stapler stapling machine
1024
+ 1006: starfish/sea star
1025
+ 1007: statue/statue sculpture
1026
+ 1008: steak/steak food
1027
+ 1009: steak knife
1028
+ 1010: steering wheel
1029
+ 1011: stepladder
1030
+ 1012: step stool
1031
+ 1013: stereo/stereo sound system
1032
+ 1014: stew
1033
+ 1015: stirrer
1034
+ 1016: stirrup
1035
+ 1017: stool
1036
+ 1018: stop sign
1037
+ 1019: brake light
1038
+ 1020: stove/kitchen stove/range/range kitchen appliance/kitchen range/cooking stove
1039
+ 1021: strainer
1040
+ 1022: strap
1041
+ 1023: straw/straw for drinking/drinking straw
1042
+ 1024: strawberry
1043
+ 1025: street sign
1044
+ 1026: streetlight/street lamp
1045
+ 1027: string cheese
1046
+ 1028: stylus
1047
+ 1029: subwoofer
1048
+ 1030: sugar bowl
1049
+ 1031: sugarcane/sugarcane plant
1050
+ 1032: suit/suit clothing
1051
+ 1033: sunflower
1052
+ 1034: sunglasses
1053
+ 1035: sunhat
1054
+ 1036: surfboard
1055
+ 1037: sushi
1056
+ 1038: mop
1057
+ 1039: sweat pants
1058
+ 1040: sweatband
1059
+ 1041: sweater
1060
+ 1042: sweatshirt
1061
+ 1043: sweet potato
1062
+ 1044: swimsuit/swimwear/bathing suit/swimming costume/bathing costume/swimming trunks/bathing trunks
1063
+ 1045: sword
1064
+ 1046: syringe
1065
+ 1047: Tabasco sauce
1066
+ 1048: table-tennis table/ping-pong table
1067
+ 1049: table
1068
+ 1050: table lamp
1069
+ 1051: tablecloth
1070
+ 1052: tachometer
1071
+ 1053: taco
1072
+ 1054: tag
1073
+ 1055: taillight/rear light
1074
+ 1056: tambourine
1075
+ 1057: army tank/armored combat vehicle/armoured combat vehicle
1076
+ 1058: tank/tank storage vessel/storage tank
1077
+ 1059: tank top/tank top clothing
1078
+ 1060: tape/tape sticky cloth or paper
1079
+ 1061: tape measure/measuring tape
1080
+ 1062: tapestry
1081
+ 1063: tarp
1082
+ 1064: tartan/plaid
1083
+ 1065: tassel
1084
+ 1066: tea bag
1085
+ 1067: teacup
1086
+ 1068: teakettle
1087
+ 1069: teapot
1088
+ 1070: teddy bear
1089
+ 1071: telephone/phone/telephone set
1090
+ 1072: telephone booth/phone booth/call box/telephone box/telephone kiosk
1091
+ 1073: telephone pole/telegraph pole/telegraph post
1092
+ 1074: telephoto lens/zoom lens
1093
+ 1075: television camera/tv camera
1094
+ 1076: television set/tv/tv set
1095
+ 1077: tennis ball
1096
+ 1078: tennis racket
1097
+ 1079: tequila
1098
+ 1080: thermometer
1099
+ 1081: thermos bottle
1100
+ 1082: thermostat
1101
+ 1083: thimble
1102
+ 1084: thread/yarn
1103
+ 1085: thumbtack/drawing pin/pushpin
1104
+ 1086: tiara
1105
+ 1087: tiger
1106
+ 1088: tights/tights clothing/leotards
1107
+ 1089: timer/stopwatch
1108
+ 1090: tinfoil
1109
+ 1091: tinsel
1110
+ 1092: tissue paper
1111
+ 1093: toast/toast food
1112
+ 1094: toaster
1113
+ 1095: toaster oven
1114
+ 1096: toilet
1115
+ 1097: toilet tissue/toilet paper/bathroom tissue
1116
+ 1098: tomato
1117
+ 1099: tongs
1118
+ 1100: toolbox
1119
+ 1101: toothbrush
1120
+ 1102: toothpaste
1121
+ 1103: toothpick
1122
+ 1104: cover
1123
+ 1105: tortilla
1124
+ 1106: tow truck
1125
+ 1107: towel
1126
+ 1108: towel rack/towel rail/towel bar
1127
+ 1109: toy
1128
+ 1110: tractor/tractor farm equipment
1129
+ 1111: traffic light
1130
+ 1112: dirt bike
1131
+ 1113: trailer truck/tractor trailer/trucking rig/articulated lorry/semi truck
1132
+ 1114: train/train railroad vehicle/railroad train
1133
+ 1115: trampoline
1134
+ 1116: tray
1135
+ 1117: trench coat
1136
+ 1118: triangle/triangle musical instrument
1137
+ 1119: tricycle
1138
+ 1120: tripod
1139
+ 1121: trousers/pants/pants clothing
1140
+ 1122: truck
1141
+ 1123: truffle/truffle chocolate/chocolate truffle
1142
+ 1124: trunk
1143
+ 1125: vat
1144
+ 1126: turban
1145
+ 1127: turkey/turkey food
1146
+ 1128: turnip
1147
+ 1129: turtle
1148
+ 1130: turtleneck/turtleneck clothing/polo-neck
1149
+ 1131: typewriter
1150
+ 1132: umbrella
1151
+ 1133: underwear/underclothes/underclothing/underpants
1152
+ 1134: unicycle
1153
+ 1135: urinal
1154
+ 1136: urn
1155
+ 1137: vacuum cleaner
1156
+ 1138: vase
1157
+ 1139: vending machine
1158
+ 1140: vent/blowhole/air vent
1159
+ 1141: vest/waistcoat
1160
+ 1142: videotape
1161
+ 1143: vinegar
1162
+ 1144: violin/fiddle
1163
+ 1145: vodka
1164
+ 1146: volleyball
1165
+ 1147: vulture
1166
+ 1148: waffle
1167
+ 1149: waffle iron
1168
+ 1150: wagon
1169
+ 1151: wagon wheel
1170
+ 1152: walking stick
1171
+ 1153: wall clock
1172
+ 1154: wall socket/wall plug/electric outlet/electrical outlet/outlet/electric receptacle
1173
+ 1155: wallet/billfold
1174
+ 1156: walrus
1175
+ 1157: wardrobe
1176
+ 1158: washbasin/basin/basin for washing/washbowl/washstand/handbasin
1177
+ 1159: automatic washer/washing machine
1178
+ 1160: watch/wristwatch
1179
+ 1161: water bottle
1180
+ 1162: water cooler
1181
+ 1163: water faucet/water tap/tap/tap water faucet
1182
+ 1164: water heater/hot-water heater
1183
+ 1165: water jug
1184
+ 1166: water gun/squirt gun
1185
+ 1167: water scooter/sea scooter/jet ski
1186
+ 1168: water ski
1187
+ 1169: water tower
1188
+ 1170: watering can
1189
+ 1171: watermelon
1190
+ 1172: weathervane/vane/vane weathervane/wind vane
1191
+ 1173: webcam
1192
+ 1174: wedding cake/bridecake
1193
+ 1175: wedding ring/wedding band
1194
+ 1176: wet suit
1195
+ 1177: wheel
1196
+ 1178: wheelchair
1197
+ 1179: whipped cream
1198
+ 1180: whistle
1199
+ 1181: wig
1200
+ 1182: wind chime
1201
+ 1183: windmill
1202
+ 1184: window box/window box for plants
1203
+ 1185: windshield wiper/windscreen wiper/wiper/wiper for windshield or screen
1204
+ 1186: windsock/air sock/air-sleeve/wind sleeve/wind cone
1205
+ 1187: wine bottle
1206
+ 1188: wine bucket/wine cooler
1207
+ 1189: wineglass
1208
+ 1190: blinder/blinder for horses
1209
+ 1191: wok
1210
+ 1192: wolf
1211
+ 1193: wooden spoon
1212
+ 1194: wreath
1213
+ 1195: wrench/spanner
1214
+ 1196: wristband
1215
+ 1197: wristlet/wrist band
1216
+ 1198: yacht
1217
+ 1199: yogurt/yoghurt/yoghourt
1218
+ 1200: yoke/yoke animal equipment
1219
+ 1201: zebra
1220
+ 1202: zucchini/courgette
1221
+
1222
+ # Download script/URL (optional)
1223
+ download: |
1224
+ from ultralytics.utils.downloads import download
1225
+ from pathlib import Path
1226
+
1227
+ # Download labels
1228
+ dir = Path(yaml['path']) # dataset root dir
1229
+ url = 'https://github.com/ultralytics/assets/releases/download/v0.0.0/'
1230
+ urls = [url + 'lvis-labels-segments.zip'] # labels
1231
+ download(urls, dir=dir.parent)
1232
+ # Download data
1233
+ urls = ['http://images.cocodataset.org/zips/train2017.zip', # 19G, 118k images
1234
+ 'http://images.cocodataset.org/zips/val2017.zip', # 1G, 5k images
1235
+ 'http://images.cocodataset.org/zips/test2017.zip'] # 7G, 41k images (optional)
1236
+ download(urls, dir=dir / 'images', threads=3)
ultralytics/cfg/datasets/medical-pills.yaml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Medical-pills dataset by Ultralytics
4
+ # Documentation: https://docs.ultralytics.com/datasets/detect/medical-pills/
5
+ # Example usage: yolo train data=medical-pills.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── medical-pills ← downloads here (8.19 MB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/medical-pills # dataset root dir
13
+ train: train/images # train images (relative to 'path') 92 images
14
+ val: valid/images # val images (relative to 'path') 23 images
15
+ test: # test images (relative to 'path')
16
+
17
+ # Classes
18
+ names:
19
+ 0: pill
20
+
21
+ # Download script/URL (optional)
22
+ download: https://github.com/ultralytics/assets/releases/download/v0.0.0/medical-pills.zip
ultralytics/cfg/datasets/open-images-v7.yaml ADDED
@@ -0,0 +1,661 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Open Images v7 dataset https://storage.googleapis.com/openimages/web/index.html by Google
4
+ # Documentation: https://docs.ultralytics.com/datasets/detect/open-images-v7/
5
+ # Example usage: yolo train data=open-images-v7.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── open-images-v7 ← downloads here (561 GB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/open-images-v7 # dataset root dir
13
+ train: images/train # train images (relative to 'path') 1743042 images
14
+ val: images/val # val images (relative to 'path') 41620 images
15
+ test: # test images (optional)
16
+
17
+ # Classes
18
+ names:
19
+ 0: Accordion
20
+ 1: Adhesive tape
21
+ 2: Aircraft
22
+ 3: Airplane
23
+ 4: Alarm clock
24
+ 5: Alpaca
25
+ 6: Ambulance
26
+ 7: Animal
27
+ 8: Ant
28
+ 9: Antelope
29
+ 10: Apple
30
+ 11: Armadillo
31
+ 12: Artichoke
32
+ 13: Auto part
33
+ 14: Axe
34
+ 15: Backpack
35
+ 16: Bagel
36
+ 17: Baked goods
37
+ 18: Balance beam
38
+ 19: Ball
39
+ 20: Balloon
40
+ 21: Banana
41
+ 22: Band-aid
42
+ 23: Banjo
43
+ 24: Barge
44
+ 25: Barrel
45
+ 26: Baseball bat
46
+ 27: Baseball glove
47
+ 28: Bat (Animal)
48
+ 29: Bathroom accessory
49
+ 30: Bathroom cabinet
50
+ 31: Bathtub
51
+ 32: Beaker
52
+ 33: Bear
53
+ 34: Bed
54
+ 35: Bee
55
+ 36: Beehive
56
+ 37: Beer
57
+ 38: Beetle
58
+ 39: Bell pepper
59
+ 40: Belt
60
+ 41: Bench
61
+ 42: Bicycle
62
+ 43: Bicycle helmet
63
+ 44: Bicycle wheel
64
+ 45: Bidet
65
+ 46: Billboard
66
+ 47: Billiard table
67
+ 48: Binoculars
68
+ 49: Bird
69
+ 50: Blender
70
+ 51: Blue jay
71
+ 52: Boat
72
+ 53: Bomb
73
+ 54: Book
74
+ 55: Bookcase
75
+ 56: Boot
76
+ 57: Bottle
77
+ 58: Bottle opener
78
+ 59: Bow and arrow
79
+ 60: Bowl
80
+ 61: Bowling equipment
81
+ 62: Box
82
+ 63: Boy
83
+ 64: Brassiere
84
+ 65: Bread
85
+ 66: Briefcase
86
+ 67: Broccoli
87
+ 68: Bronze sculpture
88
+ 69: Brown bear
89
+ 70: Building
90
+ 71: Bull
91
+ 72: Burrito
92
+ 73: Bus
93
+ 74: Bust
94
+ 75: Butterfly
95
+ 76: Cabbage
96
+ 77: Cabinetry
97
+ 78: Cake
98
+ 79: Cake stand
99
+ 80: Calculator
100
+ 81: Camel
101
+ 82: Camera
102
+ 83: Can opener
103
+ 84: Canary
104
+ 85: Candle
105
+ 86: Candy
106
+ 87: Cannon
107
+ 88: Canoe
108
+ 89: Cantaloupe
109
+ 90: Car
110
+ 91: Carnivore
111
+ 92: Carrot
112
+ 93: Cart
113
+ 94: Cassette deck
114
+ 95: Castle
115
+ 96: Cat
116
+ 97: Cat furniture
117
+ 98: Caterpillar
118
+ 99: Cattle
119
+ 100: Ceiling fan
120
+ 101: Cello
121
+ 102: Centipede
122
+ 103: Chainsaw
123
+ 104: Chair
124
+ 105: Cheese
125
+ 106: Cheetah
126
+ 107: Chest of drawers
127
+ 108: Chicken
128
+ 109: Chime
129
+ 110: Chisel
130
+ 111: Chopsticks
131
+ 112: Christmas tree
132
+ 113: Clock
133
+ 114: Closet
134
+ 115: Clothing
135
+ 116: Coat
136
+ 117: Cocktail
137
+ 118: Cocktail shaker
138
+ 119: Coconut
139
+ 120: Coffee
140
+ 121: Coffee cup
141
+ 122: Coffee table
142
+ 123: Coffeemaker
143
+ 124: Coin
144
+ 125: Common fig
145
+ 126: Common sunflower
146
+ 127: Computer keyboard
147
+ 128: Computer monitor
148
+ 129: Computer mouse
149
+ 130: Container
150
+ 131: Convenience store
151
+ 132: Cookie
152
+ 133: Cooking spray
153
+ 134: Corded phone
154
+ 135: Cosmetics
155
+ 136: Couch
156
+ 137: Countertop
157
+ 138: Cowboy hat
158
+ 139: Crab
159
+ 140: Cream
160
+ 141: Cricket ball
161
+ 142: Crocodile
162
+ 143: Croissant
163
+ 144: Crown
164
+ 145: Crutch
165
+ 146: Cucumber
166
+ 147: Cupboard
167
+ 148: Curtain
168
+ 149: Cutting board
169
+ 150: Dagger
170
+ 151: Dairy Product
171
+ 152: Deer
172
+ 153: Desk
173
+ 154: Dessert
174
+ 155: Diaper
175
+ 156: Dice
176
+ 157: Digital clock
177
+ 158: Dinosaur
178
+ 159: Dishwasher
179
+ 160: Dog
180
+ 161: Dog bed
181
+ 162: Doll
182
+ 163: Dolphin
183
+ 164: Door
184
+ 165: Door handle
185
+ 166: Doughnut
186
+ 167: Dragonfly
187
+ 168: Drawer
188
+ 169: Dress
189
+ 170: Drill (Tool)
190
+ 171: Drink
191
+ 172: Drinking straw
192
+ 173: Drum
193
+ 174: Duck
194
+ 175: Dumbbell
195
+ 176: Eagle
196
+ 177: Earrings
197
+ 178: Egg (Food)
198
+ 179: Elephant
199
+ 180: Envelope
200
+ 181: Eraser
201
+ 182: Face powder
202
+ 183: Facial tissue holder
203
+ 184: Falcon
204
+ 185: Fashion accessory
205
+ 186: Fast food
206
+ 187: Fax
207
+ 188: Fedora
208
+ 189: Filing cabinet
209
+ 190: Fire hydrant
210
+ 191: Fireplace
211
+ 192: Fish
212
+ 193: Flag
213
+ 194: Flashlight
214
+ 195: Flower
215
+ 196: Flowerpot
216
+ 197: Flute
217
+ 198: Flying disc
218
+ 199: Food
219
+ 200: Food processor
220
+ 201: Football
221
+ 202: Football helmet
222
+ 203: Footwear
223
+ 204: Fork
224
+ 205: Fountain
225
+ 206: Fox
226
+ 207: French fries
227
+ 208: French horn
228
+ 209: Frog
229
+ 210: Fruit
230
+ 211: Frying pan
231
+ 212: Furniture
232
+ 213: Garden Asparagus
233
+ 214: Gas stove
234
+ 215: Giraffe
235
+ 216: Girl
236
+ 217: Glasses
237
+ 218: Glove
238
+ 219: Goat
239
+ 220: Goggles
240
+ 221: Goldfish
241
+ 222: Golf ball
242
+ 223: Golf cart
243
+ 224: Gondola
244
+ 225: Goose
245
+ 226: Grape
246
+ 227: Grapefruit
247
+ 228: Grinder
248
+ 229: Guacamole
249
+ 230: Guitar
250
+ 231: Hair dryer
251
+ 232: Hair spray
252
+ 233: Hamburger
253
+ 234: Hammer
254
+ 235: Hamster
255
+ 236: Hand dryer
256
+ 237: Handbag
257
+ 238: Handgun
258
+ 239: Harbor seal
259
+ 240: Harmonica
260
+ 241: Harp
261
+ 242: Harpsichord
262
+ 243: Hat
263
+ 244: Headphones
264
+ 245: Heater
265
+ 246: Hedgehog
266
+ 247: Helicopter
267
+ 248: Helmet
268
+ 249: High heels
269
+ 250: Hiking equipment
270
+ 251: Hippopotamus
271
+ 252: Home appliance
272
+ 253: Honeycomb
273
+ 254: Horizontal bar
274
+ 255: Horse
275
+ 256: Hot dog
276
+ 257: House
277
+ 258: Houseplant
278
+ 259: Human arm
279
+ 260: Human beard
280
+ 261: Human body
281
+ 262: Human ear
282
+ 263: Human eye
283
+ 264: Human face
284
+ 265: Human foot
285
+ 266: Human hair
286
+ 267: Human hand
287
+ 268: Human head
288
+ 269: Human leg
289
+ 270: Human mouth
290
+ 271: Human nose
291
+ 272: Humidifier
292
+ 273: Ice cream
293
+ 274: Indoor rower
294
+ 275: Infant bed
295
+ 276: Insect
296
+ 277: Invertebrate
297
+ 278: Ipod
298
+ 279: Isopod
299
+ 280: Jacket
300
+ 281: Jacuzzi
301
+ 282: Jaguar (Animal)
302
+ 283: Jeans
303
+ 284: Jellyfish
304
+ 285: Jet ski
305
+ 286: Jug
306
+ 287: Juice
307
+ 288: Kangaroo
308
+ 289: Kettle
309
+ 290: Kitchen & dining room table
310
+ 291: Kitchen appliance
311
+ 292: Kitchen knife
312
+ 293: Kitchen utensil
313
+ 294: Kitchenware
314
+ 295: Kite
315
+ 296: Knife
316
+ 297: Koala
317
+ 298: Ladder
318
+ 299: Ladle
319
+ 300: Ladybug
320
+ 301: Lamp
321
+ 302: Land vehicle
322
+ 303: Lantern
323
+ 304: Laptop
324
+ 305: Lavender (Plant)
325
+ 306: Lemon
326
+ 307: Leopard
327
+ 308: Light bulb
328
+ 309: Light switch
329
+ 310: Lighthouse
330
+ 311: Lily
331
+ 312: Limousine
332
+ 313: Lion
333
+ 314: Lipstick
334
+ 315: Lizard
335
+ 316: Lobster
336
+ 317: Loveseat
337
+ 318: Luggage and bags
338
+ 319: Lynx
339
+ 320: Magpie
340
+ 321: Mammal
341
+ 322: Man
342
+ 323: Mango
343
+ 324: Maple
344
+ 325: Maracas
345
+ 326: Marine invertebrates
346
+ 327: Marine mammal
347
+ 328: Measuring cup
348
+ 329: Mechanical fan
349
+ 330: Medical equipment
350
+ 331: Microphone
351
+ 332: Microwave oven
352
+ 333: Milk
353
+ 334: Miniskirt
354
+ 335: Mirror
355
+ 336: Missile
356
+ 337: Mixer
357
+ 338: Mixing bowl
358
+ 339: Mobile phone
359
+ 340: Monkey
360
+ 341: Moths and butterflies
361
+ 342: Motorcycle
362
+ 343: Mouse
363
+ 344: Muffin
364
+ 345: Mug
365
+ 346: Mule
366
+ 347: Mushroom
367
+ 348: Musical instrument
368
+ 349: Musical keyboard
369
+ 350: Nail (Construction)
370
+ 351: Necklace
371
+ 352: Nightstand
372
+ 353: Oboe
373
+ 354: Office building
374
+ 355: Office supplies
375
+ 356: Orange
376
+ 357: Organ (Musical Instrument)
377
+ 358: Ostrich
378
+ 359: Otter
379
+ 360: Oven
380
+ 361: Owl
381
+ 362: Oyster
382
+ 363: Paddle
383
+ 364: Palm tree
384
+ 365: Pancake
385
+ 366: Panda
386
+ 367: Paper cutter
387
+ 368: Paper towel
388
+ 369: Parachute
389
+ 370: Parking meter
390
+ 371: Parrot
391
+ 372: Pasta
392
+ 373: Pastry
393
+ 374: Peach
394
+ 375: Pear
395
+ 376: Pen
396
+ 377: Pencil case
397
+ 378: Pencil sharpener
398
+ 379: Penguin
399
+ 380: Perfume
400
+ 381: Person
401
+ 382: Personal care
402
+ 383: Personal flotation device
403
+ 384: Piano
404
+ 385: Picnic basket
405
+ 386: Picture frame
406
+ 387: Pig
407
+ 388: Pillow
408
+ 389: Pineapple
409
+ 390: Pitcher (Container)
410
+ 391: Pizza
411
+ 392: Pizza cutter
412
+ 393: Plant
413
+ 394: Plastic bag
414
+ 395: Plate
415
+ 396: Platter
416
+ 397: Plumbing fixture
417
+ 398: Polar bear
418
+ 399: Pomegranate
419
+ 400: Popcorn
420
+ 401: Porch
421
+ 402: Porcupine
422
+ 403: Poster
423
+ 404: Potato
424
+ 405: Power plugs and sockets
425
+ 406: Pressure cooker
426
+ 407: Pretzel
427
+ 408: Printer
428
+ 409: Pumpkin
429
+ 410: Punching bag
430
+ 411: Rabbit
431
+ 412: Raccoon
432
+ 413: Racket
433
+ 414: Radish
434
+ 415: Ratchet (Device)
435
+ 416: Raven
436
+ 417: Rays and skates
437
+ 418: Red panda
438
+ 419: Refrigerator
439
+ 420: Remote control
440
+ 421: Reptile
441
+ 422: Rhinoceros
442
+ 423: Rifle
443
+ 424: Ring binder
444
+ 425: Rocket
445
+ 426: Roller skates
446
+ 427: Rose
447
+ 428: Rugby ball
448
+ 429: Ruler
449
+ 430: Salad
450
+ 431: Salt and pepper shakers
451
+ 432: Sandal
452
+ 433: Sandwich
453
+ 434: Saucer
454
+ 435: Saxophone
455
+ 436: Scale
456
+ 437: Scarf
457
+ 438: Scissors
458
+ 439: Scoreboard
459
+ 440: Scorpion
460
+ 441: Screwdriver
461
+ 442: Sculpture
462
+ 443: Sea lion
463
+ 444: Sea turtle
464
+ 445: Seafood
465
+ 446: Seahorse
466
+ 447: Seat belt
467
+ 448: Segway
468
+ 449: Serving tray
469
+ 450: Sewing machine
470
+ 451: Shark
471
+ 452: Sheep
472
+ 453: Shelf
473
+ 454: Shellfish
474
+ 455: Shirt
475
+ 456: Shorts
476
+ 457: Shotgun
477
+ 458: Shower
478
+ 459: Shrimp
479
+ 460: Sink
480
+ 461: Skateboard
481
+ 462: Ski
482
+ 463: Skirt
483
+ 464: Skull
484
+ 465: Skunk
485
+ 466: Skyscraper
486
+ 467: Slow cooker
487
+ 468: Snack
488
+ 469: Snail
489
+ 470: Snake
490
+ 471: Snowboard
491
+ 472: Snowman
492
+ 473: Snowmobile
493
+ 474: Snowplow
494
+ 475: Soap dispenser
495
+ 476: Sock
496
+ 477: Sofa bed
497
+ 478: Sombrero
498
+ 479: Sparrow
499
+ 480: Spatula
500
+ 481: Spice rack
501
+ 482: Spider
502
+ 483: Spoon
503
+ 484: Sports equipment
504
+ 485: Sports uniform
505
+ 486: Squash (Plant)
506
+ 487: Squid
507
+ 488: Squirrel
508
+ 489: Stairs
509
+ 490: Stapler
510
+ 491: Starfish
511
+ 492: Stationary bicycle
512
+ 493: Stethoscope
513
+ 494: Stool
514
+ 495: Stop sign
515
+ 496: Strawberry
516
+ 497: Street light
517
+ 498: Stretcher
518
+ 499: Studio couch
519
+ 500: Submarine
520
+ 501: Submarine sandwich
521
+ 502: Suit
522
+ 503: Suitcase
523
+ 504: Sun hat
524
+ 505: Sunglasses
525
+ 506: Surfboard
526
+ 507: Sushi
527
+ 508: Swan
528
+ 509: Swim cap
529
+ 510: Swimming pool
530
+ 511: Swimwear
531
+ 512: Sword
532
+ 513: Syringe
533
+ 514: Table
534
+ 515: Table tennis racket
535
+ 516: Tablet computer
536
+ 517: Tableware
537
+ 518: Taco
538
+ 519: Tank
539
+ 520: Tap
540
+ 521: Tart
541
+ 522: Taxi
542
+ 523: Tea
543
+ 524: Teapot
544
+ 525: Teddy bear
545
+ 526: Telephone
546
+ 527: Television
547
+ 528: Tennis ball
548
+ 529: Tennis racket
549
+ 530: Tent
550
+ 531: Tiara
551
+ 532: Tick
552
+ 533: Tie
553
+ 534: Tiger
554
+ 535: Tin can
555
+ 536: Tire
556
+ 537: Toaster
557
+ 538: Toilet
558
+ 539: Toilet paper
559
+ 540: Tomato
560
+ 541: Tool
561
+ 542: Toothbrush
562
+ 543: Torch
563
+ 544: Tortoise
564
+ 545: Towel
565
+ 546: Tower
566
+ 547: Toy
567
+ 548: Traffic light
568
+ 549: Traffic sign
569
+ 550: Train
570
+ 551: Training bench
571
+ 552: Treadmill
572
+ 553: Tree
573
+ 554: Tree house
574
+ 555: Tripod
575
+ 556: Trombone
576
+ 557: Trousers
577
+ 558: Truck
578
+ 559: Trumpet
579
+ 560: Turkey
580
+ 561: Turtle
581
+ 562: Umbrella
582
+ 563: Unicycle
583
+ 564: Van
584
+ 565: Vase
585
+ 566: Vegetable
586
+ 567: Vehicle
587
+ 568: Vehicle registration plate
588
+ 569: Violin
589
+ 570: Volleyball (Ball)
590
+ 571: Waffle
591
+ 572: Waffle iron
592
+ 573: Wall clock
593
+ 574: Wardrobe
594
+ 575: Washing machine
595
+ 576: Waste container
596
+ 577: Watch
597
+ 578: Watercraft
598
+ 579: Watermelon
599
+ 580: Weapon
600
+ 581: Whale
601
+ 582: Wheel
602
+ 583: Wheelchair
603
+ 584: Whisk
604
+ 585: Whiteboard
605
+ 586: Willow
606
+ 587: Window
607
+ 588: Window blind
608
+ 589: Wine
609
+ 590: Wine glass
610
+ 591: Wine rack
611
+ 592: Winter melon
612
+ 593: Wok
613
+ 594: Woman
614
+ 595: Wood-burning stove
615
+ 596: Woodpecker
616
+ 597: Worm
617
+ 598: Wrench
618
+ 599: Zebra
619
+ 600: Zucchini
620
+
621
+ # Download script/URL (optional) ---------------------------------------------------------------------------------------
622
+ download: |
623
+ from ultralytics.utils import LOGGER, SETTINGS, Path, is_ubuntu, get_ubuntu_version
624
+ from ultralytics.utils.checks import check_requirements, check_version
625
+
626
+ check_requirements('fiftyone')
627
+ if is_ubuntu() and check_version(get_ubuntu_version(), '>=22.04'):
628
+ # Ubuntu>=22.04 patch https://github.com/voxel51/fiftyone/issues/2961#issuecomment-1666519347
629
+ check_requirements('fiftyone-db-ubuntu2204')
630
+
631
+ import fiftyone as fo
632
+ import fiftyone.zoo as foz
633
+ import warnings
634
+
635
+ name = 'open-images-v7'
636
+ fraction = 1.0 # fraction of full dataset to use
637
+ LOGGER.warning('WARNING ⚠️ Open Images V7 dataset requires at least **561 GB of free space. Starting download...')
638
+ for split in 'train', 'validation': # 1743042 train, 41620 val images
639
+ train = split == 'train'
640
+
641
+ # Load Open Images dataset
642
+ dataset = foz.load_zoo_dataset(name,
643
+ split=split,
644
+ label_types=['detections'],
645
+ dataset_dir=Path(SETTINGS['datasets_dir']) / 'fiftyone' / name,
646
+ max_samples=round((1743042 if train else 41620) * fraction))
647
+
648
+ # Define classes
649
+ if train:
650
+ classes = dataset.default_classes # all classes
651
+ # classes = dataset.distinct('ground_truth.detections.label') # only observed classes
652
+
653
+ # Export to YOLO format
654
+ with warnings.catch_warnings():
655
+ warnings.filterwarnings("ignore", category=UserWarning, module="fiftyone.utils.yolo")
656
+ dataset.export(export_dir=str(Path(SETTINGS['datasets_dir']) / name),
657
+ dataset_type=fo.types.YOLOv5Dataset,
658
+ label_field='ground_truth',
659
+ split='val' if split == 'validation' else split,
660
+ classes=classes,
661
+ overwrite=train)
ultralytics/cfg/datasets/package-seg.yaml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Package-seg dataset by Ultralytics
4
+ # Documentation: https://docs.ultralytics.com/datasets/segment/package-seg/
5
+ # Example usage: yolo train data=package-seg.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── package-seg ← downloads here (102 MB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/package-seg # dataset root dir
13
+ train: train/images # train images (relative to 'path') 1920 images
14
+ val: valid/images # val images (relative to 'path') 89 images
15
+ test: test/images # test images (relative to 'path') 188 images
16
+
17
+ # Classes
18
+ names:
19
+ 0: package
20
+
21
+ # Download script/URL (optional)
22
+ download: https://github.com/ultralytics/assets/releases/download/v0.0.0/package-seg.zip
ultralytics/cfg/datasets/signature.yaml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Signature dataset by Ultralytics
4
+ # Documentation: https://docs.ultralytics.com/datasets/detect/signature/
5
+ # Example usage: yolo train data=signature.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── signature ← downloads here (11.2 MB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/signature # dataset root dir
13
+ train: train/images # train images (relative to 'path') 143 images
14
+ val: valid/images # val images (relative to 'path') 35 images
15
+
16
+ # Classes
17
+ names:
18
+ 0: signature
19
+
20
+ # Download script/URL (optional)
21
+ download: https://github.com/ultralytics/assets/releases/download/v0.0.0/signature.zip
ultralytics/cfg/datasets/tiger-pose.yaml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Tiger Pose dataset by Ultralytics
4
+ # Documentation: https://docs.ultralytics.com/datasets/pose/tiger-pose/
5
+ # Example usage: yolo train data=tiger-pose.yaml
6
+ # parent
7
+ # ├── ultralytics
8
+ # └── datasets
9
+ # └── tiger-pose ← downloads here (75.3 MB)
10
+
11
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
12
+ path: ../datasets/tiger-pose # dataset root dir
13
+ train: train # train images (relative to 'path') 210 images
14
+ val: val # val images (relative to 'path') 53 images
15
+
16
+ # Keypoints
17
+ kpt_shape: [12, 2] # number of keypoints, number of dims (2 for x,y or 3 for x,y,visible)
18
+ flip_idx: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
19
+
20
+ # Classes
21
+ names:
22
+ 0: tiger
23
+
24
+ # Download script/URL (optional)
25
+ download: https://github.com/ultralytics/assets/releases/download/v0.0.0/tiger-pose.zip
ultralytics/cfg/datasets/xView.yaml ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # DIUx xView 2018 Challenge https://challenge.xviewdataset.org by U.S. National Geospatial-Intelligence Agency (NGA)
4
+ # -------- DOWNLOAD DATA MANUALLY and jar xf val_images.zip to 'datasets/xView' before running train command! --------
5
+ # Documentation: https://docs.ultralytics.com/datasets/detect/xview/
6
+ # Example usage: yolo train data=xView.yaml
7
+ # parent
8
+ # ├── ultralytics
9
+ # └── datasets
10
+ # └── xView ← downloads here (20.7 GB)
11
+
12
+ # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
13
+ path: ../datasets/xView # dataset root dir
14
+ train: images/autosplit_train.txt # train images (relative to 'path') 90% of 847 train images
15
+ val: images/autosplit_val.txt # train images (relative to 'path') 10% of 847 train images
16
+
17
+ # Classes
18
+ names:
19
+ 0: Fixed-wing Aircraft
20
+ 1: Small Aircraft
21
+ 2: Cargo Plane
22
+ 3: Helicopter
23
+ 4: Passenger Vehicle
24
+ 5: Small Car
25
+ 6: Bus
26
+ 7: Pickup Truck
27
+ 8: Utility Truck
28
+ 9: Truck
29
+ 10: Cargo Truck
30
+ 11: Truck w/Box
31
+ 12: Truck Tractor
32
+ 13: Trailer
33
+ 14: Truck w/Flatbed
34
+ 15: Truck w/Liquid
35
+ 16: Crane Truck
36
+ 17: Railway Vehicle
37
+ 18: Passenger Car
38
+ 19: Cargo Car
39
+ 20: Flat Car
40
+ 21: Tank car
41
+ 22: Locomotive
42
+ 23: Maritime Vessel
43
+ 24: Motorboat
44
+ 25: Sailboat
45
+ 26: Tugboat
46
+ 27: Barge
47
+ 28: Fishing Vessel
48
+ 29: Ferry
49
+ 30: Yacht
50
+ 31: Container Ship
51
+ 32: Oil Tanker
52
+ 33: Engineering Vehicle
53
+ 34: Tower crane
54
+ 35: Container Crane
55
+ 36: Reach Stacker
56
+ 37: Straddle Carrier
57
+ 38: Mobile Crane
58
+ 39: Dump Truck
59
+ 40: Haul Truck
60
+ 41: Scraper/Tractor
61
+ 42: Front loader/Bulldozer
62
+ 43: Excavator
63
+ 44: Cement Mixer
64
+ 45: Ground Grader
65
+ 46: Hut/Tent
66
+ 47: Shed
67
+ 48: Building
68
+ 49: Aircraft Hangar
69
+ 50: Damaged Building
70
+ 51: Facility
71
+ 52: Construction Site
72
+ 53: Vehicle Lot
73
+ 54: Helipad
74
+ 55: Storage Tank
75
+ 56: Shipping container lot
76
+ 57: Shipping Container
77
+ 58: Pylon
78
+ 59: Tower
79
+
80
+ # Download script/URL (optional) ---------------------------------------------------------------------------------------
81
+ download: |
82
+ import json
83
+ import os
84
+ from pathlib import Path
85
+
86
+ import numpy as np
87
+ from PIL import Image
88
+ from tqdm import tqdm
89
+
90
+ from ultralytics.data.utils import autosplit
91
+ from ultralytics.utils.ops import xyxy2xywhn
92
+
93
+
94
+ def convert_labels(fname=Path('xView/xView_train.geojson')):
95
+ # Convert xView geoJSON labels to YOLO format
96
+ path = fname.parent
97
+ with open(fname) as f:
98
+ print(f'Loading {fname}...')
99
+ data = json.load(f)
100
+
101
+ # Make dirs
102
+ labels = Path(path / 'labels' / 'train')
103
+ os.system(f'rm -rf {labels}')
104
+ labels.mkdir(parents=True, exist_ok=True)
105
+
106
+ # xView classes 11-94 to 0-59
107
+ xview_class2index = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, -1, 3, -1, 4, 5, 6, 7, 8, -1, 9, 10, 11,
108
+ 12, 13, 14, 15, -1, -1, 16, 17, 18, 19, 20, 21, 22, -1, 23, 24, 25, -1, 26, 27, -1, 28, -1,
109
+ 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, 38, 39, 40, 41, 42, 43, 44, 45, -1, -1, -1, -1, 46,
110
+ 47, 48, 49, -1, 50, 51, -1, 52, -1, -1, -1, 53, 54, -1, 55, -1, -1, 56, -1, 57, -1, 58, 59]
111
+
112
+ shapes = {}
113
+ for feature in tqdm(data['features'], desc=f'Converting {fname}'):
114
+ p = feature['properties']
115
+ if p['bounds_imcoords']:
116
+ id = p['image_id']
117
+ file = path / 'train_images' / id
118
+ if file.exists(): # 1395.tif missing
119
+ try:
120
+ box = np.array([int(num) for num in p['bounds_imcoords'].split(",")])
121
+ assert box.shape[0] == 4, f'incorrect box shape {box.shape[0]}'
122
+ cls = p['type_id']
123
+ cls = xview_class2index[int(cls)] # xView class to 0-60
124
+ assert 59 >= cls >= 0, f'incorrect class index {cls}'
125
+
126
+ # Write YOLO label
127
+ if id not in shapes:
128
+ shapes[id] = Image.open(file).size
129
+ box = xyxy2xywhn(box[None].astype(np.float), w=shapes[id][0], h=shapes[id][1], clip=True)
130
+ with open((labels / id).with_suffix('.txt'), 'a') as f:
131
+ f.write(f"{cls} {' '.join(f'{x:.6f}' for x in box[0])}\n") # write label.txt
132
+ except Exception as e:
133
+ print(f'WARNING: skipping one label for {file}: {e}')
134
+
135
+
136
+ # Download manually from https://challenge.xviewdataset.org
137
+ dir = Path(yaml['path']) # dataset root dir
138
+ # urls = ['https://d307kc0mrhucc3.cloudfront.net/train_labels.zip', # train labels
139
+ # 'https://d307kc0mrhucc3.cloudfront.net/train_images.zip', # 15G, 847 train images
140
+ # 'https://d307kc0mrhucc3.cloudfront.net/val_images.zip'] # 5G, 282 val images (no labels)
141
+ # download(urls, dir=dir)
142
+
143
+ # Convert labels
144
+ convert_labels(dir / 'xView_train.geojson')
145
+
146
+ # Move images
147
+ images = Path(dir / 'images')
148
+ images.mkdir(parents=True, exist_ok=True)
149
+ Path(dir / 'train_images').rename(dir / 'images' / 'train')
150
+ Path(dir / 'val_images').rename(dir / 'images' / 'val')
151
+
152
+ # Split
153
+ autosplit(dir / 'images' / 'train')
ultralytics/cfg/default.yaml ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Global configuration YAML with settings and hyperparameters for YOLO training, validation, prediction and export
4
+ # For documentation see https://docs.ultralytics.com/usage/cfg/
5
+
6
+ task: detect # (str) YOLO task, i.e. detect, segment, classify, pose, obb
7
+ mode: train # (str) YOLO mode, i.e. train, val, predict, export, track, benchmark
8
+
9
+ # Train settings -------------------------------------------------------------------------------------------------------
10
+ model: # (str, optional) path to model file, i.e. yolov8n.pt, yolov8n.yaml
11
+ data: # (str, optional) path to data file, i.e. coco8.yaml
12
+ epochs: 100 # (int) number of epochs to train for
13
+ time: # (float, optional) number of hours to train for, overrides epochs if supplied
14
+ patience: 100 # (int) epochs to wait for no observable improvement for early stopping of training
15
+ batch: 16 # (int) number of images per batch (-1 for AutoBatch)
16
+ imgsz: 640 # (int | list) input images size as int for train and val modes, or list[h,w] for predict and export modes
17
+ save: True # (bool) save train checkpoints and predict results
18
+ save_period: -1 # (int) Save checkpoint every x epochs (disabled if < 1)
19
+ cache: False # (bool) True/ram, disk or False. Use cache for data loading
20
+ device: # (int | str | list, optional) device to run on, i.e. cuda device=0 or device=0,1,2,3 or device=cpu
21
+ workers: 8 # (int) number of worker threads for data loading (per RANK if DDP)
22
+ project: # (str, optional) project name
23
+ name: # (str, optional) experiment name, results saved to 'project/name' directory
24
+ exist_ok: False # (bool) whether to overwrite existing experiment
25
+ pretrained: True # (bool | str) whether to use a pretrained model (bool) or a model to load weights from (str)
26
+ optimizer: auto # (str) optimizer to use, choices=[SGD, Adam, Adamax, AdamW, NAdam, RAdam, RMSProp, auto]
27
+ verbose: True # (bool) whether to print verbose output
28
+ seed: 0 # (int) random seed for reproducibility
29
+ deterministic: True # (bool) whether to enable deterministic mode
30
+ single_cls: False # (bool) train multi-class data as single-class
31
+ rect: False # (bool) rectangular training if mode='train' or rectangular validation if mode='val'
32
+ cos_lr: False # (bool) use cosine learning rate scheduler
33
+ close_mosaic: 10 # (int) disable mosaic augmentation for final epochs (0 to disable)
34
+ resume: False # (bool) resume training from last checkpoint
35
+ amp: True # (bool) Automatic Mixed Precision (AMP) training, choices=[True, False], True runs AMP check
36
+ fraction: 1.0 # (float) dataset fraction to train on (default is 1.0, all images in train set)
37
+ profile: False # (bool) profile ONNX and TensorRT speeds during training for loggers
38
+ freeze: None # (int | list, optional) freeze first n layers, or freeze list of layer indices during training
39
+ multi_scale: False # (bool) Whether to use multiscale during training
40
+ # Segmentation
41
+ overlap_mask: True # (bool) merge object masks into a single image mask during training (segment train only)
42
+ mask_ratio: 4 # (int) mask downsample ratio (segment train only)
43
+ # Classification
44
+ dropout: 0.0 # (float) use dropout regularization (classify train only)
45
+
46
+ # Val/Test settings ----------------------------------------------------------------------------------------------------
47
+ val: True # (bool) validate/test during training
48
+ split: val # (str) dataset split to use for validation, i.e. 'val', 'test' or 'train'
49
+ save_json: False # (bool) save results to JSON file
50
+ save_hybrid: False # (bool) save hybrid version of labels (labels + additional predictions)
51
+ conf: # (float, optional) object confidence threshold for detection (default 0.25 predict, 0.001 val)
52
+ iou: 0.7 # (float) intersection over union (IoU) threshold for NMS
53
+ max_det: 300 # (int) maximum number of detections per image
54
+ half: False # (bool) use half precision (FP16)
55
+ dnn: False # (bool) use OpenCV DNN for ONNX inference
56
+ plots: True # (bool) save plots and images during train/val
57
+
58
+ # Predict settings -----------------------------------------------------------------------------------------------------
59
+ source: # (str, optional) source directory for images or videos
60
+ vid_stride: 1 # (int) video frame-rate stride
61
+ stream_buffer: False # (bool) buffer all streaming frames (True) or return the most recent frame (False)
62
+ visualize: False # (bool) visualize model features
63
+ augment: False # (bool) apply image augmentation to prediction sources
64
+ agnostic_nms: False # (bool) class-agnostic NMS
65
+ classes: # (int | list[int], optional) filter results by class, i.e. classes=0, or classes=[0,2,3]
66
+ retina_masks: False # (bool) use high-resolution segmentation masks
67
+ embed: # (list[int], optional) return feature vectors/embeddings from given layers
68
+
69
+ # Visualize settings ---------------------------------------------------------------------------------------------------
70
+ show: False # (bool) show predicted images and videos if environment allows
71
+ save_frames: False # (bool) save predicted individual video frames
72
+ save_txt: False # (bool) save results as .txt file
73
+ save_conf: False # (bool) save results with confidence scores
74
+ save_crop: False # (bool) save cropped images with results
75
+ show_labels: True # (bool) show prediction labels, i.e. 'person'
76
+ show_conf: True # (bool) show prediction confidence, i.e. '0.99'
77
+ show_boxes: True # (bool) show prediction boxes
78
+ line_width: # (int, optional) line width of the bounding boxes. Scaled to image size if None.
79
+
80
+ # Export settings ------------------------------------------------------------------------------------------------------
81
+ format: torchscript # (str) format to export to, choices at https://docs.ultralytics.com/modes/export/#export-formats
82
+ keras: False # (bool) use Kera=s
83
+ optimize: False # (bool) TorchScript: optimize for mobile
84
+ int8: False # (bool) CoreML/TF INT8 quantization
85
+ dynamic: False # (bool) ONNX/TF/TensorRT: dynamic axes
86
+ simplify: True # (bool) ONNX: simplify model using `onnxslim`
87
+ opset: # (int, optional) ONNX: opset version
88
+ workspace: None # (float, optional) TensorRT: workspace size (GiB), `None` will let TensorRT auto-allocate memory
89
+ nms: False # (bool) CoreML: add NMS
90
+
91
+ # Hyperparameters ------------------------------------------------------------------------------------------------------
92
+ lr0: 0.01 # (float) initial learning rate (i.e. SGD=1E-2, Adam=1E-3)
93
+ lrf: 0.01 # (float) final learning rate (lr0 * lrf)
94
+ momentum: 0.937 # (float) SGD momentum/Adam beta1
95
+ weight_decay: 0.0005 # (float) optimizer weight decay 5e-4
96
+ warmup_epochs: 3.0 # (float) warmup epochs (fractions ok)
97
+ warmup_momentum: 0.8 # (float) warmup initial momentum
98
+ warmup_bias_lr: 0.0 # 0.1 # (float) warmup initial bias lr
99
+ box: 7.5 # (float) box loss gain
100
+ cls: 0.5 # (float) cls loss gain (scale with pixels)
101
+ dfl: 1.5 # (float) dfl loss gain
102
+ pose: 12.0 # (float) pose loss gain
103
+ kobj: 1.0 # (float) keypoint obj loss gain
104
+ nbs: 64 # (int) nominal batch size
105
+ hsv_h: 0.015 # (float) image HSV-Hue augmentation (fraction)
106
+ hsv_s: 0.7 # (float) image HSV-Saturation augmentation (fraction)
107
+ hsv_v: 0.4 # (float) image HSV-Value augmentation (fraction)
108
+ degrees: 0.0 # (float) image rotation (+/- deg)
109
+ translate: 0.1 # (float) image translation (+/- fraction)
110
+ scale: 0.5 # (float) image scale (+/- gain)
111
+ shear: 0.0 # (float) image shear (+/- deg)
112
+ perspective: 0.0 # (float) image perspective (+/- fraction), range 0-0.001
113
+ flipud: 0.0 # (float) image flip up-down (probability)
114
+ fliplr: 0.5 # (float) image flip left-right (probability)
115
+ bgr: 0.0 # (float) image channel BGR (probability)
116
+
117
+ mosaic: 1.0 # (float) image mosaic (probability)
118
+ mixup: 0.0 # (float) image mixup (probability)
119
+ copy_paste: 0.1 # (float) segment copy-paste (probability)
120
+
121
+ copy_paste_mode: "flip" # (str) the method to do copy_paste augmentation (flip, mixup)
122
+ auto_augment: randaugment # (str) auto augmentation policy for classification (randaugment, autoaugment, augmix)
123
+ erasing: 0.4 # (float) probability of random erasing during classification training (0-0.9), 0 means no erasing, must be less than 1.0.
124
+ crop_fraction: 1.0 # (float) image crop fraction for classification (0.1-1), 1.0 means no crop, must be greater than 0.
125
+
126
+ # Custom config.yaml ---------------------------------------------------------------------------------------------------
127
+ cfg: # (str, optional) for overriding defaults.yaml
128
+
129
+ # Tracker settings ------------------------------------------------------------------------------------------------------
130
+ tracker: botsort.yaml # (str) tracker type, choices=[botsort.yaml, bytetrack.yaml]
ultralytics/cfg/models/11/yolo11-cls-resnet18.yaml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Ultralytics YOLO11-cls image classification model with ResNet18 backbone
4
+ # Model docs: https://docs.ultralytics.com/models/yolo11
5
+ # Task docs: https://docs.ultralytics.com/tasks/classify
6
+
7
+ # Parameters
8
+ nc: 10 # number of classes
9
+ scales: # model compound scaling constants, i.e. 'model=yolo11n-cls.yaml' will call yolo11-cls.yaml with scale 'n'
10
+ # [depth, width, max_channels]
11
+ n: [0.33, 0.25, 1024]
12
+ s: [0.33, 0.50, 1024]
13
+ m: [0.67, 0.75, 1024]
14
+ l: [1.00, 1.00, 1024]
15
+ x: [1.00, 1.25, 1024]
16
+
17
+ # ResNet18 backbone
18
+ backbone:
19
+ # [from, repeats, module, args]
20
+ - [-1, 1, TorchVision, [512, "resnet18", "DEFAULT", True, 2]] # truncate two layers from the end
21
+
22
+ # YOLO11n head
23
+ head:
24
+ - [-1, 1, Classify, [nc]] # Classify
ultralytics/cfg/models/11/yolo11-cls.yaml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Ultralytics YOLO11-cls image classification model
4
+ # Model docs: https://docs.ultralytics.com/models/yolo11
5
+ # Task docs: https://docs.ultralytics.com/tasks/classify
6
+
7
+ # Parameters
8
+ nc: 80 # number of classes
9
+ scales: # model compound scaling constants, i.e. 'model=yolo11n-cls.yaml' will call yolo11-cls.yaml with scale 'n'
10
+ # [depth, width, max_channels]
11
+ n: [0.50, 0.25, 1024] # summary: 151 layers, 1633584 parameters, 1633584 gradients, 3.3 GFLOPs
12
+ s: [0.50, 0.50, 1024] # summary: 151 layers, 5545488 parameters, 5545488 gradients, 12.2 GFLOPs
13
+ m: [0.50, 1.00, 512] # summary: 187 layers, 10455696 parameters, 10455696 gradients, 39.7 GFLOPs
14
+ l: [1.00, 1.00, 512] # summary: 309 layers, 12937104 parameters, 12937104 gradients, 49.9 GFLOPs
15
+ x: [1.00, 1.50, 512] # summary: 309 layers, 28458544 parameters, 28458544 gradients, 111.1 GFLOPs
16
+
17
+ # YOLO11n backbone
18
+ backbone:
19
+ # [from, repeats, module, args]
20
+ - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2
21
+ - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4
22
+ - [-1, 2, C3k2, [256, False, 0.25]]
23
+ - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8
24
+ - [-1, 2, C3k2, [512, False, 0.25]]
25
+ - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16
26
+ - [-1, 2, C3k2, [512, True]]
27
+ - [-1, 1, Conv, [1024, 3, 2]] # 7-P5/32
28
+ - [-1, 2, C3k2, [1024, True]]
29
+ - [-1, 2, C2PSA, [1024]] # 9
30
+
31
+ # YOLO11n head
32
+ head:
33
+ - [-1, 1, Classify, [nc]] # Classify
ultralytics/cfg/models/11/yolo11-obb.yaml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # Ultralytics YOLO11-obb Oriented Bounding Boxes (OBB) model with P3/8 - P5/32 outputs
4
+ # Model docs: https://docs.ultralytics.com/models/yolo11
5
+ # Task docs: https://docs.ultralytics.com/tasks/obb
6
+
7
+ # Parameters
8
+ nc: 80 # number of classes
9
+ scales: # model compound scaling constants, i.e. 'model=yolo11n-obb.yaml' will call yolo11-obb.yaml with scale 'n'
10
+ # [depth, width, max_channels]
11
+ n: [0.50, 0.25, 1024] # summary: 344 layers, 2695747 parameters, 2695731 gradients, 6.9 GFLOPs
12
+ s: [0.50, 0.50, 1024] # summary: 344 layers, 9744931 parameters, 9744915 gradients, 22.7 GFLOPs
13
+ m: [0.50, 1.00, 512] # summary: 434 layers, 20963523 parameters, 20963507 gradients, 72.2 GFLOPs
14
+ l: [1.00, 1.00, 512] # summary: 656 layers, 26220995 parameters, 26220979 gradients, 91.3 GFLOPs
15
+ x: [1.00, 1.50, 512] # summary: 656 layers, 58875331 parameters, 58875315 gradients, 204.3 GFLOPs
16
+
17
+ # YOLO11n backbone
18
+ backbone:
19
+ # [from, repeats, module, args]
20
+ - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2
21
+ - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4
22
+ - [-1, 2, C3k2, [256, False, 0.25]]
23
+ - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8
24
+ - [-1, 2, C3k2, [512, False, 0.25]]
25
+ - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16
26
+ - [-1, 2, C3k2, [512, True]]
27
+ - [-1, 1, Conv, [1024, 3, 2]] # 7-P5/32
28
+ - [-1, 2, C3k2, [1024, True]]
29
+ - [-1, 1, SPPF, [1024, 5]] # 9
30
+ - [-1, 2, C2PSA, [1024]] # 10
31
+
32
+ # YOLO11n head
33
+ head:
34
+ - [-1, 1, nn.Upsample, [None, 2, "nearest"]]
35
+ - [[-1, 6], 1, Concat, [1]] # cat backbone P4
36
+ - [-1, 2, C3k2, [512, False]] # 13
37
+
38
+ - [-1, 1, nn.Upsample, [None, 2, "nearest"]]
39
+ - [[-1, 4], 1, Concat, [1]] # cat backbone P3
40
+ - [-1, 2, C3k2, [256, False]] # 16 (P3/8-small)
41
+
42
+ - [-1, 1, Conv, [256, 3, 2]]
43
+ - [[-1, 13], 1, Concat, [1]] # cat head P4
44
+ - [-1, 2, C3k2, [512, False]] # 19 (P4/16-medium)
45
+
46
+ - [-1, 1, Conv, [512, 3, 2]]
47
+ - [[-1, 10], 1, Concat, [1]] # cat head P5
48
+ - [-1, 2, C3k2, [1024, True]] # 22 (P5/32-large)
49
+
50
+ - [[16, 19, 22], 1, OBB, [nc, 1]] # Detect(P3, P4, P5)