diff --git a/datasets/coco128/LICENSE b/datasets/coco128/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..9e419e042146a2ce2e354202d4f7d8e4a3d66f31 --- /dev/null +++ b/datasets/coco128/LICENSE @@ -0,0 +1,674 @@ +GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. \ No newline at end of file diff --git a/datasets/coco128/README.txt b/datasets/coco128/README.txt new file mode 100644 index 0000000000000000000000000000000000000000..7ab912d6e884a5b602a48bcbead6c56046079c84 --- /dev/null +++ b/datasets/coco128/README.txt @@ -0,0 +1,22 @@ +# Introduction + +This directory contains software developed by Ultralytics LLC, and **is freely available for redistribution under the GPL-3.0 license**. For more information please visit https://www.ultralytics.com. + +# Description + +The https://github.com/ultralytics/COCO2YOLO repo contains code to convert JSON datasets into YOLO (darknet) format. The code works on Linux, MacOS and Windows. + +# Requirements + +Python 3.7 or later with the following `pip3 install -U -r requirements.txt` packages: + +- `numpy` +- `tqdm` + +# Citation + +[![DOI](https://zenodo.org/badge/186122711.svg)](https://zenodo.org/badge/latestdoi/186122711) + +# Contact + +Issues should be raised directly in the repository. For additional questions or comments please email Glenn Jocher at glenn.jocher@ultralytics.com or visit us at https://contact.ultralytics.com. \ No newline at end of file diff --git a/datasets/coco128/labels/train2017.cache b/datasets/coco128/labels/train2017.cache new file mode 100644 index 0000000000000000000000000000000000000000..923974f3641f592c561737db02510b009d9b768c Binary files /dev/null and b/datasets/coco128/labels/train2017.cache differ diff --git a/datasets/coco128/labels/train2017/000000000009.txt b/datasets/coco128/labels/train2017/000000000009.txt new file mode 100644 index 0000000000000000000000000000000000000000..246934f54252ece28774476ae22d4356877979b9 --- /dev/null +++ b/datasets/coco128/labels/train2017/000000000009.txt @@ -0,0 +1,8 @@ +45 0.479492 0.688771 0.955609 0.5955 +45 0.736516 0.247188 0.498875 0.476417 +50 0.637063 0.732938 0.494125 0.510583 +45 0.339438 0.418896 0.678875 0.7815 +49 0.646836 0.132552 0.118047 0.0969375 +49 0.773148 0.129802 0.0907344 0.0972292 +49 0.668297 0.226906 0.131281 0.146896 +49 0.642859 0.0792187 0.148063 0.148062 diff --git a/datasets/coco128/labels/train2017/000000000144.txt b/datasets/coco128/labels/train2017/000000000144.txt new file mode 100644 index 0000000000000000000000000000000000000000..09bcb22cee284c525b5d18c0a5f10a9373686170 --- /dev/null +++ b/datasets/coco128/labels/train2017/000000000144.txt @@ -0,0 +1,3 @@ +23 0.650563 0.626781 0.573031 0.746438 +23 0.536969 0.637385 0.469781 0.725229 +23 0.38343 0.583146 0.615172 0.833708 diff --git a/datasets/coco128/labels/train2017/000000000149.txt b/datasets/coco128/labels/train2017/000000000149.txt new file mode 100644 index 0000000000000000000000000000000000000000..665bd25b390d7c4520849d5672510a644721b6a1 --- /dev/null +++ b/datasets/coco128/labels/train2017/000000000149.txt @@ -0,0 +1,22 @@ +0 0.613805 0.7741 0.0150156 0.0311449 +0 0.535719 0.755491 0.01075 0.0305607 +0 0.525578 0.753984 0.00984375 0.0325935 +0 0.639203 0.776121 0.0229687 0.0302804 +33 0.692844 0.46715 0.0286875 0.0350467 +33 0.446031 0.596834 0.0151562 0.0148832 +33 0.689094 0.207897 0.0162188 0.0292056 +33 0.475727 0.499147 0.0350781 0.0250234 +0 0.879875 0.763516 0.0110937 0.0432477 +0 0.845305 0.755491 0.00795313 0.0343925 +2 0.442828 0.734521 0.0151562 0.0124533 +2 0.494555 0.745853 0.0163906 0.0110514 +2 0.467687 0.744346 0.0134375 0.0096729 +2 0.415742 0.759311 0.0303906 0.0168458 +33 0.130477 0.81125 0.0651094 0.031285 +33 0.630531 0.660187 0.0588437 0.0371963 +0 0.434891 0.778084 0.0125312 0.0299533 +0 0.85457 0.76118 0.00695313 0.0380607 +0 0.919844 0.762196 0.0070625 0.0230841 +0 0.394578 0.765829 0.0083125 0.0538084 +0 0.37107 0.765047 0.0122344 0.056729 +0 0.349812 0.764147 0.0119375 0.0635748 diff --git a/datasets/coco128/labels/train2017/000000000164.txt b/datasets/coco128/labels/train2017/000000000164.txt new file mode 100644 index 0000000000000000000000000000000000000000..4291335d17529d30d16d7355e01036081454241a --- /dev/null +++ b/datasets/coco128/labels/train2017/000000000164.txt @@ -0,0 +1,40 @@ +39 0.615391 0.411156 0.0125312 0.0559792 +39 0.590367 0.416885 0.0107344 0.0436042 +39 0.58018 0.413521 0.0110156 0.057375 +39 0.60432 0.416 0.0112656 0.0505 +39 0.692109 0.61676 0.028625 0.0653542 +72 0.745406 0.500187 0.151125 0.287583 +39 0.731344 0.62699 0.0155 0.0761458 +39 0.632141 0.354646 0.0146875 0.035625 +39 0.591961 0.298708 0.0163906 0.0315833 +39 0.639766 0.292698 0.0152812 0.0328125 +39 0.65693 0.290938 0.0166406 0.035125 +56 0.36675 0.926208 0.2365 0.147583 +40 0.250586 0.425167 0.0200469 0.058875 +40 0.232906 0.435479 0.0251563 0.076125 +40 0.180586 0.443792 0.0223594 0.0695833 +40 0.106906 0.447781 0.0307187 0.0783958 +40 0.139813 0.448458 0.024125 0.0825 +40 0.15907 0.447073 0.0184844 0.0769375 +41 0.25 0.508854 0.0418437 0.0433333 +41 0.197148 0.513687 0.0362969 0.0406667 +41 0.291938 0.50151 0.0314688 0.0336042 +41 0.322883 0.49299 0.0312344 0.0323125 +45 0.834883 0.472427 0.0877344 0.0219375 +68 0.631812 0.505479 0.08325 0.06325 +69 0.465656 0.584354 0.0731563 0.0712917 +40 0.127484 0.447563 0.0169375 0.0826667 +40 0.198609 0.437896 0.0247812 0.079 +40 0.21668 0.438781 0.0167969 0.0736875 +41 0.266141 0.504708 0.0339375 0.04425 +41 0.813328 0.301812 0.0240625 0.0445417 +41 0.844102 0.305635 0.0237344 0.0285625 +41 0.795687 0.314125 0.00978125 0.0170833 +41 0.279133 0.44301 0.0277344 0.0392708 +41 0.220984 0.507156 0.0239375 0.0421042 +45 0.813344 0.445646 0.0455938 0.00975 +45 0.833727 0.461135 0.0888906 0.00877083 +45 0.836367 0.454271 0.0812969 0.0109167 +45 0.835375 0.449427 0.0869062 0.0126458 +45 0.577438 0.366531 0.020875 0.0188542 +60 0.689609 0.972083 0.214281 0.0311667 diff --git a/datasets/coco128/labels/train2017/000000000263.txt b/datasets/coco128/labels/train2017/000000000263.txt new file mode 100644 index 0000000000000000000000000000000000000000..2e497797ea3e242cbd46a1f944ecf1e1603279d8 --- /dev/null +++ b/datasets/coco128/labels/train2017/000000000263.txt @@ -0,0 +1,2 @@ +20 0.632327 0.626688 0.735347 0.724219 +20 0.330499 0.483117 0.655381 0.924672 diff --git a/datasets/coco128/labels/train2017/000000000338.txt b/datasets/coco128/labels/train2017/000000000338.txt new file mode 100644 index 0000000000000000000000000000000000000000..29acdbc08425eaf546cfcdc1d337a4a63a9c3ab8 --- /dev/null +++ b/datasets/coco128/labels/train2017/000000000338.txt @@ -0,0 +1,6 @@ +72 0.414813 0.72896 0.149656 0.54208 +74 0.734047 0.308853 0.0363125 0.0752599 +0 0.581609 0.715352 0.141344 0.561774 +0 0.730945 0.765627 0.0889219 0.468746 +69 0.146391 0.866284 0.217 0.240459 +26 0.746844 0.768563 0.0400937 0.120306 diff --git a/datasets/coco128/labels/train2017/000000000349.txt b/datasets/coco128/labels/train2017/000000000349.txt new file mode 100644 index 0000000000000000000000000000000000000000..51598f555470e155c0ed85197993e936f1592816 --- /dev/null +++ b/datasets/coco128/labels/train2017/000000000349.txt @@ -0,0 +1,4 @@ +6 0.421352 0.540448 0.842703 0.537062 +58 0.6685 0.665531 0.09825 0.163271 +58 0.750336 0.629198 0.0790469 0.130479 +58 0.80107 0.635146 0.0448594 0.0831667 diff --git a/datasets/coco128/labels/train2017/000000000357.txt b/datasets/coco128/labels/train2017/000000000357.txt new file mode 100644 index 0000000000000000000000000000000000000000..9d51b957ce59d0730de21add5f9be367adf75c3b --- /dev/null +++ b/datasets/coco128/labels/train2017/000000000357.txt @@ -0,0 +1,17 @@ +34 0.845453 0.619358 0.00625 0.124954 +35 0.892836 0.870573 0.0139219 0.0306881 +35 0.125352 0.466812 0.0108906 0.0422477 +35 0.440953 0.125642 0.00853125 0.0216514 +0 0.595023 0.178188 0.0269531 0.126743 +0 0.444703 0.169633 0.0422187 0.170459 +0 0.344438 0.174839 0.0346875 0.142248 +0 0.13107 0.473211 0.0289531 0.22055 +0 0.852109 0.750023 0.045375 0.250413 +0 0.907797 0.821261 0.0418125 0.17445 +0 0.946813 0.81656 0.0424687 0.213761 +0 0.879648 0.132087 0.0217031 0.0443578 +0 0.859398 0.156514 0.0150781 0.12 +0 0.939578 0.0609404 0.014 0.0465596 +0 0.428398 0.0922018 0.0276406 0.125413 +0 0.897008 0.188716 0.0185469 0.108899 +0 0.913047 0.202523 0.0105 0.109725 diff --git a/datasets/coco128/labels/train2017/000000000359.txt b/datasets/coco128/labels/train2017/000000000359.txt new file mode 100644 index 0000000000000000000000000000000000000000..7314e73c345e63203f00b705ce93facf0b733d1f --- /dev/null +++ b/datasets/coco128/labels/train2017/000000000359.txt @@ -0,0 +1,4 @@ +9 0.37311 0.354111 0.13074 0.103163 +9 0.53852 0.334759 0.102 0.0674699 +9 0.56142 0.890166 0.00892 0.0123795 +2 0.12372 0.930422 0.24744 0.113193 diff --git a/datasets/coco128/labels/train2017/000000000387.txt b/datasets/coco128/labels/train2017/000000000387.txt new file mode 100644 index 0000000000000000000000000000000000000000..abfe51fadb0878ff27967476198759940385a878 --- /dev/null +++ b/datasets/coco128/labels/train2017/000000000387.txt @@ -0,0 +1,3 @@ +63 0.682586 0.394385 0.586516 0.577521 +63 0.605953 0.430167 0.735719 0.650792 +67 0.683594 0.33074 0.328125 0.195312 diff --git a/datasets/coco128/labels/train2017/000000000394.txt b/datasets/coco128/labels/train2017/000000000394.txt new file mode 100644 index 0000000000000000000000000000000000000000..50299b199625e88681658dba8be794b36289502d --- /dev/null +++ b/datasets/coco128/labels/train2017/000000000394.txt @@ -0,0 +1,2 @@ +16 0.488914 0.494869 0.977828 0.936809 +29 0.645445 0.542463 0.555422 0.477889 diff --git a/datasets/coco128/labels/train2017/000000000395.txt b/datasets/coco128/labels/train2017/000000000395.txt new file mode 100644 index 0000000000000000000000000000000000000000..c4a8d4b1e348ccf29d2618a5d095cced4e7f9474 --- /dev/null +++ b/datasets/coco128/labels/train2017/000000000395.txt @@ -0,0 +1,13 @@ +67 0.470422 0.518578 0.031 0.0396034 +0 0.523391 0.613483 0.676125 0.750552 +0 0.0631328 0.597897 0.126266 0.480897 +0 0.184836 0.643534 0.128984 0.352862 +0 0.902508 0.672655 0.194984 0.65469 +67 0.979633 0.537129 0.0247344 0.0199828 +0 0.200016 0.441362 0.0607188 0.0808621 +0 0.284094 0.507862 0.128312 0.188759 +0 0.670172 0.427164 0.0514687 0.182707 +0 0.7045 0.453991 0.0685937 0.195086 +0 0.296867 0.630474 0.0943594 0.115466 +0 0.123273 0.479983 0.0756094 0.218862 +0 0.755555 0.513638 0.110609 0.154586 diff --git a/datasets/coco128/labels/train2017/000000000404.txt b/datasets/coco128/labels/train2017/000000000404.txt new file mode 100644 index 0000000000000000000000000000000000000000..5eafc69faf4ed983132e0f8cd0c12ae97d329e72 --- /dev/null +++ b/datasets/coco128/labels/train2017/000000000404.txt @@ -0,0 +1,5 @@ +8 0.496162 0.629578 0.737535 0.135094 +8 0.684789 0.598344 0.467512 0.0718125 +8 0.776596 0.576383 0.368732 0.0462656 +8 0.718721 0.571922 0.201338 0.0254375 +8 0.669155 0.564172 0.0579812 0.0172187 diff --git a/datasets/coco128/labels/train2017/000000000443.txt b/datasets/coco128/labels/train2017/000000000443.txt new file mode 100644 index 0000000000000000000000000000000000000000..92109a543feda982667f99ef7f2e6f621e30bad1 --- /dev/null +++ b/datasets/coco128/labels/train2017/000000000443.txt @@ -0,0 +1,6 @@ +15 0.601289 0.507552 0.581891 0.793104 +0 0.589883 0.494385 0.812359 0.984271 +0 0.881742 0.320229 0.236516 0.631458 +65 0.891086 0.564917 0.217828 0.317875 +57 0.446102 0.493792 0.888828 0.979667 +0 0.115742 0.642802 0.224078 0.649396 diff --git a/datasets/coco128/labels/train2017/000000000486.txt b/datasets/coco128/labels/train2017/000000000486.txt new file mode 100644 index 0000000000000000000000000000000000000000..e319ccf1d15353bac6902b49919cff10496251a5 --- /dev/null +++ b/datasets/coco128/labels/train2017/000000000486.txt @@ -0,0 +1,8 @@ +72 0.661219 0.540585 0.0985 0.257283 +69 0.806289 0.82192 0.387422 0.356159 +39 0.987359 0.590995 0.0250312 0.0893911 +43 0.354859 0.511148 0.0108125 0.121686 +39 0.797414 0.681768 0.0360156 0.059274 +39 0.133781 0.54733 0.008 0.068103 +43 0.370891 0.489778 0.00609375 0.0387119 +45 0.49707 0.805504 0.205297 0.206604 diff --git a/datasets/coco128/labels/train2017/000000000491.txt b/datasets/coco128/labels/train2017/000000000491.txt new file mode 100644 index 0000000000000000000000000000000000000000..a27cc15198f75989e3708d288eab1db694aca87a --- /dev/null +++ b/datasets/coco128/labels/train2017/000000000491.txt @@ -0,0 +1,4 @@ +77 0.53007 0.511406 0.52238 0.950799 +77 0.77515 0.250783 0.39914 0.496645 +77 0.09187 0.305192 0.18374 0.579201 +77 0.3722 0.194617 0.42652 0.383419 diff --git a/datasets/coco128/labels/train2017/000000000531.txt b/datasets/coco128/labels/train2017/000000000531.txt new file mode 100644 index 0000000000000000000000000000000000000000..d6d4463113adf02bc1995bc1b9ac57c3c931c3ba --- /dev/null +++ b/datasets/coco128/labels/train2017/000000000531.txt @@ -0,0 +1,15 @@ +1 0.0961484 0.577531 0.0396094 0.0350625 +0 0.441242 0.610219 0.0615781 0.185812 +1 0.0487266 0.581052 0.0393594 0.0324375 +0 0.158914 0.60201 0.0588594 0.136771 +0 0.402781 0.554979 0.0191562 0.0547917 +32 0.4245 0.616625 0.00290625 0.00575 +0 0.34607 0.556073 0.0166094 0.0496042 +0 0.708234 0.550083 0.0200625 0.0737917 +0 0.797523 0.542563 0.0198594 0.0664583 +38 0.471602 0.638062 0.0230469 0.0662083 +0 0.618039 0.555833 0.0188906 0.0434583 +0 0.0276328 0.575719 0.0350781 0.0746042 +38 0.0979609 0.567479 0.106297 0.0743333 +38 0.398789 0.564906 0.00676562 0.0088125 +1 0.990477 0.564375 0.0163906 0.0199167 diff --git a/datasets/coco128/labels/train2017/000000000532.txt b/datasets/coco128/labels/train2017/000000000532.txt new file mode 100644 index 0000000000000000000000000000000000000000..4bed5afc4c1351ab28bf2dc47919d5bab3a07fc9 --- /dev/null +++ b/datasets/coco128/labels/train2017/000000000532.txt @@ -0,0 +1,8 @@ +5 0.495508 0.537823 0.721359 0.546063 +0 0.455234 0.651458 0.0695625 0.325542 +0 0.229922 0.646854 0.0713437 0.237542 +0 0.359898 0.462552 0.0281094 0.0383125 +0 0.250852 0.471458 0.0191719 0.0409583 +5 0.0761484 0.538552 0.151234 0.395854 +26 0.25575 0.596667 0.0329688 0.0740417 +26 0.199906 0.686667 0.0235938 0.0528333 diff --git a/datasets/coco128/labels/train2017/000000000569.txt b/datasets/coco128/labels/train2017/000000000569.txt new file mode 100644 index 0000000000000000000000000000000000000000..c18f9467188dc5fbc10574d21c5049c22fb0fcb2 --- /dev/null +++ b/datasets/coco128/labels/train2017/000000000569.txt @@ -0,0 +1,5 @@ +0 0.200297 0.712146 0.125281 0.302875 +33 0.318227 0.461302 0.0469844 0.0648958 +33 0.278828 0.485896 0.0260312 0.067875 +33 0.245305 0.502354 0.0359219 0.049375 +33 0.230844 0.523781 0.0400937 0.0485208 diff --git a/datasets/coco128/labels/train2017/000000000659.txt b/datasets/coco128/labels/train2017/000000000659.txt new file mode 100644 index 0000000000000000000000000000000000000000..ac3c14729f0ea8d1525021c3afe82c26511728b3 --- /dev/null +++ b/datasets/coco128/labels/train2017/000000000659.txt @@ -0,0 +1,9 @@ +0 0.132172 0.552259 0.118562 0.537176 +0 0.249211 0.569659 0.104453 0.456165 +0 0.0285469 0.491588 0.0545625 0.312024 +0 0.0884609 0.379012 0.0463594 0.112612 +6 0.446703 0.554741 0.554625 0.794565 +0 0.165211 0.391718 0.0635781 0.0516706 +0 0.165625 0.400082 0.0372188 0.130424 +0 0.178945 0.354788 0.0235156 0.0436471 +26 0.174266 0.664047 0.0525 0.119341 diff --git a/ultralytics/docker/Dockerfile b/ultralytics/docker/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..44c84b0021f9b4cf74c6fef7b751a2a5e2a7021c --- /dev/null +++ b/ultralytics/docker/Dockerfile @@ -0,0 +1,89 @@ +# Ultralytics YOLO 🚀, AGPL-3.0 license +# Builds ultralytics/ultralytics:latest image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics +# Image is CUDA-optimized for YOLOv8 single/multi-GPU training and inference + +# Start FROM PyTorch image https://hub.docker.com/r/pytorch/pytorch or nvcr.io/nvidia/pytorch:23.03-py3 +FROM pytorch/pytorch:2.3.1-cuda12.1-cudnn8-runtime + +# Set environment variables +# Avoid DDP error "MKL_THREADING_LAYER=INTEL is incompatible with libgomp.so.1 library" https://github.com/pytorch/pytorch/issues/37377 +ENV PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 \ + PIP_NO_CACHE_DIR=1 \ + PIP_BREAK_SYSTEM_PACKAGES=1 \ + MKL_THREADING_LAYER=GNU + +# Downloads to user config dir +ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.ttf \ + https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.Unicode.ttf \ + /root/.config/Ultralytics/ + +# Install linux packages +# g++ required to build 'tflite_support' and 'lap' packages, libusb-1.0-0 required for 'tflite_support' package +# libsm6 required by libqxcb to create QT-based windows for visualization; set 'QT_DEBUG_PLUGINS=1' to test in docker +RUN apt update \ + && apt install --no-install-recommends -y gcc git zip unzip wget curl htop libgl1 libglib2.0-0 libpython3-dev gnupg g++ libusb-1.0-0 libsm6 + +# Security updates +# https://security.snyk.io/vuln/SNYK-UBUNTU1804-OPENSSL-3314796 +RUN apt upgrade --no-install-recommends -y openssl tar + +# Create working directory +WORKDIR /ultralytics + +# Copy contents and configure git +COPY . . +RUN sed -i '/^\[http "https:\/\/github\.com\/"\]/,+1d' .git/config +ADD https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt . + +# Install pip packages +RUN python3 -m pip install --upgrade pip wheel +# Pin TensorRT-cu12==10.1.0 to avoid 10.2.0 bug https://github.com/ultralytics/ultralytics/pull/14239 (note -cu12 must be used) +RUN pip install -e ".[export]" "tensorrt-cu12==10.1.0" "albumentations>=1.4.6" comet pycocotools + +# Run exports to AutoInstall packages +# Edge TPU export fails the first time so is run twice here +RUN yolo export model=tmp/yolov8n.pt format=edgetpu imgsz=32 || yolo export model=tmp/yolov8n.pt format=edgetpu imgsz=32 +RUN yolo export model=tmp/yolov8n.pt format=ncnn imgsz=32 +# Requires <= Python 3.10, bug with paddlepaddle==2.5.0 https://github.com/PaddlePaddle/X2Paddle/issues/991 +RUN pip install "paddlepaddle>=2.6.0" x2paddle +# Fix error: `np.bool` was a deprecated alias for the builtin `bool` segmentation error in Tests +RUN pip install numpy==1.23.5 +# Remove exported models +RUN rm -rf tmp + + +# Usage Examples ------------------------------------------------------------------------------------------------------- + +# Build and Push +# t=ultralytics/ultralytics:latest && sudo docker build -f docker/Dockerfile -t $t . && sudo docker push $t + +# Pull and Run with access to all GPUs +# t=ultralytics/ultralytics:latest && sudo docker pull $t && sudo docker run -it --ipc=host --gpus all $t + +# Pull and Run with access to GPUs 2 and 3 (inside container CUDA devices will appear as 0 and 1) +# t=ultralytics/ultralytics:latest && sudo docker pull $t && sudo docker run -it --ipc=host --gpus '"device=2,3"' $t + +# Pull and Run with local directory access +# t=ultralytics/ultralytics:latest && sudo docker pull $t && sudo docker run -it --ipc=host --gpus all -v "$(pwd)"/shared/datasets:/datasets $t + +# Kill all +# sudo docker kill $(sudo docker ps -q) + +# Kill all image-based +# sudo docker kill $(sudo docker ps -qa --filter ancestor=ultralytics/ultralytics:latest) + +# DockerHub tag update +# t=ultralytics/ultralytics:latest tnew=ultralytics/ultralytics:v6.2 && sudo docker pull $t && sudo docker tag $t $tnew && sudo docker push $tnew + +# Clean up +# sudo docker system prune -a --volumes + +# Update Ubuntu drivers +# https://www.maketecheasier.com/install-nvidia-drivers-ubuntu/ + +# DDP test +# python -m torch.distributed.run --nproc_per_node 2 --master_port 1 train.py --epochs 3 + +# GCP VM from Image +# docker.io/ultralytics/ultralytics:latest diff --git a/ultralytics/docker/Dockerfile-arm64 b/ultralytics/docker/Dockerfile-arm64 new file mode 100644 index 0000000000000000000000000000000000000000..7eeade1024397a6269d31d60a98eeb7fc0ce02ad --- /dev/null +++ b/ultralytics/docker/Dockerfile-arm64 @@ -0,0 +1,54 @@ +# Ultralytics YOLO 🚀, AGPL-3.0 license +# Builds ultralytics/ultralytics:latest-arm64 image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics +# Image is aarch64-compatible for Apple M1, M2, M3, Raspberry Pi and other ARM architectures + +# Start FROM Ubuntu image https://hub.docker.com/_/ubuntu with "FROM arm64v8/ubuntu:22.04" (deprecated) +# Start FROM Debian image for arm64v8 https://hub.docker.com/r/arm64v8/debian (new) +FROM arm64v8/debian:bookworm-slim + +# Set environment variables +ENV PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 \ + PIP_NO_CACHE_DIR=1 \ + PIP_BREAK_SYSTEM_PACKAGES=1 + +# Downloads to user config dir +ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.ttf \ + https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.Unicode.ttf \ + /root/.config/Ultralytics/ + +# Install linux packages +# g++ required to build 'tflite_support' and 'lap' packages, libusb-1.0-0 required for 'tflite_support' package +# pkg-config and libhdf5-dev (not included) are needed to build 'h5py==3.11.0' aarch64 wheel required by 'tensorflow' +RUN apt update \ + && apt install --no-install-recommends -y python3-pip git zip unzip wget curl htop gcc libgl1 libglib2.0-0 libpython3-dev gnupg g++ libusb-1.0-0 + +# Create working directory +WORKDIR /ultralytics + +# Copy contents and configure git +COPY . . +RUN sed -i '/^\[http "https:\/\/github\.com\/"\]/,+1d' .git/config +ADD https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt . + +# Install pip packages +RUN python3 -m pip install --upgrade pip wheel +RUN pip install -e ".[export]" + +# Creates a symbolic link to make 'python' point to 'python3' +RUN ln -sf /usr/bin/python3 /usr/bin/python + + +# Usage Examples ------------------------------------------------------------------------------------------------------- + +# Build and Push +# t=ultralytics/ultralytics:latest-arm64 && sudo docker build --platform linux/arm64 -f docker/Dockerfile-arm64 -t $t . && sudo docker push $t + +# Run +# t=ultralytics/ultralytics:latest-arm64 && sudo docker run -it --ipc=host $t + +# Pull and Run +# t=ultralytics/ultralytics:latest-arm64 && sudo docker pull $t && sudo docker run -it --ipc=host $t + +# Pull and Run with local volume mounted +# t=ultralytics/ultralytics:latest-arm64 && sudo docker pull $t && sudo docker run -it --ipc=host -v "$(pwd)"/shared/datasets:/datasets $t diff --git a/ultralytics/docker/Dockerfile-conda b/ultralytics/docker/Dockerfile-conda new file mode 100644 index 0000000000000000000000000000000000000000..c6a31f1cc00f88bb3b6865d1d1dfa4ec682016f0 --- /dev/null +++ b/ultralytics/docker/Dockerfile-conda @@ -0,0 +1,46 @@ +# Ultralytics YOLO 🚀, AGPL-3.0 license +# Builds ultralytics/ultralytics:latest-conda image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics +# Image is optimized for Ultralytics Anaconda (https://anaconda.org/conda-forge/ultralytics) installation and usage + +# Start FROM miniconda3 image https://hub.docker.com/r/continuumio/miniconda3 +FROM continuumio/miniconda3:latest + +# Set environment variables +ENV PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 \ + PIP_NO_CACHE_DIR=1 \ + PIP_BREAK_SYSTEM_PACKAGES=1 + +# Downloads to user config dir +ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.ttf \ + https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.Unicode.ttf \ + /root/.config/Ultralytics/ + +# Install linux packages +RUN apt update \ + && apt install --no-install-recommends -y libgl1 + +# Copy contents +ADD https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt . + +# Install conda packages +# mkl required to fix 'OSError: libmkl_intel_lp64.so.2: cannot open shared object file: No such file or directory' +RUN conda config --set solver libmamba && \ + conda install pytorch torchvision pytorch-cuda=12.1 -c pytorch -c nvidia && \ + conda install -c conda-forge ultralytics mkl + # conda install -c pytorch -c nvidia -c conda-forge pytorch torchvision pytorch-cuda=12.1 ultralytics mkl + + +# Usage Examples ------------------------------------------------------------------------------------------------------- + +# Build and Push +# t=ultralytics/ultralytics:latest-conda && sudo docker build -f docker/Dockerfile-cpu -t $t . && sudo docker push $t + +# Run +# t=ultralytics/ultralytics:latest-conda && sudo docker run -it --ipc=host $t + +# Pull and Run +# t=ultralytics/ultralytics:latest-conda && sudo docker pull $t && sudo docker run -it --ipc=host $t + +# Pull and Run with local volume mounted +# t=ultralytics/ultralytics:latest-conda && sudo docker pull $t && sudo docker run -it --ipc=host -v "$(pwd)"/shared/datasets:/datasets $t diff --git a/ultralytics/docker/Dockerfile-cpu b/ultralytics/docker/Dockerfile-cpu new file mode 100644 index 0000000000000000000000000000000000000000..fcd5336ecee9abc49ee47f1e66826d056517d37f --- /dev/null +++ b/ultralytics/docker/Dockerfile-cpu @@ -0,0 +1,60 @@ +# Ultralytics YOLO 🚀, AGPL-3.0 license +# Builds ultralytics/ultralytics:latest-cpu image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics +# Image is CPU-optimized for ONNX, OpenVINO and PyTorch YOLOv8 deployments + +# Start FROM Ubuntu image https://hub.docker.com/_/ubuntu +FROM ubuntu:23.10 + +# Set environment variables +ENV PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 \ + PIP_NO_CACHE_DIR=1 \ + PIP_BREAK_SYSTEM_PACKAGES=1 + +# Downloads to user config dir +ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.ttf \ + https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.Unicode.ttf \ + /root/.config/Ultralytics/ + +# Install linux packages +# g++ required to build 'tflite_support' and 'lap' packages, libusb-1.0-0 required for 'tflite_support' package +RUN apt update \ + && apt install --no-install-recommends -y python3-pip git zip unzip wget curl htop libgl1 libglib2.0-0 libpython3-dev gnupg g++ libusb-1.0-0 + +# Create working directory +WORKDIR /ultralytics + +# Copy contents and configure git +COPY . . +RUN sed -i '/^\[http "https:\/\/github\.com\/"\]/,+1d' .git/config +ADD https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt . + +# Install pip packages +RUN python3 -m pip install --upgrade pip wheel +RUN pip install -e ".[export]" --extra-index-url https://download.pytorch.org/whl/cpu + +# Run exports to AutoInstall packages +RUN yolo export model=tmp/yolov8n.pt format=edgetpu imgsz=32 +RUN yolo export model=tmp/yolov8n.pt format=ncnn imgsz=32 +# Requires Python<=3.10, bug with paddlepaddle==2.5.0 https://github.com/PaddlePaddle/X2Paddle/issues/991 +# RUN pip install "paddlepaddle>=2.6.0" x2paddle +# Remove exported models +RUN rm -rf tmp + +# Creates a symbolic link to make 'python' point to 'python3' +RUN ln -sf /usr/bin/python3 /usr/bin/python + + +# Usage Examples ------------------------------------------------------------------------------------------------------- + +# Build and Push +# t=ultralytics/ultralytics:latest-cpu && sudo docker build -f docker/Dockerfile-cpu -t $t . && sudo docker push $t + +# Run +# t=ultralytics/ultralytics:latest-cpu && sudo docker run -it --ipc=host --name NAME $t + +# Pull and Run +# t=ultralytics/ultralytics:latest-cpu && sudo docker pull $t && sudo docker run -it --ipc=host --name NAME $t + +# Pull and Run with local volume mounted +# t=ultralytics/ultralytics:latest-cpu && sudo docker pull $t && sudo docker run -it --ipc=host -v "$(pwd)"/shared/datasets:/datasets $t diff --git a/ultralytics/docker/Dockerfile-jetson-jetpack4 b/ultralytics/docker/Dockerfile-jetson-jetpack4 new file mode 100644 index 0000000000000000000000000000000000000000..ca238b967600e14787b522748812e717b1ece156 --- /dev/null +++ b/ultralytics/docker/Dockerfile-jetson-jetpack4 @@ -0,0 +1,65 @@ +# Ultralytics YOLO 🚀, AGPL-3.0 license +# Builds ultralytics/ultralytics:jetson-jetpack4 image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics +# Supports JetPack4.x for YOLOv8 on Jetson Nano, TX2, Xavier NX, AGX Xavier + +# Start FROM https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-cuda +FROM nvcr.io/nvidia/l4t-cuda:10.2.460-runtime + +# Set environment variables +ENV PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 + +# Downloads to user config dir +ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.ttf \ + https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.Unicode.ttf \ + /root/.config/Ultralytics/ + +# Add NVIDIA repositories for TensorRT dependencies +RUN wget -q -O - https://repo.download.nvidia.com/jetson/jetson-ota-public.asc | apt-key add - && \ + echo "deb https://repo.download.nvidia.com/jetson/common r32.7 main" > /etc/apt/sources.list.d/nvidia-l4t-apt-source.list && \ + echo "deb https://repo.download.nvidia.com/jetson/t194 r32.7 main" >> /etc/apt/sources.list.d/nvidia-l4t-apt-source.list + +# Install dependencies +RUN apt update && \ + apt install --no-install-recommends -y git python3.8 python3.8-dev python3-pip python3-libnvinfer libopenmpi-dev libopenblas-base libomp-dev gcc + +# Create symbolic links for python3.8 and pip3 +RUN ln -sf /usr/bin/python3.8 /usr/bin/python3 +RUN ln -s /usr/bin/pip3 /usr/bin/pip + +# Create working directory +WORKDIR /ultralytics + +# Copy contents and configure git +COPY . . +RUN sed -i '/^\[http "https:\/\/github\.com\/"\]/,+1d' .git/config +ADD https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt . + +# Download onnxruntime-gpu 1.8.0 and tensorrt 8.2.0.6 +# Other versions can be seen in https://elinux.org/Jetson_Zoo and https://forums.developer.nvidia.com/t/pytorch-for-jetson/72048 +ADD https://nvidia.box.com/shared/static/gjqofg7rkg97z3gc8jeyup6t8n9j8xjw.whl onnxruntime_gpu-1.8.0-cp38-cp38-linux_aarch64.whl +ADD https://forums.developer.nvidia.com/uploads/short-url/hASzFOm9YsJx6VVFrDW1g44CMmv.whl tensorrt-8.2.0.6-cp38-none-linux_aarch64.whl + +# Install pip packages +RUN python3 -m pip install --upgrade pip wheel +RUN pip install \ + onnxruntime_gpu-1.8.0-cp38-cp38-linux_aarch64.whl \ + tensorrt-8.2.0.6-cp38-none-linux_aarch64.whl \ + https://github.com/ultralytics/assets/releases/download/v0.0.0/torch-1.11.0a0+gitbc2c6ed-cp38-cp38-linux_aarch64.whl \ + https://github.com/ultralytics/assets/releases/download/v0.0.0/torchvision-0.12.0a0+9b5a3fe-cp38-cp38-linux_aarch64.whl +RUN pip install -e ".[export]" +RUN rm *.whl + +# Usage Examples ------------------------------------------------------------------------------------------------------- + +# Build and Push +# t=ultralytics/ultralytics:latest-jetson-jetpack4 && sudo docker build --platform linux/arm64 -f docker/Dockerfile-jetson-jetpack4 -t $t . && sudo docker push $t + +# Run +# t=ultralytics/ultralytics:latest-jetson-jetpack4 && sudo docker run -it --ipc=host $t + +# Pull and Run +# t=ultralytics/ultralytics:latest-jetson-jetpack4 && sudo docker pull $t && sudo docker run -it --ipc=host $t + +# Pull and Run with NVIDIA runtime +# t=ultralytics/ultralytics:latest-jetson-jetpack4 && sudo docker pull $t && sudo docker run -it --ipc=host --runtime=nvidia $t diff --git a/ultralytics/docker/Dockerfile-jetson-jetpack5 b/ultralytics/docker/Dockerfile-jetson-jetpack5 new file mode 100644 index 0000000000000000000000000000000000000000..9ec2e64a06878a222007c3f5764dba2472188e2b --- /dev/null +++ b/ultralytics/docker/Dockerfile-jetson-jetpack5 @@ -0,0 +1,59 @@ +# Ultralytics YOLO 🚀, AGPL-3.0 license +# Builds ultralytics/ultralytics:jetson-jetson-jetpack5 image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics +# Supports JetPack5.x for YOLOv8 on Jetson Xavier NX, AGX Xavier, AGX Orin, Orin Nano and Orin NX + +# Start FROM https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-pytorch +FROM nvcr.io/nvidia/l4t-pytorch:r35.2.1-pth2.0-py3 + +# Set environment variables +ENV PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 \ + PIP_NO_CACHE_DIR=1 \ + PIP_BREAK_SYSTEM_PACKAGES=1 + +# Downloads to user config dir +ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.ttf \ + https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.Unicode.ttf \ + /root/.config/Ultralytics/ + +# Install linux packages +# g++ required to build 'tflite_support' and 'lap' packages +# libusb-1.0-0 required for 'tflite_support' package when exporting to TFLite +# pkg-config and libhdf5-dev (not included) are needed to build 'h5py==3.11.0' aarch64 wheel required by 'tensorflow' +RUN apt update \ + && apt install --no-install-recommends -y gcc git zip unzip wget curl htop libgl1 libglib2.0-0 libpython3-dev gnupg g++ libusb-1.0-0 + +# Create working directory +WORKDIR /ultralytics + +# Copy contents and configure git +COPY . . +RUN sed -i '/^\[http "https:\/\/github\.com\/"\]/,+1d' .git/config +ADD https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt . + +# Remove opencv-python from Ultralytics dependencies as it conflicts with opencv-python installed in base image +RUN sed -i '/opencv-python/d' pyproject.toml + +# Download onnxruntime-gpu 1.15.1 for Jetson Linux 35.2.1 (JetPack 5.1). Other versions can be seen in https://elinux.org/Jetson_Zoo#ONNX_Runtime +ADD https://nvidia.box.com/shared/static/mvdcltm9ewdy2d5nurkiqorofz1s53ww.whl onnxruntime_gpu-1.15.1-cp38-cp38-linux_aarch64.whl + +# Install pip packages manually for TensorRT compatibility https://github.com/NVIDIA/TensorRT/issues/2567 +RUN python3 -m pip install --upgrade pip wheel +RUN pip install onnxruntime_gpu-1.15.1-cp38-cp38-linux_aarch64.whl +RUN pip install -e ".[export]" +RUN rm *.whl + + +# Usage Examples ------------------------------------------------------------------------------------------------------- + +# Build and Push +# t=ultralytics/ultralytics:latest-jetson-jetpack5 && sudo docker build --platform linux/arm64 -f docker/Dockerfile-jetson-jetpack5 -t $t . && sudo docker push $t + +# Run +# t=ultralytics/ultralytics:latest-jetson-jetpack5 && sudo docker run -it --ipc=host $t + +# Pull and Run +# t=ultralytics/ultralytics:latest-jetson-jetpack5 && sudo docker pull $t && sudo docker run -it --ipc=host $t + +# Pull and Run with NVIDIA runtime +# t=ultralytics/ultralytics:latest-jetson-jetpack5 && sudo docker pull $t && sudo docker run -it --ipc=host --runtime=nvidia $t diff --git a/ultralytics/docker/Dockerfile-jetson-jetpack6 b/ultralytics/docker/Dockerfile-jetson-jetpack6 new file mode 100644 index 0000000000000000000000000000000000000000..3b53c31d419f86b2ec794eb1c4832711b905b643 --- /dev/null +++ b/ultralytics/docker/Dockerfile-jetson-jetpack6 @@ -0,0 +1,55 @@ +# Ultralytics YOLO 🚀, AGPL-3.0 license +# Builds ultralytics/ultralytics:jetson-jetpack6 image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics +# Supports JetPack6.x for YOLOv8 on Jetson AGX Orin, Orin NX and Orin Nano Series + +# Start FROM https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-jetpack +FROM nvcr.io/nvidia/l4t-jetpack:r36.3.0 + +# Set environment variables +ENV PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 \ + PIP_NO_CACHE_DIR=1 \ + PIP_BREAK_SYSTEM_PACKAGES=1 + +# Downloads to user config dir +ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.ttf \ + https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.Unicode.ttf \ + /root/.config/Ultralytics/ + +# Install dependencies +RUN apt update && \ + apt install --no-install-recommends -y git python3-pip libopenmpi-dev libopenblas-base libomp-dev + +# Create working directory +WORKDIR /ultralytics + +# Copy contents and configure git +COPY . . +RUN sed -i '/^\[http "https:\/\/github\.com\/"\]/,+1d' .git/config +ADD https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt . + +# Download onnxruntime-gpu 1.18.0 from https://elinux.org/Jetson_Zoo and https://forums.developer.nvidia.com/t/pytorch-for-jetson/72048 +ADD https://nvidia.box.com/shared/static/48dtuob7meiw6ebgfsfqakc9vse62sg4.whl onnxruntime_gpu-1.18.0-cp310-cp310-linux_aarch64.whl + +# Pip install onnxruntime-gpu, torch, torchvision and ultralytics +RUN python3 -m pip install --upgrade pip wheel +RUN pip install \ + onnxruntime_gpu-1.18.0-cp310-cp310-linux_aarch64.whl \ + https://github.com/ultralytics/assets/releases/download/v0.0.0/torch-2.3.0-cp310-cp310-linux_aarch64.whl \ + https://github.com/ultralytics/assets/releases/download/v0.0.0/torchvision-0.18.0a0+6043bc2-cp310-cp310-linux_aarch64.whl +RUN pip install -e ".[export]" +RUN rm *.whl + +# Usage Examples ------------------------------------------------------------------------------------------------------- + +# Build and Push +# t=ultralytics/ultralytics:latest-jetson-jetpack6 && sudo docker build --platform linux/arm64 -f docker/Dockerfile-jetson-jetpack6 -t $t . && sudo docker push $t + +# Run +# t=ultralytics/ultralytics:latest-jetson-jetpack6 && sudo docker run -it --ipc=host $t + +# Pull and Run +# t=ultralytics/ultralytics:latest-jetson-jetpack6 && sudo docker pull $t && sudo docker run -it --ipc=host $t + +# Pull and Run with NVIDIA runtime +# t=ultralytics/ultralytics:latest-jetson-jetpack6 && sudo docker pull $t && sudo docker run -it --ipc=host --runtime=nvidia $t diff --git a/ultralytics/docker/Dockerfile-python b/ultralytics/docker/Dockerfile-python new file mode 100644 index 0000000000000000000000000000000000000000..f8a8611c4cee671d59336bf076fafeb2b186a96e --- /dev/null +++ b/ultralytics/docker/Dockerfile-python @@ -0,0 +1,57 @@ +# Ultralytics YOLO 🚀, AGPL-3.0 license +# Builds ultralytics/ultralytics:latest-cpu image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics +# Image is CPU-optimized for ONNX, OpenVINO and PyTorch YOLOv8 deployments + +# Use the official Python 3.10 slim-bookworm as base image +FROM python:3.10-slim-bookworm + +# Set environment variables +ENV PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 \ + PIP_NO_CACHE_DIR=1 \ + PIP_BREAK_SYSTEM_PACKAGES=1 + +# Downloads to user config dir +ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.ttf \ + https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.Unicode.ttf \ + /root/.config/Ultralytics/ + +# Install linux packages +# g++ required to build 'tflite_support' and 'lap' packages, libusb-1.0-0 required for 'tflite_support' package +RUN apt update \ + && apt install --no-install-recommends -y python3-pip git zip unzip wget curl htop libgl1 libglib2.0-0 libpython3-dev gnupg g++ libusb-1.0-0 + +# Create working directory +WORKDIR /ultralytics + +# Copy contents and configure git +COPY . . +RUN sed -i '/^\[http "https:\/\/github\.com\/"\]/,+1d' .git/config +ADD https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt . + +# Install pip packages +RUN python3 -m pip install --upgrade pip wheel +RUN pip install -e ".[export]" --extra-index-url https://download.pytorch.org/whl/cpu + +# Run exports to AutoInstall packages +RUN yolo export model=tmp/yolov8n.pt format=edgetpu imgsz=32 +RUN yolo export model=tmp/yolov8n.pt format=ncnn imgsz=32 +# Requires Python<=3.10, bug with paddlepaddle==2.5.0 https://github.com/PaddlePaddle/X2Paddle/issues/991 +RUN pip install "paddlepaddle>=2.6.0" x2paddle +# Remove exported models +RUN rm -rf tmp + + +# Usage Examples ------------------------------------------------------------------------------------------------------- + +# Build and Push +# t=ultralytics/ultralytics:latest-python && sudo docker build -f docker/Dockerfile-python -t $t . && sudo docker push $t + +# Run +# t=ultralytics/ultralytics:latest-python && sudo docker run -it --ipc=host $t + +# Pull and Run +# t=ultralytics/ultralytics:latest-python && sudo docker pull $t && sudo docker run -it --ipc=host $t + +# Pull and Run with local volume mounted +# t=ultralytics/ultralytics:latest-python && sudo docker pull $t && sudo docker run -it --ipc=host -v "$(pwd)"/shared/datasets:/datasets $t diff --git a/ultralytics/docker/Dockerfile-runner b/ultralytics/docker/Dockerfile-runner new file mode 100644 index 0000000000000000000000000000000000000000..8f01477252b6caf152847e5a214db58300909ea1 --- /dev/null +++ b/ultralytics/docker/Dockerfile-runner @@ -0,0 +1,45 @@ +# Ultralytics YOLO 🚀, AGPL-3.0 license +# Builds GitHub actions CI runner image for deployment to DockerHub https://hub.docker.com/r/ultralytics/ultralytics +# Image is CUDA-optimized for YOLOv8 single/multi-GPU training and inference tests + +# Start FROM Ultralytics GPU image +FROM ultralytics/ultralytics:latest + +# Set environment variables +ENV PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 \ + PIP_NO_CACHE_DIR=1 \ + PIP_BREAK_SYSTEM_PACKAGES=1 \ + RUNNER_ALLOW_RUNASROOT=1 \ + DEBIAN_FRONTEND=noninteractive + +# Set the working directory +WORKDIR /actions-runner + +# Download and unpack the latest runner from https://github.com/actions/runner +RUN FILENAME=actions-runner-linux-x64-2.317.0.tar.gz && \ + curl -o $FILENAME -L https://github.com/actions/runner/releases/download/v2.317.0/$FILENAME && \ + tar xzf $FILENAME && \ + rm $FILENAME + +# Install runner dependencies +RUN pip install pytest-cov +RUN ./bin/installdependencies.sh && \ + apt-get -y install libicu-dev + +# Inline ENTRYPOINT command to configure and start runner with default TOKEN and NAME +ENTRYPOINT sh -c './config.sh --url https://github.com/ultralytics/ultralytics \ + --token ${GITHUB_RUNNER_TOKEN:-TOKEN} \ + --name ${GITHUB_RUNNER_NAME:-NAME} \ + --labels gpu-latest \ + --replace && \ + ./run.sh' + + +# Usage Examples ------------------------------------------------------------------------------------------------------- + +# Build and Push +# t=ultralytics/ultralytics:latest-runner && sudo docker build -f docker/Dockerfile-runner -t $t . && sudo docker push $t + +# Pull and Run in detached mode with access to GPUs 0 and 1 +# t=ultralytics/ultralytics:latest-runner && sudo docker run -d -e GITHUB_RUNNER_TOKEN=TOKEN -e GITHUB_RUNNER_NAME=NAME --ipc=host --gpus '"device=0,1"' $t diff --git a/ultralytics/docs/en/datasets/detect/argoverse.md b/ultralytics/docs/en/datasets/detect/argoverse.md new file mode 100644 index 0000000000000000000000000000000000000000..47ef822b087726aace604129642d3b023f4dc7c9 --- /dev/null +++ b/ultralytics/docs/en/datasets/detect/argoverse.md @@ -0,0 +1,153 @@ +--- +comments: true +description: Explore the comprehensive Argoverse dataset by Argo AI for 3D tracking, motion forecasting, and stereo depth estimation in autonomous driving research. +keywords: Argoverse dataset, autonomous driving, 3D tracking, motion forecasting, stereo depth estimation, Argo AI, LiDAR point clouds, high-resolution images, HD maps +--- + +# Argoverse Dataset + +The [Argoverse](https://www.argoverse.org/) dataset is a collection of data designed to support research in autonomous driving tasks, such as 3D tracking, motion forecasting, and stereo depth estimation. Developed by Argo AI, the dataset provides a wide range of high-quality sensor data, including high-resolution images, LiDAR point clouds, and map data. + +!!! note + + The Argoverse dataset `*.zip` file required for training was removed from Amazon S3 after the shutdown of Argo AI by Ford, but we have made it available for manual download on [Google Drive](https://drive.google.com/file/d/1st9qW3BeIwQsnR0t8mRpvbsSWIo16ACi/view?usp=drive_link). + +## Key Features + +- Argoverse contains over 290K labeled 3D object tracks and 5 million object instances across 1,263 distinct scenes. +- The dataset includes high-resolution camera images, LiDAR point clouds, and richly annotated HD maps. +- Annotations include 3D bounding boxes for objects, object tracks, and trajectory information. +- Argoverse provides multiple subsets for different tasks, such as 3D tracking, motion forecasting, and stereo depth estimation. + +## Dataset Structure + +The Argoverse dataset is organized into three main subsets: + +1. **Argoverse 3D Tracking**: This subset contains 113 scenes with over 290K labeled 3D object tracks, focusing on 3D object tracking tasks. It includes LiDAR point clouds, camera images, and sensor calibration information. +2. **Argoverse Motion Forecasting**: This subset consists of 324K vehicle trajectories collected from 60 hours of driving data, suitable for motion forecasting tasks. +3. **Argoverse Stereo Depth Estimation**: This subset is designed for stereo depth estimation tasks and includes over 10K stereo image pairs with corresponding LiDAR point clouds for ground truth depth estimation. + +## Applications + +The Argoverse dataset is widely used for training and evaluating deep learning models in autonomous driving tasks such as 3D object tracking, motion forecasting, and stereo depth estimation. The dataset's diverse set of sensor data, object annotations, and map information make it a valuable resource for researchers and practitioners in the field of autonomous driving. + +## Dataset YAML + +A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. For the case of the Argoverse dataset, the `Argoverse.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/Argoverse.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/Argoverse.yaml). + +!!! example "ultralytics/cfg/datasets/Argoverse.yaml" + + ```yaml + --8<-- "ultralytics/cfg/datasets/Argoverse.yaml" + ``` + +## Usage + +To train a YOLOv8n model on the Argoverse dataset for 100 epochs with an image size of 640, you can use the following code snippets. For a comprehensive list of available arguments, refer to the model [Training](../../modes/train.md) page. + +!!! example "Train Example" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a model + model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training) + + # Train the model + results = model.train(data="Argoverse.yaml", epochs=100, imgsz=640) + ``` + + === "CLI" + + ```bash + # Start training from a pretrained *.pt model + yolo detect train data=Argoverse.yaml model=yolov8n.pt epochs=100 imgsz=640 + ``` + +## Sample Data and Annotations + +The Argoverse dataset contains a diverse set of sensor data, including camera images, LiDAR point clouds, and HD map information, providing rich context for autonomous driving tasks. Here are some examples of data from the dataset, along with their corresponding annotations: + +![Dataset sample image](https://github.com/ultralytics/docs/releases/download/0/argoverse-3d-tracking-sample.avif) + +- **Argoverse 3D Tracking**: This image demonstrates an example of 3D object tracking, where objects are annotated with 3D bounding boxes. The dataset provides LiDAR point clouds and camera images to facilitate the development of models for this task. + +The example showcases the variety and complexity of the data in the Argoverse dataset and highlights the importance of high-quality sensor data for autonomous driving tasks. + +## Citations and Acknowledgments + +If you use the Argoverse dataset in your research or development work, please cite the following paper: + +!!! quote "" + + === "BibTeX" + + ```bibtex + @inproceedings{chang2019argoverse, + title={Argoverse: 3D Tracking and Forecasting with Rich Maps}, + author={Chang, Ming-Fang and Lambert, John and Sangkloy, Patsorn and Singh, Jagjeet and Bak, Slawomir and Hartnett, Andrew and Wang, Dequan and Carr, Peter and Lucey, Simon and Ramanan, Deva and others}, + booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition}, + pages={8748--8757}, + year={2019} + } + ``` + +We would like to acknowledge Argo AI for creating and maintaining the Argoverse dataset as a valuable resource for the autonomous driving research community. For more information about the Argoverse dataset and its creators, visit the [Argoverse dataset website](https://www.argoverse.org/). + +## FAQ + +### What is the Argoverse dataset and its key features? + +The [Argoverse](https://www.argoverse.org/) dataset, developed by Argo AI, supports autonomous driving research. It includes over 290K labeled 3D object tracks and 5 million object instances across 1,263 distinct scenes. The dataset provides high-resolution camera images, LiDAR point clouds, and annotated HD maps, making it valuable for tasks like 3D tracking, motion forecasting, and stereo depth estimation. + +### How can I train an Ultralytics YOLO model using the Argoverse dataset? + +To train a YOLOv8 model with the Argoverse dataset, use the provided YAML configuration file and the following code: + +!!! example "Train Example" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a model + model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training) + + # Train the model + results = model.train(data="Argoverse.yaml", epochs=100, imgsz=640) + ``` + + + === "CLI" + + ```bash + # Start training from a pretrained *.pt model + yolo detect train data=Argoverse.yaml model=yolov8n.pt epochs=100 imgsz=640 + ``` + +For a detailed explanation of the arguments, refer to the model [Training](../../modes/train.md) page. + +### What types of data and annotations are available in the Argoverse dataset? + +The Argoverse dataset includes various sensor data types such as high-resolution camera images, LiDAR point clouds, and HD map data. Annotations include 3D bounding boxes, object tracks, and trajectory information. These comprehensive annotations are essential for accurate model training in tasks like 3D object tracking, motion forecasting, and stereo depth estimation. + +### How is the Argoverse dataset structured? + +The dataset is divided into three main subsets: + +1. **Argoverse 3D Tracking**: Contains 113 scenes with over 290K labeled 3D object tracks, focusing on 3D object tracking tasks. It includes LiDAR point clouds, camera images, and sensor calibration information. +2. **Argoverse Motion Forecasting**: Consists of 324K vehicle trajectories collected from 60 hours of driving data, suitable for motion forecasting tasks. +3. **Argoverse Stereo Depth Estimation**: Includes over 10K stereo image pairs with corresponding LiDAR point clouds for ground truth depth estimation. + +### Where can I download the Argoverse dataset now that it has been removed from Amazon S3? + +The Argoverse dataset `*.zip` file, previously available on Amazon S3, can now be manually downloaded from [Google Drive](https://drive.google.com/file/d/1st9qW3BeIwQsnR0t8mRpvbsSWIo16ACi/view?usp=drive_link). + +### What is the YAML configuration file used for with the Argoverse dataset? + +A YAML file contains the dataset's paths, classes, and other essential information. For the Argoverse dataset, the configuration file, `Argoverse.yaml`, can be found at the following link: [Argoverse.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/Argoverse.yaml). + +For more information about YAML configurations, see our [datasets](../index.md) guide. diff --git a/ultralytics/docs/en/datasets/detect/coco.md b/ultralytics/docs/en/datasets/detect/coco.md new file mode 100644 index 0000000000000000000000000000000000000000..25878ed91338ee5ba85c6a338240562885ee3a46 --- /dev/null +++ b/ultralytics/docs/en/datasets/detect/coco.md @@ -0,0 +1,177 @@ +--- +comments: true +description: Explore the COCO dataset for object detection and segmentation. Learn about its structure, usage, pretrained models, and key features. +keywords: COCO dataset, object detection, segmentation, benchmarking, computer vision, pose estimation, YOLO models, COCO annotations +--- + +# COCO Dataset + +The [COCO](https://cocodataset.org/#home) (Common Objects in Context) dataset is a large-scale object detection, segmentation, and captioning dataset. It is designed to encourage research on a wide variety of object categories and is commonly used for benchmarking computer vision models. It is an essential dataset for researchers and developers working on object detection, segmentation, and pose estimation tasks. + +

+
+ +
+ Watch: Ultralytics COCO Dataset Overview +

+ +## COCO Pretrained Models + +| Model | size
(pixels) | mAPval
50-95 | Speed
CPU ONNX
(ms) | Speed
A100 TensorRT
(ms) | params
(M) | FLOPs
(B) | +| ------------------------------------------------------------------------------------ | --------------------- | -------------------- | ------------------------------ | ----------------------------------- | ------------------ | ----------------- | +| [YOLOv8n](https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt) | 640 | 37.3 | 80.4 | 0.99 | 3.2 | 8.7 | +| [YOLOv8s](https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8s.pt) | 640 | 44.9 | 128.4 | 1.20 | 11.2 | 28.6 | +| [YOLOv8m](https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8m.pt) | 640 | 50.2 | 234.7 | 1.83 | 25.9 | 78.9 | +| [YOLOv8l](https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8l.pt) | 640 | 52.9 | 375.2 | 2.39 | 43.7 | 165.2 | +| [YOLOv8x](https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8x.pt) | 640 | 53.9 | 479.1 | 3.53 | 68.2 | 257.8 | + +## Key Features + +- COCO contains 330K images, with 200K images having annotations for object detection, segmentation, and captioning tasks. +- The dataset comprises 80 object categories, including common objects like cars, bicycles, and animals, as well as more specific categories such as umbrellas, handbags, and sports equipment. +- Annotations include object bounding boxes, segmentation masks, and captions for each image. +- COCO provides standardized evaluation metrics like mean Average Precision (mAP) for object detection, and mean Average Recall (mAR) for segmentation tasks, making it suitable for comparing model performance. + +## Dataset Structure + +The COCO dataset is split into three subsets: + +1. **Train2017**: This subset contains 118K images for training object detection, segmentation, and captioning models. +2. **Val2017**: This subset has 5K images used for validation purposes during model training. +3. **Test2017**: This subset consists of 20K images used for testing and benchmarking the trained models. Ground truth annotations for this subset are not publicly available, and the results are submitted to the [COCO evaluation server](https://codalab.lisn.upsaclay.fr/competitions/7384) for performance evaluation. + +## Applications + +The COCO dataset is widely used for training and evaluating deep learning models in object detection (such as YOLO, Faster R-CNN, and SSD), instance segmentation (such as Mask R-CNN), and keypoint detection (such as OpenPose). The dataset's diverse set of object categories, large number of annotated images, and standardized evaluation metrics make it an essential resource for computer vision researchers and practitioners. + +## Dataset YAML + +A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. In the case of the COCO dataset, the `coco.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco.yaml). + +!!! example "ultralytics/cfg/datasets/coco.yaml" + + ```yaml + --8<-- "ultralytics/cfg/datasets/coco.yaml" + ``` + +## Usage + +To train a YOLOv8n model on the COCO dataset for 100 epochs with an image size of 640, you can use the following code snippets. For a comprehensive list of available arguments, refer to the model [Training](../../modes/train.md) page. + +!!! example "Train Example" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a model + model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training) + + # Train the model + results = model.train(data="coco.yaml", epochs=100, imgsz=640) + ``` + + === "CLI" + + ```bash + # Start training from a pretrained *.pt model + yolo detect train data=coco.yaml model=yolov8n.pt epochs=100 imgsz=640 + ``` + +## Sample Images and Annotations + +The COCO dataset contains a diverse set of images with various object categories and complex scenes. Here are some examples of images from the dataset, along with their corresponding annotations: + +![Dataset sample image](https://github.com/ultralytics/docs/releases/download/0/mosaiced-coco-dataset-sample.avif) + +- **Mosaiced Image**: This image demonstrates a training batch composed of mosaiced dataset images. Mosaicing is a technique used during training that combines multiple images into a single image to increase the variety of objects and scenes within each training batch. This helps improve the model's ability to generalize to different object sizes, aspect ratios, and contexts. + +The example showcases the variety and complexity of the images in the COCO dataset and the benefits of using mosaicing during the training process. + +## Citations and Acknowledgments + +If you use the COCO dataset in your research or development work, please cite the following paper: + +!!! quote "" + + === "BibTeX" + + ```bibtex + @misc{lin2015microsoft, + title={Microsoft COCO: Common Objects in Context}, + author={Tsung-Yi Lin and Michael Maire and Serge Belongie and Lubomir Bourdev and Ross Girshick and James Hays and Pietro Perona and Deva Ramanan and C. Lawrence Zitnick and Piotr Dollár}, + year={2015}, + eprint={1405.0312}, + archivePrefix={arXiv}, + primaryClass={cs.CV} + } + ``` + +We would like to acknowledge the COCO Consortium for creating and maintaining this valuable resource for the computer vision community. For more information about the COCO dataset and its creators, visit the [COCO dataset website](https://cocodataset.org/#home). + +## FAQ + +### What is the COCO dataset and why is it important for computer vision? + +The [COCO dataset](https://cocodataset.org/#home) (Common Objects in Context) is a large-scale dataset used for object detection, segmentation, and captioning. It contains 330K images with detailed annotations for 80 object categories, making it essential for benchmarking and training computer vision models. Researchers use COCO due to its diverse categories and standardized evaluation metrics like mean Average Precision (mAP). + +### How can I train a YOLO model using the COCO dataset? + +To train a YOLOv8 model using the COCO dataset, you can use the following code snippets: + +!!! example "Train Example" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a model + model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training) + + # Train the model + results = model.train(data="coco.yaml", epochs=100, imgsz=640) + ``` + + === "CLI" + + ```bash + # Start training from a pretrained *.pt model + yolo detect train data=coco.yaml model=yolov8n.pt epochs=100 imgsz=640 + ``` + +Refer to the [Training page](../../modes/train.md) for more details on available arguments. + +### What are the key features of the COCO dataset? + +The COCO dataset includes: + +- 330K images, with 200K annotated for object detection, segmentation, and captioning. +- 80 object categories ranging from common items like cars and animals to specific ones like handbags and sports equipment. +- Standardized evaluation metrics for object detection (mAP) and segmentation (mean Average Recall, mAR). +- **Mosaicing** technique in training batches to enhance model generalization across various object sizes and contexts. + +### Where can I find pretrained YOLOv8 models trained on the COCO dataset? + +Pretrained YOLOv8 models on the COCO dataset can be downloaded from the links provided in the documentation. Examples include: + +- [YOLOv8n](https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt) +- [YOLOv8s](https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8s.pt) +- [YOLOv8m](https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8m.pt) + +These models vary in size, mAP, and inference speed, providing options for different performance and resource requirements. + +### How is the COCO dataset structured and how do I use it? + +The COCO dataset is split into three subsets: + +1. **Train2017**: 118K images for training. +2. **Val2017**: 5K images for validation during training. +3. **Test2017**: 20K images for benchmarking trained models. Results need to be submitted to the [COCO evaluation server](https://codalab.lisn.upsaclay.fr/competitions/7384) for performance evaluation. + +The dataset's YAML configuration file is available at [coco.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco.yaml), which defines paths, classes, and dataset details. diff --git a/ultralytics/docs/en/datasets/detect/coco8.md b/ultralytics/docs/en/datasets/detect/coco8.md new file mode 100644 index 0000000000000000000000000000000000000000..a0972693ea43fce618a31cef2892aef63feeb3d3 --- /dev/null +++ b/ultralytics/docs/en/datasets/detect/coco8.md @@ -0,0 +1,135 @@ +--- +comments: true +description: Explore the Ultralytics COCO8 dataset, a versatile and manageable set of 8 images perfect for testing object detection models and training pipelines. +keywords: COCO8, Ultralytics, dataset, object detection, YOLOv8, training, validation, machine learning, computer vision +--- + +# COCO8 Dataset + +## Introduction + +[Ultralytics](https://www.ultralytics.com/) COCO8 is a small, but versatile object detection dataset composed of the first 8 images of the COCO train 2017 set, 4 for training and 4 for validation. This dataset is ideal for testing and debugging object detection models, or for experimenting with new detection approaches. With 8 images, it is small enough to be easily manageable, yet diverse enough to test training pipelines for errors and act as a sanity check before training larger datasets. + +

+
+ +
+ Watch: Ultralytics COCO Dataset Overview +

+ +This dataset is intended for use with Ultralytics [HUB](https://hub.ultralytics.com/) and [YOLOv8](https://github.com/ultralytics/ultralytics). + +## Dataset YAML + +A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. In the case of the COCO8 dataset, the `coco8.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco8.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco8.yaml). + +!!! example "ultralytics/cfg/datasets/coco8.yaml" + + ```yaml + --8<-- "ultralytics/cfg/datasets/coco8.yaml" + ``` + +## Usage + +To train a YOLOv8n model on the COCO8 dataset for 100 epochs with an image size of 640, you can use the following code snippets. For a comprehensive list of available arguments, refer to the model [Training](../../modes/train.md) page. + +!!! example "Train Example" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a model + model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training) + + # Train the model + results = model.train(data="coco8.yaml", epochs=100, imgsz=640) + ``` + + === "CLI" + + ```bash + # Start training from a pretrained *.pt model + yolo detect train data=coco8.yaml model=yolov8n.pt epochs=100 imgsz=640 + ``` + +## Sample Images and Annotations + +Here are some examples of images from the COCO8 dataset, along with their corresponding annotations: + +Dataset sample image + +- **Mosaiced Image**: This image demonstrates a training batch composed of mosaiced dataset images. Mosaicing is a technique used during training that combines multiple images into a single image to increase the variety of objects and scenes within each training batch. This helps improve the model's ability to generalize to different object sizes, aspect ratios, and contexts. + +The example showcases the variety and complexity of the images in the COCO8 dataset and the benefits of using mosaicing during the training process. + +## Citations and Acknowledgments + +If you use the COCO dataset in your research or development work, please cite the following paper: + +!!! quote "" + + === "BibTeX" + + ```bibtex + @misc{lin2015microsoft, + title={Microsoft COCO: Common Objects in Context}, + author={Tsung-Yi Lin and Michael Maire and Serge Belongie and Lubomir Bourdev and Ross Girshick and James Hays and Pietro Perona and Deva Ramanan and C. Lawrence Zitnick and Piotr Dollár}, + year={2015}, + eprint={1405.0312}, + archivePrefix={arXiv}, + primaryClass={cs.CV} + } + ``` + +We would like to acknowledge the COCO Consortium for creating and maintaining this valuable resource for the computer vision community. For more information about the COCO dataset and its creators, visit the [COCO dataset website](https://cocodataset.org/#home). + +## FAQ + +### What is the Ultralytics COCO8 dataset used for? + +The Ultralytics COCO8 dataset is a compact yet versatile object detection dataset consisting of the first 8 images from the COCO train 2017 set, with 4 images for training and 4 for validation. It is designed for testing and debugging object detection models and experimentation with new detection approaches. Despite its small size, COCO8 offers enough diversity to act as a sanity check for your training pipelines before deploying larger datasets. For more details, view the [COCO8 dataset](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco8.yaml). + +### How do I train a YOLOv8 model using the COCO8 dataset? + +To train a YOLOv8 model using the COCO8 dataset, you can employ either Python or CLI commands. Here's how you can start: + +!!! example "Train Example" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a model + model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training) + + # Train the model + results = model.train(data="coco8.yaml", epochs=100, imgsz=640) + ``` + + === "CLI" + + ```bash + # Start training from a pretrained *.pt model + yolo detect train data=coco8.yaml model=yolov8n.pt epochs=100 imgsz=640 + ``` + +For a comprehensive list of available arguments, refer to the model [Training](../../modes/train.md) page. + +### Why should I use Ultralytics HUB for managing my COCO8 training? + +Ultralytics HUB is an all-in-one web tool designed to simplify the training and deployment of YOLO models, including the Ultralytics YOLOv8 models on the COCO8 dataset. It offers cloud training, real-time tracking, and seamless dataset management. HUB allows you to start training with a single click and avoids the complexities of manual setups. Discover more about [Ultralytics HUB](https://hub.ultralytics.com/) and its benefits. + +### What are the benefits of using mosaic augmentation in training with the COCO8 dataset? + +Mosaic augmentation, demonstrated in the COCO8 dataset, combines multiple images into a single image during training. This technique increases the variety of objects and scenes in each training batch, improving the model's ability to generalize across different object sizes, aspect ratios, and contexts. This results in a more robust object detection model. For more details, refer to the [training guide](#usage). + +### How can I validate my YOLOv8 model trained on the COCO8 dataset? + +Validation of your YOLOv8 model trained on the COCO8 dataset can be performed using the model's validation commands. You can invoke the validation mode via CLI or Python script to evaluate the model's performance using precise metrics. For detailed instructions, visit the [Validation](../../modes/val.md) page. diff --git a/ultralytics/docs/en/datasets/detect/globalwheat2020.md b/ultralytics/docs/en/datasets/detect/globalwheat2020.md new file mode 100644 index 0000000000000000000000000000000000000000..37b9759f36a059da25ab28ae487187ea7ec2e38e --- /dev/null +++ b/ultralytics/docs/en/datasets/detect/globalwheat2020.md @@ -0,0 +1,145 @@ +--- +comments: true +description: Explore the Global Wheat Head Dataset to develop accurate wheat head detection models. Includes training images, annotations, and usage for crop management. +keywords: Global Wheat Head Dataset, wheat head detection, wheat phenotyping, crop management, deep learning, object detection, training datasets +--- + +# Global Wheat Head Dataset + +The [Global Wheat Head Dataset](https://www.global-wheat.com/) is a collection of images designed to support the development of accurate wheat head detection models for applications in wheat phenotyping and crop management. Wheat heads, also known as spikes, are the grain-bearing parts of the wheat plant. Accurate estimation of wheat head density and size is essential for assessing crop health, maturity, and yield potential. The dataset, created by a collaboration of nine research institutes from seven countries, covers multiple growing regions to ensure models generalize well across different environments. + +## Key Features + +- The dataset contains over 3,000 training images from Europe (France, UK, Switzerland) and North America (Canada). +- It includes approximately 1,000 test images from Australia, Japan, and China. +- Images are outdoor field images, capturing the natural variability in wheat head appearances. +- Annotations include wheat head bounding boxes to support object detection tasks. + +## Dataset Structure + +The Global Wheat Head Dataset is organized into two main subsets: + +1. **Training Set**: This subset contains over 3,000 images from Europe and North America. The images are labeled with wheat head bounding boxes, providing ground truth for training object detection models. +2. **Test Set**: This subset consists of approximately 1,000 images from Australia, Japan, and China. These images are used for evaluating the performance of trained models on unseen genotypes, environments, and observational conditions. + +## Applications + +The Global Wheat Head Dataset is widely used for training and evaluating deep learning models in wheat head detection tasks. The dataset's diverse set of images, capturing a wide range of appearances, environments, and conditions, make it a valuable resource for researchers and practitioners in the field of plant phenotyping and crop management. + +## Dataset YAML + +A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. For the case of the Global Wheat Head Dataset, the `GlobalWheat2020.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/GlobalWheat2020.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/GlobalWheat2020.yaml). + +!!! example "ultralytics/cfg/datasets/GlobalWheat2020.yaml" + + ```yaml + --8<-- "ultralytics/cfg/datasets/GlobalWheat2020.yaml" + ``` + +## Usage + +To train a YOLOv8n model on the Global Wheat Head Dataset for 100 epochs with an image size of 640, you can use the following code snippets. For a comprehensive list of available arguments, refer to the model [Training](../../modes/train.md) page. + +!!! example "Train Example" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a model + model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training) + + # Train the model + results = model.train(data="GlobalWheat2020.yaml", epochs=100, imgsz=640) + ``` + + === "CLI" + + ```bash + # Start training from a pretrained *.pt model + yolo detect train data=GlobalWheat2020.yaml model=yolov8n.pt epochs=100 imgsz=640 + ``` + +## Sample Data and Annotations + +The Global Wheat Head Dataset contains a diverse set of outdoor field images, capturing the natural variability in wheat head appearances, environments, and conditions. Here are some examples of data from the dataset, along with their corresponding annotations: + +![Dataset sample image](https://github.com/ultralytics/docs/releases/download/0/wheat-head-detection-sample.avif) + +- **Wheat Head Detection**: This image demonstrates an example of wheat head detection, where wheat heads are annotated with bounding boxes. The dataset provides a variety of images to facilitate the development of models for this task. + +The example showcases the variety and complexity of the data in the Global Wheat Head Dataset and highlights the importance of accurate wheat head detection for applications in wheat phenotyping and crop management. + +## Citations and Acknowledgments + +If you use the Global Wheat Head Dataset in your research or development work, please cite the following paper: + +!!! quote "" + + === "BibTeX" + + ```bibtex + @article{david2020global, + title={Global Wheat Head Detection (GWHD) Dataset: A Large and Diverse Dataset of High-Resolution RGB-Labelled Images to Develop and Benchmark Wheat Head Detection Methods}, + author={David, Etienne and Madec, Simon and Sadeghi-Tehran, Pouria and Aasen, Helge and Zheng, Bangyou and Liu, Shouyang and Kirchgessner, Norbert and Ishikawa, Goro and Nagasawa, Koichi and Badhon, Minhajul and others}, + journal={arXiv preprint arXiv:2005.02162}, + year={2020} + } + ``` + +We would like to acknowledge the researchers and institutions that contributed to the creation and maintenance of the Global Wheat Head Dataset as a valuable resource for the plant phenotyping and crop management research community. For more information about the dataset and its creators, visit the [Global Wheat Head Dataset website](https://www.global-wheat.com/). + +## FAQ + +### What is the Global Wheat Head Dataset used for? + +The Global Wheat Head Dataset is primarily used for developing and training deep learning models aimed at wheat head detection. This is crucial for applications in wheat phenotyping and crop management, allowing for more accurate estimations of wheat head density, size, and overall crop yield potential. Accurate detection methods help in assessing crop health and maturity, essential for efficient crop management. + +### How do I train a YOLOv8n model on the Global Wheat Head Dataset? + +To train a YOLOv8n model on the Global Wheat Head Dataset, you can use the following code snippets. Make sure you have the `GlobalWheat2020.yaml` configuration file specifying dataset paths and classes: + +!!! example "Train Example" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a pre-trained model (recommended for training) + model = YOLO("yolov8n.pt") + + # Train the model + results = model.train(data="GlobalWheat2020.yaml", epochs=100, imgsz=640) + ``` + + === "CLI" + + ```bash + # Start training from a pretrained *.pt model + yolo detect train data=GlobalWheat2020.yaml model=yolov8n.pt epochs=100 imgsz=640 + ``` + +For a comprehensive list of available arguments, refer to the model [Training](../../modes/train.md) page. + +### What are the key features of the Global Wheat Head Dataset? + +Key features of the Global Wheat Head Dataset include: + +- Over 3,000 training images from Europe (France, UK, Switzerland) and North America (Canada). +- Approximately 1,000 test images from Australia, Japan, and China. +- High variability in wheat head appearances due to different growing environments. +- Detailed annotations with wheat head bounding boxes to aid object detection models. + +These features facilitate the development of robust models capable of generalization across multiple regions. + +### Where can I find the configuration YAML file for the Global Wheat Head Dataset? + +The configuration YAML file for the Global Wheat Head Dataset, named `GlobalWheat2020.yaml`, is available on GitHub. You can access it at this [link](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/GlobalWheat2020.yaml). This file contains necessary information about dataset paths, classes, and other configuration details needed for model training in Ultralytics YOLO. + +### Why is wheat head detection important in crop management? + +Wheat head detection is critical in crop management because it enables accurate estimation of wheat head density and size, which are essential for evaluating crop health, maturity, and yield potential. By leveraging deep learning models trained on datasets like the Global Wheat Head Dataset, farmers and researchers can better monitor and manage crops, leading to improved productivity and optimized resource use in agricultural practices. This technological advancement supports sustainable agriculture and food security initiatives. + +For more information on applications of AI in agriculture, visit [AI in Agriculture](https://www.ultralytics.com/solutions/ai-in-agriculture). diff --git a/ultralytics/docs/en/datasets/detect/index.md b/ultralytics/docs/en/datasets/detect/index.md new file mode 100644 index 0000000000000000000000000000000000000000..f76ba40bc2516cfb8ebe155ad5d7742110ca0893 --- /dev/null +++ b/ultralytics/docs/en/datasets/detect/index.md @@ -0,0 +1,188 @@ +--- +comments: true +description: Learn about dataset formats compatible with Ultralytics YOLO for robust object detection. Explore supported datasets and learn how to convert formats. +keywords: Ultralytics, YOLO, object detection datasets, dataset formats, COCO, dataset conversion, training datasets +--- + +# Object Detection Datasets Overview + +Training a robust and accurate object detection model requires a comprehensive dataset. This guide introduces various formats of datasets that are compatible with the Ultralytics YOLO model and provides insights into their structure, usage, and how to convert between different formats. + +## Supported Dataset Formats + +### Ultralytics YOLO format + +The Ultralytics YOLO format is a dataset configuration format that allows you to define the dataset root directory, the relative paths to training/validation/testing image directories or `*.txt` files containing image paths, and a dictionary of class names. Here is an example: + +```yaml +# 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, ..] +path: ../datasets/coco8 # dataset root dir +train: images/train # train images (relative to 'path') 4 images +val: images/val # val images (relative to 'path') 4 images +test: # test images (optional) + +# Classes (80 COCO classes) +names: + 0: person + 1: bicycle + 2: car + # ... + 77: teddy bear + 78: hair drier + 79: toothbrush +``` + +Labels for this format should be exported to YOLO format with one `*.txt` file per image. If there are no objects in an image, no `*.txt` file is required. The `*.txt` file should be formatted with one row per object in `class x_center y_center width height` format. Box coordinates must be in **normalized xywh** format (from 0 to 1). If your boxes are in pixels, you should divide `x_center` and `width` by image width, and `y_center` and `height` by image height. Class numbers should be zero-indexed (start with 0). + +

Example labelled image

+ +The label file corresponding to the above image contains 2 persons (class `0`) and a tie (class `27`): + +

Example label file

+ +When using the Ultralytics YOLO format, organize your training and validation images and labels as shown in the [COCO8 dataset](coco8.md) example below. + +

Example dataset directory structure

+ +## Usage + +Here's how you can use these formats to train your model: + +!!! example + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a model + model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training) + + # Train the model + results = model.train(data="coco8.yaml", epochs=100, imgsz=640) + ``` + + === "CLI" + + ```bash + # Start training from a pretrained *.pt model + yolo detect train data=coco8.yaml model=yolov8n.pt epochs=100 imgsz=640 + ``` + +## Supported Datasets + +Here is a list of the supported datasets and a brief description for each: + +- [Argoverse](argoverse.md): A dataset containing 3D tracking and motion forecasting data from urban environments with rich annotations. +- [COCO](coco.md): Common Objects in Context (COCO) is a large-scale object detection, segmentation, and captioning dataset with 80 object categories. +- [LVIS](lvis.md): A large-scale object detection, segmentation, and captioning dataset with 1203 object categories. +- [COCO8](coco8.md): A smaller subset of the first 4 images from COCO train and COCO val, suitable for quick tests. +- [COCO128](coco.md): A smaller subset of the first 128 images from COCO train and COCO val, suitable for tests. +- [Global Wheat 2020](globalwheat2020.md): A dataset containing images of wheat heads for the Global Wheat Challenge 2020. +- [Objects365](objects365.md): A high-quality, large-scale dataset for object detection with 365 object categories and over 600K annotated images. +- [OpenImagesV7](open-images-v7.md): A comprehensive dataset by Google with 1.7M train images and 42k validation images. +- [SKU-110K](sku-110k.md): A dataset featuring dense object detection in retail environments with over 11K images and 1.7 million bounding boxes. +- [VisDrone](visdrone.md): A dataset containing object detection and multi-object tracking data from drone-captured imagery with over 10K images and video sequences. +- [VOC](voc.md): The Pascal Visual Object Classes (VOC) dataset for object detection and segmentation with 20 object classes and over 11K images. +- [xView](xview.md): A dataset for object detection in overhead imagery with 60 object categories and over 1 million annotated objects. +- [Roboflow 100](roboflow-100.md): A diverse object detection benchmark with 100 datasets spanning seven imagery domains for comprehensive model evaluation. +- [Brain-tumor](brain-tumor.md): A dataset for detecting brain tumors includes MRI or CT scan images with details on tumor presence, location, and characteristics. +- [African-wildlife](african-wildlife.md): A dataset featuring images of African wildlife, including buffalo, elephant, rhino, and zebras. +- [Signature](signature.md): A dataset featuring images of various documents with annotated signatures, supporting document verification and fraud detection research. + +### Adding your own dataset + +If you have your own dataset and would like to use it for training detection models with Ultralytics YOLO format, ensure that it follows the format specified above under "Ultralytics YOLO format". Convert your annotations to the required format and specify the paths, number of classes, and class names in the YAML configuration file. + +## Port or Convert Label Formats + +### COCO Dataset Format to YOLO Format + +You can easily convert labels from the popular COCO dataset format to the YOLO format using the following code snippet: + +!!! example + + === "Python" + + ```python + from ultralytics.data.converter import convert_coco + + convert_coco(labels_dir="path/to/coco/annotations/") + ``` + +This conversion tool can be used to convert the COCO dataset or any dataset in the COCO format to the Ultralytics YOLO format. + +Remember to double-check if the dataset you want to use is compatible with your model and follows the necessary format conventions. Properly formatted datasets are crucial for training successful object detection models. + +## FAQ + +### What is the Ultralytics YOLO dataset format and how to structure it? + +The Ultralytics YOLO format is a structured configuration for defining datasets in your training projects. It involves setting paths to your training, validation, and testing images and corresponding labels. For example: + +```yaml +path: ../datasets/coco8 # dataset root directory +train: images/train # training images (relative to 'path') +val: images/val # validation images (relative to 'path') +test: # optional test images +names: + 0: person + 1: bicycle + 2: car + # ... +``` + +Labels are saved in `*.txt` files with one file per image, formatted as `class x_center y_center width height` with normalized coordinates. For a detailed guide, see the [COCO8 dataset example](coco8.md). + +### How do I convert a COCO dataset to the YOLO format? + +You can convert a COCO dataset to the YOLO format using the Ultralytics conversion tools. Here's a quick method: + +```python +from ultralytics.data.converter import convert_coco + +convert_coco(labels_dir="path/to/coco/annotations/") +``` + +This code will convert your COCO annotations to YOLO format, enabling seamless integration with Ultralytics YOLO models. For additional details, visit the [Port or Convert Label Formats](#port-or-convert-label-formats) section. + +### Which datasets are supported by Ultralytics YOLO for object detection? + +Ultralytics YOLO supports a wide range of datasets, including: + +- [Argoverse](argoverse.md) +- [COCO](coco.md) +- [LVIS](lvis.md) +- [COCO8](coco8.md) +- [Global Wheat 2020](globalwheat2020.md) +- [Objects365](objects365.md) +- [OpenImagesV7](open-images-v7.md) + +Each dataset page provides detailed information on the structure and usage tailored for efficient YOLOv8 training. Explore the full list in the [Supported Datasets](#supported-datasets) section. + +### How do I start training a YOLOv8 model using my dataset? + +To start training a YOLOv8 model, ensure your dataset is formatted correctly and the paths are defined in a YAML file. Use the following script to begin training: + +!!! example + + === "Python" + + ```python + from ultralytics import YOLO + + model = YOLO("yolov8n.pt") # Load a pretrained model + results = model.train(data="path/to/your_dataset.yaml", epochs=100, imgsz=640) + ``` + + === "CLI" + + ```bash + yolo detect train data=path/to/your_dataset.yaml model=yolov8n.pt epochs=100 imgsz=640 + ``` + +Refer to the [Usage](#usage) section for more details on utilizing different modes, including CLI commands. + +### Where can I find practical examples of using Ultralytics YOLO for object detection? + +Ultralytics provides numerous examples and practical guides for using YOLOv8 in diverse applications. For a comprehensive overview, visit the [Ultralytics Blog](https://www.ultralytics.com/blog) where you can find case studies, detailed tutorials, and community stories showcasing object detection, segmentation, and more with YOLOv8. For specific examples, check the [Usage](../../modes/predict.md) section in the documentation. diff --git a/ultralytics/docs/en/datasets/detect/lvis.md b/ultralytics/docs/en/datasets/detect/lvis.md new file mode 100644 index 0000000000000000000000000000000000000000..8c06920fd6db41a6e87c7c2542741f63d818c486 --- /dev/null +++ b/ultralytics/docs/en/datasets/detect/lvis.md @@ -0,0 +1,159 @@ +--- +comments: true +description: Discover the LVIS dataset by Facebook AI Research, a benchmark for object detection and instance segmentation with a large, diverse vocabulary. Learn how to utilize it. +keywords: LVIS dataset, object detection, instance segmentation, Facebook AI Research, YOLO, computer vision, model training, LVIS examples +--- + +# LVIS Dataset + +The [LVIS dataset](https://www.lvisdataset.org/) is a large-scale, fine-grained vocabulary-level annotation dataset developed and released by Facebook AI Research (FAIR). It is primarily used as a research benchmark for object detection and instance segmentation with a large vocabulary of categories, aiming to drive further advancements in computer vision field. + +

+
+ +
+ Watch: YOLO World training workflow with LVIS dataset +

+ +

+ LVIS Dataset example images +

+ +## Key Features + +- LVIS contains 160k images and 2M instance annotations for object detection, segmentation, and captioning tasks. +- The dataset comprises 1203 object categories, including common objects like cars, bicycles, and animals, as well as more specific categories such as umbrellas, handbags, and sports equipment. +- Annotations include object bounding boxes, segmentation masks, and captions for each image. +- LVIS provides standardized evaluation metrics like mean Average Precision (mAP) for object detection, and mean Average Recall (mAR) for segmentation tasks, making it suitable for comparing model performance. +- LVIS uses exactly the same images as [COCO](./coco.md) dataset, but with different splits and different annotations. + +## Dataset Structure + +The LVIS dataset is split into three subsets: + +1. **Train**: This subset contains 100k images for training object detection, segmentation, and captioning models. +2. **Val**: This subset has 20k images used for validation purposes during model training. +3. **Minival**: This subset is exactly the same as COCO val2017 set which has 5k images used for validation purposes during model training. +4. **Test**: This subset consists of 20k images used for testing and benchmarking the trained models. Ground truth annotations for this subset are not publicly available, and the results are submitted to the [LVIS evaluation server](https://eval.ai/web/challenges/challenge-page/675/overview) for performance evaluation. + +## Applications + +The LVIS dataset is widely used for training and evaluating deep learning models in object detection (such as YOLO, Faster R-CNN, and SSD), instance segmentation (such as Mask R-CNN). The dataset's diverse set of object categories, large number of annotated images, and standardized evaluation metrics make it an essential resource for computer vision researchers and practitioners. + +## Dataset YAML + +A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. In the case of the LVIS dataset, the `lvis.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/lvis.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/lvis.yaml). + +!!! example "ultralytics/cfg/datasets/lvis.yaml" + + ```yaml + --8<-- "ultralytics/cfg/datasets/lvis.yaml" + ``` + +## Usage + +To train a YOLOv8n model on the LVIS dataset for 100 epochs with an image size of 640, you can use the following code snippets. For a comprehensive list of available arguments, refer to the model [Training](../../modes/train.md) page. + +!!! example "Train Example" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a model + model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training) + + # Train the model + results = model.train(data="lvis.yaml", epochs=100, imgsz=640) + ``` + + === "CLI" + + ```bash + # Start training from a pretrained *.pt model + yolo detect train data=lvis.yaml model=yolov8n.pt epochs=100 imgsz=640 + ``` + +## Sample Images and Annotations + +The LVIS dataset contains a diverse set of images with various object categories and complex scenes. Here are some examples of images from the dataset, along with their corresponding annotations: + +![LVIS Dataset sample image](https://github.com/ultralytics/docs/releases/download/0/lvis-mosaiced-training-batch.avif) + +- **Mosaiced Image**: This image demonstrates a training batch composed of mosaiced dataset images. Mosaicing is a technique used during training that combines multiple images into a single image to increase the variety of objects and scenes within each training batch. This helps improve the model's ability to generalize to different object sizes, aspect ratios, and contexts. + +The example showcases the variety and complexity of the images in the LVIS dataset and the benefits of using mosaicing during the training process. + +## Citations and Acknowledgments + +If you use the LVIS dataset in your research or development work, please cite the following paper: + +!!! quote "" + + === "BibTeX" + + ```bibtex + @inproceedings{gupta2019lvis, + title={LVIS: A Dataset for Large Vocabulary Instance Segmentation}, + author={Gupta, Agrim and Dollar, Piotr and Girshick, Ross}, + booktitle={Proceedings of the {IEEE} Conference on Computer Vision and Pattern Recognition}, + year={2019} + } + ``` + +We would like to acknowledge the LVIS Consortium for creating and maintaining this valuable resource for the computer vision community. For more information about the LVIS dataset and its creators, visit the [LVIS dataset website](https://www.lvisdataset.org/). + +## FAQ + +### What is the LVIS dataset, and how is it used in computer vision? + +The [LVIS dataset](https://www.lvisdataset.org/) is a large-scale dataset with fine-grained vocabulary-level annotations developed by Facebook AI Research (FAIR). It is primarily used for object detection and instance segmentation, featuring over 1203 object categories and 2 million instance annotations. Researchers and practitioners use it to train and benchmark models like Ultralytics YOLO for advanced computer vision tasks. The dataset's extensive size and diversity make it an essential resource for pushing the boundaries of model performance in detection and segmentation. + +### How can I train a YOLOv8n model using the LVIS dataset? + +To train a YOLOv8n model on the LVIS dataset for 100 epochs with an image size of 640, follow the example below. This process utilizes Ultralytics' framework, which offers comprehensive training features. + +!!! example "Train Example" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a model + model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training) + + # Train the model + results = model.train(data="lvis.yaml", epochs=100, imgsz=640) + ``` + + + === "CLI" + + ```bash + # Start training from a pretrained *.pt model + yolo detect train data=lvis.yaml model=yolov8n.pt epochs=100 imgsz=640 + ``` + +For detailed training configurations, refer to the [Training](../../modes/train.md) documentation. + +### How does the LVIS dataset differ from the COCO dataset? + +The images in the LVIS dataset are the same as those in the [COCO dataset](./coco.md), but the two differ in terms of splitting and annotations. LVIS provides a larger and more detailed vocabulary with 1203 object categories compared to COCO's 80 categories. Additionally, LVIS focuses on annotation completeness and diversity, aiming to push the limits of object detection and instance segmentation models by offering more nuanced and comprehensive data. + +### Why should I use Ultralytics YOLO for training on the LVIS dataset? + +Ultralytics YOLO models, including the latest YOLOv8, are optimized for real-time object detection with state-of-the-art accuracy and speed. They support a wide range of annotations, such as the fine-grained ones provided by the LVIS dataset, making them ideal for advanced computer vision applications. Moreover, Ultralytics offers seamless integration with various [training](../../modes/train.md), [validation](../../modes/val.md), and [prediction](../../modes/predict.md) modes, ensuring efficient model development and deployment. + +### Can I see some sample annotations from the LVIS dataset? + +Yes, the LVIS dataset includes a variety of images with diverse object categories and complex scenes. Here is an example of a sample image along with its annotations: + +![LVIS Dataset sample image](https://github.com/ultralytics/docs/releases/download/0/lvis-mosaiced-training-batch.avif) + +This mosaiced image demonstrates a training batch composed of multiple dataset images combined into one. Mosaicing increases the variety of objects and scenes within each training batch, enhancing the model's ability to generalize across different contexts. For more details on the LVIS dataset, explore the [LVIS dataset documentation](#key-features). diff --git a/ultralytics/docs/en/datasets/detect/objects365.md b/ultralytics/docs/en/datasets/detect/objects365.md new file mode 100644 index 0000000000000000000000000000000000000000..f2b44f245a10b302381e45ecd5ec5296bdc47de2 --- /dev/null +++ b/ultralytics/docs/en/datasets/detect/objects365.md @@ -0,0 +1,141 @@ +--- +comments: true +description: Explore the Objects365 Dataset with 2M images and 30M bounding boxes across 365 categories. Enhance your object detection models with diverse, high-quality data. +keywords: Objects365 dataset, object detection, machine learning, deep learning, computer vision, annotated images, bounding boxes, YOLOv8, high-resolution images, dataset configuration +--- + +# Objects365 Dataset + +The [Objects365](https://www.objects365.org/) dataset is a large-scale, high-quality dataset designed to foster object detection research with a focus on diverse objects in the wild. Created by a team of [Megvii](https://en.megvii.com/) researchers, the dataset offers a wide range of high-resolution images with a comprehensive set of annotated bounding boxes covering 365 object categories. + +## Key Features + +- Objects365 contains 365 object categories, with 2 million images and over 30 million bounding boxes. +- The dataset includes diverse objects in various scenarios, providing a rich and challenging benchmark for object detection tasks. +- Annotations include bounding boxes for objects, making it suitable for training and evaluating object detection models. +- Objects365 pre-trained models significantly outperform ImageNet pre-trained models, leading to better generalization on various tasks. + +## Dataset Structure + +The Objects365 dataset is organized into a single set of images with corresponding annotations: + +- **Images**: The dataset includes 2 million high-resolution images, each containing a variety of objects across 365 categories. +- **Annotations**: The images are annotated with over 30 million bounding boxes, providing comprehensive ground truth information for object detection tasks. + +## Applications + +The Objects365 dataset is widely used for training and evaluating deep learning models in object detection tasks. The dataset's diverse set of object categories and high-quality annotations make it a valuable resource for researchers and practitioners in the field of computer vision. + +## Dataset YAML + +A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. For the case of the Objects365 Dataset, the `Objects365.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/Objects365.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/Objects365.yaml). + +!!! example "ultralytics/cfg/datasets/Objects365.yaml" + + ```yaml + --8<-- "ultralytics/cfg/datasets/Objects365.yaml" + ``` + +## Usage + +To train a YOLOv8n model on the Objects365 dataset for 100 epochs with an image size of 640, you can use the following code snippets. For a comprehensive list of available arguments, refer to the model [Training](../../modes/train.md) page. + +!!! example "Train Example" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a model + model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training) + + # Train the model + results = model.train(data="Objects365.yaml", epochs=100, imgsz=640) + ``` + + === "CLI" + + ```bash + # Start training from a pretrained *.pt model + yolo detect train data=Objects365.yaml model=yolov8n.pt epochs=100 imgsz=640 + ``` + +## Sample Data and Annotations + +The Objects365 dataset contains a diverse set of high-resolution images with objects from 365 categories, providing rich context for object detection tasks. Here are some examples of the images in the dataset: + +![Dataset sample image](https://github.com/ultralytics/docs/releases/download/0/objects365-sample-image.avif) + +- **Objects365**: This image demonstrates an example of object detection, where objects are annotated with bounding boxes. The dataset provides a wide range of images to facilitate the development of models for this task. + +The example showcases the variety and complexity of the data in the Objects365 dataset and highlights the importance of accurate object detection for computer vision applications. + +## Citations and Acknowledgments + +If you use the Objects365 dataset in your research or development work, please cite the following paper: + +!!! quote "" + + === "BibTeX" + + ```bibtex + @inproceedings{shao2019objects365, + title={Objects365: A Large-scale, High-quality Dataset for Object Detection}, + author={Shao, Shuai and Li, Zeming and Zhang, Tianyuan and Peng, Chao and Yu, Gang and Li, Jing and Zhang, Xiangyu and Sun, Jian}, + booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision}, + pages={8425--8434}, + year={2019} + } + ``` + +We would like to acknowledge the team of researchers who created and maintain the Objects365 dataset as a valuable resource for the computer vision research community. For more information about the Objects365 dataset and its creators, visit the [Objects365 dataset website](https://www.objects365.org/). + +## FAQ + +### What is the Objects365 dataset used for? + +The [Objects365 dataset](https://www.objects365.org/) is designed for object detection tasks in machine learning and computer vision. It provides a large-scale, high-quality dataset with 2 million annotated images and 30 million bounding boxes across 365 categories. Leveraging such a diverse dataset helps improve the performance and generalization of object detection models, making it invaluable for research and development in the field. + +### How can I train a YOLOv8 model on the Objects365 dataset? + +To train a YOLOv8n model using the Objects365 dataset for 100 epochs with an image size of 640, follow these instructions: + +!!! example "Train Example" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a model + model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training) + + # Train the model + results = model.train(data="Objects365.yaml", epochs=100, imgsz=640) + ``` + + === "CLI" + + ```bash + # Start training from a pretrained *.pt model + yolo detect train data=Objects365.yaml model=yolov8n.pt epochs=100 imgsz=640 + ``` + +Refer to the [Training](../../modes/train.md) page for a comprehensive list of available arguments. + +### Why should I use the Objects365 dataset for my object detection projects? + +The Objects365 dataset offers several advantages for object detection tasks: + +1. **Diversity**: It includes 2 million images with objects in diverse scenarios, covering 365 categories. +2. **High-quality Annotations**: Over 30 million bounding boxes provide comprehensive ground truth data. +3. **Performance**: Models pre-trained on Objects365 significantly outperform those trained on datasets like ImageNet, leading to better generalization. + +### Where can I find the YAML configuration file for the Objects365 dataset? + +The YAML configuration file for the Objects365 dataset is available at [Objects365.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/Objects365.yaml). This file contains essential information such as dataset paths and class labels, crucial for setting up your training environment. + +### How does the dataset structure of Objects365 enhance object detection modeling? + +The [Objects365 dataset](https://www.objects365.org/) is organized with 2 million high-resolution images and comprehensive annotations of over 30 million bounding boxes. This structure ensures a robust dataset for training deep learning models in object detection, offering a wide variety of objects and scenarios. Such diversity and volume help in developing models that are more accurate and capable of generalizing well to real-world applications. For more details on the dataset structure, refer to the [Dataset YAML](#dataset-yaml) section. diff --git a/ultralytics/docs/en/datasets/detect/open-images-v7.md b/ultralytics/docs/en/datasets/detect/open-images-v7.md new file mode 100644 index 0000000000000000000000000000000000000000..f6b0c63bc47ac9464c8873706402d1de915d74e3 --- /dev/null +++ b/ultralytics/docs/en/datasets/detect/open-images-v7.md @@ -0,0 +1,200 @@ +--- +comments: true +description: Explore the comprehensive Open Images V7 dataset by Google. Learn about its annotations, applications, and use YOLOv8 pretrained models for computer vision tasks. +keywords: Open Images V7, Google dataset, computer vision, YOLOv8 models, object detection, image segmentation, visual relationships, AI research, Ultralytics +--- + +# Open Images V7 Dataset + +[Open Images V7](https://storage.googleapis.com/openimages/web/index.html) is a versatile and expansive dataset championed by Google. Aimed at propelling research in the realm of computer vision, it boasts a vast collection of images annotated with a plethora of data, including image-level labels, object bounding boxes, object segmentation masks, visual relationships, and localized narratives. + +

+
+ +
+ Watch: Object Detection using OpenImagesV7 Pretrained Model +

+ +## Open Images V7 Pretrained Models + +| Model | size
(pixels) | mAPval
50-95 | Speed
CPU ONNX
(ms) | Speed
A100 TensorRT
(ms) | params
(M) | FLOPs
(B) | +| ----------------------------------------------------------------------------------------- | --------------------- | -------------------- | ------------------------------ | ----------------------------------- | ------------------ | ----------------- | +| [YOLOv8n](https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n-oiv7.pt) | 640 | 18.4 | 142.4 | 1.21 | 3.5 | 10.5 | +| [YOLOv8s](https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8s-oiv7.pt) | 640 | 27.7 | 183.1 | 1.40 | 11.4 | 29.7 | +| [YOLOv8m](https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8m-oiv7.pt) | 640 | 33.6 | 408.5 | 2.26 | 26.2 | 80.6 | +| [YOLOv8l](https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8l-oiv7.pt) | 640 | 34.9 | 596.9 | 2.43 | 44.1 | 167.4 | +| [YOLOv8x](https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8x-oiv7.pt) | 640 | 36.3 | 860.6 | 3.56 | 68.7 | 260.6 | + +![Open Images V7 classes visual](https://github.com/ultralytics/docs/releases/download/0/open-images-v7-classes-visual.avif) + +## Key Features + +- Encompasses ~9M images annotated in various ways to suit multiple computer vision tasks. +- Houses a staggering 16M bounding boxes across 600 object classes in 1.9M images. These boxes are primarily hand-drawn by experts ensuring high precision. +- Visual relationship annotations totaling 3.3M are available, detailing 1,466 unique relationship triplets, object properties, and human activities. +- V5 introduced segmentation masks for 2.8M objects across 350 classes. +- V6 introduced 675k localized narratives that amalgamate voice, text, and mouse traces highlighting described objects. +- V7 introduced 66.4M point-level labels on 1.4M images, spanning 5,827 classes. +- Encompasses 61.4M image-level labels across a diverse set of 20,638 classes. +- Provides a unified platform for image classification, object detection, relationship detection, instance segmentation, and multimodal image descriptions. + +## Dataset Structure + +Open Images V7 is structured in multiple components catering to varied computer vision challenges: + +- **Images**: About 9 million images, often showcasing intricate scenes with an average of 8.3 objects per image. +- **Bounding Boxes**: Over 16 million boxes that demarcate objects across 600 categories. +- **Segmentation Masks**: These detail the exact boundary of 2.8M objects across 350 classes. +- **Visual Relationships**: 3.3M annotations indicating object relationships, properties, and actions. +- **Localized Narratives**: 675k descriptions combining voice, text, and mouse traces. +- **Point-Level Labels**: 66.4M labels across 1.4M images, suitable for zero/few-shot semantic segmentation. + +## Applications + +Open Images V7 is a cornerstone for training and evaluating state-of-the-art models in various computer vision tasks. The dataset's broad scope and high-quality annotations make it indispensable for researchers and developers specializing in computer vision. + +## Dataset YAML + +Typically, datasets come with a YAML (Yet Another Markup Language) file that delineates the dataset's configuration. For the case of Open Images V7, a hypothetical `OpenImagesV7.yaml` might exist. For accurate paths and configurations, one should refer to the dataset's official repository or documentation. + +!!! example "OpenImagesV7.yaml" + + ```yaml + --8<-- "ultralytics/cfg/datasets/open-images-v7.yaml" + ``` + +## Usage + +To train a YOLOv8n model on the Open Images V7 dataset for 100 epochs with an image size of 640, you can use the following code snippets. For a comprehensive list of available arguments, refer to the model [Training](../../modes/train.md) page. + +!!! warning + + The complete Open Images V7 dataset comprises 1,743,042 training images and 41,620 validation images, requiring approximately **561 GB of storage space** upon download. + + Executing the commands provided below will trigger an automatic download of the full dataset if it's not already present locally. Before running the below example it's crucial to: + + - Verify that your device has enough storage capacity. + - Ensure a robust and speedy internet connection. + +!!! example "Train Example" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a COCO-pretrained YOLOv8n model + model = YOLO("yolov8n.pt") + + # Train the model on the Open Images V7 dataset + results = model.train(data="open-images-v7.yaml", epochs=100, imgsz=640) + ``` + + === "CLI" + + ```bash + # Train a COCO-pretrained YOLOv8n model on the Open Images V7 dataset + yolo detect train data=open-images-v7.yaml model=yolov8n.pt epochs=100 imgsz=640 + ``` + +## Sample Data and Annotations + +Illustrations of the dataset help provide insights into its richness: + +![Dataset sample image](https://github.com/ultralytics/docs/releases/download/0/oidv7-all-in-one-example-ab.avif) + +- **Open Images V7**: This image exemplifies the depth and detail of annotations available, including bounding boxes, relationships, and segmentation masks. + +Researchers can gain invaluable insights into the array of computer vision challenges that the dataset addresses, from basic object detection to intricate relationship identification. + +## Citations and Acknowledgments + +For those employing Open Images V7 in their work, it's prudent to cite the relevant papers and acknowledge the creators: + +!!! quote "" + + === "BibTeX" + + ```bibtex + @article{OpenImages, + author = {Alina Kuznetsova and Hassan Rom and Neil Alldrin and Jasper Uijlings and Ivan Krasin and Jordi Pont-Tuset and Shahab Kamali and Stefan Popov and Matteo Malloci and Alexander Kolesnikov and Tom Duerig and Vittorio Ferrari}, + title = {The Open Images Dataset V4: Unified image classification, object detection, and visual relationship detection at scale}, + year = {2020}, + journal = {IJCV} + } + ``` + +A heartfelt acknowledgment goes out to the Google AI team for creating and maintaining the Open Images V7 dataset. For a deep dive into the dataset and its offerings, navigate to the [official Open Images V7 website](https://storage.googleapis.com/openimages/web/index.html). + +## FAQ + +### What is the Open Images V7 dataset? + +Open Images V7 is an extensive and versatile dataset created by Google, designed to advance research in computer vision. It includes image-level labels, object bounding boxes, object segmentation masks, visual relationships, and localized narratives, making it ideal for various computer vision tasks such as object detection, segmentation, and relationship detection. + +### How do I train a YOLOv8 model on the Open Images V7 dataset? + +To train a YOLOv8 model on the Open Images V7 dataset, you can use both Python and CLI commands. Here's an example of training the YOLOv8n model for 100 epochs with an image size of 640: + +!!! example "Train Example" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a COCO-pretrained YOLOv8n model + model = YOLO("yolov8n.pt") + + # Train the model on the Open Images V7 dataset + results = model.train(data="open-images-v7.yaml", epochs=100, imgsz=640) + ``` + + + === "CLI" + + ```bash + # Train a COCO-pretrained YOLOv8n model on the Open Images V7 dataset + yolo detect train data=open-images-v7.yaml model=yolov8n.pt epochs=100 imgsz=640 + ``` + +For more details on arguments and settings, refer to the [Training](../../modes/train.md) page. + +### What are some key features of the Open Images V7 dataset? + +The Open Images V7 dataset includes approximately 9 million images with various annotations: + +- **Bounding Boxes**: 16 million bounding boxes across 600 object classes. +- **Segmentation Masks**: Masks for 2.8 million objects across 350 classes. +- **Visual Relationships**: 3.3 million annotations indicating relationships, properties, and actions. +- **Localized Narratives**: 675,000 descriptions combining voice, text, and mouse traces. +- **Point-Level Labels**: 66.4 million labels across 1.4 million images. +- **Image-Level Labels**: 61.4 million labels across 20,638 classes. + +### What pretrained models are available for the Open Images V7 dataset? + +Ultralytics provides several YOLOv8 pretrained models for the Open Images V7 dataset, each with different sizes and performance metrics: + +| Model | size
(pixels) | mAPval
50-95 | Speed
CPU ONNX
(ms) | Speed
A100 TensorRT
(ms) | params
(M) | FLOPs
(B) | +| ----------------------------------------------------------------------------------------- | --------------------- | -------------------- | ------------------------------ | ----------------------------------- | ------------------ | ----------------- | +| [YOLOv8n](https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n-oiv7.pt) | 640 | 18.4 | 142.4 | 1.21 | 3.5 | 10.5 | +| [YOLOv8s](https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8s-oiv7.pt) | 640 | 27.7 | 183.1 | 1.40 | 11.4 | 29.7 | +| [YOLOv8m](https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8m-oiv7.pt) | 640 | 33.6 | 408.5 | 2.26 | 26.2 | 80.6 | +| [YOLOv8l](https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8l-oiv7.pt) | 640 | 34.9 | 596.9 | 2.43 | 44.1 | 167.4 | +| [YOLOv8x](https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8x-oiv7.pt) | 640 | 36.3 | 860.6 | 3.56 | 68.7 | 260.6 | + +### What applications can the Open Images V7 dataset be used for? + +The Open Images V7 dataset supports a variety of computer vision tasks including: + +- **Image Classification** +- **Object Detection** +- **Instance Segmentation** +- **Visual Relationship Detection** +- **Multimodal Image Descriptions** + +Its comprehensive annotations and broad scope make it suitable for training and evaluating advanced machine learning models, as highlighted in practical use cases detailed in our [applications](#applications) section. diff --git a/ultralytics/docs/en/datasets/detect/roboflow-100.md b/ultralytics/docs/en/datasets/detect/roboflow-100.md new file mode 100644 index 0000000000000000000000000000000000000000..844326c38127dcddf95fc1a2cc8519caf88a4ec2 --- /dev/null +++ b/ultralytics/docs/en/datasets/detect/roboflow-100.md @@ -0,0 +1,218 @@ +--- +comments: true +description: Explore the Roboflow 100 dataset featuring 100 diverse datasets designed to test object detection models across various domains, from healthcare to video games. +keywords: Roboflow 100, Ultralytics, object detection, dataset, benchmarking, machine learning, computer vision, diverse datasets, model evaluation +--- + +# Roboflow 100 Dataset + +Roboflow 100, developed by [Roboflow](https://roboflow.com/?ref=ultralytics) and sponsored by Intel, is a groundbreaking [object detection](../../tasks/detect.md) benchmark. It includes 100 diverse datasets sampled from over 90,000 public datasets. This benchmark is designed to test the adaptability of models to various domains, including healthcare, aerial imagery, and video games. + +

+ Roboflow 100 Overview +

+ +## Key Features + +- Includes 100 datasets across seven domains: Aerial, Video games, Microscopic, Underwater, Documents, Electromagnetic, and Real World. +- The benchmark comprises 224,714 images across 805 classes, thanks to over 11,170 hours of labeling efforts. +- All images are resized to 640x640 pixels, with a focus on eliminating class ambiguity and filtering out underrepresented classes. +- Annotations include bounding boxes for objects, making it suitable for [training](../../modes/train.md) and evaluating object detection models. + +## Dataset Structure + +The Roboflow 100 dataset is organized into seven categories, each with a distinct set of datasets, images, and classes: + +- **Aerial**: Consists of 7 datasets with a total of 9,683 images, covering 24 distinct classes. +- **Video Games**: Includes 7 datasets, featuring 11,579 images across 88 classes. +- **Microscopic**: Comprises 11 datasets with 13,378 images, spanning 28 classes. +- **Underwater**: Contains 5 datasets, encompassing 18,003 images in 39 classes. +- **Documents**: Consists of 8 datasets with 24,813 images, divided into 90 classes. +- **Electromagnetic**: Made up of 12 datasets, totaling 36,381 images in 41 classes. +- **Real World**: The largest category with 50 datasets, offering 110,615 images across 495 classes. + +This structure enables a diverse and extensive testing ground for object detection models, reflecting real-world application scenarios. + +## Benchmarking + +Dataset benchmarking evaluates machine learning model performance on specific datasets using standardized metrics like accuracy, mean average precision and F1-score. + +!!! tip "Benchmarking" + + Benchmarking results will be stored in "ultralytics-benchmarks/evaluation.txt" + +!!! example "Benchmarking example" + + === "Python" + + ```python + import os + import shutil + from pathlib import Path + + from ultralytics.utils.benchmarks import RF100Benchmark + + # Initialize RF100Benchmark and set API key + benchmark = RF100Benchmark() + benchmark.set_key(api_key="YOUR_ROBOFLOW_API_KEY") + + # Parse dataset and define file paths + names, cfg_yamls = benchmark.parse_dataset() + val_log_file = Path("ultralytics-benchmarks") / "validation.txt" + eval_log_file = Path("ultralytics-benchmarks") / "evaluation.txt" + + # Run benchmarks on each dataset in RF100 + for ind, path in enumerate(cfg_yamls): + path = Path(path) + if path.exists(): + # Fix YAML file and run training + benchmark.fix_yaml(str(path)) + os.system(f"yolo detect train data={path} model=yolov8s.pt epochs=1 batch=16") + + # Run validation and evaluate + os.system(f"yolo detect val data={path} model=runs/detect/train/weights/best.pt > {val_log_file} 2>&1") + benchmark.evaluate(str(path), str(val_log_file), str(eval_log_file), ind) + + # Remove the 'runs' directory + runs_dir = Path.cwd() / "runs" + shutil.rmtree(runs_dir) + else: + print("YAML file path does not exist") + continue + + print("RF100 Benchmarking completed!") + ``` + +## Applications + +Roboflow 100 is invaluable for various applications related to computer vision and deep learning. Researchers and engineers can use this benchmark to: + +- Evaluate the performance of object detection models in a multi-domain context. +- Test the adaptability of models to real-world scenarios beyond common object recognition. +- Benchmark the capabilities of object detection models across diverse datasets, including those in healthcare, aerial imagery, and video games. + +For more ideas and inspiration on real-world applications, be sure to check out [our guides on real-world projects](../../guides/index.md). + +## Usage + +The Roboflow 100 dataset is available on both [GitHub](https://github.com/roboflow/roboflow-100-benchmark) and [Roboflow Universe](https://universe.roboflow.com/roboflow-100?ref=ultralytics). + +You can access it directly from the Roboflow 100 GitHub repository. In addition, on Roboflow Universe, you have the flexibility to download individual datasets by simply clicking the export button within each dataset. + +## Sample Data and Annotations + +Roboflow 100 consists of datasets with diverse images and videos captured from various angles and domains. Here's a look at examples of annotated images in the RF100 benchmark. + +

+ Sample Data and Annotations +

+ +The diversity in the Roboflow 100 benchmark that can be seen above is a significant advancement from traditional benchmarks which often focus on optimizing a single metric within a limited domain. + +## Citations and Acknowledgments + +If you use the Roboflow 100 dataset in your research or development work, please cite the following paper: + +!!! quote "" + + === "BibTeX" + + ```bibtex + @misc{2211.13523, + Author = {Floriana Ciaglia and Francesco Saverio Zuppichini and Paul Guerrie and Mark McQuade and Jacob Solawetz}, + Title = {Roboflow 100: A Rich, Multi-Domain Object Detection Benchmark}, + Eprint = {arXiv:2211.13523}, + } + ``` + +Our thanks go to the Roboflow team and all the contributors for their hard work in creating and sustaining the Roboflow 100 dataset. + +If you are interested in exploring more datasets to enhance your object detection and machine learning projects, feel free to visit [our comprehensive dataset collection](../index.md). + +## FAQ + +### What is the Roboflow 100 dataset, and why is it significant for object detection? + +The **Roboflow 100** dataset, developed by [Roboflow](https://roboflow.com/?ref=ultralytics) and sponsored by Intel, is a crucial [object detection](../../tasks/detect.md) benchmark. It features 100 diverse datasets from over 90,000 public datasets, covering domains such as healthcare, aerial imagery, and video games. This diversity ensures that models can adapt to various real-world scenarios, enhancing their robustness and performance. + +### How can I use the Roboflow 100 dataset for benchmarking my object detection models? + +To use the Roboflow 100 dataset for benchmarking, you can implement the RF100Benchmark class from the Ultralytics library. Here's a brief example: + +!!! example "Benchmarking example" + + === "Python" + + ```python + import os + import shutil + from pathlib import Path + + from ultralytics.utils.benchmarks import RF100Benchmark + + # Initialize RF100Benchmark and set API key + benchmark = RF100Benchmark() + benchmark.set_key(api_key="YOUR_ROBOFLOW_API_KEY") + + # Parse dataset and define file paths + names, cfg_yamls = benchmark.parse_dataset() + val_log_file = Path("ultralytics-benchmarks") / "validation.txt" + eval_log_file = Path("ultralytics-benchmarks") / "evaluation.txt" + + # Run benchmarks on each dataset in RF100 + for ind, path in enumerate(cfg_yamls): + path = Path(path) + if path.exists(): + # Fix YAML file and run training + benchmark.fix_yaml(str(path)) + os.system(f"yolo detect train data={path} model=yolov8s.pt epochs=1 batch=16") + + # Run validation and evaluate + os.system(f"yolo detect val data={path} model=runs/detect/train/weights/best.pt > {val_log_file} 2>&1") + benchmark.evaluate(str(path), str(val_log_file), str(eval_log_file), ind) + + # Remove 'runs' directory + runs_dir = Path.cwd() / "runs" + shutil.rmtree(runs_dir) + else: + print("YAML file path does not exist") + continue + + print("RF100 Benchmarking completed!") + ``` + +### Which domains are covered by the Roboflow 100 dataset? + +The **Roboflow 100** dataset spans seven domains, each providing unique challenges and applications for object detection models: + +1. **Aerial**: 7 datasets, 9,683 images, 24 classes +2. **Video Games**: 7 datasets, 11,579 images, 88 classes +3. **Microscopic**: 11 datasets, 13,378 images, 28 classes +4. **Underwater**: 5 datasets, 18,003 images, 39 classes +5. **Documents**: 8 datasets, 24,813 images, 90 classes +6. **Electromagnetic**: 12 datasets, 36,381 images, 41 classes +7. **Real World**: 50 datasets, 110,615 images, 495 classes + +This setup allows for extensive and varied testing of models across different real-world applications. + +### How do I access and download the Roboflow 100 dataset? + +The **Roboflow 100** dataset is accessible on [GitHub](https://github.com/roboflow/roboflow-100-benchmark) and [Roboflow Universe](https://universe.roboflow.com/roboflow-100?ref=ultralytics). You can download the entire dataset from GitHub or select individual datasets on Roboflow Universe using the export button. + +### What should I include when citing the Roboflow 100 dataset in my research? + +When using the Roboflow 100 dataset in your research, ensure to properly cite it. Here is the recommended citation: + +!!! quote "" + + === "BibTeX" + + ```bibtex + @misc{2211.13523, + Author = {Floriana Ciaglia and Francesco Saverio Zuppichini and Paul Guerrie and Mark McQuade and Jacob Solawetz}, + Title = {Roboflow 100: A Rich, Multi-Domain Object Detection Benchmark}, + Eprint = {arXiv:2211.13523}, + } + ``` + +For more details, you can refer to our [comprehensive dataset collection](../index.md). diff --git a/ultralytics/docs/en/datasets/detect/signature.md b/ultralytics/docs/en/datasets/detect/signature.md new file mode 100644 index 0000000000000000000000000000000000000000..0d76e11f5084c1ce6ba709393f958ee02de1d31f --- /dev/null +++ b/ultralytics/docs/en/datasets/detect/signature.md @@ -0,0 +1,170 @@ +--- +comments: true +description: Discover the Signature Detection Dataset for training models to identify and verify human signatures in various documents. Perfect for document verification and fraud prevention. +keywords: Signature Detection Dataset, document verification, fraud detection, computer vision, YOLOv8, Ultralytics, annotated signatures, training dataset +--- + +# Signature Detection Dataset + +This dataset focuses on detecting human written signatures within documents. It includes a variety of document types with annotated signatures, providing valuable insights for applications in document verification and fraud detection. Essential for training computer vision algorithms, this dataset aids in identifying signatures in various document formats, supporting research and practical applications in document analysis. + +## Dataset Structure + +The signature detection dataset is split into three subsets: + +- **Training set**: Contains 143 images, each with corresponding annotations. +- **Validation set**: Includes 35 images, each with paired annotations. + +## Applications + +This dataset can be applied in various computer vision tasks such as object detection, object tracking, and document analysis. Specifically, it can be used to train and evaluate models for identifying signatures in documents, which can have applications in document verification, fraud detection, and archival research. Additionally, it can serve as a valuable resource for educational purposes, enabling students and researchers to study and understand the characteristics and behaviors of signatures in different document types. + +## Dataset YAML + +A YAML (Yet Another Markup Language) file defines the dataset configuration, including paths and classes information. For the signature detection dataset, the `signature.yaml` file is located at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/signature.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/signature.yaml). + +!!! example "ultralytics/cfg/datasets/signature.yaml" + + ```yaml + --8<-- "ultralytics/cfg/datasets/signature.yaml" + ``` + +## Usage + +To train a YOLOv8n model on the signature detection dataset for 100 epochs with an image size of 640, use the provided code samples. For a comprehensive list of available parameters, refer to the model's [Training](../../modes/train.md) page. + +!!! example "Train Example" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a model + model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training) + + # Train the model + results = model.train(data="signature.yaml", epochs=100, imgsz=640) + ``` + + === "CLI" + + ```bash + # Start training from a pretrained *.pt model + yolo detect train data=signature.yaml model=yolov8n.pt epochs=100 imgsz=640 + ``` + +!!! example "Inference Example" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a model + model = YOLO("path/to/best.pt") # load a signature-detection fine-tuned model + + # Inference using the model + results = model.predict("https://ultralytics.com/assets/signature-s.mp4", conf=0.75) + ``` + + === "CLI" + + ```bash + # Start prediction with a finetuned *.pt model + yolo detect predict model='path/to/best.pt' imgsz=640 source="https://ultralytics.com/assets/signature-s.mp4" conf=0.75 + ``` + +## Sample Images and Annotations + +The signature detection dataset comprises a wide variety of images showcasing different document types and annotated signatures. Below are examples of images from the dataset, each accompanied by its corresponding annotations. + +![Signature detection dataset sample image](https://github.com/ultralytics/docs/releases/download/0/signature-detection-mosaiced-sample.avif) + +- **Mosaiced Image**: Here, we present a training batch consisting of mosaiced dataset images. Mosaicing, a training technique, combines multiple images into one, enriching batch diversity. This method helps enhance the model's ability to generalize across different signature sizes, aspect ratios, and contexts. + +This example illustrates the variety and complexity of images in the signature Detection Dataset, emphasizing the benefits of including mosaicing during the training process. + +## Citations and Acknowledgments + +The dataset has been released available under the [AGPL-3.0 License](https://github.com/ultralytics/ultralytics/blob/main/LICENSE). + +## FAQ + +### What is the Signature Detection Dataset, and how can it be used? + +The Signature Detection Dataset is a collection of annotated images aimed at detecting human signatures within various document types. It can be applied in computer vision tasks such as object detection and tracking, primarily for document verification, fraud detection, and archival research. This dataset helps train models to recognize signatures in different contexts, making it valuable for both research and practical applications. + +### How do I train a YOLOv8n model on the Signature Detection Dataset? + +To train a YOLOv8n model on the Signature Detection Dataset, follow these steps: + +1. Download the `signature.yaml` dataset configuration file from [signature.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/signature.yaml). +2. Use the following Python script or CLI command to start training: + +!!! example "Train Example" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a pretrained model + model = YOLO("yolov8n.pt") + + # Train the model + results = model.train(data="signature.yaml", epochs=100, imgsz=640) + ``` + + === "CLI" + + ```bash + yolo detect train data=signature.yaml model=yolov8n.pt epochs=100 imgsz=640 + ``` + +For more details, refer to the [Training](../../modes/train.md) page. + +### What are the main applications of the Signature Detection Dataset? + +The Signature Detection Dataset can be used for: + +1. **Document Verification**: Automatically verifying the presence and authenticity of human signatures in documents. +2. **Fraud Detection**: Identifying forged or fraudulent signatures in legal and financial documents. +3. **Archival Research**: Assisting historians and archivists in the digital analysis and cataloging of historical documents. +4. **Education**: Supporting academic research and teaching in the fields of computer vision and machine learning. + +### How can I perform inference using a model trained on the Signature Detection Dataset? + +To perform inference using a model trained on the Signature Detection Dataset, follow these steps: + +1. Load your fine-tuned model. +2. Use the below Python script or CLI command to perform inference: + +!!! example "Inference Example" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load the fine-tuned model + model = YOLO("path/to/best.pt") + + # Perform inference + results = model.predict("https://ultralytics.com/assets/signature-s.mp4", conf=0.75) + ``` + + === "CLI" + + ```bash + yolo detect predict model='path/to/best.pt' imgsz=640 source="https://ultralytics.com/assets/signature-s.mp4" conf=0.75 + ``` + +### What is the structure of the Signature Detection Dataset, and where can I find more information? + +The Signature Detection Dataset is divided into two subsets: + +- **Training Set**: Contains 143 images with annotations. +- **Validation Set**: Includes 35 images with annotations. + +For detailed information, you can refer to the [Dataset Structure](#dataset-structure) section. Additionally, view the complete dataset configuration in the `signature.yaml` file located at [signature.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/signature.yaml). diff --git a/ultralytics/docs/en/datasets/detect/sku-110k.md b/ultralytics/docs/en/datasets/detect/sku-110k.md new file mode 100644 index 0000000000000000000000000000000000000000..145468321e6be4cee04f86c1bff22cfb23a5b461 --- /dev/null +++ b/ultralytics/docs/en/datasets/detect/sku-110k.md @@ -0,0 +1,181 @@ +--- +comments: true +description: Explore the SKU-110k dataset of densely packed retail shelf images, perfect for training and evaluating deep learning models in object detection tasks. +keywords: SKU-110k, dataset, object detection, retail shelf images, deep learning, computer vision, model training +--- + +# SKU-110k Dataset + +The [SKU-110k](https://github.com/eg4000/SKU110K_CVPR19) dataset is a collection of densely packed retail shelf images, designed to support research in object detection tasks. Developed by Eran Goldman et al., the dataset contains over 110,000 unique store keeping unit (SKU) categories with densely packed objects, often looking similar or even identical, positioned in close proximity. + +

+
+ +
+ Watch: How to Train YOLOv10 on SKU-110k Dataset using Ultralytics | Retail Dataset +

+ +![Dataset sample image](https://github.com/ultralytics/docs/releases/download/0/densely-packed-retail-shelf.avif) + +## Key Features + +- SKU-110k contains images of store shelves from around the world, featuring densely packed objects that pose challenges for state-of-the-art object detectors. +- The dataset includes over 110,000 unique SKU categories, providing a diverse range of object appearances. +- Annotations include bounding boxes for objects and SKU category labels. + +## Dataset Structure + +The SKU-110k dataset is organized into three main subsets: + +1. **Training set**: This subset contains images and annotations used for training object detection models. +2. **Validation set**: This subset consists of images and annotations used for model validation during training. +3. **Test set**: This subset is designed for the final evaluation of trained object detection models. + +## Applications + +The SKU-110k dataset is widely used for training and evaluating deep learning models in object detection tasks, especially in densely packed scenes such as retail shelf displays. The dataset's diverse set of SKU categories and densely packed object arrangements make it a valuable resource for researchers and practitioners in the field of computer vision. + +## Dataset YAML + +A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. For the case of the SKU-110K dataset, the `SKU-110K.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/SKU-110K.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/SKU-110K.yaml). + +!!! example "ultralytics/cfg/datasets/SKU-110K.yaml" + + ```yaml + --8<-- "ultralytics/cfg/datasets/SKU-110K.yaml" + ``` + +## Usage + +To train a YOLOv8n model on the SKU-110K dataset for 100 epochs with an image size of 640, you can use the following code snippets. For a comprehensive list of available arguments, refer to the model [Training](../../modes/train.md) page. + +!!! example "Train Example" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a model + model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training) + + # Train the model + results = model.train(data="SKU-110K.yaml", epochs=100, imgsz=640) + ``` + + === "CLI" + + ```bash + # Start training from a pretrained *.pt model + yolo detect train data=SKU-110K.yaml model=yolov8n.pt epochs=100 imgsz=640 + ``` + +## Sample Data and Annotations + +The SKU-110k dataset contains a diverse set of retail shelf images with densely packed objects, providing rich context for object detection tasks. Here are some examples of data from the dataset, along with their corresponding annotations: + +![Dataset sample image](https://github.com/ultralytics/docs/releases/download/0/densely-packed-retail-shelf-1.avif) + +- **Densely packed retail shelf image**: This image demonstrates an example of densely packed objects in a retail shelf setting. Objects are annotated with bounding boxes and SKU category labels. + +The example showcases the variety and complexity of the data in the SKU-110k dataset and highlights the importance of high-quality data for object detection tasks. + +## Citations and Acknowledgments + +If you use the SKU-110k dataset in your research or development work, please cite the following paper: + +!!! quote "" + + === "BibTeX" + + ```bibtex + @inproceedings{goldman2019dense, + author = {Eran Goldman and Roei Herzig and Aviv Eisenschtat and Jacob Goldberger and Tal Hassner}, + title = {Precise Detection in Densely Packed Scenes}, + booktitle = {Proc. Conf. Comput. Vision Pattern Recognition (CVPR)}, + year = {2019} + } + ``` + +We would like to acknowledge Eran Goldman et al. for creating and maintaining the SKU-110k dataset as a valuable resource for the computer vision research community. For more information about the SKU-110k dataset and its creators, visit the [SKU-110k dataset GitHub repository](https://github.com/eg4000/SKU110K_CVPR19). + +## FAQ + +### What is the SKU-110k dataset and why is it important for object detection? + +The SKU-110k dataset consists of densely packed retail shelf images designed to aid research in object detection tasks. Developed by Eran Goldman et al., it includes over 110,000 unique SKU categories. Its importance lies in its ability to challenge state-of-the-art object detectors with diverse object appearances and close proximity, making it an invaluable resource for researchers and practitioners in computer vision. Learn more about the dataset's structure and applications in our [SKU-110k Dataset](#sku-110k-dataset) section. + +### How do I train a YOLOv8 model using the SKU-110k dataset? + +Training a YOLOv8 model on the SKU-110k dataset is straightforward. Here's an example to train a YOLOv8n model for 100 epochs with an image size of 640: + +!!! example "Train Example" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a model + model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training) + + # Train the model + results = model.train(data="SKU-110K.yaml", epochs=100, imgsz=640) + ``` + + + === "CLI" + + ```bash + # Start training from a pretrained *.pt model + yolo detect train data=SKU-110K.yaml model=yolov8n.pt epochs=100 imgsz=640 + ``` + +For a comprehensive list of available arguments, refer to the model [Training](../../modes/train.md) page. + +### What are the main subsets of the SKU-110k dataset? + +The SKU-110k dataset is organized into three main subsets: + +1. **Training set**: Contains images and annotations used for training object detection models. +2. **Validation set**: Consists of images and annotations used for model validation during training. +3. **Test set**: Designed for the final evaluation of trained object detection models. + +Refer to the [Dataset Structure](#dataset-structure) section for more details. + +### How do I configure the SKU-110k dataset for training? + +The SKU-110k dataset configuration is defined in a YAML file, which includes details about the dataset's paths, classes, and other relevant information. The `SKU-110K.yaml` file is maintained at [SKU-110K.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/SKU-110K.yaml). For example, you can train a model using this configuration as shown in our [Usage](#usage) section. + +### What are the key features of the SKU-110k dataset in the context of deep learning? + +The SKU-110k dataset features images of store shelves from around the world, showcasing densely packed objects that pose significant challenges for object detectors: + +- Over 110,000 unique SKU categories +- Diverse object appearances +- Annotations include bounding boxes and SKU category labels + +These features make the SKU-110k dataset particularly valuable for training and evaluating deep learning models in object detection tasks. For more details, see the [Key Features](#key-features) section. + +### How do I cite the SKU-110k dataset in my research? + +If you use the SKU-110k dataset in your research or development work, please cite the following paper: + +!!! quote "" + + === "BibTeX" + + ```bibtex + @inproceedings{goldman2019dense, + author = {Eran Goldman and Roei Herzig and Aviv Eisenschtat and Jacob Goldberger and Tal Hassner}, + title = {Precise Detection in Densely Packed Scenes}, + booktitle = {Proc. Conf. Comput. Vision Pattern Recognition (CVPR)}, + year = {2019} + } + ``` + +More information about the dataset can be found in the [Citations and Acknowledgments](#citations-and-acknowledgments) section. diff --git a/ultralytics/docs/en/datasets/detect/visdrone.md b/ultralytics/docs/en/datasets/detect/visdrone.md new file mode 100644 index 0000000000000000000000000000000000000000..c1060e99898f37ffa0691ee0d56de87c0f14066c --- /dev/null +++ b/ultralytics/docs/en/datasets/detect/visdrone.md @@ -0,0 +1,179 @@ +--- +comments: true +description: Explore the VisDrone Dataset, a large-scale benchmark for drone-based image and video analysis with over 2.6 million annotations for objects like pedestrians and vehicles. +keywords: VisDrone, drone dataset, computer vision, object detection, object tracking, crowd counting, machine learning, deep learning +--- + +# VisDrone Dataset + +The [VisDrone Dataset](https://github.com/VisDrone/VisDrone-Dataset) is a large-scale benchmark created by the AISKYEYE team at the Lab of Machine Learning and Data Mining, Tianjin University, China. It contains carefully annotated ground truth data for various computer vision tasks related to drone-based image and video analysis. + +

+
+ +
+ Watch: How to Train Ultralytics YOLO Models on the VisDrone Dataset for Drone Image Analysis +

+ +VisDrone is composed of 288 video clips with 261,908 frames and 10,209 static images, captured by various drone-mounted cameras. The dataset covers a wide range of aspects, including location (14 different cities across China), environment (urban and rural), objects (pedestrians, vehicles, bicycles, etc.), and density (sparse and crowded scenes). The dataset was collected using various drone platforms under different scenarios and weather and lighting conditions. These frames are manually annotated with over 2.6 million bounding boxes of targets such as pedestrians, cars, bicycles, and tricycles. Attributes like scene visibility, object class, and occlusion are also provided for better data utilization. + +## Dataset Structure + +The VisDrone dataset is organized into five main subsets, each focusing on a specific task: + +1. **Task 1**: Object detection in images +2. **Task 2**: Object detection in videos +3. **Task 3**: Single-object tracking +4. **Task 4**: Multi-object tracking +5. **Task 5**: Crowd counting + +## Applications + +The VisDrone dataset is widely used for training and evaluating deep learning models in drone-based computer vision tasks such as object detection, object tracking, and crowd counting. The dataset's diverse set of sensor data, object annotations, and attributes make it a valuable resource for researchers and practitioners in the field of drone-based computer vision. + +## Dataset YAML + +A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. In the case of the Visdrone dataset, the `VisDrone.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/VisDrone.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/VisDrone.yaml). + +!!! example "ultralytics/cfg/datasets/VisDrone.yaml" + + ```yaml + --8<-- "ultralytics/cfg/datasets/VisDrone.yaml" + ``` + +## Usage + +To train a YOLOv8n model on the VisDrone dataset for 100 epochs with an image size of 640, you can use the following code snippets. For a comprehensive list of available arguments, refer to the model [Training](../../modes/train.md) page. + +!!! example "Train Example" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a model + model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training) + + # Train the model + results = model.train(data="VisDrone.yaml", epochs=100, imgsz=640) + ``` + + === "CLI" + + ```bash + # Start training from a pretrained *.pt model + yolo detect train data=VisDrone.yaml model=yolov8n.pt epochs=100 imgsz=640 + ``` + +## Sample Data and Annotations + +The VisDrone dataset contains a diverse set of images and videos captured by drone-mounted cameras. Here are some examples of data from the dataset, along with their corresponding annotations: + +![Dataset sample image](https://github.com/ultralytics/docs/releases/download/0/visdrone-object-detection-sample.avif) + +- **Task 1**: Object detection in images - This image demonstrates an example of object detection in images, where objects are annotated with bounding boxes. The dataset provides a wide variety of images taken from different locations, environments, and densities to facilitate the development of models for this task. + +The example showcases the variety and complexity of the data in the VisDrone dataset and highlights the importance of high-quality sensor data for drone-based computer vision tasks. + +## Citations and Acknowledgments + +If you use the VisDrone dataset in your research or development work, please cite the following paper: + +!!! quote "" + + === "BibTeX" + + ```bibtex + @ARTICLE{9573394, + author={Zhu, Pengfei and Wen, Longyin and Du, Dawei and Bian, Xiao and Fan, Heng and Hu, Qinghua and Ling, Haibin}, + journal={IEEE Transactions on Pattern Analysis and Machine Intelligence}, + title={Detection and Tracking Meet Drones Challenge}, + year={2021}, + volume={}, + number={}, + pages={1-1}, + doi={10.1109/TPAMI.2021.3119563}} + ``` + +We would like to acknowledge the AISKYEYE team at the Lab of Machine Learning and Data Mining, Tianjin University, China, for creating and maintaining the VisDrone dataset as a valuable resource for the drone-based computer vision research community. For more information about the VisDrone dataset and its creators, visit the [VisDrone Dataset GitHub repository](https://github.com/VisDrone/VisDrone-Dataset). + +## FAQ + +### What is the VisDrone Dataset and what are its key features? + +The [VisDrone Dataset](https://github.com/VisDrone/VisDrone-Dataset) is a large-scale benchmark created by the AISKYEYE team at Tianjin University, China. It is designed for various computer vision tasks related to drone-based image and video analysis. Key features include: + +- **Composition**: 288 video clips with 261,908 frames and 10,209 static images. +- **Annotations**: Over 2.6 million bounding boxes for objects like pedestrians, cars, bicycles, and tricycles. +- **Diversity**: Collected across 14 cities, in urban and rural settings, under different weather and lighting conditions. +- **Tasks**: Split into five main tasks—object detection in images and videos, single-object and multi-object tracking, and crowd counting. + +### How can I use the VisDrone Dataset to train a YOLOv8 model with Ultralytics? + +To train a YOLOv8 model on the VisDrone dataset for 100 epochs with an image size of 640, you can follow these steps: + +!!! example "Train Example" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a pretrained model + model = YOLO("yolov8n.pt") + + # Train the model + results = model.train(data="VisDrone.yaml", epochs=100, imgsz=640) + ``` + + === "CLI" + + ```bash + # Start training from a pretrained *.pt model + yolo detect train data=VisDrone.yaml model=yolov8n.pt epochs=100 imgsz=640 + ``` + +For additional configuration options, please refer to the model [Training](../../modes/train.md) page. + +### What are the main subsets of the VisDrone dataset and their applications? + +The VisDrone dataset is divided into five main subsets, each tailored for a specific computer vision task: + +1. **Task 1**: Object detection in images. +2. **Task 2**: Object detection in videos. +3. **Task 3**: Single-object tracking. +4. **Task 4**: Multi-object tracking. +5. **Task 5**: Crowd counting. + +These subsets are widely used for training and evaluating deep learning models in drone-based applications such as surveillance, traffic monitoring, and public safety. + +### Where can I find the configuration file for the VisDrone dataset in Ultralytics? + +The configuration file for the VisDrone dataset, `VisDrone.yaml`, can be found in the Ultralytics repository at the following link: +[VisDrone.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/VisDrone.yaml). + +### How can I cite the VisDrone dataset if I use it in my research? + +If you use the VisDrone dataset in your research or development work, please cite the following paper: + +!!! quote "" + + === "BibTeX" + + ```bibtex + @ARTICLE{9573394, + author={Zhu, Pengfei and Wen, Longyin and Du, Dawei and Bian, Xiao and Fan, Heng and Hu, Qinghua and Ling, Haibin}, + journal={IEEE Transactions on Pattern Analysis and Machine Intelligence}, + title={Detection and Tracking Meet Drones Challenge}, + year={2021}, + volume={}, + number={}, + pages={1-1}, + doi={10.1109/TPAMI.2021.3119563} + } + ``` diff --git a/ultralytics/docs/en/datasets/detect/xview.md b/ultralytics/docs/en/datasets/detect/xview.md new file mode 100644 index 0000000000000000000000000000000000000000..e7e2f3d3f7d0b46b2c604412167f262889d6257a --- /dev/null +++ b/ultralytics/docs/en/datasets/detect/xview.md @@ -0,0 +1,165 @@ +--- +comments: true +description: Explore the xView dataset, a rich resource of 1M+ object instances in high-resolution satellite imagery. Enhance detection, learning efficiency, and more. +keywords: xView dataset, overhead imagery, satellite images, object detection, high resolution, bounding boxes, computer vision, TensorFlow, PyTorch, dataset structure +--- + +# xView Dataset + +The [xView](http://xviewdataset.org/) dataset is one of the largest publicly available datasets of overhead imagery, containing images from complex scenes around the world annotated using bounding boxes. The goal of the xView dataset is to accelerate progress in four computer vision frontiers: + +1. Reduce minimum resolution for detection. +2. Improve learning efficiency. +3. Enable discovery of more object classes. +4. Improve detection of fine-grained classes. + +xView builds on the success of challenges like Common Objects in Context (COCO) and aims to leverage computer vision to analyze the growing amount of available imagery from space in order to understand the visual world in new ways and address a range of important applications. + +## Key Features + +- xView contains over 1 million object instances across 60 classes. +- The dataset has a resolution of 0.3 meters, providing higher resolution imagery than most public satellite imagery datasets. +- xView features a diverse collection of small, rare, fine-grained, and multi-type objects with bounding box annotation. +- Comes with a pre-trained baseline model using the TensorFlow object detection API and an example for PyTorch. + +## Dataset Structure + +The xView dataset is composed of satellite images collected from WorldView-3 satellites at a 0.3m ground sample distance. It contains over 1 million objects across 60 classes in over 1,400 km² of imagery. + +## Applications + +The xView dataset is widely used for training and evaluating deep learning models for object detection in overhead imagery. The dataset's diverse set of object classes and high-resolution imagery make it a valuable resource for researchers and practitioners in the field of computer vision, especially for satellite imagery analysis. + +## Dataset YAML + +A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. In the case of the xView dataset, the `xView.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/xView.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/xView.yaml). + +!!! example "ultralytics/cfg/datasets/xView.yaml" + + ```yaml + --8<-- "ultralytics/cfg/datasets/xView.yaml" + ``` + +## Usage + +To train a model on the xView dataset for 100 epochs with an image size of 640, you can use the following code snippets. For a comprehensive list of available arguments, refer to the model [Training](../../modes/train.md) page. + +!!! example "Train Example" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a model + model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training) + + # Train the model + results = model.train(data="xView.yaml", epochs=100, imgsz=640) + ``` + + === "CLI" + + ```bash + # Start training from a pretrained *.pt model + yolo detect train data=xView.yaml model=yolov8n.pt epochs=100 imgsz=640 + ``` + +## Sample Data and Annotations + +The xView dataset contains high-resolution satellite images with a diverse set of objects annotated using bounding boxes. Here are some examples of data from the dataset, along with their corresponding annotations: + +![Dataset sample image](https://github.com/ultralytics/docs/releases/download/0/overhead-imagery-object-detection.avif) + +- **Overhead Imagery**: This image demonstrates an example of object detection in overhead imagery, where objects are annotated with bounding boxes. The dataset provides high-resolution satellite images to facilitate the development of models for this task. + +The example showcases the variety and complexity of the data in the xView dataset and highlights the importance of high-quality satellite imagery for object detection tasks. + +## Citations and Acknowledgments + +If you use the xView dataset in your research or development work, please cite the following paper: + +!!! quote "" + + === "BibTeX" + + ```bibtex + @misc{lam2018xview, + title={xView: Objects in Context in Overhead Imagery}, + author={Darius Lam and Richard Kuzma and Kevin McGee and Samuel Dooley and Michael Laielli and Matthew Klaric and Yaroslav Bulatov and Brendan McCord}, + year={2018}, + eprint={1802.07856}, + archivePrefix={arXiv}, + primaryClass={cs.CV} + } + ``` + +We would like to acknowledge the [Defense Innovation Unit](https://www.diu.mil/) (DIU) and the creators of the xView dataset for their valuable contribution to the computer vision research community. For more information about the xView dataset and its creators, visit the [xView dataset website](http://xviewdataset.org/). + +## FAQ + +### What is the xView dataset and how does it benefit computer vision research? + +The [xView](http://xviewdataset.org/) dataset is one of the largest publicly available collections of high-resolution overhead imagery, containing over 1 million object instances across 60 classes. It is designed to enhance various facets of computer vision research such as reducing the minimum resolution for detection, improving learning efficiency, discovering more object classes, and advancing fine-grained object detection. + +### How can I use Ultralytics YOLO to train a model on the xView dataset? + +To train a model on the xView dataset using Ultralytics YOLO, follow these steps: + +!!! example "Train Example" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a model + model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training) + + # Train the model + results = model.train(data="xView.yaml", epochs=100, imgsz=640) + ``` + + + === "CLI" + + ```bash + # Start training from a pretrained *.pt model + yolo detect train data=xView.yaml model=yolov8n.pt epochs=100 imgsz=640 + ``` + +For detailed arguments and settings, refer to the model [Training](../../modes/train.md) page. + +### What are the key features of the xView dataset? + +The xView dataset stands out due to its comprehensive set of features: + +- Over 1 million object instances across 60 distinct classes. +- High-resolution imagery at 0.3 meters. +- Diverse object types including small, rare, and fine-grained objects, all annotated with bounding boxes. +- Availability of a pre-trained baseline model and examples in TensorFlow and PyTorch. + +### What is the dataset structure of xView, and how is it annotated? + +The xView dataset comprises high-resolution satellite images collected from WorldView-3 satellites at a 0.3m ground sample distance. It encompasses over 1 million objects across 60 classes in approximately 1,400 km² of imagery. Each object within the dataset is annotated with bounding boxes, making it ideal for training and evaluating deep learning models for object detection in overhead imagery. For a detailed overview, you can look at the dataset structure section [here](#dataset-structure). + +### How do I cite the xView dataset in my research? + +If you utilize the xView dataset in your research, please cite the following paper: + +!!! quote "" + + === "BibTeX" + + ```bibtex + @misc{lam2018xview, + title={xView: Objects in Context in Overhead Imagery}, + author={Darius Lam and Richard Kuzma and Kevin McGee and Samuel Dooley and Michael Laielli and Matthew Klaric and Yaroslav Bulatov and Brendan McCord}, + year={2018}, + eprint={1802.07856}, + archivePrefix={arXiv}, + primaryClass={cs.CV} + } + ``` + +For more information about the xView dataset, visit the official [xView dataset website](http://xviewdataset.org/). diff --git a/ultralytics/docs/en/integrations/amazon-sagemaker.md b/ultralytics/docs/en/integrations/amazon-sagemaker.md new file mode 100644 index 0000000000000000000000000000000000000000..38edceebd67de7592413c7d137f17c877ba6f4ff --- /dev/null +++ b/ultralytics/docs/en/integrations/amazon-sagemaker.md @@ -0,0 +1,256 @@ +--- +comments: true +description: Learn step-by-step how to deploy Ultralytics' YOLOv8 on Amazon SageMaker Endpoints, from setup to testing, for powerful real-time inference with AWS services. +keywords: YOLOv8, Amazon SageMaker, AWS, Ultralytics, machine learning, computer vision, model deployment, AWS CloudFormation, AWS CDK, real-time inference +--- + +# A Guide to Deploying YOLOv8 on Amazon SageMaker Endpoints + +Deploying advanced computer vision models like [Ultralytics' YOLOv8](https://github.com/ultralytics/ultralytics) on Amazon SageMaker Endpoints opens up a wide range of possibilities for various machine learning applications. The key to effectively using these models lies in understanding their setup, configuration, and deployment processes. YOLOv8 becomes even more powerful when integrated seamlessly with Amazon SageMaker, a robust and scalable machine learning service by AWS. + +This guide will take you through the process of deploying YOLOv8 PyTorch models on Amazon SageMaker Endpoints step by step. You'll learn the essentials of preparing your AWS environment, configuring the model appropriately, and using tools like AWS CloudFormation and the AWS Cloud Development Kit (CDK) for deployment. + +## Amazon SageMaker + +

+ Amazon SageMaker Overview +

+ +[Amazon SageMaker](https://aws.amazon.com/sagemaker/) is a machine learning service from Amazon Web Services (AWS) that simplifies the process of building, training, and deploying machine learning models. It provides a broad range of tools for handling various aspects of machine learning workflows. This includes automated features for tuning models, options for training models at scale, and straightforward methods for deploying models into production. SageMaker supports popular machine learning frameworks, offering the flexibility needed for diverse projects. Its features also cover data labeling, workflow management, and performance analysis. + +## Deploying YOLOv8 on Amazon SageMaker Endpoints + +Deploying YOLOv8 on Amazon SageMaker lets you use its managed environment for real-time inference and take advantage of features like autoscaling. Take a look at the AWS architecture below. + +

+ AWS Architecture +

+ +### Step 1: Setup Your AWS Environment + +First, ensure you have the following prerequisites in place: + +- An AWS Account: If you don't already have one, sign up for an AWS account. + +- Configured IAM Roles: You'll need an IAM role with the necessary permissions for Amazon SageMaker, AWS CloudFormation, and Amazon S3. This role should have policies that allow it to access these services. + +- AWS CLI: If not already installed, download and install the AWS Command Line Interface (CLI) and configure it with your account details. Follow [the AWS CLI instructions](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) for installation. + +- AWS CDK: If not already installed, install the AWS Cloud Development Kit (CDK), which will be used for scripting the deployment. Follow [the AWS CDK instructions](https://docs.aws.amazon.com/cdk/v2/guide/getting_started.html#getting_started_install) for installation. + +- Adequate Service Quota: Confirm that you have sufficient quotas for two separate resources in Amazon SageMaker: one for `ml.m5.4xlarge` for endpoint usage and another for `ml.m5.4xlarge` for notebook instance usage. Each of these requires a minimum of one quota value. If your current quotas are below this requirement, it's important to request an increase for each. You can request a quota increase by following the detailed instructions in the [AWS Service Quotas documentation](https://docs.aws.amazon.com/servicequotas/latest/userguide/request-quota-increase.html#quota-console-increase). + +### Step 2: Clone the YOLOv8 SageMaker Repository + +The next step is to clone the specific AWS repository that contains the resources for deploying YOLOv8 on SageMaker. This repository, hosted on GitHub, includes the necessary CDK scripts and configuration files. + +- Clone the GitHub Repository: Execute the following command in your terminal to clone the host-yolov8-on-sagemaker-endpoint repository: + +```bash +git clone https://github.com/aws-samples/host-yolov8-on-sagemaker-endpoint.git +``` + +- Navigate to the Cloned Directory: Change your directory to the cloned repository: + +```bash +cd host-yolov8-on-sagemaker-endpoint/yolov8-pytorch-cdk +``` + +### Step 3: Set Up the CDK Environment + +Now that you have the necessary code, set up your environment for deploying with AWS CDK. + +- Create a Python Virtual Environment: This isolates your Python environment and dependencies. Run: + +```bash +python3 -m venv .venv +``` + +- Activate the Virtual Environment: + +```bash +source .venv/bin/activate +``` + +- Install Dependencies: Install the required Python dependencies for the project: + +```bash +pip3 install -r requirements.txt +``` + +- Upgrade AWS CDK Library: Ensure you have the latest version of the AWS CDK library: + +```bash +pip install --upgrade aws-cdk-lib +``` + +### Step 4: Create the AWS CloudFormation Stack + +- Synthesize the CDK Application: Generate the AWS CloudFormation template from your CDK code: + +```bash +cdk synth +``` + +- Bootstrap the CDK Application: Prepare your AWS environment for CDK deployment: + +```bash +cdk bootstrap +``` + +- Deploy the Stack: This will create the necessary AWS resources and deploy your model: + +```bash +cdk deploy +``` + +### Step 5: Deploy the YOLOv8 Model + +Before diving into the deployment instructions, be sure to check out the range of [YOLOv8 models offered by Ultralytics](../models/index.md). This will help you choose the most appropriate model for your project requirements. + +After creating the AWS CloudFormation Stack, the next step is to deploy YOLOv8. + +- Open the Notebook Instance: Go to the AWS Console and navigate to the Amazon SageMaker service. Select "Notebook Instances" from the dashboard, then locate the notebook instance that was created by your CDK deployment script. Open the notebook instance to access the Jupyter environment. + +- Access and Modify inference.py: After opening the SageMaker notebook instance in Jupyter, locate the inference.py file. Edit the output_fn function in inference.py as shown below and save your changes to the script, ensuring that there are no syntax errors. + +```python +import json + + +def output_fn(prediction_output): + """Formats model outputs as JSON string, extracting attributes like boxes, masks, keypoints.""" + print("Executing output_fn from inference.py ...") + infer = {} + for result in prediction_output: + if result.boxes is not None: + infer["boxes"] = result.boxes.numpy().data.tolist() + if result.masks is not None: + infer["masks"] = result.masks.numpy().data.tolist() + if result.keypoints is not None: + infer["keypoints"] = result.keypoints.numpy().data.tolist() + if result.obb is not None: + infer["obb"] = result.obb.numpy().data.tolist() + if result.probs is not None: + infer["probs"] = result.probs.numpy().data.tolist() + return json.dumps(infer) +``` + +- Deploy the Endpoint Using 1_DeployEndpoint.ipynb: In the Jupyter environment, open the 1_DeployEndpoint.ipynb notebook located in the sm-notebook directory. Follow the instructions in the notebook and run the cells to download the YOLOv8 model, package it with the updated inference code, and upload it to an Amazon S3 bucket. The notebook will guide you through creating and deploying a SageMaker endpoint for the YOLOv8 model. + +### Step 6: Testing Your Deployment + +Now that your YOLOv8 model is deployed, it's important to test its performance and functionality. + +- Open the Test Notebook: In the same Jupyter environment, locate and open the 2_TestEndpoint.ipynb notebook, also in the sm-notebook directory. + +- Run the Test Notebook: Follow the instructions within the notebook to test the deployed SageMaker endpoint. This includes sending an image to the endpoint and running inferences. Then, you'll plot the output to visualize the model's performance and accuracy, as shown below. + +

+ Testing Results YOLOv8 +

+ +- Clean-Up Resources: The test notebook will also guide you through the process of cleaning up the endpoint and the hosted model. This is an important step to manage costs and resources effectively, especially if you do not plan to use the deployed model immediately. + +### Step 7: Monitoring and Management + +After testing, continuous monitoring and management of your deployed model are essential. + +- Monitor with Amazon CloudWatch: Regularly check the performance and health of your SageMaker endpoint using [Amazon CloudWatch](https://aws.amazon.com/cloudwatch/). + +- Manage the Endpoint: Use the SageMaker console for ongoing management of the endpoint. This includes scaling, updating, or redeploying the model as required. + +By completing these steps, you will have successfully deployed and tested a YOLOv8 model on Amazon SageMaker Endpoints. This process not only equips you with practical experience in using AWS services for machine learning deployment but also lays the foundation for deploying other advanced models in the future. + +## Summary + +This guide took you step by step through deploying YOLOv8 on Amazon SageMaker Endpoints using AWS CloudFormation and the AWS Cloud Development Kit (CDK). The process includes cloning the necessary GitHub repository, setting up the CDK environment, deploying the model using AWS services, and testing its performance on SageMaker. + +For more technical details, refer to [this article](https://aws.amazon.com/blogs/machine-learning/hosting-yolov8-pytorch-model-on-amazon-sagemaker-endpoints/) on the AWS Machine Learning Blog. You can also check out the official [Amazon SageMaker Documentation](https://docs.aws.amazon.com/sagemaker/latest/dg/realtime-endpoints.html) for more insights into various features and functionalities. + +Are you interested in learning more about different YOLOv8 integrations? Visit the [Ultralytics integrations guide page](../integrations/index.md) to discover additional tools and capabilities that can enhance your machine-learning projects. + +## FAQ + +### How do I deploy the Ultralytics YOLOv8 model on Amazon SageMaker Endpoints? + +To deploy the Ultralytics YOLOv8 model on Amazon SageMaker Endpoints, follow these steps: + +1. **Set Up Your AWS Environment**: Ensure you have an AWS Account, IAM roles with necessary permissions, and the AWS CLI configured. Install AWS CDK if not already done (refer to the [AWS CDK instructions](https://docs.aws.amazon.com/cdk/v2/guide/getting_started.html#getting_started_install)). +2. **Clone the YOLOv8 SageMaker Repository**: + ```bash + git clone https://github.com/aws-samples/host-yolov8-on-sagemaker-endpoint.git + cd host-yolov8-on-sagemaker-endpoint/yolov8-pytorch-cdk + ``` +3. **Set Up the CDK Environment**: Create a Python virtual environment, activate it, install dependencies, and upgrade AWS CDK library. + ```bash + python3 -m venv .venv + source .venv/bin/activate + pip3 install -r requirements.txt + pip install --upgrade aws-cdk-lib + ``` +4. **Deploy using AWS CDK**: Synthesize and deploy the CloudFormation stack, bootstrap the environment. + ```bash + cdk synth + cdk bootstrap + cdk deploy + ``` + +For further details, review the [documentation section](#step-5-deploy-the-yolov8-model). + +### What are the prerequisites for deploying YOLOv8 on Amazon SageMaker? + +To deploy YOLOv8 on Amazon SageMaker, ensure you have the following prerequisites: + +1. **AWS Account**: Active AWS account ([sign up here](https://aws.amazon.com/)). +2. **IAM Roles**: Configured IAM roles with permissions for SageMaker, CloudFormation, and Amazon S3. +3. **AWS CLI**: Installed and configured AWS Command Line Interface ([AWS CLI installation guide](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)). +4. **AWS CDK**: Installed AWS Cloud Development Kit ([CDK setup guide](https://docs.aws.amazon.com/cdk/v2/guide/getting_started.html#getting_started_install)). +5. **Service Quotas**: Sufficient quotas for `ml.m5.4xlarge` instances for both endpoint and notebook usage ([request a quota increase](https://docs.aws.amazon.com/servicequotas/latest/userguide/request-quota-increase.html#quota-console-increase)). + +For detailed setup, refer to [this section](#step-1-setup-your-aws-environment). + +### Why should I use Ultralytics YOLOv8 on Amazon SageMaker? + +Using Ultralytics YOLOv8 on Amazon SageMaker offers several advantages: + +1. **Scalability and Management**: SageMaker provides a managed environment with features like autoscaling, which helps in real-time inference needs. +2. **Integration with AWS Services**: Seamlessly integrate with other AWS services, such as S3 for data storage, CloudFormation for infrastructure as code, and CloudWatch for monitoring. +3. **Ease of Deployment**: Simplified setup using AWS CDK scripts and streamlined deployment processes. +4. **Performance**: Leverage Amazon SageMaker's high-performance infrastructure for running large scale inference tasks efficiently. + +Explore more about the advantages of using SageMaker in the [introduction section](#amazon-sagemaker). + +### Can I customize the inference logic for YOLOv8 on Amazon SageMaker? + +Yes, you can customize the inference logic for YOLOv8 on Amazon SageMaker: + +1. **Modify `inference.py`**: Locate and customize the `output_fn` function in the `inference.py` file to tailor output formats. + + ```python + import json + + + def output_fn(prediction_output): + """Formats model outputs as JSON string, extracting attributes like boxes, masks, keypoints.""" + infer = {} + for result in prediction_output: + if result.boxes is not None: + infer["boxes"] = result.boxes.numpy().data.tolist() + # Add more processing logic if necessary + return json.dumps(infer) + ``` + +2. **Deploy Updated Model**: Ensure you redeploy the model using Jupyter notebooks provided (`1_DeployEndpoint.ipynb`) to include these changes. + +Refer to the [detailed steps](#step-5-deploy-the-yolov8-model) for deploying the modified model. + +### How can I test the deployed YOLOv8 model on Amazon SageMaker? + +To test the deployed YOLOv8 model on Amazon SageMaker: + +1. **Open the Test Notebook**: Locate the `2_TestEndpoint.ipynb` notebook in the SageMaker Jupyter environment. +2. **Run the Notebook**: Follow the notebook's instructions to send an image to the endpoint, perform inference, and display results. +3. **Visualize Results**: Use built-in plotting functionalities to visualize performance metrics, such as bounding boxes around detected objects. + +For comprehensive testing instructions, visit the [testing section](#step-6-testing-your-deployment). diff --git a/ultralytics/docs/en/integrations/clearml.md b/ultralytics/docs/en/integrations/clearml.md new file mode 100644 index 0000000000000000000000000000000000000000..8296c15533dc00c7f7ce3c10cff86204d14fe259 --- /dev/null +++ b/ultralytics/docs/en/integrations/clearml.md @@ -0,0 +1,246 @@ +--- +comments: true +description: Discover how to integrate YOLOv8 with ClearML to streamline your MLOps workflow, automate experiments, and enhance model management effortlessly. +keywords: YOLOv8, ClearML, MLOps, Ultralytics, machine learning, object detection, model training, automation, experiment management +--- + +# Training YOLOv8 with ClearML: Streamlining Your MLOps Workflow + +MLOps bridges the gap between creating and deploying machine learning models in real-world settings. It focuses on efficient deployment, scalability, and ongoing management to ensure models perform well in practical applications. + +[Ultralytics YOLOv8](https://www.ultralytics.com/) effortlessly integrates with ClearML, streamlining and enhancing your object detection model's training and management. This guide will walk you through the integration process, detailing how to set up ClearML, manage experiments, automate model management, and collaborate effectively. + +## ClearML + +

+ ClearML Overview +

+ +[ClearML](https://clear.ml/) is an innovative open-source MLOps platform that is skillfully designed to automate, monitor, and orchestrate machine learning workflows. Its key features include automated logging of all training and inference data for full experiment reproducibility, an intuitive web UI for easy data visualization and analysis, advanced hyperparameter optimization algorithms, and robust model management for efficient deployment across various platforms. + +## YOLOv8 Training with ClearML + +You can bring automation and efficiency to your machine learning workflow by improving your training process by integrating YOLOv8 with ClearML. + +## Installation + +To install the required packages, run: + +!!! tip "Installation" + + === "CLI" + + ```bash + # Install the required packages for YOLOv8 and ClearML + pip install ultralytics clearml + ``` + +For detailed instructions and best practices related to the installation process, be sure to check our [YOLOv8 Installation guide](../quickstart.md). While installing the required packages for YOLOv8, if you encounter any difficulties, consult our [Common Issues guide](../guides/yolo-common-issues.md) for solutions and tips. + +## Configuring ClearML + +Once you have installed the necessary packages, the next step is to initialize and configure your ClearML SDK. This involves setting up your ClearML account and obtaining the necessary credentials for a seamless connection between your development environment and the ClearML server. + +Begin by initializing the ClearML SDK in your environment. The 'clearml-init' command starts the setup process and prompts you for the necessary credentials. + +!!! tip "Initial SDK Setup" + + === "CLI" + + ```bash + # Initialize your ClearML SDK setup process + clearml-init + ``` + +After executing this command, visit the [ClearML Settings page](https://app.clear.ml/settings/workspace-configuration). Navigate to the top right corner and select "Settings." Go to the "Workspace" section and click on "Create new credentials." Use the credentials provided in the "Create Credentials" pop-up to complete the setup as instructed, depending on whether you are configuring ClearML in a Jupyter Notebook or a local Python environment. + +## Usage + +Before diving into the usage instructions, be sure to check out the range of [YOLOv8 models offered by Ultralytics](../models/index.md). This will help you choose the most appropriate model for your project requirements. + +!!! example "Usage" + + === "Python" + + ```python + from clearml import Task + + from ultralytics import YOLO + + # Step 1: Creating a ClearML Task + task = Task.init(project_name="my_project", task_name="my_yolov8_task") + + # Step 2: Selecting the YOLOv8 Model + model_variant = "yolov8n" + task.set_parameter("model_variant", model_variant) + + # Step 3: Loading the YOLOv8 Model + model = YOLO(f"{model_variant}.pt") + + # Step 4: Setting Up Training Arguments + args = dict(data="coco8.yaml", epochs=16) + task.connect(args) + + # Step 5: Initiating Model Training + results = model.train(**args) + ``` + +### Understanding the Code + +Let's understand the steps showcased in the usage code snippet above. + +**Step 1: Creating a ClearML Task**: A new task is initialized in ClearML, specifying your project and task names. This task will track and manage your model's training. + +**Step 2: Selecting the YOLOv8 Model**: The `model_variant` variable is set to 'yolov8n', one of the YOLOv8 models. This variant is then logged in ClearML for tracking. + +**Step 3: Loading the YOLOv8 Model**: The selected YOLOv8 model is loaded using Ultralytics' YOLO class, preparing it for training. + +**Step 4: Setting Up Training Arguments**: Key training arguments like the dataset (`coco8.yaml`) and the number of epochs (`16`) are organized in a dictionary and connected to the ClearML task. This allows for tracking and potential modification via the ClearML UI. For a detailed understanding of the model training process and best practices, refer to our [YOLOv8 Model Training guide](../modes/train.md). + +**Step 5: Initiating Model Training**: The model training is started with the specified arguments. The results of the training process are captured in the `results` variable. + +### Understanding the Output + +Upon running the usage code snippet above, you can expect the following output: + +- A confirmation message indicating the creation of a new ClearML task, along with its unique ID. +- An informational message about the script code being stored, indicating that the code execution is being tracked by ClearML. +- A URL link to the ClearML results page where you can monitor the training progress and view detailed logs. +- Download progress for the YOLOv8 model and the specified dataset, followed by a summary of the model architecture and training configuration. +- Initialization messages for various training components like TensorBoard, Automatic Mixed Precision (AMP), and dataset preparation. +- Finally, the training process starts, with progress updates as the model trains on the specified dataset. For an in-depth understanding of the performance metrics used during training, read [our guide on performance metrics](../guides/yolo-performance-metrics.md). + +### Viewing the ClearML Results Page + +By clicking on the URL link to the ClearML results page in the output of the usage code snippet, you can access a comprehensive view of your model's training process. + +#### Key Features of the ClearML Results Page + +- **Real-Time Metrics Tracking** + + - Track critical metrics like loss, accuracy, and validation scores as they occur. + - Provides immediate feedback for timely model performance adjustments. + +- **Experiment Comparison** + + - Compare different training runs side-by-side. + - Essential for hyperparameter tuning and identifying the most effective models. + +- **Detailed Logs and Outputs** + + - Access comprehensive logs, graphical representations of metrics, and console outputs. + - Gain a deeper understanding of model behavior and issue resolution. + +- **Resource Utilization Monitoring** + + - Monitor the utilization of computational resources, including CPU, GPU, and memory. + - Key to optimizing training efficiency and costs. + +- **Model Artifacts Management** + + - View, download, and share model artifacts like trained models and checkpoints. + - Enhances collaboration and streamlines model deployment and sharing. + +For a visual walkthrough of what the ClearML Results Page looks like, watch the video below: + +

+
+ +
+ Watch: YOLOv8 MLOps Integration using ClearML +

+ +### Advanced Features in ClearML + +ClearML offers several advanced features to enhance your MLOps experience. + +#### Remote Execution + +ClearML's remote execution feature facilitates the reproduction and manipulation of experiments on different machines. It logs essential details like installed packages and uncommitted changes. When a task is enqueued, the ClearML Agent pulls it, recreates the environment, and runs the experiment, reporting back with detailed results. + +Deploying a ClearML Agent is straightforward and can be done on various machines using the following command: + +```bash +clearml-agent daemon --queue [--docker] +``` + +This setup is applicable to cloud VMs, local GPUs, or laptops. ClearML Autoscalers help manage cloud workloads on platforms like AWS, GCP, and Azure, automating the deployment of agents and adjusting resources based on your resource budget. + +### Cloning, Editing, and Enqueuing + +ClearML's user-friendly interface allows easy cloning, editing, and enqueuing of tasks. Users can clone an existing experiment, adjust parameters or other details through the UI, and enqueue the task for execution. This streamlined process ensures that the ClearML Agent executing the task uses updated configurations, making it ideal for iterative experimentation and model fine-tuning. + +


+ Cloning, Editing, and Enqueuing with ClearML +

+ +## Summary + +This guide has led you through the process of integrating ClearML with Ultralytics' YOLOv8. Covering everything from initial setup to advanced model management, you've discovered how to leverage ClearML for efficient training, experiment tracking, and workflow optimization in your machine learning projects. + +For further details on usage, visit [ClearML's official documentation](https://clear.ml/docs/latest/docs/integrations/yolov8/). + +Additionally, explore more integrations and capabilities of Ultralytics by visiting the [Ultralytics integration guide page](../integrations/index.md), which is a treasure trove of resources and insights. + +## FAQ + +### What is the process for integrating Ultralytics YOLOv8 with ClearML? + +Integrating Ultralytics YOLOv8 with ClearML involves a series of steps to streamline your MLOps workflow. First, install the necessary packages: + +```bash +pip install ultralytics clearml +``` + +Next, initialize the ClearML SDK in your environment using: + +```bash +clearml-init +``` + +You then configure ClearML with your credentials from the [ClearML Settings page](https://app.clear.ml/settings/workspace-configuration). Detailed instructions on the entire setup process, including model selection and training configurations, can be found in our [YOLOv8 Model Training guide](../modes/train.md). + +### Why should I use ClearML with Ultralytics YOLOv8 for my machine learning projects? + +Using ClearML with Ultralytics YOLOv8 enhances your machine learning projects by automating experiment tracking, streamlining workflows, and enabling robust model management. ClearML offers real-time metrics tracking, resource utilization monitoring, and a user-friendly interface for comparing experiments. These features help optimize your model's performance and make the development process more efficient. Learn more about the benefits and procedures in our [MLOps Integration guide](../modes/train.md). + +### How do I troubleshoot common issues during YOLOv8 and ClearML integration? + +If you encounter issues during the integration of YOLOv8 with ClearML, consult our [Common Issues guide](../guides/yolo-common-issues.md) for solutions and tips. Typical problems might involve package installation errors, credential setup, or configuration issues. This guide provides step-by-step troubleshooting instructions to resolve these common issues efficiently. + +### How do I set up the ClearML task for YOLOv8 model training? + +Setting up a ClearML task for YOLOv8 training involves initializing a task, selecting the model variant, loading the model, setting up training arguments, and finally, starting the model training. Here's a simplified example: + +```python +from clearml import Task + +from ultralytics import YOLO + +# Step 1: Creating a ClearML Task +task = Task.init(project_name="my_project", task_name="my_yolov8_task") + +# Step 2: Selecting the YOLOv8 Model +model_variant = "yolov8n" +task.set_parameter("model_variant", model_variant) + +# Step 3: Loading the YOLOv8 Model +model = YOLO(f"{model_variant}.pt") + +# Step 4: Setting Up Training Arguments +args = dict(data="coco8.yaml", epochs=16) +task.connect(args) + +# Step 5: Initiating Model Training +results = model.train(**args) +``` + +Refer to our [Usage guide](#usage) for a detailed breakdown of these steps. + +### Where can I view the results of my YOLOv8 training in ClearML? + +After running your YOLOv8 training script with ClearML, you can view the results on the ClearML results page. The output will include a URL link to the ClearML dashboard, where you can track metrics, compare experiments, and monitor resource usage. For more details on how to view and interpret the results, check our section on [Viewing the ClearML Results Page](#viewing-the-clearml-results-page). diff --git a/ultralytics/docs/en/integrations/comet.md b/ultralytics/docs/en/integrations/comet.md new file mode 100644 index 0000000000000000000000000000000000000000..0cd1959481f9d3adfb04b8f58a5e01b9a861257e --- /dev/null +++ b/ultralytics/docs/en/integrations/comet.md @@ -0,0 +1,286 @@ +--- +comments: true +description: Learn to simplify the logging of YOLOv8 training with Comet ML. This guide covers installation, setup, real-time insights, and custom logging. +keywords: YOLOv8, Comet ML, logging, machine learning, training, model checkpoints, metrics, installation, configuration, real-time insights, custom logging +--- + +# Elevating YOLOv8 Training: Simplify Your Logging Process with Comet ML + +Logging key training details such as parameters, metrics, image predictions, and model checkpoints is essential in machine learning—it keeps your project transparent, your progress measurable, and your results repeatable. + +[Ultralytics YOLOv8](https://www.ultralytics.com/) seamlessly integrates with Comet ML, efficiently capturing and optimizing every aspect of your YOLOv8 object detection model's training process. In this guide, we'll cover the installation process, Comet ML setup, real-time insights, custom logging, and offline usage, ensuring that your YOLOv8 training is thoroughly documented and fine-tuned for outstanding results. + +## Comet ML + +

+ Comet ML Overview +

+ +[Comet ML](https://www.comet.com/site/) is a platform for tracking, comparing, explaining, and optimizing machine learning models and experiments. It allows you to log metrics, parameters, media, and more during your model training and monitor your experiments through an aesthetically pleasing web interface. Comet ML helps data scientists iterate more rapidly, enhances transparency and reproducibility, and aids in the development of production models. + +## Harnessing the Power of YOLOv8 and Comet ML + +By combining Ultralytics YOLOv8 with Comet ML, you unlock a range of benefits. These include simplified experiment management, real-time insights for quick adjustments, flexible and tailored logging options, and the ability to log experiments offline when internet access is limited. This integration empowers you to make data-driven decisions, analyze performance metrics, and achieve exceptional results. + +## Installation + +To install the required packages, run: + +!!! tip "Installation" + + === "CLI" + + ```bash + # Install the required packages for YOLOv8 and Comet ML + pip install ultralytics comet_ml torch torchvision + ``` + +## Configuring Comet ML + +After installing the required packages, you'll need to sign up, get a [Comet API Key](https://www.comet.com/signup), and configure it. + +!!! tip "Configuring Comet ML" + + === "CLI" + + ```bash + # Set your Comet Api Key + export COMET_API_KEY= + ``` + +Then, you can initialize your Comet project. Comet will automatically detect the API key and proceed with the setup. + +```python +import comet_ml + +comet_ml.login(project_name="comet-example-yolov8-coco128") +``` + +If you are using a Google Colab notebook, the code above will prompt you to enter your API key for initialization. + +## Usage + +Before diving into the usage instructions, be sure to check out the range of [YOLOv8 models offered by Ultralytics](../models/index.md). This will help you choose the most appropriate model for your project requirements. + +!!! example "Usage" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a model + model = YOLO("yolov8n.pt") + + # Train the model + results = model.train( + data="coco8.yaml", + project="comet-example-yolov8-coco128", + batch=32, + save_period=1, + save_json=True, + epochs=3, + ) + ``` + +After running the training code, Comet ML will create an experiment in your Comet workspace to track the run automatically. You will then be provided with a link to view the detailed logging of your [YOLOv8 model's training](../modes/train.md) process. + +Comet automatically logs the following data with no additional configuration: metrics such as mAP and loss, hyperparameters, model checkpoints, interactive confusion matrix, and image bounding box predictions. + +## Understanding Your Model's Performance with Comet ML Visualizations + +Let's dive into what you'll see on the Comet ML dashboard once your YOLOv8 model begins training. The dashboard is where all the action happens, presenting a range of automatically logged information through visuals and statistics. Here's a quick tour: + +**Experiment Panels** + +The experiment panels section of the Comet ML dashboard organize and present the different runs and their metrics, such as segment mask loss, class loss, precision, and mean average precision. + +

+ Comet ML Overview +

+ +**Metrics** + +In the metrics section, you have the option to examine the metrics in a tabular format as well, which is displayed in a dedicated pane as illustrated here. + +

+ Comet ML Overview +

+ +**Interactive Confusion Matrix** + +The confusion matrix, found in the Confusion Matrix tab, provides an interactive way to assess the model's classification accuracy. It details the correct and incorrect predictions, allowing you to understand the model's strengths and weaknesses. + +

+ Comet ML Overview +

+ +**System Metrics** + +Comet ML logs system metrics to help identify any bottlenecks in the training process. It includes metrics such as GPU utilization, GPU memory usage, CPU utilization, and RAM usage. These are essential for monitoring the efficiency of resource usage during model training. + +

+ Comet ML Overview +

+ +## Customizing Comet ML Logging + +Comet ML offers the flexibility to customize its logging behavior by setting environment variables. These configurations allow you to tailor Comet ML to your specific needs and preferences. Here are some helpful customization options: + +### Logging Image Predictions + +You can control the number of image predictions that Comet ML logs during your experiments. By default, Comet ML logs 100 image predictions from the validation set. However, you can change this number to better suit your requirements. For example, to log 200 image predictions, use the following code: + +```python +import os + +os.environ["COMET_MAX_IMAGE_PREDICTIONS"] = "200" +``` + +### Batch Logging Interval + +Comet ML allows you to specify how often batches of image predictions are logged. The `COMET_EVAL_BATCH_LOGGING_INTERVAL` environment variable controls this frequency. The default setting is 1, which logs predictions from every validation batch. You can adjust this value to log predictions at a different interval. For instance, setting it to 4 will log predictions from every fourth batch. + +```python +import os + +os.environ["COMET_EVAL_BATCH_LOGGING_INTERVAL"] = "4" +``` + +### Disabling Confusion Matrix Logging + +In some cases, you may not want to log the confusion matrix from your validation set after every epoch. You can disable this feature by setting the `COMET_EVAL_LOG_CONFUSION_MATRIX` environment variable to "false." The confusion matrix will only be logged once, after the training is completed. + +```python +import os + +os.environ["COMET_EVAL_LOG_CONFUSION_MATRIX"] = "false" +``` + +### Offline Logging + +If you find yourself in a situation where internet access is limited, Comet ML provides an offline logging option. You can set the `COMET_MODE` environment variable to "offline" to enable this feature. Your experiment data will be saved locally in a directory that you can later upload to Comet ML when internet connectivity is available. + +```python +import os + +os.environ["COMET_MODE"] = "offline" +``` + +## Summary + +This guide has walked you through integrating Comet ML with Ultralytics' YOLOv8. From installation to customization, you've learned to streamline experiment management, gain real-time insights, and adapt logging to your project's needs. + +Explore [Comet ML's official documentation](https://www.comet.com/docs/v2/integrations/third-party-tools/yolov8/) for more insights on integrating with YOLOv8. + +Furthermore, if you're looking to dive deeper into the practical applications of YOLOv8, specifically for image segmentation tasks, this detailed guide on [fine-tuning YOLOv8 with Comet ML](https://www.comet.com/site/blog/fine-tuning-yolov8-for-image-segmentation-with-comet/) offers valuable insights and step-by-step instructions to enhance your model's performance. + +Additionally, to explore other exciting integrations with Ultralytics, check out the [integration guide page](../integrations/index.md), which offers a wealth of resources and information. + +## FAQ + +### How do I integrate Comet ML with Ultralytics YOLOv8 for training? + +To integrate Comet ML with Ultralytics YOLOv8, follow these steps: + +1. **Install the required packages**: + + ```bash + pip install ultralytics comet_ml torch torchvision + ``` + +2. **Set up your Comet API Key**: + + ```bash + export COMET_API_KEY= + ``` + +3. **Initialize your Comet project in your Python code**: + + ```python + import comet_ml + + comet_ml.login(project_name="comet-example-yolov8-coco128") + ``` + +4. **Train your YOLOv8 model and log metrics**: + + ```python + from ultralytics import YOLO + + model = YOLO("yolov8n.pt") + results = model.train( + data="coco8.yaml", + project="comet-example-yolov8-coco128", + batch=32, + save_period=1, + save_json=True, + epochs=3, + ) + ``` + +For more detailed instructions, refer to the [Comet ML configuration section](#configuring-comet-ml). + +### What are the benefits of using Comet ML with YOLOv8? + +By integrating Ultralytics YOLOv8 with Comet ML, you can: + +- **Monitor real-time insights**: Get instant feedback on your training results, allowing for quick adjustments. +- **Log extensive metrics**: Automatically capture essential metrics such as mAP, loss, hyperparameters, and model checkpoints. +- **Track experiments offline**: Log your training runs locally when internet access is unavailable. +- **Compare different training runs**: Use the interactive Comet ML dashboard to analyze and compare multiple experiments. + +By leveraging these features, you can optimize your machine learning workflows for better performance and reproducibility. For more information, visit the [Comet ML integration guide](../integrations/index.md). + +### How do I customize the logging behavior of Comet ML during YOLOv8 training? + +Comet ML allows for extensive customization of its logging behavior using environment variables: + +- **Change the number of image predictions logged**: + + ```python + import os + + os.environ["COMET_MAX_IMAGE_PREDICTIONS"] = "200" + ``` + +- **Adjust batch logging interval**: + + ```python + import os + + os.environ["COMET_EVAL_BATCH_LOGGING_INTERVAL"] = "4" + ``` + +- **Disable confusion matrix logging**: + + ```python + import os + + os.environ["COMET_EVAL_LOG_CONFUSION_MATRIX"] = "false" + ``` + +Refer to the [Customizing Comet ML Logging](#customizing-comet-ml-logging) section for more customization options. + +### How do I view detailed metrics and visualizations of my YOLOv8 training on Comet ML? + +Once your YOLOv8 model starts training, you can access a wide range of metrics and visualizations on the Comet ML dashboard. Key features include: + +- **Experiment Panels**: View different runs and their metrics, including segment mask loss, class loss, and mean average precision. +- **Metrics**: Examine metrics in tabular format for detailed analysis. +- **Interactive Confusion Matrix**: Assess classification accuracy with an interactive confusion matrix. +- **System Metrics**: Monitor GPU and CPU utilization, memory usage, and other system metrics. + +For a detailed overview of these features, visit the [Understanding Your Model's Performance with Comet ML Visualizations](#understanding-your-models-performance-with-comet-ml-visualizations) section. + +### Can I use Comet ML for offline logging when training YOLOv8 models? + +Yes, you can enable offline logging in Comet ML by setting the `COMET_MODE` environment variable to "offline": + +```python +import os + +os.environ["COMET_MODE"] = "offline" +``` + +This feature allows you to log your experiment data locally, which can later be uploaded to Comet ML when internet connectivity is available. This is particularly useful when working in environments with limited internet access. For more details, refer to the [Offline Logging](#offline-logging) section. diff --git a/ultralytics/docs/en/integrations/coreml.md b/ultralytics/docs/en/integrations/coreml.md new file mode 100644 index 0000000000000000000000000000000000000000..b242486d1b3641d91aa68cc2fc6670e4caac792a --- /dev/null +++ b/ultralytics/docs/en/integrations/coreml.md @@ -0,0 +1,218 @@ +--- +comments: true +description: Learn how to export YOLOv8 models to CoreML for optimized, on-device machine learning on iOS and macOS. Follow step-by-step instructions. +keywords: CoreML export, YOLOv8 models, CoreML conversion, Ultralytics, iOS object detection, macOS machine learning, AI deployment, machine learning integration +--- + +# CoreML Export for YOLOv8 Models + +Deploying computer vision models on Apple devices like iPhones and Macs requires a format that ensures seamless performance. + +The CoreML export format allows you to optimize your [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics) models for efficient object detection in iOS and macOS applications. In this guide, we'll walk you through the steps for converting your models to the CoreML format, making it easier for your models to perform well on Apple devices. + +## CoreML + +

+ CoreML Overview +

+ +[CoreML](https://developer.apple.com/documentation/coreml) is Apple's foundational machine learning framework that builds upon Accelerate, BNNS, and Metal Performance Shaders. It provides a machine-learning model format that seamlessly integrates into iOS applications and supports tasks such as image analysis, natural language processing, audio-to-text conversion, and sound analysis. + +Applications can take advantage of Core ML without the need to have a network connection or API calls because the Core ML framework works using on-device computing. This means model inference can be performed locally on the user's device. + +## Key Features of CoreML Models + +Apple's CoreML framework offers robust features for on-device machine learning. Here are the key features that make CoreML a powerful tool for developers: + +- **Comprehensive Model Support**: Converts and runs models from popular frameworks like TensorFlow, PyTorch, scikit-learn, XGBoost, and LibSVM. + +

+ CoreML Supported Models +

+ +- **On-device Machine Learning**: Ensures data privacy and swift processing by executing models directly on the user's device, eliminating the need for network connectivity. + +- **Performance and Optimization**: Uses the device's CPU, GPU, and Neural Engine for optimal performance with minimal power and memory usage. Offers tools for model compression and optimization while maintaining accuracy. + +- **Ease of Integration**: Provides a unified format for various model types and a user-friendly API for seamless integration into apps. Supports domain-specific tasks through frameworks like Vision and Natural Language. + +- **Advanced Features**: Includes on-device training capabilities for personalized experiences, asynchronous predictions for interactive ML experiences, and model inspection and validation tools. + +## CoreML Deployment Options + +Before we look at the code for exporting YOLOv8 models to the CoreML format, let's understand where CoreML models are usually used. + +CoreML offers various deployment options for machine learning models, including: + +- **On-Device Deployment**: This method directly integrates CoreML models into your iOS app. It's particularly advantageous for ensuring low latency, enhanced privacy (since data remains on the device), and offline functionality. This approach, however, may be limited by the device's hardware capabilities, especially for larger and more complex models. On-device deployment can be executed in the following two ways. + + - **Embedded Models**: These models are included in the app bundle and are immediately accessible. They are ideal for small models that do not require frequent updates. + + - **Downloaded Models**: These models are fetched from a server as needed. This approach is suitable for larger models or those needing regular updates. It helps keep the app bundle size smaller. + +- **Cloud-Based Deployment**: CoreML models are hosted on servers and accessed by the iOS app through API requests. This scalable and flexible option enables easy model updates without app revisions. It's ideal for complex models or large-scale apps requiring regular updates. However, it does require an internet connection and may pose latency and security issues. + +## Exporting YOLOv8 Models to CoreML + +Exporting YOLOv8 to CoreML enables optimized, on-device machine learning performance within Apple's ecosystem, offering benefits in terms of efficiency, security, and seamless integration with iOS, macOS, watchOS, and tvOS platforms. + +### Installation + +To install the required package, run: + +!!! tip "Installation" + + === "CLI" + + ```bash + # Install the required package for YOLOv8 + pip install ultralytics + ``` + +For detailed instructions and best practices related to the installation process, check our [YOLOv8 Installation guide](../quickstart.md). While installing the required packages for YOLOv8, if you encounter any difficulties, consult our [Common Issues guide](../guides/yolo-common-issues.md) for solutions and tips. + +### Usage + +Before diving into the usage instructions, be sure to check out the range of [YOLOv8 models offered by Ultralytics](../models/index.md). This will help you choose the most appropriate model for your project requirements. + +!!! example "Usage" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load the YOLOv8 model + model = YOLO("yolov8n.pt") + + # Export the model to CoreML format + model.export(format="coreml") # creates 'yolov8n.mlpackage' + + # Load the exported CoreML model + coreml_model = YOLO("yolov8n.mlpackage") + + # Run inference + results = coreml_model("https://ultralytics.com/images/bus.jpg") + ``` + + === "CLI" + + ```bash + # Export a YOLOv8n PyTorch model to CoreML format + yolo export model=yolov8n.pt format=coreml # creates 'yolov8n.mlpackage'' + + # Run inference with the exported model + yolo predict model=yolov8n.mlpackage source='https://ultralytics.com/images/bus.jpg' + ``` + +For more details about the export process, visit the [Ultralytics documentation page on exporting](../modes/export.md). + +## Deploying Exported YOLOv8 CoreML Models + +Having successfully exported your Ultralytics YOLOv8 models to CoreML, the next critical phase is deploying these models effectively. For detailed guidance on deploying CoreML models in various environments, check out these resources: + +- **[CoreML Tools](https://apple.github.io/coremltools/docs-guides/)**: This guide includes instructions and examples to convert models from TensorFlow, PyTorch, and other libraries to Core ML. + +- **[ML and Vision](https://developer.apple.com/videos/)**: A collection of comprehensive videos that cover various aspects of using and implementing CoreML models. + +- **[Integrating a Core ML Model into Your App](https://developer.apple.com/documentation/coreml/integrating-a-core-ml-model-into-your-app)**: A comprehensive guide on integrating a CoreML model into an iOS application, detailing steps from preparing the model to implementing it in the app for various functionalities. + +## Summary + +In this guide, we went over how to export Ultralytics YOLOv8 models to CoreML format. By following the steps outlined in this guide, you can ensure maximum compatibility and performance when exporting YOLOv8 models to CoreML. + +For further details on usage, visit the [CoreML official documentation](https://developer.apple.com/documentation/coreml). + +Also, if you'd like to know more about other Ultralytics YOLOv8 integrations, visit our [integration guide page](../integrations/index.md). You'll find plenty of valuable resources and insights there. + +## FAQ + +### How do I export YOLOv8 models to CoreML format? + +To export your [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics) models to CoreML format, you'll first need to ensure you have the `ultralytics` package installed. You can install it using: + +!!! example "Installation" + + === "CLI" + + ```bash + pip install ultralytics + ``` + +Next, you can export the model using the following Python or CLI commands: + +!!! example "Usage" + + === "Python" + + ```python + from ultralytics import YOLO + + model = YOLO("yolov8n.pt") + model.export(format="coreml") + ``` + + === "CLI" + + ```bash + yolo export model=yolov8n.pt format=coreml + ``` + +For further details, refer to the [Exporting YOLOv8 Models to CoreML](../modes/export.md) section of our documentation. + +### What are the benefits of using CoreML for deploying YOLOv8 models? + +CoreML provides numerous advantages for deploying [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics) models on Apple devices: + +- **On-device Processing**: Enables local model inference on devices, ensuring data privacy and minimizing latency. +- **Performance Optimization**: Leverages the full potential of the device's CPU, GPU, and Neural Engine, optimizing both speed and efficiency. +- **Ease of Integration**: Offers a seamless integration experience with Apple's ecosystems, including iOS, macOS, watchOS, and tvOS. +- **Versatility**: Supports a wide range of machine learning tasks such as image analysis, audio processing, and natural language processing using the CoreML framework. + +For more details on integrating your CoreML model into an iOS app, check out the guide on [Integrating a Core ML Model into Your App](https://developer.apple.com/documentation/coreml/integrating-a-core-ml-model-into-your-app). + +### What are the deployment options for YOLOv8 models exported to CoreML? + +Once you export your YOLOv8 model to CoreML format, you have multiple deployment options: + +1. **On-Device Deployment**: Directly integrate CoreML models into your app for enhanced privacy and offline functionality. This can be done as: + + - **Embedded Models**: Included in the app bundle, accessible immediately. + - **Downloaded Models**: Fetched from a server as needed, keeping the app bundle size smaller. + +2. **Cloud-Based Deployment**: Host CoreML models on servers and access them via API requests. This approach supports easier updates and can handle more complex models. + +For detailed guidance on deploying CoreML models, refer to [CoreML Deployment Options](#coreml-deployment-options). + +### How does CoreML ensure optimized performance for YOLOv8 models? + +CoreML ensures optimized performance for [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics) models by utilizing various optimization techniques: + +- **Hardware Acceleration**: Uses the device's CPU, GPU, and Neural Engine for efficient computation. +- **Model Compression**: Provides tools for compressing models to reduce their footprint without compromising accuracy. +- **Adaptive Inference**: Adjusts inference based on the device's capabilities to maintain a balance between speed and performance. + +For more information on performance optimization, visit the [CoreML official documentation](https://developer.apple.com/documentation/coreml). + +### Can I run inference directly with the exported CoreML model? + +Yes, you can run inference directly using the exported CoreML model. Below are the commands for Python and CLI: + +!!! example "Running Inference" + + === "Python" + + ```python + from ultralytics import YOLO + + coreml_model = YOLO("yolov8n.mlpackage") + results = coreml_model("https://ultralytics.com/images/bus.jpg") + ``` + + === "CLI" + + ```bash + yolo predict model=yolov8n.mlpackage source='https://ultralytics.com/images/bus.jpg' + ``` + +For additional information, refer to the [Usage section](#usage) of the CoreML export guide. diff --git a/ultralytics/docs/en/integrations/dvc.md b/ultralytics/docs/en/integrations/dvc.md new file mode 100644 index 0000000000000000000000000000000000000000..11cbde860133de899087a3cb5ae42a553d688a2e --- /dev/null +++ b/ultralytics/docs/en/integrations/dvc.md @@ -0,0 +1,278 @@ +--- +comments: true +description: Unlock seamless YOLOv8 tracking with DVCLive. Discover how to log, visualize, and analyze experiments for optimized ML model performance. +keywords: YOLOv8, DVCLive, experiment tracking, machine learning, model training, data visualization, Git integration +--- + +# Advanced YOLOv8 Experiment Tracking with DVCLive + +Experiment tracking in machine learning is critical to model development and evaluation. It involves recording and analyzing various parameters, metrics, and outcomes from numerous training runs. This process is essential for understanding model performance and making data-driven decisions to refine and optimize models. + +Integrating DVCLive with [Ultralytics YOLOv8](https://www.ultralytics.com/) transforms the way experiments are tracked and managed. This integration offers a seamless solution for automatically logging key experiment details, comparing results across different runs, and visualizing data for in-depth analysis. In this guide, we'll understand how DVCLive can be used to streamline the process. + +## DVCLive + +

+ DVCLive Overview +

+ +[DVCLive](https://dvc.org/doc/dvclive), developed by DVC, is an innovative open-source tool for experiment tracking in machine learning. Integrating seamlessly with Git and DVC, it automates the logging of crucial experiment data like model parameters and training metrics. Designed for simplicity, DVCLive enables effortless comparison and analysis of multiple runs, enhancing the efficiency of machine learning projects with intuitive data visualization and analysis tools. + +## YOLOv8 Training with DVCLive + +YOLOv8 training sessions can be effectively monitored with DVCLive. Additionally, DVC provides integral features for visualizing these experiments, including the generation of a report that enables the comparison of metric plots across all tracked experiments, offering a comprehensive view of the training process. + +## Installation + +To install the required packages, run: + +!!! tip "Installation" + + === "CLI" + + ```bash + # Install the required packages for YOLOv8 and DVCLive + pip install ultralytics dvclive + ``` + +For detailed instructions and best practices related to the installation process, be sure to check our [YOLOv8 Installation guide](../quickstart.md). While installing the required packages for YOLOv8, if you encounter any difficulties, consult our [Common Issues guide](../guides/yolo-common-issues.md) for solutions and tips. + +## Configuring DVCLive + +Once you have installed the necessary packages, the next step is to set up and configure your environment with the necessary credentials. This setup ensures a smooth integration of DVCLive into your existing workflow. + +Begin by initializing a Git repository, as Git plays a crucial role in version control for both your code and DVCLive configurations. + +!!! tip "Initial Environment Setup" + + === "CLI" + + ```bash + # Initialize a Git repository + git init -q + + # Configure Git with your details + git config --local user.email "you@example.com" + git config --local user.name "Your Name" + + # Initialize DVCLive in your project + dvc init -q + + # Commit the DVCLive setup to your Git repository + git commit -m "DVC init" + ``` + +In these commands, ensure to replace "you@example.com" with the email address associated with your Git account, and "Your Name" with your Git account username. + +## Usage + +Before diving into the usage instructions, be sure to check out the range of [YOLOv8 models offered by Ultralytics](../models/index.md). This will help you choose the most appropriate model for your project requirements. + +### Training YOLOv8 Models with DVCLive + +Start by running your YOLOv8 training sessions. You can use different model configurations and training parameters to suit your project needs. For instance: + +```bash +# Example training commands for YOLOv8 with varying configurations +yolo train model=yolov8n.pt data=coco8.yaml epochs=5 imgsz=512 +yolo train model=yolov8n.pt data=coco8.yaml epochs=5 imgsz=640 +``` + +Adjust the model, data, epochs, and imgsz parameters according to your specific requirements. For a detailed understanding of the model training process and best practices, refer to our [YOLOv8 Model Training guide](../modes/train.md). + +### Monitoring Experiments with DVCLive + +DVCLive enhances the training process by enabling the tracking and visualization of key metrics. When installed, Ultralytics YOLOv8 automatically integrates with DVCLive for experiment tracking, which you can later analyze for performance insights. For a comprehensive understanding of the specific performance metrics used during training, be sure to explore [our detailed guide on performance metrics](../guides/yolo-performance-metrics.md). + +### Analyzing Results + +After your YOLOv8 training sessions are complete, you can leverage DVCLive's powerful visualization tools for in-depth analysis of the results. DVCLive's integration ensures that all training metrics are systematically logged, facilitating a comprehensive evaluation of your model's performance. + +To start the analysis, you can extract the experiment data using DVC's API and process it with Pandas for easier handling and visualization: + +```python +import dvc.api +import pandas as pd + +# Define the columns of interest +columns = ["Experiment", "epochs", "imgsz", "model", "metrics.mAP50-95(B)"] + +# Retrieve experiment data +df = pd.DataFrame(dvc.api.exp_show(), columns=columns) + +# Clean the data +df.dropna(inplace=True) +df.reset_index(drop=True, inplace=True) + +# Display the DataFrame +print(df) +``` + +The output of the code snippet above provides a clear tabular view of the different experiments conducted with YOLOv8 models. Each row represents a different training run, detailing the experiment's name, the number of epochs, image size (imgsz), the specific model used, and the mAP50-95(B) metric. This metric is crucial for evaluating the model's accuracy, with higher values indicating better performance. + +#### Visualizing Results with Plotly + +For a more interactive and visual analysis of your experiment results, you can use Plotly's parallel coordinates plot. This type of plot is particularly useful for understanding the relationships and trade-offs between different parameters and metrics. + +```python +from plotly.express import parallel_coordinates + +# Create a parallel coordinates plot +fig = parallel_coordinates(df, columns, color="metrics.mAP50-95(B)") + +# Display the plot +fig.show() +``` + +The output of the code snippet above generates a plot that will visually represent the relationships between epochs, image size, model type, and their corresponding mAP50-95(B) scores, enabling you to spot trends and patterns in your experiment data. + +#### Generating Comparative Visualizations with DVC + +DVC provides a useful command to generate comparative plots for your experiments. This can be especially helpful to compare the performance of different models over various training runs. + +```bash +# Generate DVC comparative plots +dvc plots diff $(dvc exp list --names-only) +``` + +After executing this command, DVC generates plots comparing the metrics across different experiments, which are saved as HTML files. Below is an example image illustrating typical plots generated by this process. The image showcases various graphs, including those representing mAP, recall, precision, loss values, and more, providing a visual overview of key performance metrics: + +

+ DVCLive Plots +

+ +### Displaying DVC Plots + +If you are using a Jupyter Notebook and you want to display the generated DVC plots, you can use the IPython display functionality. + +```python +from IPython.display import HTML + +# Display the DVC plots as HTML +HTML(filename="./dvc_plots/index.html") +``` + +This code will render the HTML file containing the DVC plots directly in your Jupyter Notebook, providing an easy and convenient way to analyze the visualized experiment data. + +### Making Data-Driven Decisions + +Use the insights gained from these visualizations to make informed decisions about model optimizations, hyperparameter tuning, and other modifications to enhance your model's performance. + +### Iterating on Experiments + +Based on your analysis, iterate on your experiments. Adjust model configurations, training parameters, or even the data inputs, and repeat the training and analysis process. This iterative approach is key to refining your model for the best possible performance. + +## Summary + +This guide has led you through the process of integrating DVCLive with Ultralytics' YOLOv8. You have learned how to harness the power of DVCLive for detailed experiment monitoring, effective visualization, and insightful analysis in your machine learning endeavors. + +For further details on usage, visit [DVCLive's official documentation](https://dvc.org/doc/dvclive/ml-frameworks/yolo). + +Additionally, explore more integrations and capabilities of Ultralytics by visiting the [Ultralytics integration guide page](../integrations/index.md), which is a collection of great resources and insights. + +## FAQ + +### How do I integrate DVCLive with Ultralytics YOLOv8 for experiment tracking? + +Integrating DVCLive with Ultralytics YOLOv8 is straightforward. Start by installing the necessary packages: + +!!! example "Installation" + + === "CLI" + + ```bash + pip install ultralytics dvclive + ``` + +Next, initialize a Git repository and configure DVCLive in your project: + +!!! example "Initial Environment Setup" + + === "CLI" + + ```bash + git init -q + git config --local user.email "you@example.com" + git config --local user.name "Your Name" + dvc init -q + git commit -m "DVC init" + ``` + +Follow our [YOLOv8 Installation guide](../quickstart.md) for detailed setup instructions. + +### Why should I use DVCLive for tracking YOLOv8 experiments? + +Using DVCLive with YOLOv8 provides several advantages, such as: + +- **Automated Logging**: DVCLive automatically records key experiment details like model parameters and metrics. +- **Easy Comparison**: Facilitates comparison of results across different runs. +- **Visualization Tools**: Leverages DVCLive's robust data visualization capabilities for in-depth analysis. + +For further details, refer to our guide on [YOLOv8 Model Training](../modes/train.md) and [YOLO Performance Metrics](../guides/yolo-performance-metrics.md) to maximize your experiment tracking efficiency. + +### How can DVCLive improve my results analysis for YOLOv8 training sessions? + +After completing your YOLOv8 training sessions, DVCLive helps in visualizing and analyzing the results effectively. Example code for loading and displaying experiment data: + +```python +import dvc.api +import pandas as pd + +# Define columns of interest +columns = ["Experiment", "epochs", "imgsz", "model", "metrics.mAP50-95(B)"] + +# Retrieve experiment data +df = pd.DataFrame(dvc.api.exp_show(), columns=columns) + +# Clean data +df.dropna(inplace=True) +df.reset_index(drop=True, inplace=True) + +# Display DataFrame +print(df) +``` + +To visualize results interactively, use Plotly's parallel coordinates plot: + +```python +from plotly.express import parallel_coordinates + +fig = parallel_coordinates(df, columns, color="metrics.mAP50-95(B)") +fig.show() +``` + +Refer to our guide on [YOLOv8 Training with DVCLive](#yolov8-training-with-dvclive) for more examples and best practices. + +### What are the steps to configure my environment for DVCLive and YOLOv8 integration? + +To configure your environment for a smooth integration of DVCLive and YOLOv8, follow these steps: + +1. **Install Required Packages**: Use `pip install ultralytics dvclive`. +2. **Initialize Git Repository**: Run `git init -q`. +3. **Setup DVCLive**: Execute `dvc init -q`. +4. **Commit to Git**: Use `git commit -m "DVC init"`. + +These steps ensure proper version control and setup for experiment tracking. For in-depth configuration details, visit our [Configuration guide](../quickstart.md). + +### How do I visualize YOLOv8 experiment results using DVCLive? + +DVCLive offers powerful tools to visualize the results of YOLOv8 experiments. Here's how you can generate comparative plots: + +!!! example "Generate Comparative Plots" + + === "CLI" + + ```bash + dvc plots diff $(dvc exp list --names-only) + ``` + +To display these plots in a Jupyter Notebook, use: + +```python +from IPython.display import HTML + +# Display plots as HTML +HTML(filename="./dvc_plots/index.html") +``` + +These visualizations help identify trends and optimize model performance. Check our detailed guides on [YOLOv8 Experiment Analysis](#analyzing-results) for comprehensive steps and examples. diff --git a/ultralytics/docs/en/integrations/edge-tpu.md b/ultralytics/docs/en/integrations/edge-tpu.md new file mode 100644 index 0000000000000000000000000000000000000000..d1caf90f5c5751495e87fea91a62297368a9c657 --- /dev/null +++ b/ultralytics/docs/en/integrations/edge-tpu.md @@ -0,0 +1,185 @@ +--- +comments: true +description: Learn how to export YOLOv8 models to TFLite Edge TPU format for high-speed, low-power inferencing on mobile and embedded devices. +keywords: YOLOv8, TFLite Edge TPU, TensorFlow Lite, model export, machine learning, edge computing, neural networks, Ultralytics +--- + +# Learn to Export to TFLite Edge TPU Format From YOLOv8 Model + +Deploying computer vision models on devices with limited computational power, such as mobile or embedded systems, can be tricky. Using a model format that is optimized for faster performance simplifies the process. The [TensorFlow Lite](https://ai.google.dev/edge/litert) [Edge TPU](https://coral.ai/docs/edgetpu/models-intro/) or TFLite Edge TPU model format is designed to use minimal power while delivering fast performance for neural networks. + +The export to TFLite Edge TPU format feature allows you to optimize your [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics) models for high-speed and low-power inferencing. In this guide, we'll walk you through converting your models to the TFLite Edge TPU format, making it easier for your models to perform well on various mobile and embedded devices. + +## Why Should You Export to TFLite Edge TPU? + +Exporting models to TensorFlow Edge TPU makes machine learning tasks fast and efficient. This technology suits applications with limited power, computing resources, and connectivity. The Edge TPU is a hardware accelerator by Google. It speeds up TensorFlow Lite models on edge devices. The image below shows an example of the process involved. + +

+ TFLite Edge TPU +

+ +The Edge TPU works with quantized models. Quantization makes models smaller and faster without losing much accuracy. It is ideal for the limited resources of edge computing, allowing applications to respond quickly by reducing latency and allowing for quick data processing locally, without cloud dependency. Local processing also keeps user data private and secure since it's not sent to a remote server. + +## Key Features of TFLite Edge TPU + +Here are the key features that make TFLite Edge TPU a great model format choice for developers: + +- **Optimized Performance on Edge Devices**: The TFLite Edge TPU achieves high-speed neural networking performance through quantization, model optimization, hardware acceleration, and compiler optimization. Its minimalistic architecture contributes to its smaller size and cost-efficiency. + +- **High Computational Throughput**: TFLite Edge TPU combines specialized hardware acceleration and efficient runtime execution to achieve high computational throughput. It is well-suited for deploying machine learning models with stringent performance requirements on edge devices. + +- **Efficient Matrix Computations**: The TensorFlow Edge TPU is optimized for matrix operations, which are crucial for neural network computations. This efficiency is key in machine learning models, particularly those requiring numerous and complex matrix multiplications and transformations. + +## Deployment Options with TFLite Edge TPU + +Before we jump into how to export YOLOv8 models to the TFLite Edge TPU format, let's understand where TFLite Edge TPU models are usually used. + +TFLite Edge TPU offers various deployment options for machine learning models, including: + +- **On-Device Deployment**: TensorFlow Edge TPU models can be directly deployed on mobile and embedded devices. On-device deployment allows the models to execute directly on the hardware, eliminating the need for cloud connectivity. + +- **Edge Computing with Cloud TensorFlow TPUs**: In scenarios where edge devices have limited processing capabilities, TensorFlow Edge TPUs can offload inference tasks to cloud servers equipped with TPUs. + +- **Hybrid Deployment**: A hybrid approach combines on-device and cloud deployment and offers a versatile and scalable solution for deploying machine learning models. Advantages include on-device processing for quick responses and cloud computing for more complex computations. + +## Exporting YOLOv8 Models to TFLite Edge TPU + +You can expand model compatibility and deployment flexibility by converting YOLOv8 models to TensorFlow Edge TPU. + +### Installation + +To install the required package, run: + +!!! tip "Installation" + + === "CLI" + + ```bash + # Install the required package for YOLOv8 + pip install ultralytics + ``` + +For detailed instructions and best practices related to the installation process, check our [Ultralytics Installation guide](../quickstart.md). While installing the required packages for YOLOv8, if you encounter any difficulties, consult our [Common Issues guide](../guides/yolo-common-issues.md) for solutions and tips. + +### Usage + +Before diving into the usage instructions, it's important to note that while all [Ultralytics YOLOv8 models](../models/index.md) are available for exporting, you can ensure that the model you select supports export functionality [here](../modes/export.md). + +!!! example "Usage" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load the YOLOv8 model + model = YOLO("yolov8n.pt") + + # Export the model to TFLite Edge TPU format + model.export(format="edgetpu") # creates 'yolov8n_full_integer_quant_edgetpu.tflite' + + # Load the exported TFLite Edge TPU model + edgetpu_model = YOLO("yolov8n_full_integer_quant_edgetpu.tflite") + + # Run inference + results = edgetpu_model("https://ultralytics.com/images/bus.jpg") + ``` + + === "CLI" + + ```bash + # Export a YOLOv8n PyTorch model to TFLite Edge TPU format + yolo export model=yolov8n.pt format=edgetpu # creates 'yolov8n_full_integer_quant_edgetpu.tflite' + + # Run inference with the exported model + yolo predict model=yolov8n_full_integer_quant_edgetpu.tflite source='https://ultralytics.com/images/bus.jpg' + ``` + +For more details about supported export options, visit the [Ultralytics documentation page on deployment options](../guides/model-deployment-options.md). + +## Deploying Exported YOLOv8 TFLite Edge TPU Models + +After successfully exporting your Ultralytics YOLOv8 models to TFLite Edge TPU format, you can now deploy them. The primary and recommended first step for running a TFLite Edge TPU model is to use the YOLO("model_edgetpu.tflite") method, as outlined in the previous usage code snippet. + +However, for in-depth instructions on deploying your TFLite Edge TPU models, take a look at the following resources: + +- **[Coral Edge TPU on a Raspberry Pi with Ultralytics YOLOv8](../guides/coral-edge-tpu-on-raspberry-pi.md)**: Discover how to integrate Coral Edge TPUs with Raspberry Pi for enhanced machine learning capabilities. + +- **[Code Examples](https://coral.ai/docs/edgetpu/compiler/)**: Access practical TensorFlow Edge TPU deployment examples to kickstart your projects. + +- **[Run Inference on the Edge TPU with Python](https://coral.ai/docs/edgetpu/tflite-python/#overview)**: Explore how to use the TensorFlow Lite Python API for Edge TPU applications, including setup and usage guidelines. + +## Summary + +In this guide, we've learned how to export Ultralytics YOLOv8 models to TFLite Edge TPU format. By following the steps mentioned above, you can increase the speed and power of your computer vision applications. + +For further details on usage, visit the [Edge TPU official website](https://cloud.google.com/edge-tpu). + +Also, for more information on other Ultralytics YOLOv8 integrations, please visit our [integration guide page](index.md). There, you'll discover valuable resources and insights. + +## FAQ + +### How do I export a YOLOv8 model to TFLite Edge TPU format? + +To export a YOLOv8 model to TFLite Edge TPU format, you can follow these steps: + +!!! example "Usage" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load the YOLOv8 model + model = YOLO("yolov8n.pt") + + # Export the model to TFLite Edge TPU format + model.export(format="edgetpu") # creates 'yolov8n_full_integer_quant_edgetpu.tflite' + + # Load the exported TFLite Edge TPU model + edgetpu_model = YOLO("yolov8n_full_integer_quant_edgetpu.tflite") + + # Run inference + results = edgetpu_model("https://ultralytics.com/images/bus.jpg") + ``` + + === "CLI" + + ```bash + # Export a YOLOv8n PyTorch model to TFLite Edge TPU format + yolo export model=yolov8n.pt format=edgetpu # creates 'yolov8n_full_integer_quant_edgetpu.tflite' + + # Run inference with the exported model + yolo predict model=yolov8n_full_integer_quant_edgetpu.tflite source='https://ultralytics.com/images/bus.jpg' + ``` + +For complete details on exporting models to other formats, refer to our [export guide](../modes/export.md). + +### What are the benefits of exporting YOLOv8 models to TFLite Edge TPU? + +Exporting YOLOv8 models to TFLite Edge TPU offers several benefits: + +- **Optimized Performance**: Achieve high-speed neural network performance with minimal power consumption. +- **Reduced Latency**: Quick local data processing without the need for cloud dependency. +- **Enhanced Privacy**: Local processing keeps user data private and secure. + +This makes it ideal for applications in edge computing, where devices have limited power and computational resources. Learn more about [why you should export](#why-should-you-export-to-tflite-edge-tpu). + +### Can I deploy TFLite Edge TPU models on mobile and embedded devices? + +Yes, TensorFlow Lite Edge TPU models can be deployed directly on mobile and embedded devices. This deployment approach allows models to execute directly on the hardware, offering faster and more efficient inferencing. For integration examples, check our [guide on deploying Coral Edge TPU on Raspberry Pi](../guides/coral-edge-tpu-on-raspberry-pi.md). + +### What are some common use cases for TFLite Edge TPU models? + +Common use cases for TFLite Edge TPU models include: + +- **Smart Cameras**: Enhancing real-time image and video analysis. +- **IoT Devices**: Enabling smart home and industrial automation. +- **Healthcare**: Accelerating medical imaging and diagnostics. +- **Retail**: Improving inventory management and customer behavior analysis. + +These applications benefit from the high performance and low power consumption of TFLite Edge TPU models. Discover more about [usage scenarios](#deployment-options-with-tflite-edge-tpu). + +### How can I troubleshoot issues while exporting or deploying TFLite Edge TPU models? + +If you encounter issues while exporting or deploying TFLite Edge TPU models, refer to our [Common Issues guide](../guides/yolo-common-issues.md) for troubleshooting tips. This guide covers common problems and solutions to help you ensure smooth operation. For additional support, visit our [Help Center](https://docs.ultralytics.com/help/). diff --git a/ultralytics/docs/en/integrations/google-colab.md b/ultralytics/docs/en/integrations/google-colab.md new file mode 100644 index 0000000000000000000000000000000000000000..d512e391a86b9c8806e48d6ca563dd93baea6b3e --- /dev/null +++ b/ultralytics/docs/en/integrations/google-colab.md @@ -0,0 +1,151 @@ +--- +comments: true +description: Learn how to efficiently train Ultralytics YOLOv8 models using Google Colab's powerful cloud-based environment. Start your project with ease. +keywords: YOLOv8, Google Colab, machine learning, deep learning, model training, GPU, TPU, cloud computing, Jupyter Notebook, Ultralytics +--- + +# Accelerating YOLOv8 Projects with Google Colab + +Many developers lack the powerful computing resources needed to build deep learning models. Acquiring high-end hardware or renting a decent GPU can be expensive. Google Colab is a great solution to this. It's a browser-based platform that allows you to work with large datasets, develop complex models, and share your work with others without a huge cost. + +You can use Google Colab to work on projects related to [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics) models. Google Colab's user-friendly environment is well suited for efficient model development and experimentation. Let's learn more about Google Colab, its key features, and how you can use it to train YOLOv8 models. + +## Google Colaboratory + +Google Colaboratory, commonly known as Google Colab, was developed by Google Research in 2017. It is a free online cloud-based Jupyter Notebook environment that allows you to train your machine learning and deep learning models on CPUs, GPUs, and TPUs. The motivation behind developing Google Colab was Google's broader goals to advance AI technology and educational tools, and encourage the use of cloud services. + +You can use Google Colab regardless of the specifications and configurations of your local computer. All you need is a Google account and a web browser, and you're good to go. + +## Training YOLOv8 Using Google Colaboratory + +Training YOLOv8 models on Google Colab is pretty straightforward. Thanks to the integration, you can access the [Google Colab YOLOv8 Notebook](https://colab.research.google.com/github/ultralytics/ultralytics/blob/main/examples/tutorial.ipynb) and start training your model immediately. For a detailed understanding of the model training process and best practices, refer to our [YOLOv8 Model Training guide](../modes/train.md). + +Sign in to your Google account and run the notebook's cells to train your model. + +![Training YOLOv8 Using Google Colab](https://github.com/ultralytics/docs/releases/download/0/training-yolov8-using-google-colab.avif) + +Learn how to train a YOLOv8 model with custom data on YouTube with Nicolai. Check out the guide below. + +

+
+ +
+ Watch: How to Train Ultralytics YOLOv8 models on Your Custom Dataset in Google Colab | Episode 3 +

+ +### Common Questions While Working with Google Colab + +When working with Google Colab, you might have a few common questions. Let's answer them. + +**Q: Why does my Google Colab session timeout?** +A: Google Colab sessions can time out due to inactivity, especially for free users who have a limited session duration. + +**Q: Can I increase the session duration in Google Colab?** +A: Free users face limits, but Google Colab Pro offers extended session durations. + +**Q: What should I do if my session closes unexpectedly?** +A: Regularly save your work to Google Drive or GitHub to avoid losing unsaved progress. + +**Q: How can I check my session status and resource usage?** +A: Colab provides 'RAM Usage' and 'Disk Usage' metrics in the interface to monitor your resources. + +**Q: Can I run multiple Colab sessions simultaneously?** +A: Yes, but be cautious about resource usage to avoid performance issues. + +**Q: Does Google Colab have GPU access limitations?** +A: Yes, free GPU access has limitations, but Google Colab Pro provides more substantial usage options. + +## Key Features of Google Colab + +Now, let's look at some of the standout features that make Google Colab a go-to platform for machine learning projects: + +- **Library Support:** Google Colab includes pre-installed libraries for data analysis and machine learning and allows additional libraries to be installed as needed. It also supports various libraries for creating interactive charts and visualizations. + +- **Hardware Resources:** Users also switch between different hardware options by modifying the runtime settings as shown below. Google Colab provides access to advanced hardware like Tesla K80 GPUs and TPUs, which are specialized circuits designed specifically for machine learning tasks. + +![Runtime Settings](https://github.com/ultralytics/docs/releases/download/0/runtime-settings.avif) + +- **Collaboration:** Google Colab makes collaborating and working with other developers easy. You can easily share your notebooks with others and perform edits in real-time. + +- **Custom Environment:** Users can install dependencies, configure the system, and use shell commands directly in the notebook. + +- **Educational Resources:** Google Colab offers a range of tutorials and example notebooks to help users learn and explore various functionalities. + +## Why Should You Use Google Colab for Your YOLOv8 Projects? + +There are many options for training and evaluating YOLOv8 models, so what makes the integration with Google Colab unique? Let's explore the advantages of this integration: + +- **Zero Setup:** Since Colab runs in the cloud, users can start training models immediately without the need for complex environment setups. Just create an account and start coding. + +- **Form Support:** It allows users to create forms for parameter input, making it easier to experiment with different values. + +- **Integration with Google Drive:** Colab seamlessly integrates with Google Drive to make data storage, access, and management simple. Datasets and models can be stored and retrieved directly from Google Drive. + +- **Markdown Support:** You can use Markdown format for enhanced documentation within notebooks. + +- **Scheduled Execution:** Developers can set notebooks to run automatically at specified times. + +- **Extensions and Widgets:** Google Colab allows for adding functionality through third-party extensions and interactive widgets. + +## Keep Learning about Google Colab + +If you'd like to dive deeper into Google Colab, here are a few resources to guide you. + +- **[Training Custom Datasets with Ultralytics YOLOv8 in Google Colab](https://www.ultralytics.com/blog/training-custom-datasets-with-ultralytics-yolov8-in-google-colab)**: Learn how to train custom datasets with Ultralytics YOLOv8 on Google Colab. This comprehensive blog post will take you through the entire process, from initial setup to the training and evaluation stages. + +- **[Curated Notebooks](https://colab.google/notebooks/)**: Here you can explore a series of organized and educational notebooks, each grouped by specific topic areas. + +- **[Google Colab's Medium Page](https://medium.com/google-colab)**: You can find tutorials, updates, and community contributions here that can help you better understand and utilize this tool. + +## Summary + +We've discussed how you can easily experiment with Ultralytics YOLOv8 models on Google Colab. You can use Google Colab to train and evaluate your models on GPUs and TPUs with a few clicks. + +For more details, visit [Google Colab's FAQ page](https://research.google.com/colaboratory/intl/en-GB/faq.html). + +Interested in more YOLOv8 integrations? Visit the [Ultralytics integration guide page](index.md) to explore additional tools and capabilities that can improve your machine-learning projects. + +## FAQ + +### How do I start training Ultralytics YOLOv8 models on Google Colab? + +To start training Ultralytics YOLOv8 models on Google Colab, sign in to your Google account, then access the [Google Colab YOLOv8 Notebook](https://colab.research.google.com/github/ultralytics/ultralytics/blob/main/examples/tutorial.ipynb). This notebook guides you through the setup and training process. After launching the notebook, run the cells step-by-step to train your model. For a full guide, refer to the [YOLOv8 Model Training guide](../modes/train.md). + +### What are the advantages of using Google Colab for training YOLOv8 models? + +Google Colab offers several advantages for training YOLOv8 models: + +- **Zero Setup:** No initial environment setup is required; just log in and start coding. +- **Free GPU Access:** Use powerful GPUs or TPUs without the need for expensive hardware. +- **Integration with Google Drive:** Easily store and access datasets and models. +- **Collaboration:** Share notebooks with others and collaborate in real-time. + +For more information on why you should use Google Colab, explore the [training guide](../modes/train.md) and visit the [Google Colab page](https://colab.google/notebooks/). + +### How can I handle Google Colab session timeouts during YOLOv8 training? + +Google Colab sessions timeout due to inactivity, especially for free users. To handle this: + +1. **Stay Active:** Regularly interact with your Colab notebook. +2. **Save Progress:** Continuously save your work to Google Drive or GitHub. +3. **Colab Pro:** Consider upgrading to Google Colab Pro for longer session durations. + +For more tips on managing your Colab session, visit the [Google Colab FAQ page](https://research.google.com/colaboratory/intl/en-GB/faq.html). + +### Can I use custom datasets for training YOLOv8 models in Google Colab? + +Yes, you can use custom datasets to train YOLOv8 models in Google Colab. Upload your dataset to Google Drive and load it directly into your Colab notebook. You can follow Nicolai's YouTube guide, [How to Train YOLOv8 Models on Your Custom Dataset](https://www.youtube.com/watch?v=LNwODJXcvt4), or refer to the [Custom Dataset Training guide](https://www.ultralytics.com/blog/training-custom-datasets-with-ultralytics-yolov8-in-google-colab) for detailed steps. + +### What should I do if my Google Colab training session is interrupted? + +If your Google Colab training session is interrupted: + +1. **Save Regularly:** Avoid losing unsaved progress by regularly saving your work to Google Drive or GitHub. +2. **Resume Training:** Restart your session and re-run the cells from where the interruption occurred. +3. **Use Checkpoints:** Incorporate checkpointing in your training script to save progress periodically. + +These practices help ensure your progress is secure. Learn more about session management on [Google Colab's FAQ page](https://research.google.com/colaboratory/intl/en-GB/faq.html). diff --git a/ultralytics/docs/en/integrations/gradio.md b/ultralytics/docs/en/integrations/gradio.md new file mode 100644 index 0000000000000000000000000000000000000000..798e1c3baef8093c0fb8d49a30b2940edbe1f676 --- /dev/null +++ b/ultralytics/docs/en/integrations/gradio.md @@ -0,0 +1,199 @@ +--- +comments: true +description: Discover an interactive way to perform object detection with Ultralytics YOLOv8 using Gradio. Upload images and adjust settings for real-time results. +keywords: Ultralytics, YOLOv8, Gradio, object detection, interactive, real-time, image processing, AI +--- + +# Interactive Object Detection: Gradio & Ultralytics YOLOv8 🚀 + +## Introduction to Interactive Object Detection + +This Gradio interface provides an easy and interactive way to perform object detection using the [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics/) model. Users can upload images and adjust parameters like confidence threshold and intersection-over-union (IoU) threshold to get real-time detection results. + +

+
+ +
+ Watch: Gradio Integration with Ultralytics YOLOv8 +

+ +## Why Use Gradio for Object Detection? + +- **User-Friendly Interface:** Gradio offers a straightforward platform for users to upload images and visualize detection results without any coding requirement. +- **Real-Time Adjustments:** Parameters such as confidence and IoU thresholds can be adjusted on the fly, allowing for immediate feedback and optimization of detection results. +- **Broad Accessibility:** The Gradio web interface can be accessed by anyone, making it an excellent tool for demonstrations, educational purposes, and quick experiments. + +

+ Gradio example screenshot +

+ +## How to Install the Gradio + +```bash +pip install gradio +``` + +## How to Use the Interface + +1. **Upload Image:** Click on 'Upload Image' to choose an image file for object detection. +2. **Adjust Parameters:** + - **Confidence Threshold:** Slider to set the minimum confidence level for detecting objects. + - **IoU Threshold:** Slider to set the IoU threshold for distinguishing different objects. +3. **View Results:** The processed image with detected objects and their labels will be displayed. + +## Example Use Cases + +- **Sample Image 1:** Bus detection with default thresholds. +- **Sample Image 2:** Detection on a sports image with default thresholds. + +## Usage Example + +This section provides the Python code used to create the Gradio interface with the Ultralytics YOLOv8 model. Supports classification tasks, detection tasks, segmentation tasks, and key point tasks. + +```python +import gradio as gr +import PIL.Image as Image + +from ultralytics import ASSETS, YOLO + +model = YOLO("yolov8n.pt") + + +def predict_image(img, conf_threshold, iou_threshold): + """Predicts objects in an image using a YOLOv8 model with adjustable confidence and IOU thresholds.""" + results = model.predict( + source=img, + conf=conf_threshold, + iou=iou_threshold, + show_labels=True, + show_conf=True, + imgsz=640, + ) + + for r in results: + im_array = r.plot() + im = Image.fromarray(im_array[..., ::-1]) + + return im + + +iface = gr.Interface( + fn=predict_image, + inputs=[ + gr.Image(type="pil", label="Upload Image"), + gr.Slider(minimum=0, maximum=1, value=0.25, label="Confidence threshold"), + gr.Slider(minimum=0, maximum=1, value=0.45, label="IoU threshold"), + ], + outputs=gr.Image(type="pil", label="Result"), + title="Ultralytics Gradio", + description="Upload images for inference. The Ultralytics YOLOv8n model is used by default.", + examples=[ + [ASSETS / "bus.jpg", 0.25, 0.45], + [ASSETS / "zidane.jpg", 0.25, 0.45], + ], +) + +if __name__ == "__main__": + iface.launch() +``` + +## Parameters Explanation + +| Parameter Name | Type | Description | +| ---------------- | ------- | -------------------------------------------------------- | +| `img` | `Image` | The image on which object detection will be performed. | +| `conf_threshold` | `float` | Confidence threshold for detecting objects. | +| `iou_threshold` | `float` | Intersection-over-union threshold for object separation. | + +### Gradio Interface Components + +| Component | Description | +| ------------ | ---------------------------------------- | +| Image Input | To upload the image for detection. | +| Sliders | To adjust confidence and IoU thresholds. | +| Image Output | To display the detection results. | + +## FAQ + +### How do I use Gradio with Ultralytics YOLOv8 for object detection? + +To use Gradio with Ultralytics YOLOv8 for object detection, you can follow these steps: + +1. **Install Gradio:** Use the command `pip install gradio`. +2. **Create Interface:** Write a Python script to initialize the Gradio interface. You can refer to the provided code example in the [documentation](#usage-example) for details. +3. **Upload and Adjust:** Upload your image and adjust the confidence and IoU thresholds on the Gradio interface to get real-time object detection results. + +Here's a minimal code snippet for reference: + +```python +import gradio as gr + +from ultralytics import YOLO + +model = YOLO("yolov8n.pt") + + +def predict_image(img, conf_threshold, iou_threshold): + results = model.predict( + source=img, + conf=conf_threshold, + iou=iou_threshold, + show_labels=True, + show_conf=True, + ) + return results[0].plot() if results else None + + +iface = gr.Interface( + fn=predict_image, + inputs=[ + gr.Image(type="pil", label="Upload Image"), + gr.Slider(minimum=0, maximum=1, value=0.25, label="Confidence threshold"), + gr.Slider(minimum=0, maximum=1, value=0.45, label="IoU threshold"), + ], + outputs=gr.Image(type="pil", label="Result"), + title="Ultralytics Gradio YOLOv8", + description="Upload images for YOLOv8 object detection.", +) +iface.launch() +``` + +### What are the benefits of using Gradio for Ultralytics YOLOv8 object detection? + +Using Gradio for Ultralytics YOLOv8 object detection offers several benefits: + +- **User-Friendly Interface:** Gradio provides an intuitive interface for users to upload images and visualize detection results without any coding effort. +- **Real-Time Adjustments:** You can dynamically adjust detection parameters such as confidence and IoU thresholds and see the effects immediately. +- **Accessibility:** The web interface is accessible to anyone, making it useful for quick experiments, educational purposes, and demonstrations. + +For more details, you can read this [blog post](https://www.ultralytics.com/blog/ai-and-radiology-a-new-era-of-precision-and-efficiency). + +### Can I use Gradio and Ultralytics YOLOv8 together for educational purposes? + +Yes, Gradio and Ultralytics YOLOv8 can be utilized together for educational purposes effectively. Gradio's intuitive web interface makes it easy for students and educators to interact with state-of-the-art deep learning models like Ultralytics YOLOv8 without needing advanced programming skills. This setup is ideal for demonstrating key concepts in object detection and computer vision, as Gradio provides immediate visual feedback which helps in understanding the impact of different parameters on the detection performance. + +### How do I adjust the confidence and IoU thresholds in the Gradio interface for YOLOv8? + +In the Gradio interface for YOLOv8, you can adjust the confidence and IoU thresholds using the sliders provided. These thresholds help control the prediction accuracy and object separation: + +- **Confidence Threshold:** Determines the minimum confidence level for detecting objects. Slide to increase or decrease the confidence required. +- **IoU Threshold:** Sets the intersection-over-union threshold for distinguishing between overlapping objects. Adjust this value to refine object separation. + +For more information on these parameters, visit the [parameters explanation section](#parameters-explanation). + +### What are some practical applications of using Ultralytics YOLOv8 with Gradio? + +Practical applications of combining Ultralytics YOLOv8 with Gradio include: + +- **Real-Time Object Detection Demonstrations:** Ideal for showcasing how object detection works in real-time. +- **Educational Tools:** Useful in academic settings to teach object detection and computer vision concepts. +- **Prototype Development:** Efficient for developing and testing prototype object detection applications quickly. +- **Community and Collaborations:** Making it easy to share models with the community for feedback and collaboration. + +For examples of similar use cases, check out the [Ultralytics blog](https://www.ultralytics.com/blog/monitoring-animal-behavior-using-ultralytics-yolov8). + +Providing this information within the documentation will help in enhancing the usability and accessibility of Ultralytics YOLOv8, making it more approachable for users at all levels of expertise. diff --git a/ultralytics/docs/en/integrations/ibm-watsonx.md b/ultralytics/docs/en/integrations/ibm-watsonx.md new file mode 100644 index 0000000000000000000000000000000000000000..024a6d3c5e0da0ef7ae9ed2cbf905e562a14d07f --- /dev/null +++ b/ultralytics/docs/en/integrations/ibm-watsonx.md @@ -0,0 +1,410 @@ +--- +comments: true +description: Dive into our detailed integration guide on using IBM Watson to train a YOLOv8 model. Uncover key features and step-by-step instructions on model training. +keywords: IBM Watsonx, IBM Watsonx AI, What is Watson?, IBM Watson Integration, IBM Watson Features, YOLOv8, Ultralytics, Model Training, GPU, TPU, cloud computing +--- + +# A Step-by-Step Guide to Training YOLOv8 Models with IBM Watsonx + +Nowadays, scalable [computer vision solutions](../guides/steps-of-a-cv-project.md) are becoming more common and transforming the way we handle visual data. A great example is IBM Watsonx, an advanced AI and data platform that simplifies the development, deployment, and management of AI models. It offers a complete suite for the entire AI lifecycle and seamless integration with IBM Cloud services. + +You can train [Ultralytics YOLOv8 models](https://github.com/ultralytics/ultralytics) using IBM Watsonx. It's a good option for enterprises interested in efficient [model training](../modes/train.md), fine-tuning for specific tasks, and improving [model performance](../guides/model-evaluation-insights.md) with robust tools and a user-friendly setup. In this guide, we'll walk you through the process of training YOLOv8 with IBM Watsonx, covering everything from setting up your environment to evaluating your trained models. Let's get started! + +## What is IBM Watsonx? + +[Watsonx](https://www.ibm.com/watsonx) is IBM's cloud-based platform designed for commercial generative AI and scientific data. IBM Watsonx's three components - watsonx.ai, watsonx.data, and watsonx.governance - come together to create an end-to-end, trustworthy AI platform that can accelerate AI projects aimed at solving business problems. It provides powerful tools for building, training, and [deploying machine learning models](../guides/model-deployment-options.md) and makes it easy to connect with various data sources. + +

+ Overview of IBM Watsonx +

+ +Its user-friendly interface and collaborative capabilities streamline the development process and help with efficient model management and deployment. Whether for computer vision, predictive analytics, natural language processing, or other AI applications, IBM Watsonx provides the tools and support needed to drive innovation. + +## Key Features of IBM Watsonx + +IBM Watsonx is made of three main components: watsonx.ai, watsonx.data, and watsonx.governance. Each component offers features that cater to different aspects of AI and data management. Let's take a closer look at them. + +### [Watsonx.ai](https://www.ibm.com/products/watsonx-ai) + +Watsonx.ai provides powerful tools for AI development and offers access to IBM-supported custom models, third-party models like [Llama 3](https://www.ultralytics.com/blog/getting-to-know-metas-llama-3), and IBM's own Granite models. It includes the Prompt Lab for experimenting with AI prompts, the Tuning Studio for improving model performance with labeled data, and the Flows Engine for simplifying generative AI application development. Also, it offers comprehensive tools for automating the AI model lifecycle and connecting to various APIs and libraries. + +### [Watsonx.data](https://www.ibm.com/products/watsonx-data) + +Watsonx.data supports both cloud and on-premises deployments through the IBM Storage Fusion HCI integration. Its user-friendly console provides centralized access to data across environments and makes data exploration easy with common SQL. It optimizes workloads with efficient query engines like Presto and Spark, accelerates data insights with an AI-powered semantic layer, includes a vector database for AI relevance, and supports open data formats for easy sharing of analytics and AI data. + +### [Watsonx.governance](https://www.ibm.com/products/watsonx-governance) + +Watsonx.governance makes compliance easier by automatically identifying regulatory changes and enforcing policies. It links requirements to internal risk data and provides up-to-date AI factsheets. The platform helps manage risk with alerts and tools to detect issues such as [bias and drift](../guides/model-monitoring-and-maintenance.md). It also automates the monitoring and documentation of the AI lifecycle, organizes AI development with a model inventory, and enhances collaboration with user-friendly dashboards and reporting tools. + +## How to Train YOLOv8 Using IBM Watsonx + +You can use IBM Watsonx to accelerate your YOLOv8 model training workflow. + +### Prerequisites + +You need an [IBM Cloud account](https://cloud.ibm.com/registration) to create a [watsonx.ai](https://www.ibm.com/products/watsonx-ai) project, and you'll also need a [Kaggle](./kaggle.md) account to load the data set. + +### Step 1: Set Up Your Environment + +First, you'll need to set up an IBM account to use a Jupyter Notebook. Log in to [watsonx.ai](https://eu-de.dataplatform.cloud.ibm.com/registration/stepone?preselect_region=true) using your IBM Cloud account. + +Then, create a [watsonx.ai project](https://www.ibm.com/docs/en/watsonx/saas?topic=projects-creating-project), and a [Jupyter Notebook](https://www.ibm.com/docs/en/watsonx/saas?topic=editor-creating-managing-notebooks). + +Once you do so, a notebook environment will open for you to load your data set. You can use the code from this tutorial to tackle a simple object detection model training task. + +### Step 2: Install and Import Relevant Libraries + +Next, you can install and import the necessary Python libraries. + +!!! tip "Installation" + + === "CLI" + + ```bash + # Install the required packages + pip install torch torchvision torchaudio + pip install opencv-contrib-python-headless + pip install ultralytics==8.0.196 + ``` + +For detailed instructions and best practices related to the installation process, check our [Ultralytics Installation guide](../quickstart.md). While installing the required packages for YOLOv8, if you encounter any difficulties, consult our [Common Issues guide](../guides/yolo-common-issues.md) for solutions and tips. + +Then, you can import the needed packages. + +!!! example "Import Relevant Libraries" + + === "Python" + + ```python + # Import ultralytics + import ultralytics + + ultralytics.checks() + + # Import packages to retrieve and display image files + ``` + +### Step 3: Load the Data + +For this tutorial, we will use a [marine litter dataset](https://www.kaggle.com/datasets/atiqishrak/trash-dataset-icra19) available on Kaggle. With this dataset, we will custom-train a YOLOv8 model to detect and classify litter and biological objects in underwater images. + +We can load the dataset directly into the notebook using the Kaggle API. First, create a free Kaggle account. Once you have created an account, you'll need to generate an API key. Directions for generating your key can be found in the [Kaggle API documentation](https://github.com/Kaggle/kaggle-api/blob/main/docs/README.md) under the section "API credentials". + +Copy and paste your Kaggle username and API key into the following code. Then run the code to install the API and load the dataset into Watsonx. + +!!! tip "Installation" + + === "CLI" + + ```bash + # Install kaggle + pip install kaggle + ``` + +After installing Kaggle, we can load the dataset into Watsonx. + +!!! example "Load the Data" + + === "Python" + + ```python + # Replace "username" string with your username + os.environ["KAGGLE_USERNAME"] = "username" + # Replace "apiKey" string with your key + os.environ["KAGGLE_KEY"] = "apiKey" + + # Load dataset + os.system("kaggle datasets download atiqishrak/trash-dataset-icra19 --unzip") + + # Store working directory path as work_dir + work_dir = os.getcwd() + + # Print work_dir path + print(os.getcwd()) + + # Print work_dir contents + print(os.listdir(f"{work_dir}")) + + # Print trash_ICRA19 subdirectory contents + print(os.listdir(f"{work_dir}/trash_ICRA19")) + ``` + +After loading the dataset, we printed and saved our working directory. We have also printed the contents of our working directory to confirm the "trash_ICRA19" data set was loaded properly. + +If you see "trash_ICRA19" among the directory's contents, then it has loaded successfully. You should see three files/folders: a `config.yaml` file, a `videos_for_testing` directory, and a `dataset` directory. We will ignore the `videos_for_testing` directory, so feel free to delete it. + +We will use the config.yaml file and the contents of the dataset directory to train our object detection model. Here is a sample image from our marine litter data set. + +

+ Marine Litter with Bounding Box +

+ +### Step 4: Preprocess the Data + +Fortunately, all labels in the marine litter data set are already formatted as YOLO .txt files. However, we need to rearrange the structure of the image and label directories in order to help our model process the image and labels. Right now, our loaded data set directory follows this structure: + +

+ Loaded Dataset Directory +

+ +But, YOLO models by default require separate images and labels in subdirectories within the train/val/test split. We need to reorganize the directory into the following structure: + +

+ Yolo Directory Structure +

+ +To reorganize the data set directory, we can run the following script: + +!!! example "Preprocess the Data" + + === "Python" + + ```python + # Function to reorganize dir + def organize_files(directory): + for subdir in ["train", "test", "val"]: + subdir_path = os.path.join(directory, subdir) + if not os.path.exists(subdir_path): + continue + + images_dir = os.path.join(subdir_path, "images") + labels_dir = os.path.join(subdir_path, "labels") + + # Create image and label subdirs if non-existent + os.makedirs(images_dir, exist_ok=True) + os.makedirs(labels_dir, exist_ok=True) + + # Move images and labels to respective subdirs + for filename in os.listdir(subdir_path): + if filename.endswith(".txt"): + shutil.move(os.path.join(subdir_path, filename), os.path.join(labels_dir, filename)) + elif filename.endswith(".jpg") or filename.endswith(".png") or filename.endswith(".jpeg"): + shutil.move(os.path.join(subdir_path, filename), os.path.join(images_dir, filename)) + # Delete .xml files + elif filename.endswith(".xml"): + os.remove(os.path.join(subdir_path, filename)) + + + if __name__ == "__main__": + directory = f"{work_dir}/trash_ICRA19/dataset" + organize_files(directory) + ``` + +Next, we need to modify the .yaml file for the data set. This is the setup we will use in our .yaml file. Class ID numbers start from 0: + +```yaml +path: /path/to/dataset/directory # root directory for dataset +train: train/images # train images subdirectory +val: train/images # validation images subdirectory +test: test/images # test images subdirectory + +# Classes +names: + 0: plastic + 1: bio + 2: rov +``` + +Run the following script to delete the current contents of config.yaml and replace it with the above contents that reflect our new data set directory structure. Be certain to replace the work_dir portion of the root directory path in line 4 with your own working directory path we retrieved earlier. Leave the train, val, and test subdirectory definitions. Also, do not change {work_dir} in line 23 of the code. + +!!! example "Edit the .yaml File" + + === "Python" + + ```python + # Contents of new confg.yaml file + def update_yaml_file(file_path): + data = { + "path": "work_dir/trash_ICRA19/dataset", + "train": "train/images", + "val": "train/images", + "test": "test/images", + "names": {0: "plastic", 1: "bio", 2: "rov"}, + } + + # Ensures the "names" list appears after the sub/directories + names_data = data.pop("names") + with open(file_path, "w") as yaml_file: + yaml.dump(data, yaml_file) + yaml_file.write("\n") + yaml.dump({"names": names_data}, yaml_file) + + + if __name__ == "__main__": + file_path = f"{work_dir}/trash_ICRA19/config.yaml" # .yaml file path + update_yaml_file(file_path) + print(f"{file_path} updated successfully.") + ``` + +### Step 5: Train the YOLOv8 model + +Run the following command-line code to fine tune a pretrained default YOLOv8 model. + +!!! example "Train the YOLOv8 model" + + === "CLI" + + ```bash + !yolo task=detect mode=train data={work_dir}/trash_ICRA19/config.yaml model=yolov8s.pt epochs=2 batch=32 lr0=.04 plots=True + ``` + +Here's a closer look at the parameters in the model training command: + +- **task**: It specifies the computer vision task for which you are using the specified YOLO model and data set. +- **mode**: Denotes the purpose for which you are loading the specified model and data. Since we are training a model, it is set to "train." Later, when we test our model's performance, we will set it to "predict." +- **epochs**: This delimits the number of times YOLOv8 will pass through our entire data set. +- **batch**: The numerical value stipulates the training batch sizes. Batches are the number of images a model processes before it updates its parameters. +- **lr0**: Specifies the model's initial learning rate. +- **plots**: Directs YOLO to generate and save plots of our model's training and evaluation metrics. + +For a detailed understanding of the model training process and best practices, refer to the [YOLOv8 Model Training guide](../modes/train.md). This guide will help you get the most out of your experiments and ensure you're using YOLOv8 effectively. + +### Step 6: Test the Model + +We can now run inference to test the performance of our fine-tuned model: + +!!! example "Test the YOLOv8 model" + + === "CLI" + + ```bash + !yolo task=detect mode=predict source={work_dir}/trash_ICRA19/dataset/test/images model={work_dir}/runs/detect/train/weights/best.pt conf=0.5 iou=.5 save=True save_txt=True + ``` + +This brief script generates predicted labels for each image in our test set, as well as new output image files that overlay the predicted bounding box atop the original image. + +Predicted .txt labels for each image are saved via the `save_txt=True` argument and the output images with bounding box overlays are generated through the `save=True` argument. +The parameter `conf=0.5` informs the model to ignore all predictions with a confidence level of less than 50%. + +Lastly, `iou=.5` directs the model to ignore boxes in the same class with an overlap of 50% or greater. It helps to reduce potential duplicate boxes generated for the same object. +we can load the images with predicted bounding box overlays to view how our model performs on a handful of images. + +!!! example "Display Predictions" + + === "Python" + + ```python + # Show the first ten images from the preceding prediction task + for pred_dir in glob.glob(f"{work_dir}/runs/detect/predict/*.jpg")[:10]: + img = Image.open(pred_dir) + display(img) + ``` + +The code above displays ten images from the test set with their predicted bounding boxes, accompanied by class name labels and confidence levels. + +### Step 7: Evaluate the Model + +We can produce visualizations of the model's precision and recall for each class. These visualizations are saved in the home directory, under the train folder. The precision score is displayed in the P_curve.png: + +

+ Precision Confidence Curve +

+ +The graph shows an exponential increase in precision as the model's confidence level for predictions increases. However, the model precision has not yet leveled out at a certain confidence level after two epochs. + +The recall graph (R_curve.png) displays an inverse trend: + +

+ Recall Confidence Curve +

+ +Unlike precision, recall moves in the opposite direction, showing greater recall with lower confidence instances and lower recall with higher confidence instances. This is an apt example of the trade-off in precision and recall for classification models. + +### Step 8: Calculating Intersection Over Union + +You can measure the prediction accuracy by calculating the IoU between a predicted bounding box and a ground truth bounding box for the same object. Check out [IBM's tutorial on training YOLOv8](https://developer.ibm.com/tutorials/awb-train-yolo-object-detection-model-in-python/) for more details. + +## Summary + +We explored IBM Watsonx key features, and how to train a YOLOv8 model using IBM Watsonx. We also saw how IBM Watsonx can enhance your AI workflows with advanced tools for model building, data management, and compliance. + +For further details on usage, visit [IBM Watsonx official documentation](https://www.ibm.com/watsonx). + +Also, be sure to check out the [Ultralytics integration guide page](./index.md), to learn more about different exciting integrations. + +## FAQ + +### How do I train a YOLOv8 model using IBM Watsonx? + +To train a YOLOv8 model using IBM Watsonx, follow these steps: + +1. **Set Up Your Environment**: Create an IBM Cloud account and set up a Watsonx.ai project. Use a Jupyter Notebook for your coding environment. +2. **Install Libraries**: Install necessary libraries like `torch`, `opencv`, and `ultralytics`. +3. **Load Data**: Use the Kaggle API to load your dataset into Watsonx. +4. **Preprocess Data**: Organize your dataset into the required directory structure and update the `.yaml` configuration file. +5. **Train the Model**: Use the YOLO command-line interface to train your model with specific parameters like `epochs`, `batch size`, and `learning rate`. +6. **Test and Evaluate**: Run inference to test the model and evaluate its performance using metrics like precision and recall. + +For detailed instructions, refer to our [YOLOv8 Model Training guide](../modes/train.md). + +### What are the key features of IBM Watsonx for AI model training? + +IBM Watsonx offers several key features for AI model training: + +- **Watsonx.ai**: Provides tools for AI development, including access to IBM-supported custom models and third-party models like Llama 3. It includes the Prompt Lab, Tuning Studio, and Flows Engine for comprehensive AI lifecycle management. +- **Watsonx.data**: Supports cloud and on-premises deployments, offering centralized data access, efficient query engines like Presto and Spark, and an AI-powered semantic layer. +- **Watsonx.governance**: Automates compliance, manages risk with alerts, and provides tools for detecting issues like bias and drift. It also includes dashboards and reporting tools for collaboration. + +For more information, visit the [IBM Watsonx official documentation](https://www.ibm.com/watsonx). + +### Why should I use IBM Watsonx for training Ultralytics YOLOv8 models? + +IBM Watsonx is an excellent choice for training Ultralytics YOLOv8 models due to its comprehensive suite of tools that streamline the AI lifecycle. Key benefits include: + +- **Scalability**: Easily scale your model training with IBM Cloud services. +- **Integration**: Seamlessly integrate with various data sources and APIs. +- **User-Friendly Interface**: Simplifies the development process with a collaborative and intuitive interface. +- **Advanced Tools**: Access to powerful tools like the Prompt Lab, Tuning Studio, and Flows Engine for enhancing model performance. + +Learn more about [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics) and how to train models using IBM Watsonx in our [integration guide](./index.md). + +### How can I preprocess my dataset for YOLOv8 training on IBM Watsonx? + +To preprocess your dataset for YOLOv8 training on IBM Watsonx: + +1. **Organize Directories**: Ensure your dataset follows the YOLO directory structure with separate subdirectories for images and labels within the train/val/test split. +2. **Update .yaml File**: Modify the `.yaml` configuration file to reflect the new directory structure and class names. +3. **Run Preprocessing Script**: Use a Python script to reorganize your dataset and update the `.yaml` file accordingly. + +Here's a sample script to organize your dataset: + +```python +import os +import shutil + + +def organize_files(directory): + for subdir in ["train", "test", "val"]: + subdir_path = os.path.join(directory, subdir) + if not os.path.exists(subdir_path): + continue + + images_dir = os.path.join(subdir_path, "images") + labels_dir = os.path.join(subdir_path, "labels") + + os.makedirs(images_dir, exist_ok=True) + os.makedirs(labels_dir, exist_ok=True) + + for filename in os.listdir(subdir_path): + if filename.endswith(".txt"): + shutil.move(os.path.join(subdir_path, filename), os.path.join(labels_dir, filename)) + elif filename.endswith(".jpg") or filename.endswith(".png") or filename.endswith(".jpeg"): + shutil.move(os.path.join(subdir_path, filename), os.path.join(images_dir, filename)) + + +if __name__ == "__main__": + directory = f"{work_dir}/trash_ICRA19/dataset" + organize_files(directory) +``` + +For more details, refer to our [data preprocessing guide](../guides/preprocessing_annotated_data.md). + +### What are the prerequisites for training a YOLOv8 model on IBM Watsonx? + +Before you start training a YOLOv8 model on IBM Watsonx, ensure you have the following prerequisites: + +- **IBM Cloud Account**: Create an account on IBM Cloud to access Watsonx.ai. +- **Kaggle Account**: For loading datasets, you'll need a Kaggle account and an API key. +- **Jupyter Notebook**: Set up a Jupyter Notebook environment within Watsonx.ai for coding and model training. + +For more information on setting up your environment, visit our [Ultralytics Installation guide](../quickstart.md). diff --git a/ultralytics/docs/en/integrations/index.md b/ultralytics/docs/en/integrations/index.md new file mode 100644 index 0000000000000000000000000000000000000000..92251e75ba25ff6203d90ec65b7618b9c6005f80 --- /dev/null +++ b/ultralytics/docs/en/integrations/index.md @@ -0,0 +1,132 @@ +--- +comments: true +description: Discover Ultralytics integrations for streamlined ML workflows, dataset management, optimized model training, and robust deployment solutions. +keywords: Ultralytics, machine learning, ML workflows, dataset management, model training, model deployment, Roboflow, ClearML, Comet ML, DVC, MLFlow, Ultralytics HUB, Neptune, Ray Tune, TensorBoard, Weights & Biases, Amazon SageMaker, Paperspace Gradient, Google Colab, Neural Magic, Gradio, TorchScript, ONNX, OpenVINO, TensorRT, CoreML, TF SavedModel, TF GraphDef, TFLite, TFLite Edge TPU, TF.js, PaddlePaddle, NCNN +--- + +# Ultralytics Integrations + +Welcome to the Ultralytics Integrations page! This page provides an overview of our partnerships with various tools and platforms, designed to streamline your machine learning workflows, enhance dataset management, simplify model training, and facilitate efficient deployment. + +Ultralytics YOLO ecosystem and integrations + +

+
+ +
+ Watch: Ultralytics YOLOv8 Deployment and Integrations +

+ +## Datasets Integrations + +- [Roboflow](roboflow.md): Facilitate seamless dataset management for Ultralytics models, offering robust annotation, preprocessing, and augmentation capabilities. + +## Training Integrations + +- [ClearML](clearml.md): Automate your Ultralytics ML workflows, monitor experiments, and foster team collaboration. + +- [Comet ML](comet.md): Enhance your model development with Ultralytics by tracking, comparing, and optimizing your machine learning experiments. + +- [DVC](dvc.md): Implement version control for your Ultralytics machine learning projects, synchronizing data, code, and models effectively. + +- [MLFlow](mlflow.md): Streamline the entire ML lifecycle of Ultralytics models, from experimentation and reproducibility to deployment. + +- [Ultralytics HUB](https://hub.ultralytics.com/): Access and contribute to a community of pre-trained Ultralytics models. + +- [Neptune](https://neptune.ai/): Maintain a comprehensive log of your ML experiments with Ultralytics in this metadata store designed for MLOps. + +- [Ray Tune](ray-tune.md): Optimize the hyperparameters of your Ultralytics models at any scale. + +- [TensorBoard](tensorboard.md): Visualize your Ultralytics ML workflows, monitor model metrics, and foster team collaboration. + +- [Weights & Biases (W&B)](weights-biases.md): Monitor experiments, visualize metrics, and foster reproducibility and collaboration on Ultralytics projects. + +- [Amazon SageMaker](amazon-sagemaker.md): Leverage Amazon SageMaker to efficiently build, train, and deploy Ultralytics models, providing an all-in-one platform for the ML lifecycle. + +- [Paperspace Gradient](paperspace.md): Paperspace Gradient simplifies working on YOLOv8 projects by providing easy-to-use cloud tools for training, testing, and deploying your models quickly. + +- [Google Colab](google-colab.md): Use Google Colab to train and evaluate Ultralytics models in a cloud-based environment that supports collaboration and sharing. + +- [Kaggle](kaggle.md): Explore how you can use Kaggle to train and evaluate Ultralytics models in a cloud-based environment with pre-installed libraries, GPU support, and a vibrant community for collaboration and sharing. + +- [JupyterLab](jupyterlab.md): Find out how to use JupyterLab's interactive and customizable environment to train and evaluate Ultralytics models with ease and efficiency. + +- [IBM Watsonx](ibm-watsonx.md): See how IBM Watsonx simplifies the training and evaluation of Ultralytics models with its cutting-edge AI tools, effortless integration, and advanced model management system. + +## Deployment Integrations + +- [Neural Magic](neural-magic.md): Leverage Quantization Aware Training (QAT) and pruning techniques to optimize Ultralytics models for superior performance and leaner size. + +- [Gradio](gradio.md) 🚀 NEW: Deploy Ultralytics models with Gradio for real-time, interactive object detection demos. + +- [TorchScript](torchscript.md): Developed as part of the [PyTorch](https://pytorch.org/) framework, TorchScript enables efficient execution and deployment of machine learning models in various production environments without the need for Python dependencies. + +- [ONNX](onnx.md): An open-source format created by [Microsoft](https://www.microsoft.com/) for facilitating the transfer of AI models between various frameworks, enhancing the versatility and deployment flexibility of Ultralytics models. + +- [OpenVINO](openvino.md): Intel's toolkit for optimizing and deploying computer vision models efficiently across various Intel CPU and GPU platforms. + +- [TensorRT](tensorrt.md): Developed by [NVIDIA](https://www.nvidia.com/), this high-performance deep learning inference framework and model format optimizes AI models for accelerated speed and efficiency on NVIDIA GPUs, ensuring streamlined deployment. + +- [CoreML](coreml.md): CoreML, developed by [Apple](https://www.apple.com/), is a framework designed for efficiently integrating machine learning models into applications across iOS, macOS, watchOS, and tvOS, using Apple's hardware for effective and secure model deployment. + +- [TF SavedModel](tf-savedmodel.md): Developed by [Google](https://www.google.com/), TF SavedModel is a universal serialization format for TensorFlow models, enabling easy sharing and deployment across a wide range of platforms, from servers to edge devices. + +- [TF GraphDef](tf-graphdef.md): Developed by [Google](https://www.google.com/), GraphDef is TensorFlow's format for representing computation graphs, enabling optimized execution of machine learning models across diverse hardware. + +- [TFLite](tflite.md): Developed by [Google](https://www.google.com/), TFLite is a lightweight framework for deploying machine learning models on mobile and edge devices, ensuring fast, efficient inference with minimal memory footprint. + +- [TFLite Edge TPU](edge-tpu.md): Developed by [Google](https://www.google.com/) for optimizing TensorFlow Lite models on Edge TPUs, this model format ensures high-speed, efficient edge computing. + +- [TF.js](tfjs.md): Developed by [Google](https://www.google.com/) to facilitate machine learning in browsers and Node.js, TF.js allows JavaScript-based deployment of ML models. + +- [PaddlePaddle](paddlepaddle.md): An open-source deep learning platform by [Baidu](https://www.baidu.com/), PaddlePaddle enables the efficient deployment of AI models and focuses on the scalability of industrial applications. + +- [NCNN](ncnn.md): Developed by [Tencent](http://www.tencent.com/), NCNN is an efficient neural network inference framework tailored for mobile devices. It enables direct deployment of AI models into apps, optimizing performance across various mobile platforms. + +- [VS Code](vscode.md): An extension for VS Code that provides code snippets for accelerating development workflows with Ultralytics and also for anyone looking for examples to help learn or get started with Ultralytics. + +### Export Formats + +We also support a variety of model export formats for deployment in different environments. Here are the available formats: + +{% include "macros/export-table.md" %} + +Explore the links to learn more about each integration and how to get the most out of them with Ultralytics. See full `export` details in the [Export](../modes/export.md) page. + +## Contribute to Our Integrations + +We're always excited to see how the community integrates Ultralytics YOLO with other technologies, tools, and platforms! If you have successfully integrated YOLO with a new system or have valuable insights to share, consider contributing to our Integrations Docs. + +By writing a guide or tutorial, you can help expand our documentation and provide real-world examples that benefit the community. It's an excellent way to contribute to the growing ecosystem around Ultralytics YOLO. + +To contribute, please check out our [Contributing Guide](../help/contributing.md) for instructions on how to submit a Pull Request (PR) 🛠️. We eagerly await your contributions! + +Let's collaborate to make the Ultralytics YOLO ecosystem more expansive and feature-rich 🙏! + +## FAQ + +### What is Ultralytics HUB, and how does it streamline the ML workflow? + +Ultralytics HUB is a cloud-based platform designed to make machine learning (ML) workflows for Ultralytics models seamless and efficient. By using this tool, you can easily upload datasets, train models, perform real-time tracking, and deploy YOLOv8 models without needing extensive coding skills. You can explore the key features on the [Ultralytics HUB](https://hub.ultralytics.com/) page and get started quickly with our [Quickstart](https://docs.ultralytics.com/hub/quickstart/) guide. + +### How do I integrate Ultralytics YOLO models with Roboflow for dataset management? + +Integrating Ultralytics YOLO models with Roboflow enhances dataset management by providing robust tools for annotation, preprocessing, and augmentation. To get started, follow the steps on the [Roboflow](roboflow.md) integration page. This partnership ensures efficient dataset handling, which is crucial for developing accurate and robust YOLO models. + +### Can I track the performance of my Ultralytics models using MLFlow? + +Yes, you can. Integrating MLFlow with Ultralytics models allows you to track experiments, improve reproducibility, and streamline the entire ML lifecycle. Detailed instructions for setting up this integration can be found on the [MLFlow](mlflow.md) integration page. This integration is particularly useful for monitoring model metrics and managing the ML workflow efficiently. + +### What are the benefits of using Neural Magic for YOLOv8 model optimization? + +Neural Magic optimizes YOLOv8 models by leveraging techniques like Quantization Aware Training (QAT) and pruning, resulting in highly efficient, smaller models that perform better on resource-limited hardware. Check out the [Neural Magic](neural-magic.md) integration page to learn how to implement these optimizations for superior performance and leaner models. This is especially beneficial for deployment on edge devices. + +### How do I deploy Ultralytics YOLO models with Gradio for interactive demos? + +To deploy Ultralytics YOLO models with Gradio for interactive object detection demos, you can follow the steps outlined on the [Gradio](gradio.md) integration page. Gradio allows you to create easy-to-use web interfaces for real-time model inference, making it an excellent tool for showcasing your YOLO model's capabilities in a user-friendly format suitable for both developers and end-users. + +By addressing these common questions, we aim to improve user experience and provide valuable insights into the powerful capabilities of Ultralytics products. Incorporating these FAQs will not only enhance the documentation but also drive more organic traffic to the Ultralytics website. diff --git a/ultralytics/docs/en/integrations/jupyterlab.md b/ultralytics/docs/en/integrations/jupyterlab.md new file mode 100644 index 0000000000000000000000000000000000000000..fa343fddd82d89619d246ed0a5561f6b9fae76b7 --- /dev/null +++ b/ultralytics/docs/en/integrations/jupyterlab.md @@ -0,0 +1,210 @@ +--- +comments: true +description: Explore our integration guide that explains how you can use JupyterLab to train a YOLOv8 model. We'll also cover key features and tips for common issues. +keywords: JupyterLab, What is JupyterLab, How to Use JupyterLab, JupyterLab How to Use, YOLOv8, Ultralytics, Model Training, GPU, TPU, cloud computing +--- + +# A Guide on How to Use JupyterLab to Train Your YOLOv8 Models + +Building deep learning models can be tough, especially when you don't have the right tools or environment to work with. If you are facing this issue, JupyterLab might be the right solution for you. JupyterLab is a user-friendly, web-based platform that makes coding more flexible and interactive. You can use it to handle big datasets, create complex models, and even collaborate with others, all in one place. + +You can use JupyterLab to [work on projects](../guides/steps-of-a-cv-project.md) related to [Ultralytics YOLOv8 models](https://github.com/ultralytics/ultralytics). JupyterLab is a great option for efficient model development and experimentation. It makes it easy to start experimenting with and [training YOLOv8 models](../modes/train.md) right from your computer. Let's dive deeper into JupyterLab, its key features, and how you can use it to train YOLOv8 models. + +## What is JupyterLab? + +JupyterLab is an open-source web-based platform designed for working with Jupyter notebooks, code, and data. It's an upgrade from the traditional Jupyter Notebook interface that provides a more versatile and powerful user experience. + +JupyterLab allows you to work with notebooks, text editors, terminals, and other tools all in one place. Its flexible design lets you organize your workspace to fit your needs and makes it easier to perform tasks like data analysis, visualization, and machine learning. JupyterLab also supports real-time collaboration, making it ideal for team projects in research and data science. + +## Key Features of JupyterLab + +Here are some of the key features that make JupyterLab a great option for model development and experimentation: + +- **All-in-One Workspace**: JupyterLab is a one-stop shop for all your data science needs. Unlike the classic Jupyter Notebook, which had separate interfaces for text editing, terminal access, and notebooks, JupyterLab integrates all these features into a single, cohesive environment. You can view and edit various file formats, including JPEG, PDF, and CSV, directly within JupyterLab. An all-in-one workspace lets you access everything you need at your fingertips, streamlining your workflow and saving you time. +- **Flexible Layouts**: One of JupyterLab's standout features is its flexible layout. You can drag, drop, and resize tabs to create a personalized layout that helps you work more efficiently. The collapsible left sidebar keeps essential tabs like the file browser, running kernels, and command palette within easy reach. You can have multiple windows open at once, allowing you to multitask and manage your projects more effectively. +- **Interactive Code Consoles**: Code consoles in JupyterLab provide an interactive space to test out snippets of code or functions. They also serve as a log of computations made within a notebook. Creating a new console for a notebook and viewing all kernel activity is straightforward. This feature is especially useful when you're experimenting with new ideas or troubleshooting issues in your code. +- **Markdown Preview**: Working with Markdown files is more efficient in JupyterLab, thanks to its simultaneous preview feature. As you write or edit your Markdown file, you can see the formatted output in real-time. It makes it easier to double-check that your documentation looks perfect, saving you from having to switch back and forth between editing and preview modes. +- **Run Code from Text Files**: If you're sharing a text file with code, JupyterLab makes it easy to run it directly within the platform. You can highlight the code and press Shift + Enter to execute it. It is great for verifying code snippets quickly and helps guarantee that the code you share is functional and error-free. + +## Why Should You Use JupyterLab for Your YOLOv8 Projects? + +There are multiple platforms for developing and evaluating machine learning models, so what makes JupyterLab stand out? Let's explore some of the unique aspects that JupyterLab offers for your machine-learning projects: + +- **Easy Cell Management**: Managing cells in JupyterLab is a breeze. Instead of the cumbersome cut-and-paste method, you can simply drag and drop cells to rearrange them. +- **Cross-Notebook Cell Copying**: JupyterLab makes it simple to copy cells between different notebooks. You can drag and drop cells from one notebook to another. +- **Easy Switch to Classic Notebook View**: For those who miss the classic Jupyter Notebook interface, JupyterLab offers an easy switch back. Simply replace `/lab` in the URL with `/tree` to return to the familiar notebook view. +- **Multiple Views**: JupyterLab supports multiple views of the same notebook, which is particularly useful for long notebooks. You can open different sections side-by-side for comparison or exploration, and any changes made in one view are reflected in the other. +- **Customizable Themes**: JupyterLab includes a built-in Dark theme for the notebook, which is perfect for late-night coding sessions. There are also themes available for the text editor and terminal, allowing you to customize the appearance of your entire workspace. + +## Common Issues While Working with JupyterLab + +When working with Kaggle, you might come across some common issues. Here are some tips to help you navigate the platform smoothly: + +- **Managing Kernels**: Kernels are crucial because they manage the connection between the code you write in JupyterLab and the environment where it runs. They can also access and share data between notebooks. When you close a Jupyter Notebook, the kernel might still be running because other notebooks could be using it. If you want to completely shut down a kernel, you can select it, right-click, and choose "Shut Down Kernel" from the pop-up menu. +- **Installing Python Packages**: Sometimes, you might need additional Python packages that aren't pre-installed on the server. You can easily install these packages in your home directory or a virtual environment by using the command `python -m pip install package-name`. To see all installed packages, use `python -m pip list`. +- **Deploying Flask/FastAPI API to Posit Connect**: You can deploy your Flask and FastAPI APIs to Posit Connect using the [rsconnect-python](https://docs.posit.co/rsconnect-python/) package from the terminal. Doing so makes it easier to integrate your web applications with JupyterLab and share them with others. +- **Installing JupyterLab Extensions**: JupyterLab supports various extensions to enhance functionality. You can install and customize these extensions to suit your needs. For detailed instructions, refer to [JupyterLab Extensions Guide](https://jupyterlab.readthedocs.io/en/latest/user/extensions.html) for more information. +- **Using Multiple Versions of Python**: If you need to work with different versions of Python, you can use Jupyter kernels configured with different Python versions. + +## How to Use JupyterLab to Try Out YOLOv8 + +JupyterLab makes it easy to experiment with YOLOv8. To get started, follow these simple steps. + +### Step 1: Install JupyterLab + +First, you need to install JupyterLab. Open your terminal and run the command: + +!!! tip "Installation" + + === "CLI" + + ```bash + # Install the required package for JupyterLab + pip install jupyterlab + ``` + +### Step 2: Download the YOLOv8 Tutorial Notebook + +Next, download the [tutorial.ipynb](https://github.com/ultralytics/ultralytics/blob/main/examples/tutorial.ipynb) file from the Ultralytics GitHub repository. Save this file to any directory on your local machine. + +### Step 3: Launch JupyterLab + +Navigate to the directory where you saved the notebook file using your terminal. Then, run the following command to launch JupyterLab: + +!!! example "Usage" + + === "CLI" + + ```bash + jupyter lab + ``` + +Once you've run this command, it will open JupyterLab in your default web browser, as shown below. + +![Image Showing How JupyterLab Opens On the Browser](https://github.com/ultralytics/docs/releases/download/0/jupyterlab-browser-launch.avif) + +### Step 4: Start Experimenting + +In JupyterLab, open the tutorial.ipynb notebook. You can now start running the cells to explore and experiment with YOLOv8. + +![Image Showing Opened YOLOv8 Notebook in JupyterLab](https://github.com/ultralytics/docs/releases/download/0/opened-yolov8-notebook-jupyterlab.avif) + +JupyterLab's interactive environment allows you to modify code, visualize outputs, and document your findings all in one place. You can try out different configurations and understand how YOLOv8 works. + +For a detailed understanding of the model training process and best practices, refer to the [YOLOv8 Model Training guide](../modes/train.md). This guide will help you get the most out of your experiments and ensure you're using YOLOv8 effectively. + +## Keep Learning about Jupyterlab + +If you're excited to learn more about JupyterLab, here are some great resources to get you started: + +- [**JupyterLab Documentation**](https://jupyterlab.readthedocs.io/en/stable/getting_started/starting.html): Dive into the official JupyterLab Documentation to explore its features and capabilities. It's a great way to understand how to use this powerful tool to its fullest potential. +- [**Try It With Binder**](https://mybinder.org/v2/gh/jupyterlab/jupyterlab-demo/HEAD?urlpath=lab/tree/demo): Experiment with JupyterLab without installing anything by using Binder, which lets you launch a live JupyterLab instance directly in your browser. It's a great way to start experimenting immediately. +- [**Installation Guide**](https://jupyterlab.readthedocs.io/en/stable/getting_started/installation.html): For a step-by-step guide on installing JupyterLab on your local machine, check out the installation guide. + +## Summary + +We've explored how JupyterLab can be a powerful tool for experimenting with Ultralytics YOLOv8 models. Using its flexible and interactive environment, you can easily set up JupyterLab on your local machine and start working with YOLOv8. JupyterLab makes it simple to [train](../guides/model-training-tips.md) and [evaluate](../guides/model-testing.md) your models, visualize outputs, and [document your findings](../guides/model-monitoring-and-maintenance.md) all in one place. + +For more details, visit the [JupyterLab FAQ Page](https://jupyterlab.readthedocs.io/en/stable/getting_started/faq.html). + +Interested in more YOLOv8 integrations? Check out the [Ultralytics integration guide](./index.md) to explore additional tools and capabilities for your machine learning projects. + +## FAQ + +### How do I use JupyterLab to train a YOLOv8 model? + +To train a YOLOv8 model using JupyterLab: + +1. Install JupyterLab and the Ultralytics package: + + ```bash + pip install jupyterlab ultralytics + ``` + +2. Launch JupyterLab and open a new notebook. + +3. Import the YOLO model and load a pretrained model: + + ```python + from ultralytics import YOLO + + model = YOLO("yolov8n.pt") + ``` + +4. Train the model on your custom dataset: + + ```python + results = model.train(data="path/to/your/data.yaml", epochs=100, imgsz=640) + ``` + +5. Visualize training results using JupyterLab's built-in plotting capabilities: + + ```ipython + %matplotlib inline + from ultralytics.utils.plotting import plot_results + plot_results(results) + ``` + +JupyterLab's interactive environment allows you to easily modify parameters, visualize results, and iterate on your model training process. + +### What are the key features of JupyterLab that make it suitable for YOLOv8 projects? + +JupyterLab offers several features that make it ideal for YOLOv8 projects: + +1. Interactive code execution: Test and debug YOLOv8 code snippets in real-time. +2. Integrated file browser: Easily manage datasets, model weights, and configuration files. +3. Flexible layout: Arrange multiple notebooks, terminals, and output windows side-by-side for efficient workflow. +4. Rich output display: Visualize YOLOv8 detection results, training curves, and model performance metrics inline. +5. Markdown support: Document your YOLOv8 experiments and findings with rich text and images. +6. Extension ecosystem: Enhance functionality with extensions for version control, [remote computing](google-colab.md), and more. + +These features allow for a seamless development experience when working with YOLOv8 models, from data preparation to model deployment. + +### How can I optimize YOLOv8 model performance using JupyterLab? + +To optimize YOLOv8 model performance in JupyterLab: + +1. Use the autobatch feature to determine the optimal batch size: + + ```python + from ultralytics.utils.autobatch import autobatch + + optimal_batch_size = autobatch(model) + ``` + +2. Implement [hyperparameter tuning](../guides/hyperparameter-tuning.md) using libraries like Ray Tune: + + ```python + from ultralytics.utils.tuner import run_ray_tune + + best_results = run_ray_tune(model, data="path/to/data.yaml") + ``` + +3. Visualize and analyze model metrics using JupyterLab's plotting capabilities: + + ```python + from ultralytics.utils.plotting import plot_results + + plot_results(results.results_dict) + ``` + +4. Experiment with different model architectures and [export formats](../modes/export.md) to find the best balance of speed and accuracy for your specific use case. + +JupyterLab's interactive environment allows for quick iterations and real-time feedback, making it easier to optimize your YOLOv8 models efficiently. + +### How do I handle common issues when working with JupyterLab and YOLOv8? + +When working with JupyterLab and YOLOv8, you might encounter some common issues. Here's how to handle them: + +1. GPU memory issues: + + - Use `torch.cuda.empty_cache()` to clear GPU memory between runs. + - Adjust batch size or image size to fit your GPU memory. + +2. Package conflicts: + + - Create a separate conda environment for your YOLOv8 projects to avoid conflicts. + - Use `!pip install package_name` in a notebook cell to install missing packages. + +3. Kernel crashes: + - Restart the kernel and run cells one by one to identify the problematic code. diff --git a/ultralytics/docs/en/integrations/kaggle.md b/ultralytics/docs/en/integrations/kaggle.md new file mode 100644 index 0000000000000000000000000000000000000000..23d0091865755ec662a2f31cf33d9f2282eca759 --- /dev/null +++ b/ultralytics/docs/en/integrations/kaggle.md @@ -0,0 +1,139 @@ +--- +comments: true +description: Dive into our guide on YOLOv8's integration with Kaggle. Find out what Kaggle is, its key features, and how to train a YOLOv8 model using the integration. +keywords: What is Kaggle, What is Kaggle Used For, YOLOv8, Kaggle Machine Learning, Model Training, GPU, TPU, cloud computing +--- + +# A Guide on Using Kaggle to Train Your YOLOv8 Models + +If you are learning about AI and working on [small projects](../solutions/index.md), you might not have access to powerful computing resources yet, and high-end hardware can be pretty expensive. Fortunately, Kaggle, a platform owned by Google, offers a great solution. Kaggle provides a free, cloud-based environment where you can access GPU resources, handle large datasets, and collaborate with a diverse community of data scientists and machine learning enthusiasts. + +Kaggle is a great choice for [training](../guides/model-training-tips.md) and experimenting with [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics?tab=readme-ov-file) models. Kaggle Notebooks make using popular machine-learning libraries and frameworks in your projects easy. Let's explore Kaggle's main features and learn how you can train YOLOv8 models on this platform! + +## What is Kaggle? + +Kaggle is a platform that brings together data scientists from around the world to collaborate, learn, and compete in solving real-world data science problems. Launched in 2010 by Anthony Goldbloom and Jeremy Howard and acquired by Google in 2017. Kaggle enables users to connect, discover and share datasets, use GPU-powered notebooks, and participate in data science competitions. The platform is designed to help both seasoned professionals and eager learners achieve their goals by offering robust tools and resources. + +With more than [10 million users](https://www.kaggle.com/discussions/general/332147) as of 2022, Kaggle provides a rich environment for developing and experimenting with machine learning models. You don't need to worry about your local machine's specs or setup; you can dive right in with just a Kaggle account and a web browser. + +## Training YOLOv8 Using Kaggle + +Training YOLOv8 models on Kaggle is simple and efficient, thanks to the platform's access to powerful GPUs. + +To get started, access the [Kaggle YOLOv8 Notebook](https://www.kaggle.com/code/ultralytics/yolov8). Kaggle's environment comes with pre-installed libraries like TensorFlow and PyTorch, making the setup process hassle-free. + +![What is the kaggle integration with respect to YOLOv8?](https://github.com/ultralytics/docs/releases/download/0/kaggle-integration-yolov8.avif) + +Once you sign in to your Kaggle account, you can click on the option to copy and edit the code, select a GPU under the accelerator settings, and run the notebook's cells to begin training your model. For a detailed understanding of the model training process and best practices, refer to our [YOLOv8 Model Training guide](../modes/train.md). + +![Using kaggle for machine learning model training with a GPU](https://github.com/ultralytics/docs/releases/download/0/using-kaggle-for-machine-learning-model-training-with-a-gpu.avif) + +On the [official YOLOv8 Kaggle notebook page](https://www.kaggle.com/code/ultralytics/yolov8), if you click on the three dots in the upper right-hand corner, you'll notice more options will pop up. + +![Overview of Options From the Official YOLOv8 Kaggle Notebook Page](https://github.com/ultralytics/docs/releases/download/0/overview-options-yolov8-kaggle-notebook.avif) + +These options include: + +- **View Versions**: Browse through different versions of the notebook to see changes over time and revert to previous versions if needed. +- **Copy API Command**: Get an API command to programmatically interact with the notebook, which is useful for automation and integration into workflows. +- **Open in Google Notebooks**: Open the notebook in Google's hosted notebook environment. +- **Open in Colab**: Launch the notebook in [Google Colab](./google-colab.md) for further editing and execution. +- **Follow Comments**: Subscribe to the comments section to get updates and engage with the community. +- **Download Code**: Download the entire notebook as a Jupyter (.ipynb) file for offline use or version control in your local environment. +- **Add to Collection**: Save the notebook to a collection within your Kaggle account for easy access and organization. +- **Bookmark**: Bookmark the notebook for quick access in the future. +- **Embed Notebook**: Get an embed link to include the notebook in blogs, websites, or documentation. + +### Common Issues While Working with Kaggle + +When working with Kaggle, you might come across some common issues. Here are some points to help you navigate the platform smoothly: + +- **Access to GPUs**: In your Kaggle notebooks, you can activate a GPU at any time, with usage allowed for up to 30 hours per week. Kaggle provides the Nvidia Tesla P100 GPU with 16GB of memory and also offers the option of using a Nvidia GPU T4 x2. Powerful hardware accelerates your machine-learning tasks, making model training and inference much faster. +- **Kaggle Kernels**: Kaggle Kernels are free Jupyter notebook servers that can integrate GPUs, allowing you to perform machine learning operations on cloud computers. You don't have to rely on your own computer's CPU, avoiding overload and freeing up your local resources. +- **Kaggle Datasets**: Kaggle datasets are free to download. However, it's important to check the license for each dataset to understand any usage restrictions. Some datasets may have limitations on academic publications or commercial use. You can download datasets directly to your Kaggle notebook or anywhere else via the Kaggle API. +- **Saving and Committing Notebooks**: To save and commit a notebook on Kaggle, click "Save Version." This saves the current state of your notebook. Once the background kernel finishes generating the output files, you can access them from the Output tab on the main notebook page. +- **Collaboration**: Kaggle supports collaboration, but multiple users cannot edit a notebook simultaneously. Collaboration on Kaggle is asynchronous, meaning users can share and work on the same notebook at different times. +- **Reverting to a Previous Version**: If you need to revert to a previous version of your notebook, open the notebook and click on the three vertical dots in the top right corner to select "View Versions." Find the version you want to revert to, click on the "..." menu next to it, and select "Revert to Version." After the notebook reverts, click "Save Version" to commit the changes. + +## Key Features of Kaggle + +Next, let's understand the features Kaggle offers that make it an excellent platform for data science and machine learning enthusiasts. Here are some of the key highlights: + +- **Datasets**: Kaggle hosts a massive collection of datasets on various topics. You can easily search and use these datasets in your projects, which is particularly handy for training and testing your YOLOv8 models. +- **Competitions**: Known for its exciting competitions, Kaggle allows data scientists and machine learning enthusiasts to solve real-world problems. Competing helps you improve your skills, learn new techniques, and gain recognition in the community. +- **Free Access to TPUs**: Kaggle provides free access to powerful TPUs, which are essential for training complex machine learning models. This means you can speed up processing and boost the performance of your YOLOv8 projects without incurring extra costs. +- **Integration with Github**: Kaggle allows you to easily connect your GitHub repository to upload notebooks and save your work. This integration makes it convenient to manage and access your files. +- **Community and Discussions**: Kaggle boasts a strong community of data scientists and machine learning practitioners. The discussion forums and shared notebooks are fantastic resources for learning and troubleshooting. You can easily find help, share your knowledge, and collaborate with others. + +## Why Should You Use Kaggle for Your YOLOv8 Projects? + +There are multiple platforms for training and evaluating machine learning models, so what makes Kaggle stand out? Let's dive into the benefits of using Kaggle for your machine-learning projects: + +- **Public Notebooks**: You can make your Kaggle notebooks public, allowing other users to view, vote, fork, and discuss your work. Kaggle promotes collaboration, feedback, and the sharing of ideas, helping you improve your YOLOv8 models. +- **Comprehensive History of Notebook Commits**: Kaggle creates a detailed history of your notebook commits. This allows you to review and track changes over time, making it easier to understand the evolution of your project and revert to previous versions if needed. +- **Console Access**: Kaggle provides a console, giving you more control over your environment. This feature allows you to perform various tasks directly from the command line, enhancing your workflow and productivity. +- **Resource Availability**: Each notebook editing session on Kaggle is provided with significant resources: 12 hours of execution time for CPU and GPU sessions, 9 hours of execution time for TPU sessions, and 20 gigabytes of auto-saved disk space. +- **Notebook Scheduling**: Kaggle allows you to schedule your notebooks to run at specific times. You can automate repetitive tasks without manual intervention, such as training your model at regular intervals. + +## Keep Learning about Kaggle + +If you want to learn more about Kaggle, here are some helpful resources to guide you: + +- [**Kaggle Learn**](https://www.kaggle.com/learn): Discover a variety of free, interactive tutorials on Kaggle Learn. These courses cover essential data science topics and provide hands-on experience to help you master new skills. +- [**Getting Started with Kaggle**](https://www.kaggle.com/code/alexisbcook/getting-started-with-kaggle): This comprehensive guide walks you through the basics of using Kaggle, from joining competitions to creating your first notebook. It's a great starting point for newcomers. +- [**Kaggle Medium Page**](https://medium.com/@kaggleteam): Explore tutorials, updates, and community contributions on Kaggle's Medium page. It's an excellent source for staying up-to-date with the latest trends and gaining deeper insights into data science. + +## Summary + +We've seen how Kaggle can boost your YOLOv8 projects by providing free access to powerful GPUs, making model training and evaluation efficient. Kaggle's platform is user-friendly, with pre-installed libraries for quick setup. + +For more details, visit [Kaggle's documentation](https://www.kaggle.com/docs). + +Interested in more YOLOv8 integrations? Check out the[ Ultralytics integration guide](https://docs.ultralytics.com/integrations/) to explore additional tools and capabilities for your machine learning projects. + +## FAQ + +### How do I train a YOLOv8 model on Kaggle? + +Training a YOLOv8 model on Kaggle is straightforward. First, access the [Kaggle YOLOv8 Notebook](https://www.kaggle.com/ultralytics/yolov8). Sign in to your Kaggle account, copy and edit the notebook, and select a GPU under the accelerator settings. Run the notebook cells to start training. For more detailed steps, refer to our [YOLOv8 Model Training guide](../modes/train.md). + +### What are the benefits of using Kaggle for YOLOv8 model training? + +Kaggle offers several advantages for training YOLOv8 models: + +- **Free GPU Access**: Utilize powerful GPUs like Nvidia Tesla P100 or T4 x2 for up to 30 hours per week. +- **Pre-installed Libraries**: Libraries like TensorFlow and PyTorch are pre-installed, simplifying the setup. +- **Community Collaboration**: Engage with a vast community of data scientists and machine learning enthusiasts. +- **Version Control**: Easily manage different versions of your notebooks and revert to previous versions if needed. + +For more details, visit our [Ultralytics integration guide](https://docs.ultralytics.com/integrations/). + +### What common issues might I encounter when using Kaggle for YOLOv8, and how can I resolve them? + +Common issues include: + +- **Access to GPUs**: Ensure you activate a GPU in your notebook settings. Kaggle allows up to 30 hours of GPU usage per week. +- **Dataset Licenses**: Check the license of each dataset to understand usage restrictions. +- **Saving and Committing Notebooks**: Click "Save Version" to save your notebook's state and access output files from the Output tab. +- **Collaboration**: Kaggle supports asynchronous collaboration; multiple users cannot edit a notebook simultaneously. + +For more troubleshooting tips, see our [Common Issues guide](../guides/yolo-common-issues.md). + +### Why should I choose Kaggle over other platforms like Google Colab for training YOLOv8 models? + +Kaggle offers unique features that make it an excellent choice: + +- **Public Notebooks**: Share your work with the community for feedback and collaboration. +- **Free Access to TPUs**: Speed up training with powerful TPUs without extra costs. +- **Comprehensive History**: Track changes over time with a detailed history of notebook commits. +- **Resource Availability**: Significant resources are provided for each notebook session, including 12 hours of execution time for CPU and GPU sessions. + For a comparison with Google Colab, refer to our [Google Colab guide](./google-colab.md). + +### How can I revert to a previous version of my Kaggle notebook? + +To revert to a previous version: + +1. Open the notebook and click on the three vertical dots in the top right corner. +2. Select "View Versions." +3. Find the version you want to revert to, click on the "..." menu next to it, and select "Revert to Version." +4. Click "Save Version" to commit the changes. diff --git a/ultralytics/docs/en/integrations/mlflow.md b/ultralytics/docs/en/integrations/mlflow.md new file mode 100644 index 0000000000000000000000000000000000000000..727b79e0bb78c08af2e0c943f592f4d8988d40af --- /dev/null +++ b/ultralytics/docs/en/integrations/mlflow.md @@ -0,0 +1,207 @@ +--- +comments: true +description: Learn how to set up and use MLflow logging with Ultralytics YOLO for enhanced experiment tracking, model reproducibility, and performance improvements. +keywords: MLflow, Ultralytics YOLO, machine learning, experiment tracking, metrics logging, parameter logging, artifact logging +--- + +# MLflow Integration for Ultralytics YOLO + +MLflow ecosystem + +## Introduction + +Experiment logging is a crucial aspect of machine learning workflows that enables tracking of various metrics, parameters, and artifacts. It helps to enhance model reproducibility, debug issues, and improve model performance. [Ultralytics](https://www.ultralytics.com/) YOLO, known for its real-time object detection capabilities, now offers integration with [MLflow](https://mlflow.org/), an open-source platform for complete machine learning lifecycle management. + +This documentation page is a comprehensive guide to setting up and utilizing the MLflow logging capabilities for your Ultralytics YOLO project. + +## What is MLflow? + +[MLflow](https://mlflow.org/) is an open-source platform developed by [Databricks](https://www.databricks.com/) for managing the end-to-end machine learning lifecycle. It includes tools for tracking experiments, packaging code into reproducible runs, and sharing and deploying models. MLflow is designed to work with any machine learning library and programming language. + +## Features + +- **Metrics Logging**: Logs metrics at the end of each epoch and at the end of the training. +- **Parameter Logging**: Logs all the parameters used in the training. +- **Artifacts Logging**: Logs model artifacts, including weights and configuration files, at the end of the training. + +## Setup and Prerequisites + +Ensure MLflow is installed. If not, install it using pip: + +```bash +pip install mlflow +``` + +Make sure that MLflow logging is enabled in Ultralytics settings. Usually, this is controlled by the settings `mflow` key. See the [settings](../quickstart.md#ultralytics-settings) page for more info. + +!!! example "Update Ultralytics MLflow Settings" + + === "Python" + + Within the Python environment, call the `update` method on the `settings` object to change your settings: + ```python + from ultralytics import settings + + # Update a setting + settings.update({"mlflow": True}) + + # Reset settings to default values + settings.reset() + ``` + + === "CLI" + + If you prefer using the command-line interface, the following commands will allow you to modify your settings: + ```bash + # Update a setting + yolo settings runs_dir='/path/to/runs' + + # Reset settings to default values + yolo settings reset + ``` + +## How to Use + +### Commands + +1. **Set a Project Name**: You can set the project name via an environment variable: + + ```bash + export MLFLOW_EXPERIMENT_NAME= + ``` + + Or use the `project=` argument when training a YOLO model, i.e. `yolo train project=my_project`. + +2. **Set a Run Name**: Similar to setting a project name, you can set the run name via an environment variable: + + ```bash + export MLFLOW_RUN= + ``` + + Or use the `name=` argument when training a YOLO model, i.e. `yolo train project=my_project name=my_name`. + +3. **Start Local MLflow Server**: To start tracking, use: + + ```bash + mlflow server --backend-store-uri runs/mlflow' + ``` + + This will start a local server at http://127.0.0.1:5000 by default and save all mlflow logs to the 'runs/mlflow' directory. To specify a different URI, set the `MLFLOW_TRACKING_URI` environment variable. + +4. **Kill MLflow Server Instances**: To stop all running MLflow instances, run: + + ```bash + ps aux | grep 'mlflow' | grep -v 'grep' | awk '{print $2}' | xargs kill -9 + ``` + +### Logging + +The logging is taken care of by the `on_pretrain_routine_end`, `on_fit_epoch_end`, and `on_train_end` callback functions. These functions are automatically called during the respective stages of the training process, and they handle the logging of parameters, metrics, and artifacts. + +## Examples + +1. **Logging Custom Metrics**: You can add custom metrics to be logged by modifying the `trainer.metrics` dictionary before `on_fit_epoch_end` is called. + +2. **View Experiment**: To view your logs, navigate to your MLflow server (usually http://127.0.0.1:5000) and select your experiment and run. YOLO MLflow Experiment + +3. **View Run**: Runs are individual models inside an experiment. Click on a Run and see the Run details, including uploaded artifacts and model weights. YOLO MLflow Run + +## Disabling MLflow + +To turn off MLflow logging: + +```bash +yolo settings mlflow=False +``` + +## Conclusion + +MLflow logging integration with Ultralytics YOLO offers a streamlined way to keep track of your machine learning experiments. It empowers you to monitor performance metrics and manage artifacts effectively, thus aiding in robust model development and deployment. For further details please visit the MLflow [official documentation](https://mlflow.org/docs/latest/index.html). + +## FAQ + +### How do I set up MLflow logging with Ultralytics YOLO? + +To set up MLflow logging with Ultralytics YOLO, you first need to ensure MLflow is installed. You can install it using pip: + +```bash +pip install mlflow +``` + +Next, enable MLflow logging in Ultralytics settings. This can be controlled using the `mlflow` key. For more information, see the [settings guide](../quickstart.md#ultralytics-settings). + +!!! example "Update Ultralytics MLflow Settings" + + === "Python" + + ```python + from ultralytics import settings + + # Update a setting + settings.update({"mlflow": True}) + + # Reset settings to default values + settings.reset() + ``` + + === "CLI" + + ```bash + # Update a setting + yolo settings runs_dir='/path/to/runs' + + # Reset settings to default values + yolo settings reset + ``` + +Finally, start a local MLflow server for tracking: + +```bash +mlflow server --backend-store-uri runs/mlflow +``` + +### What metrics and parameters can I log using MLflow with Ultralytics YOLO? + +Ultralytics YOLO with MLflow supports logging various metrics, parameters, and artifacts throughout the training process: + +- **Metrics Logging**: Tracks metrics at the end of each epoch and upon training completion. +- **Parameter Logging**: Logs all parameters used in the training process. +- **Artifacts Logging**: Saves model artifacts like weights and configuration files after training. + +For more detailed information, visit the [Ultralytics YOLO tracking documentation](#features). + +### Can I disable MLflow logging once it is enabled? + +Yes, you can disable MLflow logging for Ultralytics YOLO by updating the settings. Here's how you can do it using the CLI: + +```bash +yolo settings mlflow=False +``` + +For further customization and resetting settings, refer to the [settings guide](../quickstart.md#ultralytics-settings). + +### How can I start and stop an MLflow server for Ultralytics YOLO tracking? + +To start an MLflow server for tracking your experiments in Ultralytics YOLO, use the following command: + +```bash +mlflow server --backend-store-uri runs/mlflow +``` + +This command starts a local server at http://127.0.0.1:5000 by default. If you need to stop running MLflow server instances, use the following bash command: + +```bash +ps aux | grep 'mlflow' | grep -v 'grep' | awk '{print $2}' | xargs kill -9 +``` + +Refer to the [commands section](#commands) for more command options. + +### What are the benefits of integrating MLflow with Ultralytics YOLO for experiment tracking? + +Integrating MLflow with Ultralytics YOLO offers several benefits for managing your machine learning experiments: + +- **Enhanced Experiment Tracking**: Easily track and compare different runs and their outcomes. +- **Improved Model Reproducibility**: Ensure that your experiments are reproducible by logging all parameters and artifacts. +- **Performance Monitoring**: Visualize performance metrics over time to make data-driven decisions for model improvements. + +For an in-depth look at setting up and leveraging MLflow with Ultralytics YOLO, explore the [MLflow Integration for Ultralytics YOLO](#introduction) documentation. diff --git a/ultralytics/docs/en/integrations/ncnn.md b/ultralytics/docs/en/integrations/ncnn.md new file mode 100644 index 0000000000000000000000000000000000000000..cc64a0f84c8b5d3632505238dc2607512910b4a4 --- /dev/null +++ b/ultralytics/docs/en/integrations/ncnn.md @@ -0,0 +1,186 @@ +--- +comments: true +description: Optimize YOLOv8 models for mobile and embedded devices by exporting to NCNN format. Enhance performance in resource-constrained environments. +keywords: Ultralytics, YOLOv8, NCNN, model export, machine learning, deployment, mobile, embedded systems, deep learning, AI models +--- + +# How to Export to NCNN from YOLOv8 for Smooth Deployment + +Deploying computer vision models on devices with limited computational power, such as mobile or embedded systems, can be tricky. You need to make sure you use a format optimized for optimal performance. This makes sure that even devices with limited processing power can handle advanced computer vision tasks well. + +The export to NCNN format feature allows you to optimize your [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics) models for lightweight device-based applications. In this guide, we'll walk you through how to convert your models to the NCNN format, making it easier for your models to perform well on various mobile and embedded devices. + +## Why should you export to NCNN? + +

+ NCNN overview +

+ +The [NCNN](https://github.com/Tencent/ncnn) framework, developed by Tencent, is a high-performance neural network inference computing framework optimized specifically for mobile platforms, including mobile phones, embedded devices, and IoT devices. NCNN is compatible with a wide range of platforms, including Linux, Android, iOS, and macOS. + +NCNN is known for its fast processing speed on mobile CPUs and enables rapid deployment of deep learning models to mobile platforms. This makes it easier to build smart apps, putting the power of AI right at your fingertips. + +## Key Features of NCNN Models + +NCNN models offer a wide range of key features that enable on-device machine learning by helping developers run their models on mobile, embedded, and edge devices: + +- **Efficient and High-Performance**: NCNN models are made to be efficient and lightweight, optimized for running on mobile and embedded devices like Raspberry Pi with limited resources. They can also achieve high performance with high accuracy on various computer vision-based tasks. + +- **Quantization**: NCNN models often support quantization which is a technique that reduces the precision of the model's weights and activations. This leads to further improvements in performance and reduces memory footprint. + +- **Compatibility**: NCNN models are compatible with popular deep learning frameworks like [TensorFlow](https://www.tensorflow.org/), [Caffe](https://caffe.berkeleyvision.org/), and [ONNX](https://onnx.ai/). This compatibility allows developers to use existing models and workflows easily. + +- **Easy to Use**: NCNN models are designed for easy integration into various applications, thanks to their compatibility with popular deep learning frameworks. Additionally, NCNN offers user-friendly tools for converting models between different formats, ensuring smooth interoperability across the development landscape. + +## Deployment Options with NCNN + +Before we look at the code for exporting YOLOv8 models to the NCNN format, let's understand how NCNN models are normally used. + +NCNN models, designed for efficiency and performance, are compatible with a variety of deployment platforms: + +- **Mobile Deployment**: Specifically optimized for Android and iOS, allowing for seamless integration into mobile applications for efficient on-device inference. + +- **Embedded Systems and IoT Devices**: If you find that running inference on a Raspberry Pi with the [Ultralytics Guide](../guides/raspberry-pi.md) isn't fast enough, switching to an NCNN exported model could help speed things up. NCNN is great for devices like Raspberry Pi and NVIDIA Jetson, especially in situations where you need quick processing right on the device. + +- **Desktop and Server Deployment**: Capable of being deployed in desktop and server environments across Linux, Windows, and macOS, supporting development, training, and evaluation with higher computational capacities. + +## Export to NCNN: Converting Your YOLOv8 Model + +You can expand model compatibility and deployment flexibility by converting YOLOv8 models to NCNN format. + +### Installation + +To install the required packages, run: + +!!! tip "Installation" + + === "CLI" + + ```bash + # Install the required package for YOLOv8 + pip install ultralytics + ``` + +For detailed instructions and best practices related to the installation process, check our [Ultralytics Installation guide](../quickstart.md). While installing the required packages for YOLOv8, if you encounter any difficulties, consult our [Common Issues guide](../guides/yolo-common-issues.md) for solutions and tips. + +### Usage + +Before diving into the usage instructions, it's important to note that while all [Ultralytics YOLOv8 models](../models/index.md) are available for exporting, you can ensure that the model you select supports export functionality [here](../modes/export.md). + +!!! example "Usage" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load the YOLOv8 model + model = YOLO("yolov8n.pt") + + # Export the model to NCNN format + model.export(format="ncnn") # creates '/yolov8n_ncnn_model' + + # Load the exported NCNN model + ncnn_model = YOLO("./yolov8n_ncnn_model") + + # Run inference + results = ncnn_model("https://ultralytics.com/images/bus.jpg") + ``` + + === "CLI" + + ```bash + # Export a YOLOv8n PyTorch model to NCNN format + yolo export model=yolov8n.pt format=ncnn # creates '/yolov8n_ncnn_model' + + # Run inference with the exported model + yolo predict model='./yolov8n_ncnn_model' source='https://ultralytics.com/images/bus.jpg' + ``` + +For more details about supported export options, visit the [Ultralytics documentation page on deployment options](../guides/model-deployment-options.md). + +## Deploying Exported YOLOv8 NCNN Models + +After successfully exporting your Ultralytics YOLOv8 models to NCNN format, you can now deploy them. The primary and recommended first step for running a NCNN model is to utilize the YOLO("./model_ncnn_model") method, as outlined in the previous usage code snippet. However, for in-depth instructions on deploying your NCNN models in various other settings, take a look at the following resources: + +- **[Android](https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-android)**: This blog explains how to use NCNN models for performing tasks like object detection through Android applications. + +- **[macOS](https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-macos)**: Understand how to use NCNN models for performing tasks through macOS. + +- **[Linux](https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-linux)**: Explore this page to learn how to deploy NCNN models on limited resource devices like Raspberry Pi and other similar devices. + +- **[Windows x64 using VS2017](https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-windows-x64-using-visual-studio-community-2017)**: Explore this blog to learn how to deploy NCNN models on windows x64 using Visual Studio Community 2017. + +## Summary + +In this guide, we've gone over exporting Ultralytics YOLOv8 models to the NCNN format. This conversion step is crucial for improving the efficiency and speed of YOLOv8 models, making them more effective and suitable for limited-resource computing environments. + +For detailed instructions on usage, please refer to the [official NCNN documentation](https://ncnn.readthedocs.io/en/latest/index.html). + +Also, if you're interested in exploring other integration options for Ultralytics YOLOv8, be sure to visit our [integration guide page](index.md) for further insights and information. + +## FAQ + +### How do I export Ultralytics YOLOv8 models to NCNN format? + +To export your Ultralytics YOLOv8 model to NCNN format, follow these steps: + +- **Python**: Use the `export` function from the YOLO class. + + ```python + from ultralytics import YOLO + + # Load the YOLOv8 model + model = YOLO("yolov8n.pt") + + # Export to NCNN format + model.export(format="ncnn") # creates '/yolov8n_ncnn_model' + ``` + +- **CLI**: Use the `yolo` command with the `export` argument. + ```bash + yolo export model=yolov8n.pt format=ncnn # creates '/yolov8n_ncnn_model' + ``` + +For detailed export options, check the [Export](../modes/export.md) page in the documentation. + +### What are the advantages of exporting YOLOv8 models to NCNN? + +Exporting your Ultralytics YOLOv8 models to NCNN offers several benefits: + +- **Efficiency**: NCNN models are optimized for mobile and embedded devices, ensuring high performance even with limited computational resources. +- **Quantization**: NCNN supports techniques like quantization that improve model speed and reduce memory usage. +- **Broad Compatibility**: You can deploy NCNN models on multiple platforms, including Android, iOS, Linux, and macOS. + +For more details, see the [Export to NCNN](#why-should-you-export-to-ncnn) section in the documentation. + +### Why should I use NCNN for my mobile AI applications? + +NCNN, developed by Tencent, is specifically optimized for mobile platforms. Key reasons to use NCNN include: + +- **High Performance**: Designed for efficient and fast processing on mobile CPUs. +- **Cross-Platform**: Compatible with popular frameworks such as TensorFlow and ONNX, making it easier to convert and deploy models across different platforms. +- **Community Support**: Active community support ensures continual improvements and updates. + +To understand more, visit the [NCNN overview](#key-features-of-ncnn-models) in the documentation. + +### What platforms are supported for NCNN model deployment? + +NCNN is versatile and supports various platforms: + +- **Mobile**: Android, iOS. +- **Embedded Systems and IoT Devices**: Devices like Raspberry Pi and NVIDIA Jetson. +- **Desktop and Servers**: Linux, Windows, and macOS. + +If running models on a Raspberry Pi isn't fast enough, converting to the NCNN format could speed things up as detailed in our [Raspberry Pi Guide](../guides/raspberry-pi.md). + +### How can I deploy Ultralytics YOLOv8 NCNN models on Android? + +To deploy your YOLOv8 models on Android: + +1. **Build for Android**: Follow the [NCNN Build for Android](https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-android) guide. +2. **Integrate with Your App**: Use the NCNN Android SDK to integrate the exported model into your application for efficient on-device inference. + +For step-by-step instructions, refer to our guide on [Deploying YOLOv8 NCNN Models](#deploying-exported-yolov8-ncnn-models). + +For more advanced guides and use cases, visit the [Ultralytics documentation page](../guides/model-deployment-options.md). diff --git a/ultralytics/docs/en/integrations/neural-magic.md b/ultralytics/docs/en/integrations/neural-magic.md new file mode 100644 index 0000000000000000000000000000000000000000..31eebda53a715b793952de36c3d8041f168c7c61 --- /dev/null +++ b/ultralytics/docs/en/integrations/neural-magic.md @@ -0,0 +1,211 @@ +--- +comments: true +description: Enhance YOLOv8 performance using Neural Magic's DeepSparse Engine. Learn how to deploy and benchmark YOLOv8 models on CPUs for efficient object detection. +keywords: YOLOv8, DeepSparse, Neural Magic, model optimization, object detection, inference speed, CPU performance, sparsity, pruning, quantization +--- + +# Optimizing YOLOv8 Inferences with Neural Magic's DeepSparse Engine + +When deploying object detection models like [Ultralytics YOLOv8](https://www.ultralytics.com/) on various hardware, you can bump into unique issues like optimization. This is where YOLOv8's integration with Neural Magic's DeepSparse Engine steps in. It transforms the way YOLOv8 models are executed and enables GPU-level performance directly on CPUs. + +This guide shows you how to deploy YOLOv8 using Neural Magic's DeepSparse, how to run inferences, and also how to benchmark performance to ensure it is optimized. + +## Neural Magic's DeepSparse + +

+ Neural Magic's DeepSparse Overview +

+ +[Neural Magic's DeepSparse](https://neuralmagic.com/deepsparse/) is an inference run-time designed to optimize the execution of neural networks on CPUs. It applies advanced techniques like sparsity, pruning, and quantization to dramatically reduce computational demands while maintaining accuracy. DeepSparse offers an agile solution for efficient and scalable neural network execution across various devices. + +## Benefits of Integrating Neural Magic's DeepSparse with YOLOv8 + +Before diving into how to deploy YOLOV8 using DeepSparse, let's understand the benefits of using DeepSparse. Some key advantages include: + +- **Enhanced Inference Speed**: Achieves up to 525 FPS (on YOLOv8n), significantly speeding up YOLOv8's inference capabilities compared to traditional methods. + +

+ Enhanced Inference Speed +

+ +- **Optimized Model Efficiency**: Uses pruning and quantization to enhance YOLOv8's efficiency, reducing model size and computational requirements while maintaining accuracy. + +

+ Optimized Model Efficiency +

+ +- **High Performance on Standard CPUs**: Delivers GPU-like performance on CPUs, providing a more accessible and cost-effective option for various applications. + +- **Streamlined Integration and Deployment**: Offers user-friendly tools for easy integration of YOLOv8 into applications, including image and video annotation features. + +- **Support for Various Model Types**: Compatible with both standard and sparsity-optimized YOLOv8 models, adding deployment flexibility. + +- **Cost-Effective and Scalable Solution**: Reduces operational expenses and offers scalable deployment of advanced object detection models. + +## How Does Neural Magic's DeepSparse Technology Works? + +Neural Magic's Deep Sparse technology is inspired by the human brain's efficiency in neural network computation. It adopts two key principles from the brain as follows: + +- **Sparsity**: The process of sparsification involves pruning redundant information from deep learning networks, leading to smaller and faster models without compromising accuracy. This technique reduces the network's size and computational needs significantly. + +- **Locality of Reference**: DeepSparse uses a unique execution method, breaking the network into Tensor Columns. These columns are executed depth-wise, fitting entirely within the CPU's cache. This approach mimics the brain's efficiency, minimizing data movement and maximizing the CPU's cache use. + +

+ How Neural Magic's DeepSparse Technology Works +

+ +For more details on how Neural Magic's DeepSparse technology work, check out [their blog post](https://neuralmagic.com/blog/how-neural-magics-deep-sparse-technology-works/). + +## Creating A Sparse Version of YOLOv8 Trained on a Custom Dataset + +SparseZoo, an open-source model repository by Neural Magic, offers [a collection of pre-sparsified YOLOv8 model checkpoints](https://sparsezoo.neuralmagic.com/?modelSet=computer_vision&searchModels=yolo). With SparseML, seamlessly integrated with Ultralytics, users can effortlessly fine-tune these sparse checkpoints on their specific datasets using a straightforward command-line interface. + +Checkout [Neural Magic's SparseML YOLOv8 documentation](https://github.com/neuralmagic/sparseml/tree/main/integrations/ultralytics-yolov8) for more details. + +## Usage: Deploying YOLOV8 using DeepSparse + +Deploying YOLOv8 with Neural Magic's DeepSparse involves a few straightforward steps. Before diving into the usage instructions, be sure to check out the range of [YOLOv8 models offered by Ultralytics](../models/index.md). This will help you choose the most appropriate model for your project requirements. Here's how you can get started. + +### Step 1: Installation + +To install the required packages, run: + +!!! tip "Installation" + + === "CLI" + + ```bash + # Install the required packages + pip install deepsparse[yolov8] + ``` + +### Step 2: Exporting YOLOv8 to ONNX Format + +DeepSparse Engine requires YOLOv8 models in ONNX format. Exporting your model to this format is essential for compatibility with DeepSparse. Use the following command to export YOLOv8 models: + +!!! tip "Model Export" + + === "CLI" + + ```bash + # Export YOLOv8 model to ONNX format + yolo task=detect mode=export model=yolov8n.pt format=onnx opset=13 + ``` + +This command will save the `yolov8n.onnx` model to your disk. + +### Step 3: Deploying and Running Inferences + +With your YOLOv8 model in ONNX format, you can deploy and run inferences using DeepSparse. This can be done easily with their intuitive Python API: + +!!! tip "Deploying and Running Inferences" + + === "Python" + + ```python + from deepsparse import Pipeline + + # Specify the path to your YOLOv8 ONNX model + model_path = "path/to/yolov8n.onnx" + + # Set up the DeepSparse Pipeline + yolo_pipeline = Pipeline.create(task="yolov8", model_path=model_path) + + # Run the model on your images + images = ["path/to/image.jpg"] + pipeline_outputs = yolo_pipeline(images=images) + ``` + +### Step 4: Benchmarking Performance + +It's important to check that your YOLOv8 model is performing optimally on DeepSparse. You can benchmark your model's performance to analyze throughput and latency: + +!!! tip "Benchmarking" + + === "CLI" + + ```bash + # Benchmark performance + deepsparse.benchmark model_path="path/to/yolov8n.onnx" --scenario=sync --input_shapes="[1,3,640,640]" + ``` + +### Step 5: Additional Features + +DeepSparse provides additional features for practical integration of YOLOv8 in applications, such as image annotation and dataset evaluation. + +!!! tip "Additional Features" + + === "CLI" + + ```bash + # For image annotation + deepsparse.yolov8.annotate --source "path/to/image.jpg" --model_filepath "path/to/yolov8n.onnx" + + # For evaluating model performance on a dataset + deepsparse.yolov8.eval --model_path "path/to/yolov8n.onnx" + ``` + +Running the annotate command processes your specified image, detecting objects, and saving the annotated image with bounding boxes and classifications. The annotated image will be stored in an annotation-results folder. This helps provide a visual representation of the model's detection capabilities. + +

+ Image Annotation Feature +

+ +After running the eval command, you will receive detailed output metrics such as precision, recall, and mAP (mean Average Precision). This provides a comprehensive view of your model's performance on the dataset. This functionality is particularly useful for fine-tuning and optimizing your YOLOv8 models for specific use cases, ensuring high accuracy and efficiency. + +## Summary + +This guide explored integrating Ultralytics' YOLOv8 with Neural Magic's DeepSparse Engine. It highlighted how this integration enhances YOLOv8's performance on CPU platforms, offering GPU-level efficiency and advanced neural network sparsity techniques. + +For more detailed information and advanced usage, visit [Neural Magic's DeepSparse documentation](https://docs.neuralmagic.com/products/deepsparse/). Also, check out Neural Magic's documentation on the integration with YOLOv8 [here](https://github.com/neuralmagic/deepsparse/tree/main/src/deepsparse/yolov8#yolov8-inference-pipelines) and watch a great session on it [here](https://www.youtube.com/watch?v=qtJ7bdt52x8). + +Additionally, for a broader understanding of various YOLOv8 integrations, visit the [Ultralytics integration guide page](../integrations/index.md), where you can discover a range of other exciting integration possibilities. + +## FAQ + +### What is Neural Magic's DeepSparse Engine and how does it optimize YOLOv8 performance? + +Neural Magic's DeepSparse Engine is an inference runtime designed to optimize the execution of neural networks on CPUs through advanced techniques such as sparsity, pruning, and quantization. By integrating DeepSparse with YOLOv8, you can achieve GPU-like performance on standard CPUs, significantly enhancing inference speed, model efficiency, and overall performance while maintaining accuracy. For more details, check out the [Neural Magic's DeepSparse section](#neural-magics-deepsparse). + +### How can I install the needed packages to deploy YOLOv8 using Neural Magic's DeepSparse? + +Installing the required packages for deploying YOLOv8 with Neural Magic's DeepSparse is straightforward. You can easily install them using the CLI. Here's the command you need to run: + +```bash +pip install deepsparse[yolov8] +``` + +Once installed, follow the steps provided in the [Installation section](#step-1-installation) to set up your environment and start using DeepSparse with YOLOv8. + +### How do I convert YOLOv8 models to ONNX format for use with DeepSparse? + +To convert YOLOv8 models to the ONNX format, which is required for compatibility with DeepSparse, you can use the following CLI command: + +```bash +yolo task=detect mode=export model=yolov8n.pt format=onnx opset=13 +``` + +This command will export your YOLOv8 model (`yolov8n.pt`) to a format (`yolov8n.onnx`) that can be utilized by the DeepSparse Engine. More information about model export can be found in the [Model Export section](#step-2-exporting-yolov8-to-onnx-format). + +### How do I benchmark YOLOv8 performance on the DeepSparse Engine? + +Benchmarking YOLOv8 performance on DeepSparse helps you analyze throughput and latency to ensure your model is optimized. You can use the following CLI command to run a benchmark: + +```bash +deepsparse.benchmark model_path="path/to/yolov8n.onnx" --scenario=sync --input_shapes="[1,3,640,640]" +``` + +This command will provide you with vital performance metrics. For more details, see the [Benchmarking Performance section](#step-4-benchmarking-performance). + +### Why should I use Neural Magic's DeepSparse with YOLOv8 for object detection tasks? + +Integrating Neural Magic's DeepSparse with YOLOv8 offers several benefits: + +- **Enhanced Inference Speed:** Achieves up to 525 FPS, significantly speeding up YOLOv8's capabilities. +- **Optimized Model Efficiency:** Uses sparsity, pruning, and quantization techniques to reduce model size and computational needs while maintaining accuracy. +- **High Performance on Standard CPUs:** Offers GPU-like performance on cost-effective CPU hardware. +- **Streamlined Integration:** User-friendly tools for easy deployment and integration. +- **Flexibility:** Supports both standard and sparsity-optimized YOLOv8 models. +- **Cost-Effective:** Reduces operational expenses through efficient resource utilization. + +For a deeper dive into these advantages, visit the [Benefits of Integrating Neural Magic's DeepSparse with YOLOv8 section](#benefits-of-integrating-neural-magics-deepsparse-with-yolov8). diff --git a/ultralytics/docs/en/integrations/onnx.md b/ultralytics/docs/en/integrations/onnx.md new file mode 100644 index 0000000000000000000000000000000000000000..766757cde3911b5506ea27cf469d0d3ca8677464 --- /dev/null +++ b/ultralytics/docs/en/integrations/onnx.md @@ -0,0 +1,213 @@ +--- +comments: true +description: Learn how to export YOLOv8 models to ONNX format for flexible deployment across various platforms with enhanced performance. +keywords: YOLOv8, ONNX, model export, Ultralytics, ONNX Runtime, machine learning, model deployment, computer vision, deep learning +--- + +# ONNX Export for YOLOv8 Models + +Often, when deploying computer vision models, you'll need a model format that's both flexible and compatible with multiple platforms. + +Exporting [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics) models to ONNX format streamlines deployment and ensures optimal performance across various environments. This guide will show you how to easily convert your YOLOv8 models to ONNX and enhance their scalability and effectiveness in real-world applications. + +## ONNX and ONNX Runtime + +[ONNX](https://onnx.ai/), which stands for Open Neural Network Exchange, is a community project that Facebook and Microsoft initially developed. The ongoing development of ONNX is a collaborative effort supported by various organizations like IBM, Amazon (through AWS), and Google. The project aims to create an open file format designed to represent machine learning models in a way that allows them to be used across different AI frameworks and hardware. + +ONNX models can be used to transition between different frameworks seamlessly. For instance, a deep learning model trained in PyTorch can be exported to ONNX format and then easily imported into TensorFlow. + +

+ ONNX +

+ +Alternatively, ONNX models can be used with ONNX Runtime. [ONNX Runtime](https://onnxruntime.ai/) is a versatile cross-platform accelerator for machine learning models that is compatible with frameworks like PyTorch, TensorFlow, TFLite, scikit-learn, etc. + +ONNX Runtime optimizes the execution of ONNX models by leveraging hardware-specific capabilities. This optimization allows the models to run efficiently and with high performance on various hardware platforms, including CPUs, GPUs, and specialized accelerators. + +

+ ONNX with ONNX Runtime +

+ +Whether used independently or in tandem with ONNX Runtime, ONNX provides a flexible solution for machine learning model deployment and compatibility. + +## Key Features of ONNX Models + +The ability of ONNX to handle various formats can be attributed to the following key features: + +- **Common Model Representation**: ONNX defines a common set of operators (like convolutions, layers, etc.) and a standard data format. When a model is converted to ONNX format, its architecture and weights are translated into this common representation. This uniformity ensures that the model can be understood by any framework that supports ONNX. + +- **Versioning and Backward Compatibility**: ONNX maintains a versioning system for its operators. This ensures that even as the standard evolves, models created in older versions remain usable. Backward compatibility is a crucial feature that prevents models from becoming obsolete quickly. + +- **Graph-based Model Representation**: ONNX represents models as computational graphs. This graph-based structure is a universal way of representing machine learning models, where nodes represent operations or computations, and edges represent the tensors flowing between them. This format is easily adaptable to various frameworks which also represent models as graphs. + +- **Tools and Ecosystem**: There is a rich ecosystem of tools around ONNX that assist in model conversion, visualization, and optimization. These tools make it easier for developers to work with ONNX models and to convert models between different frameworks seamlessly. + +## Common Usage of ONNX + +Before we jump into how to export YOLOv8 models to the ONNX format, let's take a look at where ONNX models are usually used. + +### CPU Deployment + +ONNX models are often deployed on CPUs due to their compatibility with ONNX Runtime. This runtime is optimized for CPU execution. It significantly improves inference speed and makes real-time CPU deployments feasible. + +### Supported Deployment Options + +While ONNX models are commonly used on CPUs, they can also be deployed on the following platforms: + +- **GPU Acceleration**: ONNX fully supports GPU acceleration, particularly NVIDIA CUDA. This enables efficient execution on NVIDIA GPUs for tasks that demand high computational power. + +- **Edge and Mobile Devices**: ONNX extends to edge and mobile devices, perfect for on-device and real-time inference scenarios. It's lightweight and compatible with edge hardware. + +- **Web Browsers**: ONNX can run directly in web browsers, powering interactive and dynamic web-based AI applications. + +## Exporting YOLOv8 Models to ONNX + +You can expand model compatibility and deployment flexibility by converting YOLOv8 models to ONNX format. + +### Installation + +To install the required package, run: + +!!! tip "Installation" + + === "CLI" + + ```bash + # Install the required package for YOLOv8 + pip install ultralytics + ``` + +For detailed instructions and best practices related to the installation process, check our [YOLOv8 Installation guide](../quickstart.md). While installing the required packages for YOLOv8, if you encounter any difficulties, consult our [Common Issues guide](../guides/yolo-common-issues.md) for solutions and tips. + +### Usage + +Before diving into the usage instructions, be sure to check out the range of [YOLOv8 models offered by Ultralytics](../models/index.md). This will help you choose the most appropriate model for your project requirements. + +!!! example "Usage" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load the YOLOv8 model + model = YOLO("yolov8n.pt") + + # Export the model to ONNX format + model.export(format="onnx") # creates 'yolov8n.onnx' + + # Load the exported ONNX model + onnx_model = YOLO("yolov8n.onnx") + + # Run inference + results = onnx_model("https://ultralytics.com/images/bus.jpg") + ``` + + === "CLI" + + ```bash + # Export a YOLOv8n PyTorch model to ONNX format + yolo export model=yolov8n.pt format=onnx # creates 'yolov8n.onnx' + + # Run inference with the exported model + yolo predict model=yolov8n.onnx source='https://ultralytics.com/images/bus.jpg' + ``` + +For more details about the export process, visit the [Ultralytics documentation page on exporting](../modes/export.md). + +## Deploying Exported YOLOv8 ONNX Models + +Once you've successfully exported your Ultralytics YOLOv8 models to ONNX format, the next step is deploying these models in various environments. For detailed instructions on deploying your ONNX models, take a look at the following resources: + +- **[ONNX Runtime Python API Documentation](https://onnxruntime.ai/docs/api/python/api_summary.html)**: This guide provides essential information for loading and running ONNX models using ONNX Runtime. + +- **[Deploying on Edge Devices](https://onnxruntime.ai/docs/tutorials/iot-edge/)**: Check out this docs page for different examples of deploying ONNX models on edge. + +- **[ONNX Tutorials on GitHub](https://github.com/onnx/tutorials)**: A collection of comprehensive tutorials that cover various aspects of using and implementing ONNX models in different scenarios. + +## Summary + +In this guide, you've learned how to export Ultralytics YOLOv8 models to ONNX format to increase their interoperability and performance across various platforms. You were also introduced to the ONNX Runtime and ONNX deployment options. + +For further details on usage, visit the [ONNX official documentation](https://onnx.ai/onnx/intro/). + +Also, if you'd like to know more about other Ultralytics YOLOv8 integrations, visit our [integration guide page](../integrations/index.md). You'll find plenty of useful resources and insights there. + +## FAQ + +### How do I export YOLOv8 models to ONNX format using Ultralytics? + +To export your YOLOv8 models to ONNX format using Ultralytics, follow these steps: + +!!! example "Usage" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load the YOLOv8 model + model = YOLO("yolov8n.pt") + + # Export the model to ONNX format + model.export(format="onnx") # creates 'yolov8n.onnx' + + # Load the exported ONNX model + onnx_model = YOLO("yolov8n.onnx") + + # Run inference + results = onnx_model("https://ultralytics.com/images/bus.jpg") + ``` + + === "CLI" + + ```bash + # Export a YOLOv8n PyTorch model to ONNX format + yolo export model=yolov8n.pt format=onnx # creates 'yolov8n.onnx' + + # Run inference with the exported model + yolo predict model=yolov8n.onnx source='https://ultralytics.com/images/bus.jpg' + ``` + +For more details, visit the [export documentation](../modes/export.md). + +### What are the advantages of using ONNX Runtime for deploying YOLOv8 models? + +Using ONNX Runtime for deploying YOLOv8 models offers several advantages: + +- **Cross-platform compatibility**: ONNX Runtime supports various platforms, such as Windows, macOS, and Linux, ensuring your models run smoothly across different environments. +- **Hardware acceleration**: ONNX Runtime can leverage hardware-specific optimizations for CPUs, GPUs, and dedicated accelerators, providing high-performance inference. +- **Framework interoperability**: Models trained in popular frameworks like PyTorch or TensorFlow can be easily converted to ONNX format and run using ONNX Runtime. + +Learn more by checking the [ONNX Runtime documentation](https://onnxruntime.ai/docs/api/python/api_summary.html). + +### What deployment options are available for YOLOv8 models exported to ONNX? + +YOLOv8 models exported to ONNX can be deployed on various platforms including: + +- **CPUs**: Utilizing ONNX Runtime for optimized CPU inference. +- **GPUs**: Leveraging NVIDIA CUDA for high-performance GPU acceleration. +- **Edge devices**: Running lightweight models on edge and mobile devices for real-time, on-device inference. +- **Web browsers**: Executing models directly within web browsers for interactive web-based applications. + +For more information, explore our guide on [model deployment options](../guides/model-deployment-options.md). + +### Why should I use ONNX format for Ultralytics YOLOv8 models? + +Using ONNX format for Ultralytics YOLOv8 models provides numerous benefits: + +- **Interoperability**: ONNX allows models to be transferred between different machine learning frameworks seamlessly. +- **Performance Optimization**: ONNX Runtime can enhance model performance by utilizing hardware-specific optimizations. +- **Flexibility**: ONNX supports various deployment environments, enabling you to use the same model on different platforms without modification. + +Refer to the comprehensive guide on [exporting YOLOv8 models to ONNX](https://www.ultralytics.com/blog/export-and-optimize-a-yolov8-model-for-inference-on-openvino). + +### How can I troubleshoot issues when exporting YOLOv8 models to ONNX? + +When exporting YOLOv8 models to ONNX, you might encounter common issues such as mismatched dependencies or unsupported operations. To troubleshoot these problems: + +1. Verify that you have the correct version of required dependencies installed. +2. Check the official [ONNX documentation](https://onnx.ai/onnx/intro/) for supported operators and features. +3. Review the error messages for clues and consult the [Ultralytics Common Issues guide](../guides/yolo-common-issues.md). + +If issues persist, contact Ultralytics support for further assistance. diff --git a/ultralytics/docs/en/integrations/openvino.md b/ultralytics/docs/en/integrations/openvino.md new file mode 100644 index 0000000000000000000000000000000000000000..1278091f6e87fd7a70155419e5018c335812bd29 --- /dev/null +++ b/ultralytics/docs/en/integrations/openvino.md @@ -0,0 +1,393 @@ +--- +comments: true +description: Learn to export YOLOv8 models to OpenVINO format for up to 3x CPU speedup and hardware acceleration on Intel GPU and NPU. +keywords: YOLOv8, OpenVINO, model export, Intel, AI inference, CPU speedup, GPU acceleration, NPU, deep learning +--- + +# Intel OpenVINO Export + +OpenVINO Ecosystem + +In this guide, we cover exporting YOLOv8 models to the [OpenVINO](https://docs.openvino.ai/) format, which can provide up to 3x [CPU](https://docs.openvino.ai/2024/openvino-workflow/running-inference/inference-devices-and-modes/cpu-device.html) speedup, as well as accelerating YOLO inference on Intel [GPU](https://docs.openvino.ai/2024/openvino-workflow/running-inference/inference-devices-and-modes/gpu-device.html) and [NPU](https://docs.openvino.ai/2024/openvino-workflow/running-inference/inference-devices-and-modes/npu-device.html) hardware. + +OpenVINO, short for Open Visual Inference & Neural Network Optimization toolkit, is a comprehensive toolkit for optimizing and deploying AI inference models. Even though the name contains Visual, OpenVINO also supports various additional tasks including language, audio, time series, etc. + +

+
+ +
+ Watch: How To Export and Optimize an Ultralytics YOLOv8 Model for Inference with OpenVINO. +

+ +## Usage Examples + +Export a YOLOv8n model to OpenVINO format and run inference with the exported model. + +!!! example + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a YOLOv8n PyTorch model + model = YOLO("yolov8n.pt") + + # Export the model + model.export(format="openvino") # creates 'yolov8n_openvino_model/' + + # Load the exported OpenVINO model + ov_model = YOLO("yolov8n_openvino_model/") + + # Run inference + results = ov_model("https://ultralytics.com/images/bus.jpg") + ``` + + === "CLI" + + ```bash + # Export a YOLOv8n PyTorch model to OpenVINO format + yolo export model=yolov8n.pt format=openvino # creates 'yolov8n_openvino_model/' + + # Run inference with the exported model + yolo predict model=yolov8n_openvino_model source='https://ultralytics.com/images/bus.jpg' + ``` + +## Arguments + +| Key | Value | Description | +| --------- | ------------ | ---------------------------------------------------- | +| `format` | `'openvino'` | format to export to | +| `imgsz` | `640` | image size as scalar or (h, w) list, i.e. (640, 480) | +| `half` | `False` | FP16 quantization | +| `int8` | `False` | INT8 quantization | +| `batch` | `1` | batch size for inference | +| `dynamic` | `False` | allows dynamic input sizes | + +## Benefits of OpenVINO + +1. **Performance**: OpenVINO delivers high-performance inference by utilizing the power of Intel CPUs, integrated and discrete GPUs, and FPGAs. +2. **Support for Heterogeneous Execution**: OpenVINO provides an API to write once and deploy on any supported Intel hardware (CPU, GPU, FPGA, VPU, etc.). +3. **Model Optimizer**: OpenVINO provides a Model Optimizer that imports, converts, and optimizes models from popular deep learning frameworks such as PyTorch, TensorFlow, TensorFlow Lite, Keras, ONNX, PaddlePaddle, and Caffe. +4. **Ease of Use**: The toolkit comes with more than [80 tutorial notebooks](https://github.com/openvinotoolkit/openvino_notebooks) (including [YOLOv8 optimization](https://github.com/openvinotoolkit/openvino_notebooks/tree/latest/notebooks/yolov8-optimization)) teaching different aspects of the toolkit. + +## OpenVINO Export Structure + +When you export a model to OpenVINO format, it results in a directory containing the following: + +1. **XML file**: Describes the network topology. +2. **BIN file**: Contains the weights and biases binary data. +3. **Mapping file**: Holds mapping of original model output tensors to OpenVINO tensor names. + +You can use these files to run inference with the OpenVINO Inference Engine. + +## Using OpenVINO Export in Deployment + +Once you have the OpenVINO files, you can use the OpenVINO Runtime to run the model. The Runtime provides a unified API to inference across all supported Intel hardware. It also provides advanced capabilities like load balancing across Intel hardware and asynchronous execution. For more information on running the inference, refer to the [Inference with OpenVINO Runtime Guide](https://docs.openvino.ai/2024/openvino-workflow/running-inference.html). + +Remember, you'll need the XML and BIN files as well as any application-specific settings like input size, scale factor for normalization, etc., to correctly set up and use the model with the Runtime. + +In your deployment application, you would typically do the following steps: + +1. Initialize OpenVINO by creating `core = Core()`. +2. Load the model using the `core.read_model()` method. +3. Compile the model using the `core.compile_model()` function. +4. Prepare the input (image, text, audio, etc.). +5. Run inference using `compiled_model(input_data)`. + +For more detailed steps and code snippets, refer to the [OpenVINO documentation](https://docs.openvino.ai/) or [API tutorial](https://github.com/openvinotoolkit/openvino_notebooks/blob/latest/notebooks/openvino-api/openvino-api.ipynb). + +## OpenVINO YOLOv8 Benchmarks + +YOLOv8 benchmarks below were run by the Ultralytics team on 4 different model formats measuring speed and accuracy: PyTorch, TorchScript, ONNX and OpenVINO. Benchmarks were run on Intel Flex and Arc GPUs, and on Intel Xeon CPUs at FP32 precision (with the `half=False` argument). + +!!! note + + The benchmarking results below are for reference and might vary based on the exact hardware and software configuration of a system, as well as the current workload of the system at the time the benchmarks are run. + + All benchmarks run with `openvino` Python package version [2023.0.1](https://pypi.org/project/openvino/2023.0.1/). + +### Intel Flex GPU + +The Intel® Data Center GPU Flex Series is a versatile and robust solution designed for the intelligent visual cloud. This GPU supports a wide array of workloads including media streaming, cloud gaming, AI visual inference, and virtual desktop Infrastructure workloads. It stands out for its open architecture and built-in support for the AV1 encode, providing a standards-based software stack for high-performance, cross-architecture applications. The Flex Series GPU is optimized for density and quality, offering high reliability, availability, and scalability. + +Benchmarks below run on Intel® Data Center GPU Flex 170 at FP32 precision. + +
+Flex GPU benchmarks +
+ +| Model | Format | Status | Size (MB) | mAP50-95(B) | Inference time (ms/im) | +| ------- | ----------- | ------ | --------- | ----------- | ---------------------- | +| YOLOv8n | PyTorch | ✅ | 6.2 | 0.3709 | 21.79 | +| YOLOv8n | TorchScript | ✅ | 12.4 | 0.3704 | 23.24 | +| YOLOv8n | ONNX | ✅ | 12.2 | 0.3704 | 37.22 | +| YOLOv8n | OpenVINO | ✅ | 12.3 | 0.3703 | 3.29 | +| YOLOv8s | PyTorch | ✅ | 21.5 | 0.4471 | 31.89 | +| YOLOv8s | TorchScript | ✅ | 42.9 | 0.4472 | 32.71 | +| YOLOv8s | ONNX | ✅ | 42.8 | 0.4472 | 43.42 | +| YOLOv8s | OpenVINO | ✅ | 42.9 | 0.4470 | 3.92 | +| YOLOv8m | PyTorch | ✅ | 49.7 | 0.5013 | 50.75 | +| YOLOv8m | TorchScript | ✅ | 99.2 | 0.4999 | 47.90 | +| YOLOv8m | ONNX | ✅ | 99.0 | 0.4999 | 63.16 | +| YOLOv8m | OpenVINO | ✅ | 49.8 | 0.4997 | 7.11 | +| YOLOv8l | PyTorch | ✅ | 83.7 | 0.5293 | 77.45 | +| YOLOv8l | TorchScript | ✅ | 167.2 | 0.5268 | 85.71 | +| YOLOv8l | ONNX | ✅ | 166.8 | 0.5268 | 88.94 | +| YOLOv8l | OpenVINO | ✅ | 167.0 | 0.5264 | 9.37 | +| YOLOv8x | PyTorch | ✅ | 130.5 | 0.5404 | 100.09 | +| YOLOv8x | TorchScript | ✅ | 260.7 | 0.5371 | 114.64 | +| YOLOv8x | ONNX | ✅ | 260.4 | 0.5371 | 110.32 | +| YOLOv8x | OpenVINO | ✅ | 260.6 | 0.5367 | 15.02 | + +This table represents the benchmark results for five different models (YOLOv8n, YOLOv8s, YOLOv8m, YOLOv8l, YOLOv8x) across four different formats (PyTorch, TorchScript, ONNX, OpenVINO), giving us the status, size, mAP50-95(B) metric, and inference time for each combination. + +### Intel Arc GPU + +Intel® Arc™ represents Intel's foray into the dedicated GPU market. The Arc™ series, designed to compete with leading GPU manufacturers like AMD and Nvidia, caters to both the laptop and desktop markets. The series includes mobile versions for compact devices like laptops, and larger, more powerful versions for desktop computers. + +The Arc™ series is divided into three categories: Arc™ 3, Arc™ 5, and Arc™ 7, with each number indicating the performance level. Each category includes several models, and the 'M' in the GPU model name signifies a mobile, integrated variant. + +Early reviews have praised the Arc™ series, particularly the integrated A770M GPU, for its impressive graphics performance. The availability of the Arc™ series varies by region, and additional models are expected to be released soon. Intel® Arc™ GPUs offer high-performance solutions for a range of computing needs, from gaming to content creation. + +Benchmarks below run on Intel® Arc 770 GPU at FP32 precision. + +
+Arc GPU benchmarks +
+ +| Model | Format | Status | Size (MB) | metrics/mAP50-95(B) | Inference time (ms/im) | +| ------- | ----------- | ------ | --------- | ------------------- | ---------------------- | +| YOLOv8n | PyTorch | ✅ | 6.2 | 0.3709 | 88.79 | +| YOLOv8n | TorchScript | ✅ | 12.4 | 0.3704 | 102.66 | +| YOLOv8n | ONNX | ✅ | 12.2 | 0.3704 | 57.98 | +| YOLOv8n | OpenVINO | ✅ | 12.3 | 0.3703 | 8.52 | +| YOLOv8s | PyTorch | ✅ | 21.5 | 0.4471 | 189.83 | +| YOLOv8s | TorchScript | ✅ | 42.9 | 0.4472 | 227.58 | +| YOLOv8s | ONNX | ✅ | 42.7 | 0.4472 | 142.03 | +| YOLOv8s | OpenVINO | ✅ | 42.9 | 0.4469 | 9.19 | +| YOLOv8m | PyTorch | ✅ | 49.7 | 0.5013 | 411.64 | +| YOLOv8m | TorchScript | ✅ | 99.2 | 0.4999 | 517.12 | +| YOLOv8m | ONNX | ✅ | 98.9 | 0.4999 | 298.68 | +| YOLOv8m | OpenVINO | ✅ | 99.1 | 0.4996 | 12.55 | +| YOLOv8l | PyTorch | ✅ | 83.7 | 0.5293 | 725.73 | +| YOLOv8l | TorchScript | ✅ | 167.1 | 0.5268 | 892.83 | +| YOLOv8l | ONNX | ✅ | 166.8 | 0.5268 | 576.11 | +| YOLOv8l | OpenVINO | ✅ | 167.0 | 0.5262 | 17.62 | +| YOLOv8x | PyTorch | ✅ | 130.5 | 0.5404 | 988.92 | +| YOLOv8x | TorchScript | ✅ | 260.7 | 0.5371 | 1186.42 | +| YOLOv8x | ONNX | ✅ | 260.4 | 0.5371 | 768.90 | +| YOLOv8x | OpenVINO | ✅ | 260.6 | 0.5367 | 19 | + +### Intel Xeon CPU + +The Intel® Xeon® CPU is a high-performance, server-grade processor designed for complex and demanding workloads. From high-end cloud computing and virtualization to artificial intelligence and machine learning applications, Xeon® CPUs provide the power, reliability, and flexibility required for today's data centers. + +Notably, Xeon® CPUs deliver high compute density and scalability, making them ideal for both small businesses and large enterprises. By choosing Intel® Xeon® CPUs, organizations can confidently handle their most demanding computing tasks and foster innovation while maintaining cost-effectiveness and operational efficiency. + +Benchmarks below run on 4th Gen Intel® Xeon® Scalable CPU at FP32 precision. + +
+Xeon CPU benchmarks +
+ +| Model | Format | Status | Size (MB) | metrics/mAP50-95(B) | Inference time (ms/im) | +| ------- | ----------- | ------ | --------- | ------------------- | ---------------------- | +| YOLOv8n | PyTorch | ✅ | 6.2 | 0.3709 | 24.36 | +| YOLOv8n | TorchScript | ✅ | 12.4 | 0.3704 | 23.93 | +| YOLOv8n | ONNX | ✅ | 12.2 | 0.3704 | 39.86 | +| YOLOv8n | OpenVINO | ✅ | 12.3 | 0.3704 | 11.34 | +| YOLOv8s | PyTorch | ✅ | 21.5 | 0.4471 | 33.77 | +| YOLOv8s | TorchScript | ✅ | 42.9 | 0.4472 | 34.84 | +| YOLOv8s | ONNX | ✅ | 42.8 | 0.4472 | 43.23 | +| YOLOv8s | OpenVINO | ✅ | 42.9 | 0.4471 | 13.86 | +| YOLOv8m | PyTorch | ✅ | 49.7 | 0.5013 | 53.91 | +| YOLOv8m | TorchScript | ✅ | 99.2 | 0.4999 | 53.51 | +| YOLOv8m | ONNX | ✅ | 99.0 | 0.4999 | 64.16 | +| YOLOv8m | OpenVINO | ✅ | 99.1 | 0.4996 | 28.79 | +| YOLOv8l | PyTorch | ✅ | 83.7 | 0.5293 | 75.78 | +| YOLOv8l | TorchScript | ✅ | 167.2 | 0.5268 | 79.13 | +| YOLOv8l | ONNX | ✅ | 166.8 | 0.5268 | 88.45 | +| YOLOv8l | OpenVINO | ✅ | 167.0 | 0.5263 | 56.23 | +| YOLOv8x | PyTorch | ✅ | 130.5 | 0.5404 | 96.60 | +| YOLOv8x | TorchScript | ✅ | 260.7 | 0.5371 | 114.28 | +| YOLOv8x | ONNX | ✅ | 260.4 | 0.5371 | 111.02 | +| YOLOv8x | OpenVINO | ✅ | 260.6 | 0.5371 | 83.28 | + +### Intel Core CPU + +The Intel® Core® series is a range of high-performance processors by Intel. The lineup includes Core i3 (entry-level), Core i5 (mid-range), Core i7 (high-end), and Core i9 (extreme performance). Each series caters to different computing needs and budgets, from everyday tasks to demanding professional workloads. With each new generation, improvements are made to performance, energy efficiency, and features. + +Benchmarks below run on 13th Gen Intel® Core® i7-13700H CPU at FP32 precision. + +
+Core CPU benchmarks +
+ +| Model | Format | Status | Size (MB) | metrics/mAP50-95(B) | Inference time (ms/im) | +| ------- | ----------- | ------ | --------- | ------------------- | ---------------------- | +| YOLOv8n | PyTorch | ✅ | 6.2 | 0.4478 | 104.61 | +| YOLOv8n | TorchScript | ✅ | 12.4 | 0.4525 | 112.39 | +| YOLOv8n | ONNX | ✅ | 12.2 | 0.4525 | 28.02 | +| YOLOv8n | OpenVINO | ✅ | 12.3 | 0.4504 | 23.53 | +| YOLOv8s | PyTorch | ✅ | 21.5 | 0.5885 | 194.83 | +| YOLOv8s | TorchScript | ✅ | 43.0 | 0.5962 | 202.01 | +| YOLOv8s | ONNX | ✅ | 42.8 | 0.5962 | 65.74 | +| YOLOv8s | OpenVINO | ✅ | 42.9 | 0.5966 | 38.66 | +| YOLOv8m | PyTorch | ✅ | 49.7 | 0.6101 | 355.23 | +| YOLOv8m | TorchScript | ✅ | 99.2 | 0.6120 | 424.78 | +| YOLOv8m | ONNX | ✅ | 99.0 | 0.6120 | 173.39 | +| YOLOv8m | OpenVINO | ✅ | 99.1 | 0.6091 | 69.80 | +| YOLOv8l | PyTorch | ✅ | 83.7 | 0.6591 | 593.00 | +| YOLOv8l | TorchScript | ✅ | 167.2 | 0.6580 | 697.54 | +| YOLOv8l | ONNX | ✅ | 166.8 | 0.6580 | 342.15 | +| YOLOv8l | OpenVINO | ✅ | 167.0 | 0.0708 | 117.69 | +| YOLOv8x | PyTorch | ✅ | 130.5 | 0.6651 | 804.65 | +| YOLOv8x | TorchScript | ✅ | 260.8 | 0.6650 | 921.46 | +| YOLOv8x | ONNX | ✅ | 260.4 | 0.6650 | 526.66 | +| YOLOv8x | OpenVINO | ✅ | 260.6 | 0.6619 | 158.73 | + +## Reproduce Our Results + +To reproduce the Ultralytics benchmarks above on all export [formats](../modes/export.md) run this code: + +!!! example + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a YOLOv8n PyTorch model + model = YOLO("yolov8n.pt") + + # Benchmark YOLOv8n speed and accuracy on the COCO8 dataset for all export formats + results = model.benchmarks(data="coco8.yaml") + ``` + + === "CLI" + + ```bash + # Benchmark YOLOv8n speed and accuracy on the COCO8 dataset for all export formats + yolo benchmark model=yolov8n.pt data=coco8.yaml + ``` + + Note that benchmarking results might vary based on the exact hardware and software configuration of a system, as well as the current workload of the system at the time the benchmarks are run. For the most reliable results use a dataset with a large number of images, i.e. `data='coco128.yaml' (128 val images), or `data='coco.yaml'` (5000 val images). + +## Conclusion + +The benchmarking results clearly demonstrate the benefits of exporting the YOLOv8 model to the OpenVINO format. Across different models and hardware platforms, the OpenVINO format consistently outperforms other formats in terms of inference speed while maintaining comparable accuracy. + +For the Intel® Data Center GPU Flex Series, the OpenVINO format was able to deliver inference speeds almost 10 times faster than the original PyTorch format. On the Xeon CPU, the OpenVINO format was twice as fast as the PyTorch format. The accuracy of the models remained nearly identical across the different formats. + +The benchmarks underline the effectiveness of OpenVINO as a tool for deploying deep learning models. By converting models to the OpenVINO format, developers can achieve significant performance improvements, making it easier to deploy these models in real-world applications. + +For more detailed information and instructions on using OpenVINO, refer to the [official OpenVINO documentation](https://docs.openvino.ai/). + +## FAQ + +### How do I export YOLOv8 models to OpenVINO format? + +Exporting YOLOv8 models to the OpenVINO format can significantly enhance CPU speed and enable GPU and NPU accelerations on Intel hardware. To export, you can use either Python or CLI as shown below: + +!!! example + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a YOLOv8n PyTorch model + model = YOLO("yolov8n.pt") + + # Export the model + model.export(format="openvino") # creates 'yolov8n_openvino_model/' + ``` + + === "CLI" + + ```bash + # Export a YOLOv8n PyTorch model to OpenVINO format + yolo export model=yolov8n.pt format=openvino # creates 'yolov8n_openvino_model/' + ``` + +For more information, refer to the [export formats documentation](../modes/export.md). + +### What are the benefits of using OpenVINO with YOLOv8 models? + +Using Intel's OpenVINO toolkit with YOLOv8 models offers several benefits: + +1. **Performance**: Achieve up to 3x speedup on CPU inference and leverage Intel GPUs and NPUs for acceleration. +2. **Model Optimizer**: Convert, optimize, and execute models from popular frameworks like PyTorch, TensorFlow, and ONNX. +3. **Ease of Use**: Over 80 tutorial notebooks are available to help users get started, including ones for YOLOv8. +4. **Heterogeneous Execution**: Deploy models on various Intel hardware with a unified API. + +For detailed performance comparisons, visit our [benchmarks section](#openvino-yolov8-benchmarks). + +### How can I run inference using a YOLOv8 model exported to OpenVINO? + +After exporting a YOLOv8 model to OpenVINO format, you can run inference using Python or CLI: + +!!! example + + === "Python" + + ```python + from ultralytics import YOLO + + # Load the exported OpenVINO model + ov_model = YOLO("yolov8n_openvino_model/") + + # Run inference + results = ov_model("https://ultralytics.com/images/bus.jpg") + ``` + + === "CLI" + + ```bash + # Run inference with the exported model + yolo predict model=yolov8n_openvino_model source='https://ultralytics.com/images/bus.jpg' + ``` + +Refer to our [predict mode documentation](../modes/predict.md) for more details. + +### Why should I choose Ultralytics YOLOv8 over other models for OpenVINO export? + +Ultralytics YOLOv8 is optimized for real-time object detection with high accuracy and speed. Specifically, when combined with OpenVINO, YOLOv8 provides: + +- Up to 3x speedup on Intel CPUs +- Seamless deployment on Intel GPUs and NPUs +- Consistent and comparable accuracy across various export formats + +For in-depth performance analysis, check our detailed [YOLOv8 benchmarks](#openvino-yolov8-benchmarks) on different hardware. + +### Can I benchmark YOLOv8 models on different formats such as PyTorch, ONNX, and OpenVINO? + +Yes, you can benchmark YOLOv8 models in various formats including PyTorch, TorchScript, ONNX, and OpenVINO. Use the following code snippet to run benchmarks on your chosen dataset: + +!!! example + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a YOLOv8n PyTorch model + model = YOLO("yolov8n.pt") + + # Benchmark YOLOv8n speed and accuracy on the COCO8 dataset for all export formats + results = model.benchmarks(data="coco8.yaml") + ``` + + === "CLI" + + ```bash + # Benchmark YOLOv8n speed and accuracy on the COCO8 dataset for all export formats + yolo benchmark model=yolov8n.pt data=coco8.yaml + ``` + +For detailed benchmark results, refer to our [benchmarks section](#openvino-yolov8-benchmarks) and [export formats](../modes/export.md) documentation. diff --git a/ultralytics/docs/en/integrations/paddlepaddle.md b/ultralytics/docs/en/integrations/paddlepaddle.md new file mode 100644 index 0000000000000000000000000000000000000000..700c24f62e2efa14734c7c1d78f0dfde60cef801 --- /dev/null +++ b/ultralytics/docs/en/integrations/paddlepaddle.md @@ -0,0 +1,202 @@ +--- +comments: true +description: Learn how to export YOLOv8 models to PaddlePaddle format for enhanced performance, flexibility, and deployment across various platforms and devices. +keywords: YOLOv8, PaddlePaddle, export models, computer vision, deep learning, model deployment, performance optimization +--- + +# How to Export to PaddlePaddle Format from YOLOv8 Models + +Bridging the gap between developing and deploying computer vision models in real-world scenarios with varying conditions can be difficult. PaddlePaddle makes this process easier with its focus on flexibility, performance, and its capability for parallel processing in distributed environments. This means you can use your YOLOv8 computer vision models on a wide variety of devices and platforms, from smartphones to cloud-based servers. + +The ability to export to PaddlePaddle model format allows you to optimize your [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics) models for use within the PaddlePaddle framework. PaddlePaddle is known for facilitating industrial deployments and is a good choice for deploying computer vision applications in real-world settings across various domains. + +## Why should you export to PaddlePaddle? + +

+ PaddlePaddle Logo +

+ +Developed by Baidu, [PaddlePaddle](https://www.paddlepaddle.org.cn/en) (**PA**rallel **D**istributed **D**eep **LE**arning) is China's first open-source deep learning platform. Unlike some frameworks built mainly for research, PaddlePaddle prioritizes ease of use and smooth integration across industries. + +It offers tools and resources similar to popular frameworks like TensorFlow and PyTorch, making it accessible for developers of all experience levels. From farming and factories to service businesses, PaddlePaddle's large developer community of over 4.77 million is helping create and deploy AI applications. + +By exporting your Ultralytics YOLOv8 models to PaddlePaddle format, you can tap into PaddlePaddle's strengths in performance optimization. PaddlePaddle prioritizes efficient model execution and reduced memory usage. As a result, your YOLOv8 models can potentially achieve even better performance, delivering top-notch results in practical scenarios. + +## Key Features of PaddlePaddle Models + +PaddlePaddle models offer a range of key features that contribute to their flexibility, performance, and scalability across diverse deployment scenarios: + +- **Dynamic-to-Static Graph**: PaddlePaddle supports [dynamic-to-static compilation](https://www.paddlepaddle.org.cn/documentation/docs/en/guides/jit/index_en.html), where models can be translated into a static computational graph. This enables optimizations that reduce runtime overhead and boost inference performance. + +- **Operator Fusion**: PaddlePaddle, like TensorRT, uses [operator fusion](https://developer.nvidia.com/gtc/2020/video/s21436-vid) to streamline computation and reduce overhead. The framework minimizes memory transfers and computational steps by merging compatible operations, resulting in faster inference. + +- **Quantization**: PaddlePaddle supports [quantization techniques](https://www.paddlepaddle.org.cn/documentation/docs/en/api/paddle/quantization/PTQ_en.html), including post-training quantization and quantization-aware training. These techniques allow for the use of lower-precision data representations, effectively boosting performance and reducing model size. + +## Deployment Options in PaddlePaddle + +Before diving into the code for exporting YOLOv8 models to PaddlePaddle, let's take a look at the different deployment scenarios in which PaddlePaddle models excel. + +PaddlePaddle provides a range of options, each offering a distinct balance of ease of use, flexibility, and performance: + +- **Paddle Serving**: This framework simplifies the deployment of PaddlePaddle models as high-performance RESTful APIs. Paddle Serving is ideal for production environments, providing features like model versioning, online A/B testing, and scalability for handling large volumes of requests. + +- **Paddle Inference API**: The Paddle Inference API gives you low-level control over model execution. This option is well-suited for scenarios where you need to integrate the model tightly within a custom application or optimize performance for specific hardware. + +- **Paddle Lite**: Paddle Lite is designed for deployment on mobile and embedded devices where resources are limited. It optimizes models for smaller sizes and faster inference on ARM CPUs, GPUs, and other specialized hardware. + +- **Paddle.js**: Paddle.js enables you to deploy PaddlePaddle models directly within web browsers. Paddle.js can either load a pre-trained model or transform a model from [paddle-hub](https://github.com/PaddlePaddle/PaddleHub) with model transforming tools provided by Paddle.js. It can run in browsers that support WebGL/WebGPU/WebAssembly. + +## Export to PaddlePaddle: Converting Your YOLOv8 Model + +Converting YOLOv8 models to the PaddlePaddle format can improve execution flexibility and optimize performance for various deployment scenarios. + +### Installation + +To install the required package, run: + +!!! tip "Installation" + + === "CLI" + + ```bash + # Install the required package for YOLOv8 + pip install ultralytics + ``` + +For detailed instructions and best practices related to the installation process, check our [Ultralytics Installation guide](../quickstart.md). While installing the required packages for YOLOv8, if you encounter any difficulties, consult our [Common Issues guide](../guides/yolo-common-issues.md) for solutions and tips. + +### Usage + +Before diving into the usage instructions, it's important to note that while all [Ultralytics YOLOv8 models](../models/index.md) are available for exporting, you can ensure that the model you select supports export functionality [here](../modes/export.md). + +!!! example "Usage" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load the YOLOv8 model + model = YOLO("yolov8n.pt") + + # Export the model to PaddlePaddle format + model.export(format="paddle") # creates '/yolov8n_paddle_model' + + # Load the exported PaddlePaddle model + paddle_model = YOLO("./yolov8n_paddle_model") + + # Run inference + results = paddle_model("https://ultralytics.com/images/bus.jpg") + ``` + + === "CLI" + + ```bash + # Export a YOLOv8n PyTorch model to PaddlePaddle format + yolo export model=yolov8n.pt format=paddle # creates '/yolov8n_paddle_model' + + # Run inference with the exported model + yolo predict model='./yolov8n_paddle_model' source='https://ultralytics.com/images/bus.jpg' + ``` + +For more details about supported export options, visit the [Ultralytics documentation page on deployment options](../guides/model-deployment-options.md). + +## Deploying Exported YOLOv8 PaddlePaddle Models + +After successfully exporting your Ultralytics YOLOv8 models to PaddlePaddle format, you can now deploy them. The primary and recommended first step for running a PaddlePaddle model is to use the YOLO("./model_paddle_model") method, as outlined in the previous usage code snippet. + +However, for in-depth instructions on deploying your PaddlePaddle models in various other settings, take a look at the following resources: + +- **[Paddle Serving](https://github.com/PaddlePaddle/Serving/blob/v0.9.0/README_CN.md)**: Learn how to deploy your PaddlePaddle models as performant services using Paddle Serving. + +- **[Paddle Lite](https://github.com/PaddlePaddle/Paddle-Lite/blob/develop/README_en.md)**: Explore how to optimize and deploy models on mobile and embedded devices using Paddle Lite. + +- **[Paddle.js](https://github.com/PaddlePaddle/Paddle.js)**: Discover how to run PaddlePaddle models in web browsers for client-side AI using Paddle.js. + +## Summary + +In this guide, we explored the process of exporting Ultralytics YOLOv8 models to the PaddlePaddle format. By following these steps, you can leverage PaddlePaddle's strengths in diverse deployment scenarios, optimizing your models for different hardware and software environments. + +For further details on usage, visit the [PaddlePaddle official documentation](https://www.paddlepaddle.org.cn/documentation/docs/en/guides/index_en.html) + +Want to explore more ways to integrate your Ultralytics YOLOv8 models? Our [integration guide page](index.md) explores various options, equipping you with valuable resources and insights. + +## FAQ + +### How do I export Ultralytics YOLOv8 models to PaddlePaddle format? + +Exporting Ultralytics YOLOv8 models to PaddlePaddle format is straightforward. You can use the `export` method of the YOLO class to perform this exportation. Here is an example using Python: + +!!! example "Usage" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load the YOLOv8 model + model = YOLO("yolov8n.pt") + + # Export the model to PaddlePaddle format + model.export(format="paddle") # creates '/yolov8n_paddle_model' + + # Load the exported PaddlePaddle model + paddle_model = YOLO("./yolov8n_paddle_model") + + # Run inference + results = paddle_model("https://ultralytics.com/images/bus.jpg") + ``` + + === "CLI" + + ```bash + # Export a YOLOv8n PyTorch model to PaddlePaddle format + yolo export model=yolov8n.pt format=paddle # creates '/yolov8n_paddle_model' + + # Run inference with the exported model + yolo predict model='./yolov8n_paddle_model' source='https://ultralytics.com/images/bus.jpg' + ``` + +For more detailed setup and troubleshooting, check the [Ultralytics Installation Guide](../quickstart.md) and [Common Issues Guide](../guides/yolo-common-issues.md). + +### What are the advantages of using PaddlePaddle for model deployment? + +PaddlePaddle offers several key advantages for model deployment: + +- **Performance Optimization**: PaddlePaddle excels in efficient model execution and reduced memory usage. +- **Dynamic-to-Static Graph Compilation**: It supports dynamic-to-static compilation, allowing for runtime optimizations. +- **Operator Fusion**: By merging compatible operations, it reduces computational overhead. +- **Quantization Techniques**: Supports both post-training and quantization-aware training, enabling lower-precision data representations for improved performance. + +You can achieve enhanced results by exporting your Ultralytics YOLOv8 models to PaddlePaddle, ensuring flexibility and high performance across various applications and hardware platforms. Learn more about PaddlePaddle's features [here](https://www.paddlepaddle.org.cn/en). + +### Why should I choose PaddlePaddle for deploying my YOLOv8 models? + +PaddlePaddle, developed by Baidu, is optimized for industrial and commercial AI deployments. Its large developer community and robust framework provide extensive tools similar to TensorFlow and PyTorch. By exporting your YOLOv8 models to PaddlePaddle, you leverage: + +- **Enhanced Performance**: Optimal execution speed and reduced memory footprint. +- **Flexibility**: Wide compatibility with various devices from smartphones to cloud servers. +- **Scalability**: Efficient parallel processing capabilities for distributed environments. + +These features make PaddlePaddle a compelling choice for deploying YOLOv8 models in production settings. + +### How does PaddlePaddle improve model performance over other frameworks? + +PaddlePaddle employs several advanced techniques to optimize model performance: + +- **Dynamic-to-Static Graph**: Converts models into a static computational graph for runtime optimizations. +- **Operator Fusion**: Combines compatible operations to minimize memory transfer and increase inference speed. +- **Quantization**: Reduces model size and increases efficiency using lower-precision data while maintaining accuracy. + +These techniques prioritize efficient model execution, making PaddlePaddle an excellent option for deploying high-performance YOLOv8 models. For more on optimization, see the [PaddlePaddle official documentation](https://www.paddlepaddle.org.cn/documentation/docs/en/guides/index_en.html). + +### What deployment options does PaddlePaddle offer for YOLOv8 models? + +PaddlePaddle provides flexible deployment options: + +- **Paddle Serving**: Deploys models as RESTful APIs, ideal for production with features like model versioning and online A/B testing. +- **Paddle Inference API**: Gives low-level control over model execution for custom applications. +- **Paddle Lite**: Optimizes models for mobile and embedded devices' limited resources. +- **Paddle.js**: Enables deploying models directly within web browsers. + +These options cover a broad range of deployment scenarios, from on-device inference to scalable cloud services. Explore more deployment strategies on the [Ultralytics Model Deployment Options page](../guides/model-deployment-options.md). diff --git a/ultralytics/docs/en/integrations/paperspace.md b/ultralytics/docs/en/integrations/paperspace.md new file mode 100644 index 0000000000000000000000000000000000000000..447898509c8bab5c13e74dd903dace9911e72cec --- /dev/null +++ b/ultralytics/docs/en/integrations/paperspace.md @@ -0,0 +1,115 @@ +--- +comments: true +description: Simplify YOLOv8 training with Paperspace Gradient's all-in-one MLOps platform. Access GPUs, automate workflows, and deploy with ease. +keywords: YOLOv8, Paperspace Gradient, MLOps, machine learning, training, GPUs, Jupyter notebooks, model deployment, AI, cloud platform +--- + +# YOLOv8 Model Training Made Simple with Paperspace Gradient + +Training computer vision models like [YOLOv8](https://github.com/ultralytics/ultralytics) can be complicated. It involves managing large datasets, using different types of computer hardware like GPUs, TPUs, and CPUs, and making sure data flows smoothly during the training process. Typically, developers end up spending a lot of time managing their computer systems and environments. It can be frustrating when you just want to focus on building the best model. + +This is where a platform like Paperspace Gradient can make things simpler. Paperspace Gradient is a MLOps platform that lets you build, train, and deploy machine learning models all in one place. With Gradient, developers can focus on training their YOLOv8 models without the hassle of managing infrastructure and environments. + +## Paperspace + +

+ Paperspace Overview +

+ +[Paperspace](https://www.paperspace.com/), launched in 2014 by University of Michigan graduates and acquired by DigitalOcean in 2023, is a cloud platform specifically designed for machine learning. It provides users with powerful GPUs, collaborative Jupyter notebooks, a container service for deployments, automated workflows for machine learning tasks, and high-performance virtual machines. These features aim to streamline the entire machine learning development process, from coding to deployment. + +## Paperspace Gradient + +

+ PaperSpace Gradient Overview +

+ +Paperspace Gradient is a suite of tools designed to make working with AI and machine learning in the cloud much faster and easier. Gradient addresses the entire machine learning development process, from building and training models to deploying them. + +Within its toolkit, it includes support for Google's TPUs via a job runner, comprehensive support for Jupyter notebooks and containers, and new programming language integrations. Its focus on language integration particularly stands out, allowing users to easily adapt their existing Python projects to use the most advanced GPU infrastructure available. + +## Training YOLOv8 Using Paperspace Gradient + +Paperspace Gradient makes training a YOLOv8 model possible with a few clicks. Thanks to the integration, you can access the [Paperspace console](https://console.paperspace.com/github/ultralytics/ultralytics) and start training your model immediately. For a detailed understanding of the model training process and best practices, refer to our [YOLOv8 Model Training guide](../modes/train.md). + +Sign in and then click on the “Start Machine” button shown in the image below. In a few seconds, a managed GPU environment will start up, and then you can run the notebook's cells. + +![Training YOLOv8 Using Paperspace Gradient](https://github.com/ultralytics/docs/releases/download/0/start-machine-button.avif) + +Explore more capabilities of YOLOv8 and Paperspace Gradient in a discussion with Glenn Jocher, Ultralytics founder, and James Skelton from Paperspace. Watch the discussion below. + +

+
+ +
+ Watch: Ultralytics Live Session 7: It's All About the Environment: Optimizing YOLOv8 Training With Gradient +

+ +## Key Features of Paperspace Gradient + +As you explore the Paperspace console, you'll see how each step of the machine-learning workflow is supported and enhanced. Here are some things to look out for: + +- **One-Click Notebooks:** Gradient provides pre-configured Jupyter Notebooks specifically tailored for YOLOv8, eliminating the need for environment setup and dependency management. Simply choose the desired notebook and start experimenting immediately. + +- **Hardware Flexibility:** Choose from a range of machine types with varying CPU, GPU, and TPU configurations to suit your training needs and budget. Gradient handles all the backend setup, allowing you to focus on model development. + +- **Experiment Tracking:** Gradient automatically tracks your experiments, including hyperparameters, metrics, and code changes. This allows you to easily compare different training runs, identify optimal configurations, and reproduce successful results. + +- **Dataset Management:** Efficiently manage your datasets directly within Gradient. Upload, version, and pre-process data with ease, streamlining the data preparation phase of your project. + +- **Model Serving:** Deploy your trained YOLOv8 models as REST APIs with just a few clicks. Gradient handles the infrastructure, allowing you to easily integrate your object detection models into your applications. + +- **Real-time Monitoring:** Monitor the performance and health of your deployed models through Gradient's intuitive dashboard. Gain insights into inference speed, resource utilization, and potential errors. + +## Why Should You Use Gradient for Your YOLOv8 Projects? + +While many options are available for training, deploying, and evaluating YOLOv8 models, the integration with Paperspace Gradient offers a unique set of advantages that separates it from other solutions. Let's explore what makes this integration unique: + +- **Enhanced Collaboration:** Shared workspaces and version control facilitate seamless teamwork and ensure reproducibility, allowing your team to work together effectively and maintain a clear history of your project. + +- **Low-Cost GPUs:** Gradient provides access to high-performance GPUs at significantly lower costs than major cloud providers or on-premise solutions. With per-second billing, you only pay for the resources you actually use, optimizing your budget. + +- **Predictable Costs:** Gradient's on-demand pricing ensures cost transparency and predictability. You can scale your resources up or down as needed and only pay for the time you use, avoiding unnecessary expenses. + +- **No Commitments:** You can adjust your instance types anytime to adapt to changing project requirements and optimize the cost-performance balance. There are no lock-in periods or commitments, providing maximum flexibility. + +## Summary + +This guide explored the Paperspace Gradient integration for training YOLOv8 models. Gradient provides the tools and infrastructure to accelerate your AI development journey from effortless model training and evaluation to streamlined deployment options. + +For further exploration, visit [PaperSpace's official documentation](https://docs.digitalocean.com/products/paperspace/). + +Also, visit the [Ultralytics integration guide page](index.md) to learn more about different YOLOv8 integrations. It's full of insights and tips to take your computer vision projects to the next level. + +## FAQ + +### How do I train a YOLOv8 model using Paperspace Gradient? + +Training a YOLOv8 model with Paperspace Gradient is straightforward and efficient. First, sign in to the [Paperspace console](https://console.paperspace.com/github/ultralytics/ultralytics). Next, click the “Start Machine” button to initiate a managed GPU environment. Once the environment is ready, you can run the notebook's cells to start training your YOLOv8 model. For detailed instructions, refer to our [YOLOv8 Model Training guide](../modes/train.md). + +### What are the advantages of using Paperspace Gradient for YOLOv8 projects? + +Paperspace Gradient offers several unique advantages for training and deploying YOLOv8 models: + +- **Hardware Flexibility:** Choose from various CPU, GPU, and TPU configurations. +- **One-Click Notebooks:** Use pre-configured Jupyter Notebooks for YOLOv8 without worrying about environment setup. +- **Experiment Tracking:** Automatic tracking of hyperparameters, metrics, and code changes. +- **Dataset Management:** Efficiently manage your datasets within Gradient. +- **Model Serving:** Deploy models as REST APIs easily. +- **Real-time Monitoring:** Monitor model performance and resource utilization through a dashboard. + +### Why should I choose Ultralytics YOLOv8 over other object detection models? + +Ultralytics YOLOv8 stands out for its real-time object detection capabilities and high accuracy. Its seamless integration with platforms like Paperspace Gradient enhances productivity by simplifying the training and deployment process. YOLOv8 supports various use cases, from security systems to retail inventory management. Explore more about YOLOv8's advantages [here](https://www.ultralytics.com/yolo). + +### Can I deploy my YOLOv8 model on edge devices using Paperspace Gradient? + +Yes, you can deploy YOLOv8 models on edge devices using Paperspace Gradient. The platform supports various deployment formats like TFLite and Edge TPU, which are optimized for edge devices. After training your model on Gradient, refer to our [export guide](../modes/export.md) for instructions on converting your model to the desired format. + +### How does experiment tracking in Paperspace Gradient help improve YOLOv8 training? + +Experiment tracking in Paperspace Gradient streamlines the model development process by automatically logging hyperparameters, metrics, and code changes. This allows you to easily compare different training runs, identify optimal configurations, and reproduce successful experiments. diff --git a/ultralytics/docs/en/integrations/ray-tune.md b/ultralytics/docs/en/integrations/ray-tune.md new file mode 100644 index 0000000000000000000000000000000000000000..d216cf38e90f1aabe2292c85d4cbb74f914de259 --- /dev/null +++ b/ultralytics/docs/en/integrations/ray-tune.md @@ -0,0 +1,284 @@ +--- +comments: true +description: Optimize YOLOv8 model performance with Ray Tune. Learn efficient hyperparameter tuning using advanced search strategies, parallelism, and early stopping. +keywords: YOLOv8, Ray Tune, hyperparameter tuning, model optimization, machine learning, deep learning, AI, Ultralytics, Weights & Biases +--- + +# Efficient Hyperparameter Tuning with Ray Tune and YOLOv8 + +Hyperparameter tuning is vital in achieving peak model performance by discovering the optimal set of hyperparameters. This involves running trials with different hyperparameters and evaluating each trial's performance. + +## Accelerate Tuning with Ultralytics YOLOv8 and Ray Tune + +[Ultralytics YOLOv8](https://www.ultralytics.com/) incorporates Ray Tune for hyperparameter tuning, streamlining the optimization of YOLOv8 model hyperparameters. With Ray Tune, you can utilize advanced search strategies, parallelism, and early stopping to expedite the tuning process. + +### Ray Tune + +

+ Ray Tune Overview +

+ +[Ray Tune](https://docs.ray.io/en/latest/tune/index.html) is a hyperparameter tuning library designed for efficiency and flexibility. It supports various search strategies, parallelism, and early stopping strategies, and seamlessly integrates with popular machine learning frameworks, including Ultralytics YOLOv8. + +### Integration with Weights & Biases + +YOLOv8 also allows optional integration with [Weights & Biases](https://wandb.ai/site) for monitoring the tuning process. + +## Installation + +To install the required packages, run: + +!!! tip "Installation" + + === "CLI" + + ```bash + # Install and update Ultralytics and Ray Tune packages + pip install -U ultralytics "ray[tune]" + + # Optionally install W&B for logging + pip install wandb + ``` + +## Usage + +!!! example "Usage" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a YOLOv8n model + model = YOLO("yolov8n.pt") + + # Start tuning hyperparameters for YOLOv8n training on the COCO8 dataset + result_grid = model.tune(data="coco8.yaml", use_ray=True) + ``` + +## `tune()` Method Parameters + +The `tune()` method in YOLOv8 provides an easy-to-use interface for hyperparameter tuning with Ray Tune. It accepts several arguments that allow you to customize the tuning process. Below is a detailed explanation of each parameter: + +| Parameter | Type | Description | Default Value | +| --------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | +| `data` | `str` | The dataset configuration file (in YAML format) to run the tuner on. This file should specify the training and validation data paths, as well as other dataset-specific settings. | | +| `space` | `dict, optional` | A dictionary defining the hyperparameter search space for Ray Tune. Each key corresponds to a hyperparameter name, and the value specifies the range of values to explore during tuning. If not provided, YOLOv8 uses a default search space with various hyperparameters. | | +| `grace_period` | `int, optional` | The grace period in epochs for the [ASHA scheduler](https://docs.ray.io/en/latest/tune/api/schedulers.html) in Ray Tune. The scheduler will not terminate any trial before this number of epochs, allowing the model to have some minimum training before making a decision on early stopping. | 10 | +| `gpu_per_trial` | `int, optional` | The number of GPUs to allocate per trial during tuning. This helps manage GPU usage, particularly in multi-GPU environments. If not provided, the tuner will use all available GPUs. | None | +| `iterations` | `int, optional` | The maximum number of trials to run during tuning. This parameter helps control the total number of hyperparameter combinations tested, ensuring the tuning process does not run indefinitely. | 10 | +| `**train_args` | `dict, optional` | Additional arguments to pass to the `train()` method during tuning. These arguments can include settings like the number of training epochs, batch size, and other training-specific configurations. | {} | + +By customizing these parameters, you can fine-tune the hyperparameter optimization process to suit your specific needs and available computational resources. + +## Default Search Space Description + +The following table lists the default search space parameters for hyperparameter tuning in YOLOv8 with Ray Tune. Each parameter has a specific value range defined by `tune.uniform()`. + +| Parameter | Value Range | Description | +| ----------------- | -------------------------- | ---------------------------------------- | +| `lr0` | `tune.uniform(1e-5, 1e-1)` | Initial learning rate | +| `lrf` | `tune.uniform(0.01, 1.0)` | Final learning rate factor | +| `momentum` | `tune.uniform(0.6, 0.98)` | Momentum | +| `weight_decay` | `tune.uniform(0.0, 0.001)` | Weight decay | +| `warmup_epochs` | `tune.uniform(0.0, 5.0)` | Warmup epochs | +| `warmup_momentum` | `tune.uniform(0.0, 0.95)` | Warmup momentum | +| `box` | `tune.uniform(0.02, 0.2)` | Box loss weight | +| `cls` | `tune.uniform(0.2, 4.0)` | Class loss weight | +| `hsv_h` | `tune.uniform(0.0, 0.1)` | Hue augmentation range | +| `hsv_s` | `tune.uniform(0.0, 0.9)` | Saturation augmentation range | +| `hsv_v` | `tune.uniform(0.0, 0.9)` | Value (brightness) augmentation range | +| `degrees` | `tune.uniform(0.0, 45.0)` | Rotation augmentation range (degrees) | +| `translate` | `tune.uniform(0.0, 0.9)` | Translation augmentation range | +| `scale` | `tune.uniform(0.0, 0.9)` | Scaling augmentation range | +| `shear` | `tune.uniform(0.0, 10.0)` | Shear augmentation range (degrees) | +| `perspective` | `tune.uniform(0.0, 0.001)` | Perspective augmentation range | +| `flipud` | `tune.uniform(0.0, 1.0)` | Vertical flip augmentation probability | +| `fliplr` | `tune.uniform(0.0, 1.0)` | Horizontal flip augmentation probability | +| `mosaic` | `tune.uniform(0.0, 1.0)` | Mosaic augmentation probability | +| `mixup` | `tune.uniform(0.0, 1.0)` | Mixup augmentation probability | +| `copy_paste` | `tune.uniform(0.0, 1.0)` | Copy-paste augmentation probability | + +## Custom Search Space Example + +In this example, we demonstrate how to use a custom search space for hyperparameter tuning with Ray Tune and YOLOv8. By providing a custom search space, you can focus the tuning process on specific hyperparameters of interest. + +!!! example "Usage" + + ```python + from ultralytics import YOLO + + # Define a YOLO model + model = YOLO("yolov8n.pt") + + # Run Ray Tune on the model + result_grid = model.tune( + data="coco8.yaml", + space={"lr0": tune.uniform(1e-5, 1e-1)}, + epochs=50, + use_ray=True, + ) + ``` + +In the code snippet above, we create a YOLO model with the "yolov8n.pt" pretrained weights. Then, we call the `tune()` method, specifying the dataset configuration with "coco8.yaml". We provide a custom search space for the initial learning rate `lr0` using a dictionary with the key "lr0" and the value `tune.uniform(1e-5, 1e-1)`. Finally, we pass additional training arguments, such as the number of epochs directly to the tune method as `epochs=50`. + +## Processing Ray Tune Results + +After running a hyperparameter tuning experiment with Ray Tune, you might want to perform various analyses on the obtained results. This guide will take you through common workflows for processing and analyzing these results. + +### Loading Tune Experiment Results from a Directory + +After running the tuning experiment with `tuner.fit()`, you can load the results from a directory. This is useful, especially if you're performing the analysis after the initial training script has exited. + +```python +experiment_path = f"{storage_path}/{exp_name}" +print(f"Loading results from {experiment_path}...") + +restored_tuner = tune.Tuner.restore(experiment_path, trainable=train_mnist) +result_grid = restored_tuner.get_results() +``` + +### Basic Experiment-Level Analysis + +Get an overview of how trials performed. You can quickly check if there were any errors during the trials. + +```python +if result_grid.errors: + print("One or more trials failed!") +else: + print("No errors!") +``` + +### Basic Trial-Level Analysis + +Access individual trial hyperparameter configurations and the last reported metrics. + +```python +for i, result in enumerate(result_grid): + print(f"Trial #{i}: Configuration: {result.config}, Last Reported Metrics: {result.metrics}") +``` + +### Plotting the Entire History of Reported Metrics for a Trial + +You can plot the history of reported metrics for each trial to see how the metrics evolved over time. + +```python +import matplotlib.pyplot as plt + +for i, result in enumerate(result_grid): + plt.plot( + result.metrics_dataframe["training_iteration"], + result.metrics_dataframe["mean_accuracy"], + label=f"Trial {i}", + ) + +plt.xlabel("Training Iterations") +plt.ylabel("Mean Accuracy") +plt.legend() +plt.show() +``` + +## Summary + +In this documentation, we covered common workflows to analyze the results of experiments run with Ray Tune using Ultralytics. The key steps include loading the experiment results from a directory, performing basic experiment-level and trial-level analysis and plotting metrics. + +Explore further by looking into Ray Tune's [Analyze Results](https://docs.ray.io/en/latest/tune/examples/tune_analyze_results.html) docs page to get the most out of your hyperparameter tuning experiments. + +## FAQ + +### How do I tune the hyperparameters of my YOLOv8 model using Ray Tune? + +To tune the hyperparameters of your Ultralytics YOLOv8 model using Ray Tune, follow these steps: + +1. **Install the required packages:** + + ```bash + pip install -U ultralytics "ray[tune]" + pip install wandb # optional for logging + ``` + +2. **Load your YOLOv8 model and start tuning:** + + ```python + from ultralytics import YOLO + + # Load a YOLOv8 model + model = YOLO("yolov8n.pt") + + # Start tuning with the COCO8 dataset + result_grid = model.tune(data="coco8.yaml", use_ray=True) + ``` + +This utilizes Ray Tune's advanced search strategies and parallelism to efficiently optimize your model's hyperparameters. For more information, check out the [Ray Tune documentation](https://docs.ray.io/en/latest/tune/index.html). + +### What are the default hyperparameters for YOLOv8 tuning with Ray Tune? + +Ultralytics YOLOv8 uses the following default hyperparameters for tuning with Ray Tune: + +| Parameter | Value Range | Description | +| --------------- | -------------------------- | ------------------------------ | +| `lr0` | `tune.uniform(1e-5, 1e-1)` | Initial learning rate | +| `lrf` | `tune.uniform(0.01, 1.0)` | Final learning rate factor | +| `momentum` | `tune.uniform(0.6, 0.98)` | Momentum | +| `weight_decay` | `tune.uniform(0.0, 0.001)` | Weight decay | +| `warmup_epochs` | `tune.uniform(0.0, 5.0)` | Warmup epochs | +| `box` | `tune.uniform(0.02, 0.2)` | Box loss weight | +| `cls` | `tune.uniform(0.2, 4.0)` | Class loss weight | +| `hsv_h` | `tune.uniform(0.0, 0.1)` | Hue augmentation range | +| `translate` | `tune.uniform(0.0, 0.9)` | Translation augmentation range | + +These hyperparameters can be customized to suit your specific needs. For a complete list and more details, refer to the [Hyperparameter Tuning](../guides/hyperparameter-tuning.md) guide. + +### How can I integrate Weights & Biases with my YOLOv8 model tuning? + +To integrate Weights & Biases (W&B) with your Ultralytics YOLOv8 tuning process: + +1. **Install W&B:** + + ```bash + pip install wandb + ``` + +2. **Modify your tuning script:** + + ```python + import wandb + + from ultralytics import YOLO + + wandb.init(project="YOLO-Tuning", entity="your-entity") + + # Load YOLO model + model = YOLO("yolov8n.pt") + + # Tune hyperparameters + result_grid = model.tune(data="coco8.yaml", use_ray=True) + ``` + +This setup will allow you to monitor the tuning process, track hyperparameter configurations, and visualize results in W&B. + +### Why should I use Ray Tune for hyperparameter optimization with YOLOv8? + +Ray Tune offers numerous advantages for hyperparameter optimization: + +- **Advanced Search Strategies:** Utilizes algorithms like Bayesian Optimization and HyperOpt for efficient parameter search. +- **Parallelism:** Supports parallel execution of multiple trials, significantly speeding up the tuning process. +- **Early Stopping:** Employs strategies like ASHA to terminate under-performing trials early, saving computational resources. + +Ray Tune seamlessly integrates with Ultralytics YOLOv8, providing an easy-to-use interface for tuning hyperparameters effectively. To get started, check out the [Efficient Hyperparameter Tuning with Ray Tune and YOLOv8](../guides/hyperparameter-tuning.md) guide. + +### How can I define a custom search space for YOLOv8 hyperparameter tuning? + +To define a custom search space for your YOLOv8 hyperparameter tuning with Ray Tune: + +```python +from ray import tune + +from ultralytics import YOLO + +model = YOLO("yolov8n.pt") +search_space = {"lr0": tune.uniform(1e-5, 1e-1), "momentum": tune.uniform(0.6, 0.98)} +result_grid = model.tune(data="coco8.yaml", space=search_space, use_ray=True) +``` + +This customizes the range of hyperparameters like initial learning rate and momentum to be explored during the tuning process. For advanced configurations, refer to the [Custom Search Space Example](#custom-search-space-example) section. diff --git a/ultralytics/docs/en/integrations/roboflow.md b/ultralytics/docs/en/integrations/roboflow.md new file mode 100644 index 0000000000000000000000000000000000000000..e851e1bde7b79a43e54e1d4f410c19d5b456b821 --- /dev/null +++ b/ultralytics/docs/en/integrations/roboflow.md @@ -0,0 +1,269 @@ +--- +comments: true +description: Learn how to gather, label, and deploy data for custom YOLOv8 models using Roboflow's powerful tools. Optimize your computer vision pipeline effortlessly. +keywords: Roboflow, YOLOv8, data labeling, computer vision, model training, model deployment, dataset management, automated image annotation, AI tools +--- + +# Roboflow + +[Roboflow](https://roboflow.com/?ref=ultralytics) has everything you need to build and deploy computer vision models. Connect Roboflow at any step in your pipeline with APIs and SDKs, or use the end-to-end interface to automate the entire process from image to inference. Whether you're in need of [data labeling](https://roboflow.com/annotate?ref=ultralytics), [model training](https://roboflow.com/train?ref=ultralytics), or [model deployment](https://roboflow.com/deploy?ref=ultralytics), Roboflow gives you building blocks to bring custom computer vision solutions to your project. + +!!! question "Licensing" + + Ultralytics offers two licensing options: + + - The [AGPL-3.0 License](https://github.com/ultralytics/ultralytics/blob/main/LICENSE), an [OSI-approved](https://opensource.org/license) open-source license ideal for students and enthusiasts. + - The [Enterprise License](https://www.ultralytics.com/license) for businesses seeking to incorporate our AI models into their products and services. + + For more details see [Ultralytics Licensing](https://www.ultralytics.com/license). + +In this guide, we are going to showcase how to find, label, and organize data for use in training a custom Ultralytics YOLOv8 model. Use the table of contents below to jump directly to a specific section: + +- Gather data for training a custom YOLOv8 model +- Upload, convert and label data for YOLOv8 format +- Pre-process and augment data for model robustness +- Dataset management for [YOLOv8](../models/yolov8.md) +- Export data in 40+ formats for model training +- Upload custom YOLOv8 model weights for testing and deployment +- Gather Data for Training a Custom YOLOv8 Model + +Roboflow provides two services that can help you collect data for YOLOv8 models: [Universe](https://universe.roboflow.com/?ref=ultralytics) and [Collect](https://github.com/roboflow/roboflow-collect?ref=ultralytics). + +Universe is an online repository with over 250,000 vision datasets totalling over 100 million images. + +

+Roboflow Universe +

+ +With a [free Roboflow account](https://app.roboflow.com/?ref=ultralytics), you can export any dataset available on Universe. To export a dataset, click the "Download this Dataset" button on any dataset. + +

+Roboflow Universe dataset export +

+ +For YOLOv8, select "YOLOv8" as the export format: + +

+Roboflow Universe dataset export +

+ +Universe also has a page that aggregates all [public fine-tuned YOLOv8 models uploaded to Roboflow](https://universe.roboflow.com/search?q=model%3Ayolov8&ref=ultralytics). You can use this page to explore pre-trained models you can use for testing or [for automated data labeling](https://docs.roboflow.com/annotate/use-roboflow-annotate/model-assisted-labeling?ref=ultralytics) or to prototype with [Roboflow inference](https://github.com/roboflow/inference?ref=ultralytics). + +If you want to gather images yourself, try [Collect](https://github.com/roboflow/roboflow-collect), an open source project that allows you to automatically gather images using a webcam on the edge. You can use text or image prompts with Collect to instruct what data should be collected, allowing you to capture only the useful data you need to build your vision model. + +## Upload, Convert and Label Data for YOLOv8 Format + +[Roboflow Annotate](https://docs.roboflow.com/annotate/use-roboflow-annotate?ref=ultralytics) is an online annotation tool for use in labeling images for object detection, classification, and segmentation. + +To label data for a YOLOv8 object detection, instance segmentation, or classification model, first create a project in Roboflow. + +

+Create a Roboflow project +

+ +Next, upload your images, and any pre-existing annotations you have from other tools ([using one of the 40+ supported import formats](https://roboflow.com/formats?ref=ultralytics)), into Roboflow. + +

+Upload images to Roboflow +

+ +Select the batch of images you have uploaded on the Annotate page to which you are taken after uploading images. Then, click "Start Annotating" to label images. + +To label with bounding boxes, press the `B` key on your keyboard or click the box icon in the sidebar. Click on a point where you want to start your bounding box, then drag to create the box: + +

+Annotating an image in Roboflow +

+ +A pop-up will appear asking you to select a class for your annotation once you have created an annotation. + +To label with polygons, press the `P` key on your keyboard, or the polygon icon in the sidebar. With the polygon annotation tool enabled, click on individual points in the image to draw a polygon. + +Roboflow offers a SAM-based label assistant with which you can label images faster than ever. SAM (Segment Anything Model) is a state-of-the-art computer vision model that can precisely label images. With SAM, you can significantly speed up the image labeling process. Annotating images with polygons becomes as simple as a few clicks, rather than the tedious process of precisely clicking points around an object. + +To use the label assistant, click the cursor icon in the sidebar, SAM will be loaded for use in your project. + +

+Annotating an image in Roboflow with SAM-powered label assist +

+ +Hover over any object in the image and SAM will recommend an annotation. You can hover to find the right place to annotate, then click to create your annotation. To amend your annotation to be more or less specific, you can click inside or outside the annotation SAM has created on the document. + +You can also add tags to images from the Tags panel in the sidebar. You can apply tags to data from a particular area, taken from a specific camera, and more. You can then use these tags to search through data for images matching a tag and generate versions of a dataset with images that contain a particular tag or set of tags. + +

+Adding tags to an image in Roboflow +

+ +Models hosted on Roboflow can be used with Label Assist, an automated annotation tool that uses your YOLOv8 model to recommend annotations. To use Label Assist, first upload a YOLOv8 model to Roboflow (see instructions later in the guide). Then, click the magic wand icon in the left sidebar and select your model for use in Label Assist. + +Choose a model, then click "Continue" to enable Label Assist: + +

+Enabling Label Assist +

+ +When you open new images for annotation, Label Assist will trigger and recommend annotations. + +

+ALabel Assist recommending an annotation +

+ +## Dataset Management for YOLOv8 + +Roboflow provides a suite of tools for understanding computer vision datasets. + +First, you can use dataset search to find images that meet a semantic text description (i.e. find all images that contain people), or that meet a specified label (i.e. the image is associated with a specific tag). To use dataset search, click "Dataset" in the sidebar. Then, input a search query using the search bar and associated filters at the top of the page. + +For example, the following text query finds images that contain people in a dataset: + +

+Searching for an image +

+ +You can narrow your search to images with a particular tag using the "Tags" selector: + +

+Filter images by tag +

+ +Before you start training a model with your dataset, we recommend using Roboflow [Health Check](https://docs.roboflow.com/datasets/dataset-health-check?ref=ultralytics), a web tool that provides an insight into your dataset and how you can improve the dataset prior to training a vision model. + +To use Health Check, click the "Health Check" sidebar link. A list of statistics will appear that show the average size of images in your dataset, class balance, a heatmap of where annotations are in your images, and more. + +

+Roboflow Health Check analysis +

+ +Health Check may recommend changes to help enhance dataset performance. For example, the class balance feature may show that there is an imbalance in labels that, if solved, may boost performance or your model. + +## Export Data in 40+ Formats for Model Training + +To export your data, you will need a dataset version. A version is a state of your dataset frozen-in-time. To create a version, first click "Versions" in the sidebar. Then, click the "Create New Version" button. On this page, you will be able to choose augmentations and preprocessing steps to apply to your dataset: + +

+Creating a dataset version on Roboflow +

+ +For each augmentation you select, a pop-up will appear allowing you to tune the augmentation to your needs. Here is an example of tuning a brightness augmentation within specified parameters: + +

+Applying augmentations to a dataset +

+ +When your dataset version has been generated, you can export your data into a range of formats. Click the "Export Dataset" button on your dataset version page to export your data: + +

+Exporting a dataset +

+ +You are now ready to train YOLOv8 on a custom dataset. Follow this [written guide](https://blog.roboflow.com/how-to-train-yolov8-on-a-custom-dataset/?ref=ultralytics) and [YouTube video](https://www.youtube.com/watch?v=wuZtUMEiKWY) for step-by-step instructions or refer to the [Ultralytics documentation](../modes/train.md). + +## Upload Custom YOLOv8 Model Weights for Testing and Deployment + +Roboflow offers an infinitely scalable API for deployed models and SDKs for use with NVIDIA Jetsons, Luxonis OAKs, Raspberry Pis, GPU-based devices, and more. + +You can deploy YOLOv8 models by uploading YOLOv8 weights to Roboflow. You can do this in a few lines of Python code. Create a new Python file and add the following code: + +```python +import roboflow # install with 'pip install roboflow' + +roboflow.login() + +rf = roboflow.Roboflow() + +project = rf.workspace(WORKSPACE_ID).project("football-players-detection-3zvbc") +dataset = project.version(VERSION).download("yolov8") + +project.version(dataset.version).deploy(model_type="yolov8", model_path=f"{HOME}/runs/detect/train/") +``` + +In this code, replace the project ID and version ID with the values for your account and project. [Learn how to retrieve your Roboflow API key](https://docs.roboflow.com/api-reference/authentication?ref=ultralytics#retrieve-an-api-key). + +When you run the code above, you will be asked to authenticate. Then, your model will be uploaded and an API will be created for your project. This process can take up to 30 minutes to complete. + +To test your model and find deployment instructions for supported SDKs, go to the "Deploy" tab in the Roboflow sidebar. At the top of this page, a widget will appear with which you can test your model. You can use your webcam for live testing or upload images or videos. + +

+Running inference on an example image +

+ +You can also use your uploaded model as a [labeling assistant](https://docs.roboflow.com/annotate/use-roboflow-annotate/model-assisted-labeling?ref=ultralytics). This feature uses your trained model to recommend annotations on images uploaded to Roboflow. + +## How to Evaluate YOLOv8 Models + +Roboflow provides a range of features for use in evaluating models. + +Once you have uploaded a model to Roboflow, you can access our model evaluation tool, which provides a confusion matrix showing the performance of your model as well as an interactive vector analysis plot. These features can help you find opportunities to improve your model. + +To access a confusion matrix, go to your model page on the Roboflow dashboard, then click "View Detailed Evaluation": + +

+Start a Roboflow model evaluation +

+ +A pop-up will appear showing a confusion matrix: + +

+A confusion matrix +

+ +Hover over a box on the confusion matrix to see the value associated with the box. Click on a box to see images in the respective category. Click on an image to view the model predictions and ground truth data associated with that image. + +For more insights, click Vector Analysis. This will show a scatter plot of the images in your dataset, calculated using CLIP. The closer images are in the plot, the more similar they are, semantically. Each image is represented as a dot with a color between white and red. The more red the dot, the worse the model performed. + +

+A vector analysis plot +

+ +You can use Vector Analysis to: + +- Find clusters of images; +- Identify clusters where the model performs poorly, and; +- Visualize commonalities between images on which the model performs poorly. + +## Learning Resources + +Want to learn more about using Roboflow for creating YOLOv8 models? The following resources may be helpful in your work. + +- [Train YOLOv8 on a Custom Dataset](https://github.com/roboflow/notebooks/blob/main/notebooks/train-yolov8-object-detection-on-custom-dataset.ipynb): Follow our interactive notebook that shows you how to train a YOLOv8 model on a custom dataset. +- [Autodistill](https://docs.autodistill.com/): Use large foundation vision models to label data for specific models. You can label images for use in training YOLOv8 classification, detection, and segmentation models with Autodistill. +- [Supervision](https://supervision.roboflow.com/?ref=ultralytics): A Python package with helpful utilities for use in working with computer vision models. You can use supervision to filter detections, compute confusion matrices, and more, all in a few lines of Python code. +- [Roboflow Blog](https://blog.roboflow.com/?ref=ultralytics): The Roboflow Blog features over 500 articles on computer vision, covering topics from how to train a YOLOv8 model to annotation best practices. +- [Roboflow YouTube channel](https://www.youtube.com/@Roboflow): Browse dozens of in-depth computer vision guides on our YouTube channel, covering topics from training YOLOv8 models to automated image labeling. + +## Project Showcase + +Below are a few of the many pieces of feedback we have received for using YOLOv8 and Roboflow together to create computer vision models. + +

+Showcase image +Showcase image +Showcase image +

+ +## FAQ + +### How do I label data for YOLOv8 models using Roboflow? + +Labeling data for YOLOv8 models using Roboflow is straightforward with Roboflow Annotate. First, create a project on Roboflow and upload your images. After uploading, select the batch of images and click "Start Annotating." You can use the `B` key for bounding boxes or the `P` key for polygons. For faster annotation, use the SAM-based label assistant by clicking the cursor icon in the sidebar. Detailed steps can be found [here](#upload-convert-and-label-data-for-yolov8-format). + +### What services does Roboflow offer for collecting YOLOv8 training data? + +Roboflow provides two key services for collecting YOLOv8 training data: [Universe](https://universe.roboflow.com/?ref=ultralytics) and [Collect](https://github.com/roboflow/roboflow-collect?ref=ultralytics). Universe offers access to over 250,000 vision datasets, while Collect helps you gather images using a webcam and automated prompts. + +### How can I manage and analyze my YOLOv8 dataset using Roboflow? + +Roboflow offers robust dataset management tools, including dataset search, tagging, and Health Check. Use the search feature to find images based on text descriptions or tags. Health Check provides insights into dataset quality, showing class balance, image sizes, and annotation heatmaps. This helps optimize dataset performance before training YOLOv8 models. Detailed information can be found [here](#dataset-management-for-yolov8). + +### How do I export my YOLOv8 dataset from Roboflow? + +To export your YOLOv8 dataset from Roboflow, you need to create a dataset version. Click "Versions" in the sidebar, then "Create New Version" and apply any desired augmentations. Once the version is generated, click "Export Dataset" and choose the YOLOv8 format. Follow this process [here](#export-data-in-40-formats-for-model-training). + +### How can I integrate and deploy YOLOv8 models with Roboflow? + +Integrate and deploy YOLOv8 models on Roboflow by uploading your YOLOv8 weights through a few lines of Python code. Use the provided script to authenticate and upload your model, which will create an API for deployment. For details on the script and further instructions, see [this section](#upload-custom-yolov8-model-weights-for-testing-and-deployment). + +### What tools does Roboflow provide for evaluating YOLOv8 models? + +Roboflow offers model evaluation tools, including a confusion matrix and vector analysis plots. Access these tools from the "View Detailed Evaluation" button on your model page. These features help identify model performance issues and find areas for improvement. For more information, refer to [this section](#how-to-evaluate-yolov8-models). diff --git a/ultralytics/docs/en/integrations/tensorboard.md b/ultralytics/docs/en/integrations/tensorboard.md new file mode 100644 index 0000000000000000000000000000000000000000..59add9258fa28f30144dfeb084468ee61d340d83 --- /dev/null +++ b/ultralytics/docs/en/integrations/tensorboard.md @@ -0,0 +1,213 @@ +--- +comments: true +description: Learn how to integrate YOLOv8 with TensorBoard for real-time visual insights into your model's training metrics, performance graphs, and debugging workflows. +keywords: YOLOv8, TensorBoard, model training, visualization, machine learning, deep learning, Ultralytics, training metrics, performance analysis +--- + +# Gain Visual Insights with YOLOv8's Integration with TensorBoard + +Understanding and fine-tuning computer vision models like [Ultralytics' YOLOv8](https://www.ultralytics.com/) becomes more straightforward when you take a closer look at their training processes. Model training visualization helps with getting insights into the model's learning patterns, performance metrics, and overall behavior. YOLOv8's integration with TensorBoard makes this process of visualization and analysis easier and enables more efficient and informed adjustments to the model. + +This guide covers how to use TensorBoard with YOLOv8. You'll learn about various visualizations, from tracking metrics to analyzing model graphs. These tools will help you understand your YOLOv8 model's performance better. + +## TensorBoard + +

+ Tensorboard Overview +

+ +[TensorBoard](https://www.tensorflow.org/tensorboard), TensorFlow's visualization toolkit, is essential for machine learning experimentation. TensorBoard features a range of visualization tools, crucial for monitoring machine learning models. These tools include tracking key metrics like loss and accuracy, visualizing model graphs, and viewing histograms of weights and biases over time. It also provides capabilities for projecting embeddings to lower-dimensional spaces and displaying multimedia data. + +## YOLOv8 Training with TensorBoard + +Using TensorBoard while training YOLOv8 models is straightforward and offers significant benefits. + +## Installation + +To install the required package, run: + +!!! tip "Installation" + + === "CLI" + + ```bash + # Install the required package for YOLOv8 and Tensorboard + pip install ultralytics + ``` + +TensorBoard is conveniently pre-installed with YOLOv8, eliminating the need for additional setup for visualization purposes. + +For detailed instructions and best practices related to the installation process, be sure to check our [YOLOv8 Installation guide](../quickstart.md). While installing the required packages for YOLOv8, if you encounter any difficulties, consult our [Common Issues guide](../guides/yolo-common-issues.md) for solutions and tips. + +## Configuring TensorBoard for Google Colab + +When using Google Colab, it's important to set up TensorBoard before starting your training code: + +!!! example "Configure TensorBoard for Google Colab" + + === "Python" + + ```ipython + %load_ext tensorboard + %tensorboard --logdir path/to/runs + ``` + +## Usage + +Before diving into the usage instructions, be sure to check out the range of [YOLOv8 models offered by Ultralytics](../models/index.md). This will help you choose the most appropriate model for your project requirements. + +!!! example "Usage" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load a pre-trained model + model = YOLO("yolov8n.pt") + + # Train the model + results = model.train(data="coco8.yaml", epochs=100, imgsz=640) + ``` + +Upon running the usage code snippet above, you can expect the following output: + +```bash +TensorBoard: Start with 'tensorboard --logdir path_to_your_tensorboard_logs', view at http://localhost:6006/ +``` + +This output indicates that TensorBoard is now actively monitoring your YOLOv8 training session. You can access the TensorBoard dashboard by visiting the provided URL (http://localhost:6006/) to view real-time training metrics and model performance. For users working in Google Colab, the TensorBoard will be displayed in the same cell where you executed the TensorBoard configuration commands. + +For more information related to the model training process, be sure to check our [YOLOv8 Model Training guide](../modes/train.md). If you are interested in learning more about logging, checkpoints, plotting, and file management, read our [usage guide on configuration](../usage/cfg.md). + +## Understanding Your TensorBoard for YOLOv8 Training + +Now, let's focus on understanding the various features and components of TensorBoard in the context of YOLOv8 training. The three key sections of the TensorBoard are Time Series, Scalars, and Graphs. + +### Time Series + +The Time Series feature in the TensorBoard offers a dynamic and detailed perspective of various training metrics over time for YOLOv8 models. It focuses on the progression and trends of metrics across training epochs. Here's an example of what you can expect to see. + +![image](https://github.com/ultralytics/docs/releases/download/0/time-series-tensorboard-yolov8.avif) + +#### Key Features of Time Series in TensorBoard + +- **Filter Tags and Pinned Cards**: This functionality allows users to filter specific metrics and pin cards for quick comparison and access. It's particularly useful for focusing on specific aspects of the training process. + +- **Detailed Metric Cards**: Time Series divides metrics into different categories like learning rate (lr), training (train), and validation (val) metrics, each represented by individual cards. + +- **Graphical Display**: Each card in the Time Series section shows a detailed graph of a specific metric over the course of training. This visual representation aids in identifying trends, patterns, or anomalies in the training process. + +- **In-Depth Analysis**: Time Series provides an in-depth analysis of each metric. For instance, different learning rate segments are shown, offering insights into how adjustments in learning rate impact the model's learning curve. + +#### Importance of Time Series in YOLOv8 Training + +The Time Series section is essential for a thorough analysis of the YOLOv8 model's training progress. It lets you track the metrics in real time to promptly identify and solve issues. It also offers a detailed view of each metrics progression, which is crucial for fine-tuning the model and enhancing its performance. + +### Scalars + +Scalars in the TensorBoard are crucial for plotting and analyzing simple metrics like loss and accuracy during the training of YOLOv8 models. They offer a clear and concise view of how these metrics evolve with each training epoch, providing insights into the model's learning effectiveness and stability. Here's an example of what you can expect to see. + +![image](https://github.com/ultralytics/docs/releases/download/0/scalars-metrics-tensorboard.avif) + +#### Key Features of Scalars in TensorBoard + +- **Learning Rate (lr) Tags**: These tags show the variations in the learning rate across different segments (e.g., `pg0`, `pg1`, `pg2`). This helps us understand the impact of learning rate adjustments on the training process. + +- **Metrics Tags**: Scalars include performance indicators such as: + + - `mAP50 (B)`: Mean Average Precision at 50% Intersection over Union (IoU), crucial for assessing object detection accuracy. + + - `mAP50-95 (B)`: Mean Average Precision calculated over a range of IoU thresholds, offering a more comprehensive evaluation of accuracy. + + - `Precision (B)`: Indicates the ratio of correctly predicted positive observations, key to understanding prediction accuracy. + + - `Recall (B)`: Important for models where missing a detection is significant, this metric measures the ability to detect all relevant instances. + + - To learn more about the different metrics, read our guide on [performance metrics](../guides/yolo-performance-metrics.md). + +- **Training and Validation Tags (`train`, `val`)**: These tags display metrics specifically for the training and validation datasets, allowing for a comparative analysis of model performance across different data sets. + +#### Importance of Monitoring Scalars + +Observing scalar metrics is crucial for fine-tuning the YOLOv8 model. Variations in these metrics, such as spikes or irregular patterns in loss graphs, can highlight potential issues such as overfitting, underfitting, or inappropriate learning rate settings. By closely monitoring these scalars, you can make informed decisions to optimize the training process, ensuring that the model learns effectively and achieves the desired performance. + +### Difference Between Scalars and Time Series + +While both Scalars and Time Series in TensorBoard are used for tracking metrics, they serve slightly different purposes. Scalars focus on plotting simple metrics such as loss and accuracy as scalar values. They provide a high-level overview of how these metrics change with each training epoch. While, the time-series section of the TensorBoard offers a more detailed timeline view of various metrics. It is particularly useful for monitoring the progression and trends of metrics over time, providing a deeper dive into the specifics of the training process. + +### Graphs + +The Graphs section of the TensorBoard visualizes the computational graph of the YOLOv8 model, showing how operations and data flow within the model. It's a powerful tool for understanding the model's structure, ensuring that all layers are connected correctly, and for identifying any potential bottlenecks in data flow. Here's an example of what you can expect to see. + +![image](https://github.com/ultralytics/docs/releases/download/0/tensorboard-yolov8-computational-graph.avif) + +Graphs are particularly useful for debugging the model, especially in complex architectures typical in deep learning models like YOLOv8. They help in verifying layer connections and the overall design of the model. + +## Summary + +This guide aims to help you use TensorBoard with YOLOv8 for visualization and analysis of machine learning model training. It focuses on explaining how key TensorBoard features can provide insights into training metrics and model performance during YOLOv8 training sessions. + +For a more detailed exploration of these features and effective utilization strategies, you can refer to TensorFlow's official [TensorBoard documentation](https://www.tensorflow.org/tensorboard/get_started) and their [GitHub repository](https://github.com/tensorflow/tensorboard). + +Want to learn more about the various integrations of Ultralytics? Check out the [Ultralytics integrations guide page](../integrations/index.md) to see what other exciting capabilities are waiting to be discovered! + +## FAQ + +### What benefits does using TensorBoard with YOLOv8 offer? + +Using TensorBoard with YOLOv8 provides several visualization tools essential for efficient model training: + +- **Real-Time Metrics Tracking:** Track key metrics such as loss, accuracy, precision, and recall live. +- **Model Graph Visualization:** Understand and debug the model architecture by visualizing computational graphs. +- **Embedding Visualization:** Project embeddings to lower-dimensional spaces for better insight. + +These tools enable you to make informed adjustments to enhance your YOLOv8 model's performance. For more details on TensorBoard features, check out the TensorFlow [TensorBoard guide](https://www.tensorflow.org/tensorboard/get_started). + +### How can I monitor training metrics using TensorBoard when training a YOLOv8 model? + +To monitor training metrics while training a YOLOv8 model with TensorBoard, follow these steps: + +1. **Install TensorBoard and YOLOv8:** Run `pip install ultralytics` which includes TensorBoard. +2. **Configure TensorBoard Logging:** During the training process, YOLOv8 logs metrics to a specified log directory. +3. **Start TensorBoard:** Launch TensorBoard using the command `tensorboard --logdir path/to/your/tensorboard/logs`. + +The TensorBoard dashboard, accessible via [http://localhost:6006/](http://localhost:6006/), provides real-time insights into various training metrics. For a deeper dive into training configurations, visit our [YOLOv8 Configuration guide](../usage/cfg.md). + +### What kind of metrics can I visualize with TensorBoard when training YOLOv8 models? + +When training YOLOv8 models, TensorBoard allows you to visualize an array of important metrics including: + +- **Loss (Training and Validation):** Indicates how well the model is performing during training and validation. +- **Accuracy/Precision/Recall:** Key performance metrics to evaluate detection accuracy. +- **Learning Rate:** Track learning rate changes to understand its impact on training dynamics. +- **mAP (mean Average Precision):** For a comprehensive evaluation of object detection accuracy at various IoU thresholds. + +These visualizations are essential for tracking model performance and making necessary optimizations. For more information on these metrics, refer to our [Performance Metrics guide](../guides/yolo-performance-metrics.md). + +### Can I use TensorBoard in a Google Colab environment for training YOLOv8? + +Yes, you can use TensorBoard in a Google Colab environment to train YOLOv8 models. Here's a quick setup: + +!!! example "Configure TensorBoard for Google Colab" + + === "Python" + + ```ipython + %load_ext tensorboard + %tensorboard --logdir path/to/runs + ``` + + Then, run the YOLOv8 training script: + + ```python + from ultralytics import YOLO + + # Load a pre-trained model + model = YOLO("yolov8n.pt") + + # Train the model + results = model.train(data="coco8.yaml", epochs=100, imgsz=640) + ``` + +TensorBoard will visualize the training progress within Colab, providing real-time insights into metrics like loss and accuracy. For additional details on configuring YOLOv8 training, see our detailed [YOLOv8 Installation guide](../quickstart.md). diff --git a/ultralytics/docs/en/integrations/tensorrt.md b/ultralytics/docs/en/integrations/tensorrt.md new file mode 100644 index 0000000000000000000000000000000000000000..c40b9f654cbab814ce7093b1e698c5b437a6cf9e --- /dev/null +++ b/ultralytics/docs/en/integrations/tensorrt.md @@ -0,0 +1,546 @@ +--- +comments: true +description: Learn to convert YOLOv8 models to TensorRT for high-speed NVIDIA GPU inference. Boost efficiency and deploy optimized models with our step-by-step guide. +keywords: YOLOv8, TensorRT, NVIDIA, GPU, deep learning, model optimization, high-speed inference, model export +--- + +# TensorRT Export for YOLOv8 Models + +Deploying computer vision models in high-performance environments can require a format that maximizes speed and efficiency. This is especially true when you are deploying your model on NVIDIA GPUs. + +By using the TensorRT export format, you can enhance your [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics) models for swift and efficient inference on NVIDIA hardware. This guide will give you easy-to-follow steps for the conversion process and help you make the most of NVIDIA's advanced technology in your deep learning projects. + +## TensorRT + +

+ TensorRT Overview +

+ +[TensorRT](https://developer.nvidia.com/tensorrt), developed by NVIDIA, is an advanced software development kit (SDK) designed for high-speed deep learning inference. It's well-suited for real-time applications like object detection. + +This toolkit optimizes deep learning models for NVIDIA GPUs and results in faster and more efficient operations. TensorRT models undergo TensorRT optimization, which includes techniques like layer fusion, precision calibration (INT8 and FP16), dynamic tensor memory management, and kernel auto-tuning. Converting deep learning models into the TensorRT format allows developers to realize the potential of NVIDIA GPUs fully. + +TensorRT is known for its compatibility with various model formats, including TensorFlow, PyTorch, and ONNX, providing developers with a flexible solution for integrating and optimizing models from different frameworks. This versatility enables efficient model deployment across diverse hardware and software environments. + +## Key Features of TensorRT Models + +TensorRT models offer a range of key features that contribute to their efficiency and effectiveness in high-speed deep learning inference: + +- **Precision Calibration**: TensorRT supports precision calibration, allowing models to be fine-tuned for specific accuracy requirements. This includes support for reduced precision formats like INT8 and FP16, which can further boost inference speed while maintaining acceptable accuracy levels. + +- **Layer Fusion**: The TensorRT optimization process includes layer fusion, where multiple layers of a neural network are combined into a single operation. This reduces computational overhead and improves inference speed by minimizing memory access and computation. + +

+ TensorRT Layer Fusion +

+ +- **Dynamic Tensor Memory Management**: TensorRT efficiently manages tensor memory usage during inference, reducing memory overhead and optimizing memory allocation. This results in more efficient GPU memory utilization. + +- **Automatic Kernel Tuning**: TensorRT applies automatic kernel tuning to select the most optimized GPU kernel for each layer of the model. This adaptive approach ensures that the model takes full advantage of the GPU's computational power. + +## Deployment Options in TensorRT + +Before we look at the code for exporting YOLOv8 models to the TensorRT format, let's understand where TensorRT models are normally used. + +TensorRT offers several deployment options, and each option balances ease of integration, performance optimization, and flexibility differently: + +- **Deploying within TensorFlow**: This method integrates TensorRT into TensorFlow, allowing optimized models to run in a familiar TensorFlow environment. It's useful for models with a mix of supported and unsupported layers, as TF-TRT can handle these efficiently. + +

+ TensorRT Overview +

+ +- **Standalone TensorRT Runtime API**: Offers granular control, ideal for performance-critical applications. It's more complex but allows for custom implementation of unsupported operators. + +- **NVIDIA Triton Inference Server**: An option that supports models from various frameworks. Particularly suited for cloud or edge inference, it provides features like concurrent model execution and model analysis. + +## Exporting YOLOv8 Models to TensorRT + +You can improve execution efficiency and optimize performance by converting YOLOv8 models to TensorRT format. + +### Installation + +To install the required package, run: + +!!! tip "Installation" + + === "CLI" + + ```bash + # Install the required package for YOLOv8 + pip install ultralytics + ``` + +For detailed instructions and best practices related to the installation process, check our [YOLOv8 Installation guide](../quickstart.md). While installing the required packages for YOLOv8, if you encounter any difficulties, consult our [Common Issues guide](../guides/yolo-common-issues.md) for solutions and tips. + +### Usage + +Before diving into the usage instructions, be sure to check out the range of [YOLOv8 models offered by Ultralytics](../models/index.md). This will help you choose the most appropriate model for your project requirements. + +!!! example "Usage" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load the YOLOv8 model + model = YOLO("yolov8n.pt") + + # Export the model to TensorRT format + model.export(format="engine") # creates 'yolov8n.engine' + + # Load the exported TensorRT model + tensorrt_model = YOLO("yolov8n.engine") + + # Run inference + results = tensorrt_model("https://ultralytics.com/images/bus.jpg") + ``` + + === "CLI" + + ```bash + # Export a YOLOv8n PyTorch model to TensorRT format + yolo export model=yolov8n.pt format=engine # creates 'yolov8n.engine'' + + # Run inference with the exported model + yolo predict model=yolov8n.engine source='https://ultralytics.com/images/bus.jpg' + ``` + +For more details about the export process, visit the [Ultralytics documentation page on exporting](../modes/export.md). + +### Exporting TensorRT with INT8 Quantization + +Exporting Ultralytics YOLO models using TensorRT with INT8 precision executes post-training quantization (PTQ). TensorRT uses calibration for PTQ, which measures the distribution of activations within each activation tensor as the YOLO model processes inference on representative input data, and then uses that distribution to estimate scale values for each tensor. Each activation tensor that is a candidate for quantization has an associated scale that is deduced by a calibration process. + +When processing implicitly quantized networks TensorRT uses INT8 opportunistically to optimize layer execution time. If a layer runs faster in INT8 and has assigned quantization scales on its data inputs and outputs, then a kernel with INT8 precision is assigned to that layer, otherwise TensorRT selects a precision of either FP32 or FP16 for the kernel based on whichever results in faster execution time for that layer. + +!!! tip + + It is **critical** to ensure that the same device that will use the TensorRT model weights for deployment is used for exporting with INT8 precision, as the calibration results can vary across devices. + +#### Configuring INT8 Export + +The arguments provided when using [export](../modes/export.md) for an Ultralytics YOLO model will **greatly** influence the performance of the exported model. They will also need to be selected based on the device resources available, however the default arguments _should_ work for most [Ampere (or newer) NVIDIA discrete GPUs](https://developer.nvidia.com/blog/nvidia-ampere-architecture-in-depth/). The calibration algorithm used is `"ENTROPY_CALIBRATION_2"` and you can read more details about the options available [in the TensorRT Developer Guide](https://docs.nvidia.com/deeplearning/tensorrt/developer-guide/index.html#enable_int8_c). Ultralytics tests found that `"ENTROPY_CALIBRATION_2"` was the best choice and exports are fixed to using this algorithm. + +- `workspace` : Controls the size (in GiB) of the device memory allocation while converting the model weights. + + - Adjust the `workspace` value according to your calibration needs and resource availability. While a larger `workspace` may increase calibration time, it allows TensorRT to explore a wider range of optimization tactics, potentially enhancing model performance and accuracy. Conversely, a smaller `workspace` can reduce calibration time but may limit the optimization strategies, affecting the quality of the quantized model. + + - Default is `workspace=4` (GiB), this value may need to be increased if calibration crashes (exits without warning). + + - TensorRT will report `UNSUPPORTED_STATE` during export if the value for `workspace` is larger than the memory available to the device, which means the value for `workspace` should be lowered. + + - If `workspace` is set to max value and calibration fails/crashes, consider reducing the values for `imgsz` and `batch` to reduce memory requirements. + + - Remember calibration for INT8 is specific to each device, borrowing a "high-end" GPU for calibration, might result in poor performance when inference is run on another device. + +- `batch` : The maximum batch-size that will be used for inference. During inference smaller batches can be used, but inference will not accept batches any larger than what is specified. + +!!! note + + During calibration, twice the `batch` size provided will be used. Using small batches can lead to inaccurate scaling during calibration. This is because the process adjusts based on the data it sees. Small batches might not capture the full range of values, leading to issues with the final calibration, so the `batch` size is doubled automatically. If no batch size is specified `batch=1`, calibration will be run at `batch=1 * 2` to reduce calibration scaling errors. + +Experimentation by NVIDIA led them to recommend using at least 500 calibration images that are representative of the data for your model, with INT8 quantization calibration. This is a guideline and not a _hard_ requirement, and **you will need to experiment with what is required to perform well for your dataset**. Since the calibration data is required for INT8 calibration with TensorRT, make certain to use the `data` argument when `int8=True` for TensorRT and use `data="my_dataset.yaml"`, which will use the images from [validation](../modes/val.md) to calibrate with. When no value is passed for `data` with export to TensorRT with INT8 quantization, the default will be to use one of the ["small" example datasets based on the model task](../datasets/index.md) instead of throwing an error. + +!!! example + + === "Python" + + ```{ .py .annotate } + from ultralytics import YOLO + + model = YOLO("yolov8n.pt") + model.export( + format="engine", + dynamic=True, # (1)! + batch=8, # (2)! + workspace=4, # (3)! + int8=True, + data="coco.yaml", # (4)! + ) + + # Load the exported TensorRT INT8 model + model = YOLO("yolov8n.engine", task="detect") + + # Run inference + result = model.predict("https://ultralytics.com/images/bus.jpg") + ``` + + 1. Exports with dynamic axes, this will be enabled by default when exporting with `int8=True` even when not explicitly set. See [export arguments](../modes/export.md#arguments) for additional information. + 2. Sets max batch size of 8 for exported model, which calibrates with `batch = 2 * 8` to avoid scaling errors during calibration. + 3. Allocates 4 GiB of memory instead of allocating the entire device for conversion process. + 4. Uses [COCO dataset](../datasets/detect/coco.md) for calibration, specifically the images used for [validation](../modes/val.md) (5,000 total). + + + === "CLI" + + ```bash + # Export a YOLOv8n PyTorch model to TensorRT format with INT8 quantization + yolo export model=yolov8n.pt format=engine batch=8 workspace=4 int8=True data=coco.yaml # creates 'yolov8n.engine'' + + # Run inference with the exported TensorRT quantized model + yolo predict model=yolov8n.engine source='https://ultralytics.com/images/bus.jpg' + ``` + +???+ warning "Calibration Cache" + + TensorRT will generate a calibration `.cache` which can be re-used to speed up export of future model weights using the same data, but this may result in poor calibration when the data is vastly different or if the `batch` value is changed drastically. In these circumstances, the existing `.cache` should be renamed and moved to a different directory or deleted entirely. + +#### Advantages of using YOLO with TensorRT INT8 + +- **Reduced model size:** Quantization from FP32 to INT8 can reduce the model size by 4x (on disk or in memory), leading to faster download times. lower storage requirements, and reduced memory footprint when deploying a model. + +- **Lower power consumption:** Reduced precision operations for INT8 exported YOLO models can consume less power compared to FP32 models, especially for battery-powered devices. + +- **Improved inference speeds:** TensorRT optimizes the model for the target hardware, potentially leading to faster inference speeds on GPUs, embedded devices, and accelerators. + +??? note "Note on Inference Speeds" + + The first few inference calls with a model exported to TensorRT INT8 can be expected to have longer than usual preprocessing, inference, and/or postprocessing times. This may also occur when changing `imgsz` during inference, especially when `imgsz` is not the same as what was specified during export (export `imgsz` is set as TensorRT "optimal" profile). + +#### Drawbacks of using YOLO with TensorRT INT8 + +- **Decreases in evaluation metrics:** Using a lower precision will mean that `mAP`, `Precision`, `Recall` or any [other metric used to evaluate model performance](../guides/yolo-performance-metrics.md) is likely to be somewhat worse. See the [Performance results section](#ultralytics-yolo-tensorrt-export-performance) to compare the differences in `mAP50` and `mAP50-95` when exporting with INT8 on small sample of various devices. + +- **Increased development times:** Finding the "optimal" settings for INT8 calibration for dataset and device can take a significant amount of testing. + +- **Hardware dependency:** Calibration and performance gains could be highly hardware dependent and model weights are less transferable. + +## Ultralytics YOLO TensorRT Export Performance + +### NVIDIA A100 + +!!! tip "Performance" + + Tested with Ubuntu 22.04.3 LTS, `python 3.10.12`, `ultralytics==8.2.4`, `tensorrt==8.6.1.post1` + + === "Detection (COCO)" + + See [Detection Docs](../tasks/detect.md) for usage examples with these models trained on [COCO](../datasets/detect/coco.md), which include 80 pre-trained classes. + + !!! note + Inference times shown for `mean`, `min` (fastest), and `max` (slowest) for each test using pre-trained weights `yolov8n.engine` + + | Precision | Eval test | mean
(ms) | min \| max
(ms) | mAPval
50(B) | mAPval
50-95(B) | `batch` | size
(pixels) | + |-----------|--------------|--------------|--------------------|----------------------|-------------------------|---------|-----------------------| + | FP32 | Predict | 0.52 | 0.51 \| 0.56 | | | 8 | 640 | + | FP32 | COCOval | 0.52 | | 0.52 | 0.37 | 1 | 640 | + | FP16 | Predict | 0.34 | 0.34 \| 0.41 | | | 8 | 640 | + | FP16 | COCOval | 0.33 | | 0.52 | 0.37 | 1 | 640 | + | INT8 | Predict | 0.28 | 0.27 \| 0.31 | | | 8 | 640 | + | INT8 | COCOval | 0.29 | | 0.47 | 0.33 | 1 | 640 | + + === "Segmentation (COCO)" + + See [Segmentation Docs](../tasks/segment.md) for usage examples with these models trained on [COCO](../datasets/segment/coco.md), which include 80 pre-trained classes. + + !!! note + Inference times shown for `mean`, `min` (fastest), and `max` (slowest) for each test using pre-trained weights `yolov8n-seg.engine` + + | Precision | Eval test | mean
(ms) | min \| max
(ms) | mAPval
50(B) | mAPval
50-95(B) | mAPval
50(M) | mAPval
50-95(M) | `batch` | size
(pixels) | + |-----------|--------------|--------------|--------------------|----------------------|-------------------------|----------------------|-------------------------|---------|-----------------------| + | FP32 | Predict | 0.62 | 0.61 \| 0.68 | | | | | 8 | 640 | + | FP32 | COCOval | 0.63 | | 0.52 | 0.36 | 0.49 | 0.31 | 1 | 640 | + | FP16 | Predict | 0.40 | 0.39 \| 0.44 | | | | | 8 | 640 | + | FP16 | COCOval | 0.43 | | 0.52 | 0.36 | 0.49 | 0.30 | 1 | 640 | + | INT8 | Predict | 0.34 | 0.33 \| 0.37 | | | | | 8 | 640 | + | INT8 | COCOval | 0.36 | | 0.46 | 0.32 | 0.43 | 0.27 | 1 | 640 | + + === "Classification (ImageNet)" + + See [Classification Docs](../tasks/classify.md) for usage examples with these models trained on [ImageNet](../datasets/classify/imagenet.md), which include 1000 pre-trained classes. + + !!! note + Inference times shown for `mean`, `min` (fastest), and `max` (slowest) for each test using pre-trained weights `yolov8n-cls.engine` + + | Precision | Eval test | mean
(ms) | min \| max
(ms) | top-1 | top-5 | `batch` | size
(pixels) | + |-----------|------------------|--------------|--------------------|-------|-------|---------|-----------------------| + | FP32 | Predict | 0.26 | 0.25 \| 0.28 | | | 8 | 640 | + | FP32 | ImageNetval | 0.26 | | 0.35 | 0.61 | 1 | 640 | + | FP16 | Predict | 0.18 | 0.17 \| 0.19 | | | 8 | 640 | + | FP16 | ImageNetval | 0.18 | | 0.35 | 0.61 | 1 | 640 | + | INT8 | Predict | 0.16 | 0.15 \| 0.57 | | | 8 | 640 | + | INT8 | ImageNetval | 0.15 | | 0.32 | 0.59 | 1 | 640 | + + === "Pose (COCO)" + + See [Pose Estimation Docs](../tasks/pose.md) for usage examples with these models trained on [COCO](../datasets/pose/coco.md), which include 1 pre-trained class, "person". + + !!! note + Inference times shown for `mean`, `min` (fastest), and `max` (slowest) for each test using pre-trained weights `yolov8n-pose.engine` + + | Precision | Eval test | mean
(ms) | min \| max
(ms) | mAPval
50(B) | mAPval
50-95(B) | mAPval
50(P) | mAPval
50-95(P) | `batch` | size
(pixels) | + |-----------|--------------|--------------|--------------------|----------------------|-------------------------|----------------------|-------------------------|---------|-----------------------| + | FP32 | Predict | 0.54 | 0.53 \| 0.58 | | | | | 8 | 640 | + | FP32 | COCOval | 0.55 | | 0.91 | 0.69 | 0.80 | 0.51 | 1 | 640 | + | FP16 | Predict | 0.37 | 0.35 \| 0.41 | | | | | 8 | 640 | + | FP16 | COCOval | 0.36 | | 0.91 | 0.69 | 0.80 | 0.51 | 1 | 640 | + | INT8 | Predict | 0.29 | 0.28 \| 0.33 | | | | | 8 | 640 | + | INT8 | COCOval | 0.30 | | 0.90 | 0.68 | 0.78 | 0.47 | 1 | 640 | + + === "OBB (DOTAv1)" + + See [Oriented Detection Docs](../tasks/obb.md) for usage examples with these models trained on [DOTAv1](../datasets/obb/dota-v2.md#dota-v10), which include 15 pre-trained classes. + + !!! note + Inference times shown for `mean`, `min` (fastest), and `max` (slowest) for each test using pre-trained weights `yolov8n-obb.engine` + + | Precision | Eval test | mean
(ms) | min \| max
(ms) | mAPval
50(B) | mAPval
50-95(B) | `batch` | size
(pixels) | + |-----------|----------------|--------------|--------------------|----------------------|-------------------------|---------|-----------------------| + | FP32 | Predict | 0.52 | 0.51 \| 0.59 | | | 8 | 640 | + | FP32 | DOTAv1val | 0.76 | | 0.50 | 0.36 | 1 | 640 | + | FP16 | Predict | 0.34 | 0.33 \| 0.42 | | | 8 | 640 | + | FP16 | DOTAv1val | 0.59 | | 0.50 | 0.36 | 1 | 640 | + | INT8 | Predict | 0.29 | 0.28 \| 0.33 | | | 8 | 640 | + | INT8 | DOTAv1val | 0.32 | | 0.45 | 0.32 | 1 | 640 | + +### Consumer GPUs + +!!! tip "Detection Performance (COCO)" + + === "RTX 3080 12 GB" + + Tested with Windows 10.0.19045, `python 3.10.9`, `ultralytics==8.2.4`, `tensorrt==10.0.0b6` + + !!! note + Inference times shown for `mean`, `min` (fastest), and `max` (slowest) for each test using pre-trained weights `yolov8n.engine` + + | Precision | Eval test | mean
(ms) | min \| max
(ms) | mAPval
50(B) | mAPval
50-95(B) | `batch` | size
(pixels) | + |-----------|--------------|--------------|--------------------|----------------------|-------------------------|---------|-----------------------| + | FP32 | Predict | 1.06 | 0.75 \| 1.88 | | | 8 | 640 | + | FP32 | COCOval | 1.37 | | 0.52 | 0.37 | 1 | 640 | + | FP16 | Predict | 0.62 | 0.75 \| 1.13 | | | 8 | 640 | + | FP16 | COCOval | 0.85 | | 0.52 | 0.37 | 1 | 640 | + | INT8 | Predict | 0.52 | 0.38 \| 1.00 | | | 8 | 640 | + | INT8 | COCOval | 0.74 | | 0.47 | 0.33 | 1 | 640 | + + === "RTX 3060 12 GB" + + Tested with Windows 10.0.22631, `python 3.11.9`, `ultralytics==8.2.4`, `tensorrt==10.0.1` + + !!! note + Inference times shown for `mean`, `min` (fastest), and `max` (slowest) for each test using pre-trained weights `yolov8n.engine` + + + | Precision | Eval test | mean
(ms) | min \| max
(ms) | mAPval
50(B) | mAPval
50-95(B) | `batch` | size
(pixels) | + |-----------|--------------|--------------|--------------------|----------------------|-------------------------|---------|-----------------------| + | FP32 | Predict | 1.76 | 1.69 \| 1.87 | | | 8 | 640 | + | FP32 | COCOval | 1.94 | | 0.52 | 0.37 | 1 | 640 | + | FP16 | Predict | 0.86 | 0.75 \| 1.00 | | | 8 | 640 | + | FP16 | COCOval | 1.43 | | 0.52 | 0.37 | 1 | 640 | + | INT8 | Predict | 0.80 | 0.75 \| 1.00 | | | 8 | 640 | + | INT8 | COCOval | 1.35 | | 0.47 | 0.33 | 1 | 640 | + + === "RTX 2060 6 GB" + + Tested with Pop!_OS 22.04 LTS, `python 3.10.12`, `ultralytics==8.2.4`, `tensorrt==8.6.1.post1` + + !!! note + Inference times shown for `mean`, `min` (fastest), and `max` (slowest) for each test using pre-trained weights `yolov8n.engine` + + | Precision | Eval test | mean
(ms) | min \| max
(ms) | mAPval
50(B) | mAPval
50-95(B) | `batch` | size
(pixels) | + |-----------|--------------|--------------|--------------------|----------------------|-------------------------|---------|-----------------------| + | FP32 | Predict | 2.84 | 2.84 \| 2.85 | | | 8 | 640 | + | FP32 | COCOval | 2.94 | | 0.52 | 0.37 | 1 | 640 | + | FP16 | Predict | 1.09 | 1.09 \| 1.10 | | | 8 | 640 | + | FP16 | COCOval | 1.20 | | 0.52 | 0.37 | 1 | 640 | + | INT8 | Predict | 0.75 | 0.74 \| 0.75 | | | 8 | 640 | + | INT8 | COCOval | 0.76 | | 0.47 | 0.33 | 1 | 640 | + +### Embedded Devices + +!!! tip "Detection Performance (COCO)" + + === "Jetson Orin NX 16GB" + + Tested with JetPack 6.0 (L4T 36.3) Ubuntu 22.04.4 LTS, `python 3.10.12`, `ultralytics==8.2.16`, `tensorrt==10.0.1` + + !!! note + Inference times shown for `mean`, `min` (fastest), and `max` (slowest) for each test using pre-trained weights `yolov8n.engine` + + | Precision | Eval test | mean
(ms) | min \| max
(ms) | mAPval
50(B) | mAPval
50-95(B) | `batch` | size
(pixels) | + |-----------|--------------|--------------|--------------------|----------------------|-------------------------|---------|-----------------------| + | FP32 | Predict | 6.11 | 6.10 \| 6.29 | | | 8 | 640 | + | FP32 | COCOval | 6.17 | | 0.52 | 0.37 | 1 | 640 | + | FP16 | Predict | 3.18 | 3.18 \| 3.20 | | | 8 | 640 | + | FP16 | COCOval | 3.19 | | 0.52 | 0.37 | 1 | 640 | + | INT8 | Predict | 2.30 | 2.29 \| 2.35 | | | 8 | 640 | + | INT8 | COCOval | 2.32 | | 0.46 | 0.32 | 1 | 640 | + +!!! info + + See our [quickstart guide on NVIDIA Jetson with Ultralytics YOLO](../guides/nvidia-jetson.md) to learn more about setup and configuration. + +#### Evaluation methods + +Expand sections below for information on how these models were exported and tested. + +??? example "Export configurations" + + See [export mode](../modes/export.md) for details regarding export configuration arguments. + + ```py + from ultralytics import YOLO + + model = YOLO("yolov8n.pt") + + # TensorRT FP32 + out = model.export(format="engine", imgsz=640, dynamic=True, verbose=False, batch=8, workspace=2) + + # TensorRT FP16 + out = model.export(format="engine", imgsz=640, dynamic=True, verbose=False, batch=8, workspace=2, half=True) + + # TensorRT INT8 with calibration `data` (i.e. COCO, ImageNet, or DOTAv1 for appropriate model task) + out = model.export( + format="engine", imgsz=640, dynamic=True, verbose=False, batch=8, workspace=2, int8=True, data="coco8.yaml" + ) + ``` + +??? example "Predict loop" + + See [predict mode](../modes/predict.md) for additional information. + + ```py + import cv2 + + from ultralytics import YOLO + + model = YOLO("yolov8n.engine") + img = cv2.imread("path/to/image.jpg") + + for _ in range(100): + result = model.predict( + [img] * 8, # batch=8 of the same image + verbose=False, + device="cuda", + ) + ``` + +??? example "Validation configuration" + + See [`val` mode](../modes/val.md) to learn more about validation configuration arguments. + + ```py + from ultralytics import YOLO + + model = YOLO("yolov8n.engine") + results = model.val( + data="data.yaml", # COCO, ImageNet, or DOTAv1 for appropriate model task + batch=1, + imgsz=640, + verbose=False, + device="cuda", + ) + ``` + +## Deploying Exported YOLOv8 TensorRT Models + +Having successfully exported your Ultralytics YOLOv8 models to TensorRT format, you're now ready to deploy them. For in-depth instructions on deploying your TensorRT models in various settings, take a look at the following resources: + +- **[Deploy Ultralytics with a Triton Server](../guides/triton-inference-server.md)**: Our guide on how to use NVIDIA's Triton Inference (formerly TensorRT Inference) Server specifically for use with Ultralytics YOLO models. + +- **[Deploying Deep Neural Networks with NVIDIA TensorRT](https://developer.nvidia.com/blog/deploying-deep-learning-nvidia-tensorrt/)**: This article explains how to use NVIDIA TensorRT to deploy deep neural networks on GPU-based deployment platforms efficiently. + +- **[End-to-End AI for NVIDIA-Based PCs: NVIDIA TensorRT Deployment](https://developer.nvidia.com/blog/end-to-end-ai-for-nvidia-based-pcs-nvidia-tensorrt-deployment/)**: This blog post explains the use of NVIDIA TensorRT for optimizing and deploying AI models on NVIDIA-based PCs. + +- **[GitHub Repository for NVIDIA TensorRT:](https://github.com/NVIDIA/TensorRT)**: This is the official GitHub repository that contains the source code and documentation for NVIDIA TensorRT. + +## Summary + +In this guide, we focused on converting Ultralytics YOLOv8 models to NVIDIA's TensorRT model format. This conversion step is crucial for improving the efficiency and speed of YOLOv8 models, making them more effective and suitable for diverse deployment environments. + +For more information on usage details, take a look at the [TensorRT official documentation](https://docs.nvidia.com/deeplearning/tensorrt/). + +If you're curious about additional Ultralytics YOLOv8 integrations, our [integration guide page](../integrations/index.md) provides an extensive selection of informative resources and insights. + +## FAQ + +### How do I convert YOLOv8 models to TensorRT format? + +To convert your Ultralytics YOLOv8 models to TensorRT format for optimized NVIDIA GPU inference, follow these steps: + +1. **Install the required package**: + + ```bash + pip install ultralytics + ``` + +2. **Export your YOLOv8 model**: + + ```python + from ultralytics import YOLO + + model = YOLO("yolov8n.pt") + model.export(format="engine") # creates 'yolov8n.engine' + + # Run inference + model = YOLO("yolov8n.engine") + results = model("https://ultralytics.com/images/bus.jpg") + ``` + +For more details, visit the [YOLOv8 Installation guide](../quickstart.md) and the [export documentation](../modes/export.md). + +### What are the benefits of using TensorRT for YOLOv8 models? + +Using TensorRT to optimize YOLOv8 models offers several benefits: + +- **Faster Inference Speed**: TensorRT optimizes the model layers and uses precision calibration (INT8 and FP16) to speed up inference without significantly sacrificing accuracy. +- **Memory Efficiency**: TensorRT manages tensor memory dynamically, reducing overhead and improving GPU memory utilization. +- **Layer Fusion**: Combines multiple layers into single operations, reducing computational complexity. +- **Kernel Auto-Tuning**: Automatically selects optimized GPU kernels for each model layer, ensuring maximum performance. + +For more information, explore the detailed features of TensorRT [here](https://developer.nvidia.com/tensorrt) and read our [TensorRT overview section](#tensorrt). + +### Can I use INT8 quantization with TensorRT for YOLOv8 models? + +Yes, you can export YOLOv8 models using TensorRT with INT8 quantization. This process involves post-training quantization (PTQ) and calibration: + +1. **Export with INT8**: + + ```python + from ultralytics import YOLO + + model = YOLO("yolov8n.pt") + model.export(format="engine", batch=8, workspace=4, int8=True, data="coco.yaml") + ``` + +2. **Run inference**: + + ```python + from ultralytics import YOLO + + model = YOLO("yolov8n.engine", task="detect") + result = model.predict("https://ultralytics.com/images/bus.jpg") + ``` + +For more details, refer to the [exporting TensorRT with INT8 quantization section](#exporting-tensorrt-with-int8-quantization). + +### How do I deploy YOLOv8 TensorRT models on an NVIDIA Triton Inference Server? + +Deploying YOLOv8 TensorRT models on an NVIDIA Triton Inference Server can be done using the following resources: + +- **[Deploy Ultralytics YOLOv8 with Triton Server](../guides/triton-inference-server.md)**: Step-by-step guidance on setting up and using Triton Inference Server. +- **[NVIDIA Triton Inference Server Documentation](https://developer.nvidia.com/blog/deploying-deep-learning-nvidia-tensorrt/)**: Official NVIDIA documentation for detailed deployment options and configurations. + +These guides will help you integrate YOLOv8 models efficiently in various deployment environments. + +### What are the performance improvements observed with YOLOv8 models exported to TensorRT? + +Performance improvements with TensorRT can vary based on the hardware used. Here are some typical benchmarks: + +- **NVIDIA A100**: + + - **FP32** Inference: ~0.52 ms / image + - **FP16** Inference: ~0.34 ms / image + - **INT8** Inference: ~0.28 ms / image + - Slight reduction in mAP with INT8 precision, but significant improvement in speed. + +- **Consumer GPUs (e.g., RTX 3080)**: + - **FP32** Inference: ~1.06 ms / image + - **FP16** Inference: ~0.62 ms / image + - **INT8** Inference: ~0.52 ms / image + +Detailed performance benchmarks for different hardware configurations can be found in the [performance section](#ultralytics-yolo-tensorrt-export-performance). + +For more comprehensive insights into TensorRT performance, refer to the [Ultralytics documentation](../modes/export.md) and our performance analysis reports. diff --git a/ultralytics/docs/en/integrations/tf-graphdef.md b/ultralytics/docs/en/integrations/tf-graphdef.md new file mode 100644 index 0000000000000000000000000000000000000000..24ae0dd980c9e98234ab53a69f0139f0948406db --- /dev/null +++ b/ultralytics/docs/en/integrations/tf-graphdef.md @@ -0,0 +1,204 @@ +--- +comments: true +description: Learn how to export YOLOv8 models to the TF GraphDef format for seamless deployment on various platforms, including mobile and web. +keywords: YOLOv8, export, TensorFlow, GraphDef, model deployment, TensorFlow Serving, TensorFlow Lite, TensorFlow.js, machine learning, AI, computer vision +--- + +# How to Export to TF GraphDef from YOLOv8 for Deployment + +When you are deploying cutting-edge computer vision models, like YOLOv8, in different environments, you might run into compatibility issues. Google's TensorFlow GraphDef, or TF GraphDef, offers a solution by providing a serialized, platform-independent representation of your model. Using the TF GraphDef model format, you can deploy your YOLOv8 model in environments where the complete TensorFlow ecosystem may not be available, such as mobile devices or specialized hardware. + +In this guide, we'll walk you step by step through how to export your [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics) models to the TF GraphDef model format. By converting your model, you can streamline deployment and use YOLOv8's computer vision capabilities in a broader range of applications and platforms. + +

+ TensorFlow GraphDef +

+ +## Why Should You Export to TF GraphDef? + +TF GraphDef is a powerful component of the TensorFlow ecosystem that was developed by Google. It can be used to optimize and deploy models like YOLOv8. Exporting to TF GraphDef lets us move models from research to real-world applications. It allows models to run in environments without the full TensorFlow framework. + +The GraphDef format represents the model as a serialized computation graph. This enables various optimization techniques like constant folding, quantization, and graph transformations. These optimizations ensure efficient execution, reduced memory usage, and faster inference speeds. + +GraphDef models can use hardware accelerators such as GPUs, TPUs, and AI chips, unlocking significant performance gains for the YOLOv8 inference pipeline. The TF GraphDef format creates a self-contained package with the model and its dependencies, simplifying deployment and integration into diverse systems. + +## Key Features of TF GraphDef Models + +TF GraphDef offers distinct features for streamlining model deployment and optimization. + +Here's a look at its key characteristics: + +- **Model Serialization**: TF GraphDef provides a way to serialize and store TensorFlow models in a platform-independent format. This serialized representation allows you to load and execute your models without the original Python codebase, making deployment easier. + +- **Graph Optimization**: TF GraphDef enables the optimization of computational graphs. These optimizations can boost performance by streamlining execution flow, reducing redundancies, and tailoring operations to suit specific hardware. + +- **Deployment Flexibility**: Models exported to the GraphDef format can be used in various environments, including resource-constrained devices, web browsers, and systems with specialized hardware. This opens up possibilities for wider deployment of your TensorFlow models. + +- **Production Focus**: GraphDef is designed for production deployment. It supports efficient execution, serialization features, and optimizations that align with real-world use cases. + +## Deployment Options with TF GraphDef + +Before we dive into the process of exporting YOLOv8 models to TF GraphDef, let's take a look at some typical deployment situations where this format is used. + +Here's how you can deploy with TF GraphDef efficiently across various platforms. + +- **TensorFlow Serving:** This framework is designed to deploy TensorFlow models in production environments. TensorFlow Serving offers model management, versioning, and the infrastructure for efficient model serving at scale. It's a seamless way to integrate your GraphDef-based models into production web services or APIs. + +- **Mobile and Embedded Devices:** With tools like TensorFlow Lite, you can convert TF GraphDef models into formats optimized for smartphones, tablets, and various embedded devices. Your models can then be used for on-device inference, where execution is done locally, often providing performance gains and offline capabilities. + +- **Web Browsers:** TensorFlow.js enables the deployment of TF GraphDef models directly within web browsers. It paves the way for real-time object detection applications running on the client side, using the capabilities of YOLOv8 through JavaScript. + +- **Specialized Hardware:** TF GraphDef's platform-agnostic nature allows it to target custom hardware, such as accelerators and TPUs (Tensor Processing Units). These devices can provide performance advantages for computationally intensive models. + +## Exporting YOLOv8 Models to TF GraphDef + +You can convert your YOLOv8 object detection model to the TF GraphDef format, which is compatible with various systems, to improve its performance across platforms. + +### Installation + +To install the required package, run: + +!!! tip "Installation" + + === "CLI" + + ```bash + # Install the required package for YOLOv8 + pip install ultralytics + ``` + +For detailed instructions and best practices related to the installation process, check our [Ultralytics Installation guide](../quickstart.md). While installing the required packages for YOLOv8, if you encounter any difficulties, consult our [Common Issues guide](../guides/yolo-common-issues.md) for solutions and tips. + +### Usage + +Before diving into the usage instructions, it's important to note that while all [Ultralytics YOLOv8 models](../models/index.md) are available for exporting, you can ensure that the model you select supports export functionality [here](../modes/export.md). + +!!! example "Usage" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load the YOLOv8 model + model = YOLO("yolov8n.pt") + + # Export the model to TF GraphDef format + model.export(format="pb") # creates 'yolov8n.pb' + + # Load the exported TF GraphDef model + tf_graphdef_model = YOLO("yolov8n.pb") + + # Run inference + results = tf_graphdef_model("https://ultralytics.com/images/bus.jpg") + ``` + + === "CLI" + + ```bash + # Export a YOLOv8n PyTorch model to TF GraphDef format + yolo export model=yolov8n.pt format=pb # creates 'yolov8n.pb' + + # Run inference with the exported model + yolo predict model='yolov8n.pb' source='https://ultralytics.com/images/bus.jpg' + ``` + +For more details about supported export options, visit the [Ultralytics documentation page on deployment options](../guides/model-deployment-options.md). + +## Deploying Exported YOLOv8 TF GraphDef Models + +Once you've exported your YOLOv8 model to the TF GraphDef format, the next step is deployment. The primary and recommended first step for running a TF GraphDef model is to use the YOLO("model.pb") method, as previously shown in the usage code snippet. + +However, for more information on deploying your TF GraphDef models, take a look at the following resources: + +- **[TensorFlow Serving](https://www.tensorflow.org/tfx/guide/serving)**: A guide on TensorFlow Serving that teaches how to deploy and serve machine learning models efficiently in production environments. + +- **[TensorFlow Lite](https://www.tensorflow.org/api_docs/python/tf/lite/TFLiteConverter)**: This page describes how to convert machine learning models into a format optimized for on-device inference with TensorFlow Lite. + +- **[TensorFlow.js](https://www.tensorflow.org/js/guide/conversion)**: A guide on model conversion that teaches how to convert TensorFlow or Keras models into TensorFlow.js format for use in web applications. + +## Summary + +In this guide, we explored how to export Ultralytics YOLOv8 models to the TF GraphDef format. By doing this, you can flexibly deploy your optimized YOLOv8 models in different environments. + +For further details on usage, visit the [TF GraphDef official documentation](https://www.tensorflow.org/api_docs/python/tf/Graph). + +For more information on integrating Ultralytics YOLOv8 with other platforms and frameworks, don't forget to check out our [integration guide page](index.md). It has great resources and insights to help you make the most of YOLOv8 in your projects. + +## FAQ + +### How do I export a YOLOv8 model to TF GraphDef format? + +Ultralytics YOLOv8 models can be exported to TensorFlow GraphDef (TF GraphDef) format seamlessly. This format provides a serialized, platform-independent representation of the model, ideal for deploying in varied environments like mobile and web. To export a YOLOv8 model to TF GraphDef, follow these steps: + +!!! example "Usage" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load the YOLOv8 model + model = YOLO("yolov8n.pt") + + # Export the model to TF GraphDef format + model.export(format="pb") # creates 'yolov8n.pb' + + # Load the exported TF GraphDef model + tf_graphdef_model = YOLO("yolov8n.pb") + + # Run inference + results = tf_graphdef_model("https://ultralytics.com/images/bus.jpg") + ``` + + === "CLI" + + ```bash + # Export a YOLOv8n PyTorch model to TF GraphDef format + yolo export model="yolov8n.pt" format="pb" # creates 'yolov8n.pb' + + # Run inference with the exported model + yolo predict model="yolov8n.pb" source="https://ultralytics.com/images/bus.jpg" + ``` + +For more information on different export options, visit the [Ultralytics documentation on model export](../modes/export.md). + +### What are the benefits of using TF GraphDef for YOLOv8 model deployment? + +Exporting YOLOv8 models to the TF GraphDef format offers multiple advantages, including: + +1. **Platform Independence**: TF GraphDef provides a platform-independent format, allowing models to be deployed across various environments including mobile and web browsers. +2. **Optimizations**: The format enables several optimizations, such as constant folding, quantization, and graph transformations, which enhance execution efficiency and reduce memory usage. +3. **Hardware Acceleration**: Models in TF GraphDef format can leverage hardware accelerators like GPUs, TPUs, and AI chips for performance gains. + +Read more about the benefits in the [TF GraphDef section](#why-should-you-export-to-tf-graphdef) of our documentation. + +### Why should I use Ultralytics YOLOv8 over other object detection models? + +Ultralytics YOLOv8 offers numerous advantages compared to other models like YOLOv5 and YOLOv7. Some key benefits include: + +1. **State-of-the-Art Performance**: YOLOv8 provides exceptional speed and accuracy for real-time object detection, segmentation, and classification. +2. **Ease of Use**: Features a user-friendly API for model training, validation, prediction, and export, making it accessible for both beginners and experts. +3. **Broad Compatibility**: Supports multiple export formats including ONNX, TensorRT, CoreML, and TensorFlow, for versatile deployment options. + +Explore further details in our [introduction to YOLOv8](https://docs.ultralytics.com/models/yolov8/). + +### How can I deploy a YOLOv8 model on specialized hardware using TF GraphDef? + +Once a YOLOv8 model is exported to TF GraphDef format, you can deploy it across various specialized hardware platforms. Typical deployment scenarios include: + +- **TensorFlow Serving**: Use TensorFlow Serving for scalable model deployment in production environments. It supports model management and efficient serving. +- **Mobile Devices**: Convert TF GraphDef models to TensorFlow Lite, optimized for mobile and embedded devices, enabling on-device inference. +- **Web Browsers**: Deploy models using TensorFlow.js for client-side inference in web applications. +- **AI Accelerators**: Leverage TPUs and custom AI chips for accelerated inference. + +Check the [deployment options](#deployment-options-with-tf-graphdef) section for detailed information. + +### Where can I find solutions for common issues while exporting YOLOv8 models? + +For troubleshooting common issues with exporting YOLOv8 models, Ultralytics provides comprehensive guides and resources. If you encounter problems during installation or model export, refer to: + +- **[Common Issues Guide](../guides/yolo-common-issues.md)**: Offers solutions to frequently faced problems. +- **[Installation Guide](../quickstart.md)**: Step-by-step instructions for setting up the required packages. + +These resources should help you resolve most issues related to YOLOv8 model export and deployment. diff --git a/ultralytics/docs/en/integrations/tf-savedmodel.md b/ultralytics/docs/en/integrations/tf-savedmodel.md new file mode 100644 index 0000000000000000000000000000000000000000..5de706a8e0817c670a4014d900e94388ca1de307 --- /dev/null +++ b/ultralytics/docs/en/integrations/tf-savedmodel.md @@ -0,0 +1,197 @@ +--- +comments: true +description: Learn how to export Ultralytics YOLOv8 models to TensorFlow SavedModel format for easy deployment across various platforms and environments. +keywords: YOLOv8, TF SavedModel, Ultralytics, TensorFlow, model export, model deployment, machine learning, AI +--- + +# Understand How to Export to TF SavedModel Format From YOLOv8 + +Deploying machine learning models can be challenging. However, using an efficient and flexible model format can make your job easier. TF SavedModel is an open-source machine-learning framework used by TensorFlow to load machine-learning models in a consistent way. It is like a suitcase for TensorFlow models, making them easy to carry and use on different devices and systems. + +Learning how to export to TF SavedModel from [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics) models can help you deploy models easily across different platforms and environments. In this guide, we'll walk through how to convert your models to the TF SavedModel format, simplifying the process of running inferences with your models on different devices. + +## Why Should You Export to TF SavedModel? + +The TensorFlow SavedModel format is a part of the TensorFlow ecosystem developed by Google as shown below. It is designed to save and serialize TensorFlow models seamlessly. It encapsulates the complete details of models like the architecture, weights, and even compilation information. This makes it straightforward to share, deploy, and continue training across different environments. + +

+ TF SavedModel +

+ +The TF SavedModel has a key advantage: its compatibility. It works well with TensorFlow Serving, TensorFlow Lite, and TensorFlow.js. This compatibility makes it easier to share and deploy models across various platforms, including web and mobile applications. The TF SavedModel format is useful both for research and production. It provides a unified way to manage your models, ensuring they are ready for any application. + +## Key Features of TF SavedModels + +Here are the key features that make TF SavedModel a great option for AI developers: + +- **Portability**: TF SavedModel provides a language-neutral, recoverable, hermetic serialization format. They enable higher-level systems and tools to produce, consume, and transform TensorFlow models. SavedModels can be easily shared and deployed across different platforms and environments. + +- **Ease of Deployment**: TF SavedModel bundles the computational graph, trained parameters, and necessary metadata into a single package. They can be easily loaded and used for inference without requiring the original code that built the model. This makes the deployment of TensorFlow models straightforward and efficient in various production environments. + +- **Asset Management**: TF SavedModel supports the inclusion of external assets such as vocabularies, embeddings, or lookup tables. These assets are stored alongside the graph definition and variables, ensuring they are available when the model is loaded. This feature simplifies the management and distribution of models that rely on external resources. + +## Deployment Options with TF SavedModel + +Before we dive into the process of exporting YOLOv8 models to the TF SavedModel format, let's explore some typical deployment scenarios where this format is used. + +TF SavedModel provides a range of options to deploy your machine learning models: + +- **TensorFlow Serving:** TensorFlow Serving is a flexible, high-performance serving system designed for production environments. It natively supports TF SavedModels, making it easy to deploy and serve your models on cloud platforms, on-premises servers, or edge devices. + +- **Cloud Platforms:** Major cloud providers like Google Cloud Platform (GCP), Amazon Web Services (AWS), and Microsoft Azure offer services for deploying and running TensorFlow models, including TF SavedModels. These services provide scalable and managed infrastructure, allowing you to deploy and scale your models easily. + +- **Mobile and Embedded Devices:** TensorFlow Lite, a lightweight solution for running machine learning models on mobile, embedded, and IoT devices, supports converting TF SavedModels to the TensorFlow Lite format. This allows you to deploy your models on a wide range of devices, from smartphones and tablets to microcontrollers and edge devices. + +- **TensorFlow Runtime:** TensorFlow Runtime (`tfrt`) is a high-performance runtime for executing TensorFlow graphs. It provides lower-level APIs for loading and running TF SavedModels in C++ environments. TensorFlow Runtime offers better performance compared to the standard TensorFlow runtime. It is suitable for deployment scenarios that require low-latency inference and tight integration with existing C++ codebases. + +## Exporting YOLOv8 Models to TF SavedModel + +By exporting YOLOv8 models to the TF SavedModel format, you enhance their adaptability and ease of deployment across various platforms. + +### Installation + +To install the required package, run: + +!!! tip "Installation" + + === "CLI" + + ```bash + # Install the required package for YOLOv8 + pip install ultralytics + ``` + +For detailed instructions and best practices related to the installation process, check our [Ultralytics Installation guide](../quickstart.md). While installing the required packages for YOLOv8, if you encounter any difficulties, consult our [Common Issues guide](../guides/yolo-common-issues.md) for solutions and tips. + +### Usage + +Before diving into the usage instructions, it's important to note that while all [Ultralytics YOLOv8 models](../models/index.md) are available for exporting, you can ensure that the model you select supports export functionality [here](../modes/export.md). + +!!! example "Usage" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load the YOLOv8 model + model = YOLO("yolov8n.pt") + + # Export the model to TF SavedModel format + model.export(format="saved_model") # creates '/yolov8n_saved_model' + + # Load the exported TF SavedModel model + tf_savedmodel_model = YOLO("./yolov8n_saved_model") + + # Run inference + results = tf_savedmodel_model("https://ultralytics.com/images/bus.jpg") + ``` + + === "CLI" + + ```bash + # Export a YOLOv8n PyTorch model to TF SavedModel format + yolo export model=yolov8n.pt format=saved_model # creates '/yolov8n_saved_model' + + # Run inference with the exported model + yolo predict model='./yolov8n_saved_model' source='https://ultralytics.com/images/bus.jpg' + ``` + +For more details about supported export options, visit the [Ultralytics documentation page on deployment options](../guides/model-deployment-options.md). + +## Deploying Exported YOLOv8 TF SavedModel Models + +Now that you have exported your YOLOv8 model to the TF SavedModel format, the next step is to deploy it. The primary and recommended first step for running a TF GraphDef model is to use the YOLO("./yolov8n_saved_model") method, as previously shown in the usage code snippet. + +However, for in-depth instructions on deploying your TF SavedModel models, take a look at the following resources: + +- **[TensorFlow Serving](https://www.tensorflow.org/tfx/guide/serving)**: Here's the developer documentation for how to deploy your TF SavedModel models using TensorFlow Serving. + +- **[Run a TensorFlow SavedModel in Node.js](https://blog.tensorflow.org/2020/01/run-tensorflow-savedmodel-in-nodejs-directly-without-conversion.html)**: A TensorFlow blog post on running a TensorFlow SavedModel in Node.js directly without conversion. + +- **[Deploying on Cloud](https://blog.tensorflow.org/2020/04/how-to-deploy-tensorflow-2-models-on-cloud-ai-platform.html)**: A TensorFlow blog post on deploying a TensorFlow SavedModel model on the Cloud AI Platform. + +## Summary + +In this guide, we explored how to export Ultralytics YOLOv8 models to the TF SavedModel format. By exporting to TF SavedModel, you gain the flexibility to optimize, deploy, and scale your YOLOv8 models on a wide range of platforms. + +For further details on usage, visit the [TF SavedModel official documentation](https://www.tensorflow.org/guide/saved_model). + +For more information on integrating Ultralytics YOLOv8 with other platforms and frameworks, don't forget to check out our [integration guide page](index.md). It's packed with great resources to help you make the most of YOLOv8 in your projects. + +## FAQ + +### How do I export an Ultralytics YOLO model to TensorFlow SavedModel format? + +Exporting an Ultralytics YOLO model to the TensorFlow SavedModel format is straightforward. You can use either Python or CLI to achieve this: + +!!! example "Exporting YOLOv8 to TF SavedModel" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load the YOLOv8 model + model = YOLO("yolov8n.pt") + + # Export the model to TF SavedModel format + model.export(format="saved_model") # creates '/yolov8n_saved_model' + + # Load the exported TF SavedModel for inference + tf_savedmodel_model = YOLO("./yolov8n_saved_model") + results = tf_savedmodel_model("https://ultralytics.com/images/bus.jpg") + ``` + + === "CLI" + + ```bash + # Export the YOLOv8 model to TF SavedModel format + yolo export model=yolov8n.pt format=saved_model # creates '/yolov8n_saved_model' + + # Run inference with the exported model + yolo predict model='./yolov8n_saved_model' source='https://ultralytics.com/images/bus.jpg' + ``` + +Refer to the [Ultralytics Export documentation](../modes/export.md) for more details. + +### Why should I use the TensorFlow SavedModel format? + +The TensorFlow SavedModel format offers several advantages for model deployment: + +- **Portability:** It provides a language-neutral format, making it easy to share and deploy models across different environments. +- **Compatibility:** Integrates seamlessly with tools like TensorFlow Serving, TensorFlow Lite, and TensorFlow.js, which are essential for deploying models on various platforms, including web and mobile applications. +- **Complete encapsulation:** Encodes the model architecture, weights, and compilation information, allowing for straightforward sharing and training continuation. + +For more benefits and deployment options, check out the [Ultralytics YOLO model deployment options](../guides/model-deployment-options.md). + +### What are the typical deployment scenarios for TF SavedModel? + +TF SavedModel can be deployed in various environments, including: + +- **TensorFlow Serving:** Ideal for production environments requiring scalable and high-performance model serving. +- **Cloud Platforms:** Supports major cloud services like Google Cloud Platform (GCP), Amazon Web Services (AWS), and Microsoft Azure for scalable model deployment. +- **Mobile and Embedded Devices:** Using TensorFlow Lite to convert TF SavedModels allows for deployment on mobile devices, IoT devices, and microcontrollers. +- **TensorFlow Runtime:** For C++ environments needing low-latency inference with better performance. + +For detailed deployment options, visit the official guides on [deploying TensorFlow models](https://www.tensorflow.org/tfx/guide/serving). + +### How can I install the necessary packages to export YOLOv8 models? + +To export YOLOv8 models, you need to install the `ultralytics` package. Run the following command in your terminal: + +```bash +pip install ultralytics +``` + +For more detailed installation instructions and best practices, refer to our [Ultralytics Installation guide](../quickstart.md). If you encounter any issues, consult our [Common Issues guide](../guides/yolo-common-issues.md). + +### What are the key features of the TensorFlow SavedModel format? + +TF SavedModel format is beneficial for AI developers due to the following features: + +- **Portability:** Allows sharing and deployment across various environments effortlessly. +- **Ease of Deployment:** Encapsulates the computational graph, trained parameters, and metadata into a single package, which simplifies loading and inference. +- **Asset Management:** Supports external assets like vocabularies, ensuring they are available when the model loads. + +For further details, explore the [official TensorFlow documentation](https://www.tensorflow.org/guide/saved_model). diff --git a/ultralytics/docs/en/integrations/tfjs.md b/ultralytics/docs/en/integrations/tfjs.md new file mode 100644 index 0000000000000000000000000000000000000000..726bba251e8605de3989cf36ca75d863c691d823 --- /dev/null +++ b/ultralytics/docs/en/integrations/tfjs.md @@ -0,0 +1,194 @@ +--- +comments: true +description: Convert your Ultralytics YOLOv8 models to TensorFlow.js for high-speed, local object detection. Learn how to optimize ML models for browser and Node.js apps. +keywords: YOLOv8, TensorFlow.js, TF.js, model export, machine learning, object detection, browser ML, Node.js, Ultralytics, YOLO, export models +--- + +# Export to TF.js Model Format From a YOLOv8 Model Format + +Deploying machine learning models directly in the browser or on Node.js can be tricky. You'll need to make sure your model format is optimized for faster performance so that the model can be used to run interactive applications locally on the user's device. The TensorFlow.js, or TF.js, model format is designed to use minimal power while delivering fast performance. + +The 'export to TF.js model format' feature allows you to optimize your [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics) models for high-speed and locally-run object detection inference. In this guide, we'll walk you through converting your models to the TF.js format, making it easier for your models to perform well on various local browsers and Node.js applications. + +## Why Should You Export to TF.js? + +Exporting your machine learning models to TensorFlow.js, developed by the TensorFlow team as part of the broader TensorFlow ecosystem, offers numerous advantages for deploying machine learning applications. It helps enhance user privacy and security by keeping sensitive data on the device. The image below shows the TensorFlow.js architecture, and how machine learning models are converted and deployed on both web browsers and Node.js. + +

+ TF.js Architecture +

+ +Running models locally also reduces latency and provides a more responsive user experience. TensorFlow.js also comes with offline capabilities, allowing users to use your application even without an internet connection. TF.js is designed for efficient execution of complex models on devices with limited resources as it is engineered for scalability, with GPU acceleration support. + +## Key Features of TF.js + +Here are the key features that make TF.js a powerful tool for developers: + +- **Cross-Platform Support:** TensorFlow.js can be used in both browser and Node.js environments, providing flexibility in deployment across different platforms. It lets developers build and deploy applications more easily. + +- **Support for Multiple Backends:** TensorFlow.js supports various backends for computation including CPU, WebGL for GPU acceleration, WebAssembly (WASM) for near-native execution speed, and WebGPU for advanced browser-based machine learning capabilities. + +- **Offline Capabilities:** With TensorFlow.js, models can run in the browser without the need for an internet connection, making it possible to develop applications that are functional offline. + +## Deployment Options with TensorFlow.js + +Before we dive into the process of exporting YOLOv8 models to the TF.js format, let's explore some typical deployment scenarios where this format is used. + +TF.js provides a range of options to deploy your machine learning models: + +- **In-Browser ML Applications:** You can build web applications that run machine learning models directly in the browser. The need for server-side computation is eliminated and the server load is reduced. + +- **Node.js Applications::** TensorFlow.js also supports deployment in Node.js environments, enabling the development of server-side machine learning applications. It is particularly useful for applications that require the processing power of a server or access to server-side data. + +- **Chrome Extensions:** An interesting deployment scenario is the creation of Chrome extensions with TensorFlow.js. For instance, you can develop an extension that allows users to right-click on an image within any webpage to classify it using a pre-trained ML model. TensorFlow.js can be integrated into everyday web browsing experiences to provide immediate insights or augmentations based on machine learning. + +## Exporting YOLOv8 Models to TensorFlow.js + +You can expand model compatibility and deployment flexibility by converting YOLOv8 models to TF.js. + +### Installation + +To install the required package, run: + +!!! tip "Installation" + + === "CLI" + + ```bash + # Install the required package for YOLOv8 + pip install ultralytics + ``` + +For detailed instructions and best practices related to the installation process, check our [Ultralytics Installation guide](../quickstart.md). While installing the required packages for YOLOv8, if you encounter any difficulties, consult our [Common Issues guide](../guides/yolo-common-issues.md) for solutions and tips. + +### Usage + +Before diving into the usage instructions, it's important to note that while all [Ultralytics YOLOv8 models](../models/index.md) are available for exporting, you can ensure that the model you select supports export functionality [here](../modes/export.md). + +!!! example "Usage" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load the YOLOv8 model + model = YOLO("yolov8n.pt") + + # Export the model to TF.js format + model.export(format="tfjs") # creates '/yolov8n_web_model' + + # Load the exported TF.js model + tfjs_model = YOLO("./yolov8n_web_model") + + # Run inference + results = tfjs_model("https://ultralytics.com/images/bus.jpg") + ``` + + === "CLI" + + ```bash + # Export a YOLOv8n PyTorch model to TF.js format + yolo export model=yolov8n.pt format=tfjs # creates '/yolov8n_web_model' + + # Run inference with the exported model + yolo predict model='./yolov8n_web_model' source='https://ultralytics.com/images/bus.jpg' + ``` + +For more details about supported export options, visit the [Ultralytics documentation page on deployment options](../guides/model-deployment-options.md). + +## Deploying Exported YOLOv8 TensorFlow.js Models + +Now that you have exported your YOLOv8 model to the TF.js format, the next step is to deploy it. The primary and recommended first step for running a TF.js is to use the YOLO("./yolov8n_web_model") method, as previously shown in the usage code snippet. + +However, for in-depth instructions on deploying your TF.js models, take a look at the following resources: + +- **[Chrome Extension](https://www.tensorflow.org/js/tutorials/deployment/web_ml_in_chrome)**: Here's the developer documentation for how to deploy your TF.js models to a Chrome extension. + +- **[Run TensorFlow.js in Node.js](https://www.tensorflow.org/js/guide/nodejs)**: A TensorFlow blog post on running TensorFlow.js in Node.js directly. + +- **[Deploying TensorFlow.js - Node Project on Cloud Platform](https://www.tensorflow.org/js/guide/node_in_cloud)**: A TensorFlow blog post on deploying a TensorFlow.js model on a Cloud Platform. + +## Summary + +In this guide, we learned how to export Ultralytics YOLOv8 models to the TensorFlow.js format. By exporting to TF.js, you gain the flexibility to optimize, deploy, and scale your YOLOv8 models on a wide range of platforms. + +For further details on usage, visit the [TensorFlow.js official documentation](https://www.tensorflow.org/js/guide). + +For more information on integrating Ultralytics YOLOv8 with other platforms and frameworks, don't forget to check out our [integration guide page](index.md). It's packed with great resources to help you make the most of YOLOv8 in your projects. + +## FAQ + +### How do I export Ultralytics YOLOv8 models to TensorFlow.js format? + +Exporting Ultralytics YOLOv8 models to TensorFlow.js (TF.js) format is straightforward. You can follow these steps: + +!!! example "Usage" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load the YOLOv8 model + model = YOLO("yolov8n.pt") + + # Export the model to TF.js format + model.export(format="tfjs") # creates '/yolov8n_web_model' + + # Load the exported TF.js model + tfjs_model = YOLO("./yolov8n_web_model") + + # Run inference + results = tfjs_model("https://ultralytics.com/images/bus.jpg") + ``` + + === "CLI" + + ```bash + # Export a YOLOv8n PyTorch model to TF.js format + yolo export model=yolov8n.pt format=tfjs # creates '/yolov8n_web_model' + + # Run inference with the exported model + yolo predict model='./yolov8n_web_model' source='https://ultralytics.com/images/bus.jpg' + ``` + +For more details about supported export options, visit the [Ultralytics documentation page on deployment options](../guides/model-deployment-options.md). + +### Why should I export my YOLOv8 models to TensorFlow.js? + +Exporting YOLOv8 models to TensorFlow.js offers several advantages, including: + +1. **Local Execution:** Models can run directly in the browser or Node.js, reducing latency and enhancing user experience. +2. **Cross-Platform Support:** TF.js supports multiple environments, allowing flexibility in deployment. +3. **Offline Capabilities:** Enables applications to function without an internet connection, ensuring reliability and privacy. +4. **GPU Acceleration:** Leverages WebGL for GPU acceleration, optimizing performance on devices with limited resources. + +For a comprehensive overview, see our [Integrations with TensorFlow.js](../integrations/tf-graphdef.md). + +### How does TensorFlow.js benefit browser-based machine learning applications? + +TensorFlow.js is specifically designed for efficient execution of ML models in browsers and Node.js environments. Here's how it benefits browser-based applications: + +- **Reduces Latency:** Runs machine learning models locally, providing immediate results without relying on server-side computations. +- **Improves Privacy:** Keeps sensitive data on the user's device, minimizing security risks. +- **Enables Offline Use:** Models can operate without an internet connection, ensuring consistent functionality. +- **Supports Multiple Backends:** Offers flexibility with backends like CPU, WebGL, WebAssembly (WASM), and WebGPU for varying computational needs. + +Interested in learning more about TF.js? Check out the [official TensorFlow.js guide](https://www.tensorflow.org/js/guide). + +### What are the key features of TensorFlow.js for deploying YOLOv8 models? + +Key features of TensorFlow.js include: + +- **Cross-Platform Support:** TF.js can be used in both web browsers and Node.js, providing extensive deployment flexibility. +- **Multiple Backends:** Supports CPU, WebGL for GPU acceleration, WebAssembly (WASM), and WebGPU for advanced operations. +- **Offline Capabilities:** Models can run directly in the browser without internet connectivity, making it ideal for developing responsive web applications. + +For deployment scenarios and more in-depth information, see our section on [Deployment Options with TensorFlow.js](#deploying-exported-yolov8-tensorflowjs-models). + +### Can I deploy a YOLOv8 model on server-side Node.js applications using TensorFlow.js? + +Yes, TensorFlow.js allows the deployment of YOLOv8 models on Node.js environments. This enables server-side machine learning applications that benefit from the processing power of a server and access to server-side data. Typical use cases include real-time data processing and machine learning pipelines on backend servers. + +To get started with Node.js deployment, refer to the [Run TensorFlow.js in Node.js](https://www.tensorflow.org/js/guide/nodejs) guide from TensorFlow. diff --git a/ultralytics/docs/en/integrations/tflite.md b/ultralytics/docs/en/integrations/tflite.md new file mode 100644 index 0000000000000000000000000000000000000000..db8b033844426e01b2c24e1da6f0b9fe1726f87b --- /dev/null +++ b/ultralytics/docs/en/integrations/tflite.md @@ -0,0 +1,193 @@ +--- +comments: true +description: Learn how to convert YOLOv8 models to TFLite for edge device deployment. Optimize performance and ensure seamless execution on various platforms. +keywords: YOLOv8, TFLite, model export, TensorFlow Lite, edge devices, deployment, Ultralytics, machine learning, on-device inference, model optimization +--- + +# A Guide on YOLOv8 Model Export to TFLite for Deployment + +

+ TFLite Logo +

+ +Deploying computer vision models on edge devices or embedded devices requires a format that can ensure seamless performance. + +The TensorFlow Lite or TFLite export format allows you to optimize your [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics) models for tasks like object detection and image classification in edge device-based applications. In this guide, we'll walk through the steps for converting your models to the TFLite format, making it easier for your models to perform well on various edge devices. + +## Why should you export to TFLite? + +Introduced by Google in May 2017 as part of their TensorFlow framework, [TensorFlow Lite](https://ai.google.dev/edge/litert), or TFLite for short, is an open-source deep learning framework designed for on-device inference, also known as edge computing. It gives developers the necessary tools to execute their trained models on mobile, embedded, and IoT devices, as well as traditional computers. + +TensorFlow Lite is compatible with a wide range of platforms, including embedded Linux, Android, iOS, and MCU. Exporting your model to TFLite makes your applications faster, more reliable, and capable of running offline. + +## Key Features of TFLite Models + +TFLite models offer a wide range of key features that enable on-device machine learning by helping developers run their models on mobile, embedded, and edge devices: + +- **On-device Optimization**: TFLite optimizes for on-device ML, reducing latency by processing data locally, enhancing privacy by not transmitting personal data, and minimizing model size to save space. + +- **Multiple Platform Support**: TFLite offers extensive platform compatibility, supporting Android, iOS, embedded Linux, and microcontrollers. + +- **Diverse Language Support**: TFLite is compatible with various programming languages, including Java, Swift, Objective-C, C++, and Python. + +- **High Performance**: Achieves superior performance through hardware acceleration and model optimization. + +## Deployment Options in TFLite + +Before we look at the code for exporting YOLOv8 models to the TFLite format, let's understand how TFLite models are normally used. + +TFLite offers various on-device deployment options for machine learning models, including: + +- **Deploying with Android and iOS**: Both Android and iOS applications with TFLite can analyze edge-based camera feeds and sensors to detect and identify objects. TFLite also offers native iOS libraries written in [Swift](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/swift) and [Objective-C](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/objc). The architecture diagram below shows the process of deploying a trained model onto Android and iOS platforms using TensorFlow Lite. + +

+ Architecture +

+ +- **Implementing with Embedded Linux**: If running inferences on a [Raspberry Pi](https://www.raspberrypi.org/) using the [Ultralytics Guide](../guides/raspberry-pi.md) does not meet the speed requirements for your use case, you can use an exported TFLite model to accelerate inference times. Additionally, it's possible to further improve performance by utilizing a [Coral Edge TPU device](https://coral.withgoogle.com/). + +- **Deploying with Microcontrollers**: TFLite models can also be deployed on microcontrollers and other devices with only a few kilobytes of memory. The core runtime just fits in 16 KB on an Arm Cortex M3 and can run many basic models. It doesn't require operating system support, any standard C or C++ libraries, or dynamic memory allocation. + +## Export to TFLite: Converting Your YOLOv8 Model + +You can improve on-device model execution efficiency and optimize performance by converting them to TFLite format. + +### Installation + +To install the required packages, run: + +!!! tip "Installation" + + === "CLI" + + ```bash + # Install the required package for YOLOv8 + pip install ultralytics + ``` + +For detailed instructions and best practices related to the installation process, check our [Ultralytics Installation guide](../quickstart.md). While installing the required packages for YOLOv8, if you encounter any difficulties, consult our [Common Issues guide](../guides/yolo-common-issues.md) for solutions and tips. + +### Usage + +Before diving into the usage instructions, it's important to note that while all [Ultralytics YOLOv8 models](../models/index.md) are available for exporting, you can ensure that the model you select supports export functionality [here](../modes/export.md). + +!!! example "Usage" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load the YOLOv8 model + model = YOLO("yolov8n.pt") + + # Export the model to TFLite format + model.export(format="tflite") # creates 'yolov8n_float32.tflite' + + # Load the exported TFLite model + tflite_model = YOLO("yolov8n_float32.tflite") + + # Run inference + results = tflite_model("https://ultralytics.com/images/bus.jpg") + ``` + + === "CLI" + + ```bash + # Export a YOLOv8n PyTorch model to TFLite format + yolo export model=yolov8n.pt format=tflite # creates 'yolov8n_float32.tflite' + + # Run inference with the exported model + yolo predict model='yolov8n_float32.tflite' source='https://ultralytics.com/images/bus.jpg' + ``` + +For more details about the export process, visit the [Ultralytics documentation page on exporting](../modes/export.md). + +## Deploying Exported YOLOv8 TFLite Models + +After successfully exporting your Ultralytics YOLOv8 models to TFLite format, you can now deploy them. The primary and recommended first step for running a TFLite model is to utilize the YOLO("model.tflite") method, as outlined in the previous usage code snippet. However, for in-depth instructions on deploying your TFLite models in various other settings, take a look at the following resources: + +- **[Android](https://ai.google.dev/edge/litert/android)**: A quick start guide for integrating TensorFlow Lite into Android applications, providing easy-to-follow steps for setting up and running machine learning models. + +- **[iOS](https://ai.google.dev/edge/litert/ios/quickstart)**: Check out this detailed guide for developers on integrating and deploying TensorFlow Lite models in iOS applications, offering step-by-step instructions and resources. + +- **[End-To-End Examples](https://github.com/tensorflow/examples/tree/master/lite/examples)**: This page provides an overview of various TensorFlow Lite examples, showcasing practical applications and tutorials designed to help developers implement TensorFlow Lite in their machine learning projects on mobile and edge devices. + +## Summary + +In this guide, we focused on how to export to TFLite format. By converting your Ultralytics YOLOv8 models to TFLite model format, you can improve the efficiency and speed of YOLOv8 models, making them more effective and suitable for edge computing environments. + +For further details on usage, visit the [TFLite official documentation](https://ai.google.dev/edge/litert). + +Also, if you're curious about other Ultralytics YOLOv8 integrations, make sure to check out our [integration guide page](../integrations/index.md). You'll find tons of helpful info and insights waiting for you there. + +## FAQ + +### How do I export a YOLOv8 model to TFLite format? + +To export a YOLOv8 model to TFLite format, you can use the Ultralytics library. First, install the required package using: + +```bash +pip install ultralytics +``` + +Then, use the following code snippet to export your model: + +```python +from ultralytics import YOLO + +# Load the YOLOv8 model +model = YOLO("yolov8n.pt") + +# Export the model to TFLite format +model.export(format="tflite") # creates 'yolov8n_float32.tflite' +``` + +For CLI users, you can achieve this with: + +```bash +yolo export model=yolov8n.pt format=tflite # creates 'yolov8n_float32.tflite' +``` + +For more details, visit the [Ultralytics export guide](../modes/export.md). + +### What are the benefits of using TensorFlow Lite for YOLOv8 model deployment? + +TensorFlow Lite (TFLite) is an open-source deep learning framework designed for on-device inference, making it ideal for deploying YOLOv8 models on mobile, embedded, and IoT devices. Key benefits include: + +- **On-device optimization**: Minimize latency and enhance privacy by processing data locally. +- **Platform compatibility**: Supports Android, iOS, embedded Linux, and MCU. +- **Performance**: Utilizes hardware acceleration to optimize model speed and efficiency. + +To learn more, check out the [TFLite guide](https://ai.google.dev/edge/litert). + +### Is it possible to run YOLOv8 TFLite models on Raspberry Pi? + +Yes, you can run YOLOv8 TFLite models on Raspberry Pi to improve inference speeds. First, export your model to TFLite format as explained [here](#how-do-i-export-a-yolov8-model-to-tflite-format). Then, use a tool like TensorFlow Lite Interpreter to execute the model on your Raspberry Pi. + +For further optimizations, you might consider using [Coral Edge TPU](https://coral.withgoogle.com/). For detailed steps, refer to our [Raspberry Pi deployment guide](../guides/raspberry-pi.md). + +### Can I use TFLite models on microcontrollers for YOLOv8 predictions? + +Yes, TFLite supports deployment on microcontrollers with limited resources. TFLite's core runtime requires only 16 KB of memory on an Arm Cortex M3 and can run basic YOLOv8 models. This makes it suitable for deployment on devices with minimal computational power and memory. + +To get started, visit the [TFLite Micro for Microcontrollers guide](https://ai.google.dev/edge/litert/microcontrollers/overview). + +### What platforms are compatible with TFLite exported YOLOv8 models? + +TensorFlow Lite provides extensive platform compatibility, allowing you to deploy YOLOv8 models on a wide range of devices, including: + +- **Android and iOS**: Native support through TFLite Android and iOS libraries. +- **Embedded Linux**: Ideal for single-board computers such as Raspberry Pi. +- **Microcontrollers**: Suitable for MCUs with constrained resources. + +For more information on deployment options, see our detailed [deployment guide](#deploying-exported-yolov8-tflite-models). + +### How do I troubleshoot common issues during YOLOv8 model export to TFLite? + +If you encounter errors while exporting YOLOv8 models to TFLite, common solutions include: + +- **Check package compatibility**: Ensure you're using compatible versions of Ultralytics and TensorFlow. Refer to our [installation guide](../quickstart.md). +- **Model support**: Verify that the specific YOLOv8 model supports TFLite export by checking [here](../modes/export.md). + +For additional troubleshooting tips, visit our [Common Issues guide](../guides/yolo-common-issues.md). diff --git a/ultralytics/docs/en/integrations/torchscript.md b/ultralytics/docs/en/integrations/torchscript.md new file mode 100644 index 0000000000000000000000000000000000000000..138f975e1ce957a899663f961fb54a6590efdbfc --- /dev/null +++ b/ultralytics/docs/en/integrations/torchscript.md @@ -0,0 +1,204 @@ +--- +comments: true +description: Learn how to export Ultralytics YOLOv8 models to TorchScript for flexible, cross-platform deployment. Boost performance and utilize in various environments. +keywords: YOLOv8, TorchScript, model export, Ultralytics, PyTorch, deep learning, AI deployment, cross-platform, performance optimization +--- + +# YOLOv8 Model Export to TorchScript for Quick Deployment + +Deploying computer vision models across different environments, including embedded systems, web browsers, or platforms with limited Python support, requires a flexible and portable solution. TorchScript focuses on portability and the ability to run models in environments where the entire Python framework is unavailable. This makes it ideal for scenarios where you need to deploy your computer vision capabilities across various devices or platforms. + +Export to Torchscript to serialize your [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics) models for cross-platform compatibility and streamlined deployment. In this guide, we'll show you how to export your YOLOv8 models to the TorchScript format, making it easier for you to use them across a wider range of applications. + +## Why should you export to TorchScript? + +![Torchscript Overview](https://github.com/ultralytics/docs/releases/download/0/torchscript-overview.avif) + +Developed by the creators of PyTorch, TorchScript is a powerful tool for optimizing and deploying PyTorch models across a variety of platforms. Exporting YOLOv8 models to [TorchScript](https://pytorch.org/docs/stable/jit.html) is crucial for moving from research to real-world applications. TorchScript, part of the PyTorch framework, helps make this transition smoother by allowing PyTorch models to be used in environments that don't support Python. + +The process involves two techniques: tracing and scripting. Tracing records operations during model execution, while scripting allows for the definition of models using a subset of Python. These techniques ensure that models like YOLOv8 can still work their magic even outside their usual Python environment. + +![TorchScript Script and Trace](https://github.com/ultralytics/docs/releases/download/0/torchscript-script-and-trace.avif) + +TorchScript models can also be optimized through techniques such as operator fusion and refinements in memory usage, ensuring efficient execution. Another advantage of exporting to TorchScript is its potential to accelerate model execution across various hardware platforms. It creates a standalone, production-ready representation of your PyTorch model that can be integrated into C++ environments, embedded systems, or deployed in web or mobile applications. + +## Key Features of TorchScript Models + +TorchScript, a key part of the PyTorch ecosystem, provides powerful features for optimizing and deploying deep learning models. + +![TorchScript Features](https://github.com/ultralytics/docs/releases/download/0/torchscript-features.avif) + +Here are the key features that make TorchScript a valuable tool for developers: + +- **Static Graph Execution**: TorchScript uses a static graph representation of the model's computation, which is different from PyTorch's dynamic graph execution. In static graph execution, the computational graph is defined and compiled once before the actual execution, resulting in improved performance during inference. + +- **Model Serialization**: TorchScript allows you to serialize PyTorch models into a platform-independent format. Serialized models can be loaded without requiring the original Python code, enabling deployment in different runtime environments. + +- **JIT Compilation**: TorchScript uses Just-In-Time (JIT) compilation to convert PyTorch models into an optimized intermediate representation. JIT compiles the model's computational graph, enabling efficient execution on target devices. + +- **Cross-Language Integration**: With TorchScript, you can export PyTorch models to other languages such as C++, Java, and JavaScript. This makes it easier to integrate PyTorch models into existing software systems written in different languages. + +- **Gradual Conversion**: TorchScript provides a gradual conversion approach, allowing you to incrementally convert parts of your PyTorch model into TorchScript. This flexibility is particularly useful when dealing with complex models or when you want to optimize specific portions of the code. + +## Deployment Options in TorchScript + +Before we look at the code for exporting YOLOv8 models to the TorchScript format, let's understand where TorchScript models are normally used. + +TorchScript offers various deployment options for machine learning models, such as: + +- **C++ API**: The most common use case for TorchScript is its C++ API, which allows you to load and execute optimized TorchScript models directly within C++ applications. This is ideal for production environments where Python may not be suitable or available. The C++ API offers low-overhead and efficient execution of TorchScript models, maximizing performance potential. + +- **Mobile Deployment**: TorchScript offers tools for converting models into formats readily deployable on mobile devices. PyTorch Mobile provides a runtime for executing these models within iOS and Android apps. This enables low-latency, offline inference capabilities, enhancing user experience and data privacy. + +- **Cloud Deployment**: TorchScript models can be deployed to cloud-based servers using solutions like TorchServe. It provides features like model versioning, batching, and metrics monitoring for scalable deployment in production environments. Cloud deployment with TorchScript can make your models accessible via APIs or other web services. + +## Export to TorchScript: Converting Your YOLOv8 Model + +Exporting YOLOv8 models to TorchScript makes it easier to use them in different places and helps them run faster and more efficiently. This is great for anyone looking to use deep learning models more effectively in real-world applications. + +### Installation + +To install the required package, run: + +!!! tip "Installation" + + === "CLI" + + ```bash + # Install the required package for YOLOv8 + pip install ultralytics + ``` + +For detailed instructions and best practices related to the installation process, check our [Ultralytics Installation guide](../quickstart.md). While installing the required packages for YOLOv8, if you encounter any difficulties, consult our [Common Issues guide](../guides/yolo-common-issues.md) for solutions and tips. + +### Usage + +Before diving into the usage instructions, it's important to note that while all [Ultralytics YOLOv8 models](../models/index.md) are available for exporting, you can ensure that the model you select supports export functionality [here](../modes/export.md). + +!!! example "Usage" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load the YOLOv8 model + model = YOLO("yolov8n.pt") + + # Export the model to TorchScript format + model.export(format="torchscript") # creates 'yolov8n.torchscript' + + # Load the exported TorchScript model + torchscript_model = YOLO("yolov8n.torchscript") + + # Run inference + results = torchscript_model("https://ultralytics.com/images/bus.jpg") + ``` + + === "CLI" + + ```bash + # Export a YOLOv8n PyTorch model to TorchScript format + yolo export model=yolov8n.pt format=torchscript # creates 'yolov8n.torchscript' + + # Run inference with the exported model + yolo predict model=yolov8n.torchscript source='https://ultralytics.com/images/bus.jpg' + ``` + +For more details about the export process, visit the [Ultralytics documentation page on exporting](../modes/export.md). + +## Deploying Exported YOLOv8 TorchScript Models + +After successfully exporting your Ultralytics YOLOv8 models to TorchScript format, you can now deploy them. The primary and recommended first step for running a TorchScript model is to utilize the YOLO("model.torchscript") method, as outlined in the previous usage code snippet. However, for in-depth instructions on deploying your TorchScript models in various other settings, take a look at the following resources: + +- **[Explore Mobile Deployment](https://pytorch.org/mobile/home/)**: The PyTorch Mobile Documentation provides comprehensive guidelines for deploying models on mobile devices, ensuring your applications are efficient and responsive. + +- **[Master Server-Side Deployment](https://pytorch.org/serve/getting_started.html)**: Learn how to deploy models server-side with TorchServe, offering a step-by-step tutorial for scalable, efficient model serving. + +- **[Implement C++ Deployment](https://pytorch.org/tutorials/advanced/cpp_export.html)**: Dive into the Tutorial on Loading a TorchScript Model in C++, facilitating the integration of your TorchScript models into C++ applications for enhanced performance and versatility. + +## Summary + +In this guide, we explored the process of exporting Ultralytics YOLOv8 models to the TorchScript format. By following the provided instructions, you can optimize YOLOv8 models for performance and gain the flexibility to deploy them across various platforms and environments. + +For further details on usage, visit [TorchScript's official documentation](https://pytorch.org/docs/stable/jit.html). + +Also, if you'd like to know more about other Ultralytics YOLOv8 integrations, visit our [integration guide page](../integrations/index.md). You'll find plenty of useful resources and insights there. + +## FAQ + +### What is Ultralytics YOLOv8 model export to TorchScript? + +Exporting an Ultralytics YOLOv8 model to TorchScript allows for flexible, cross-platform deployment. TorchScript, a part of the PyTorch ecosystem, facilitates the serialization of models, which can then be executed in environments that lack Python support. This makes it ideal for deploying models on embedded systems, C++ environments, mobile applications, and even web browsers. Exporting to TorchScript enables efficient performance and wider applicability of your YOLOv8 models across diverse platforms. + +### How can I export my YOLOv8 model to TorchScript using Ultralytics? + +To export a YOLOv8 model to TorchScript, you can use the following example code: + +!!! example "Usage" + + === "Python" + + ```python + from ultralytics import YOLO + + # Load the YOLOv8 model + model = YOLO("yolov8n.pt") + + # Export the model to TorchScript format + model.export(format="torchscript") # creates 'yolov8n.torchscript' + + # Load the exported TorchScript model + torchscript_model = YOLO("yolov8n.torchscript") + + # Run inference + results = torchscript_model("https://ultralytics.com/images/bus.jpg") + ``` + + === "CLI" + + ```bash + # Export a YOLOv8n PyTorch model to TorchScript format + yolo export model=yolov8n.pt format=torchscript # creates 'yolov8n.torchscript' + + # Run inference with the exported model + yolo predict model=yolov8n.torchscript source='https://ultralytics.com/images/bus.jpg' + ``` + +For more details about the export process, refer to the [Ultralytics documentation on exporting](../modes/export.md). + +### Why should I use TorchScript for deploying YOLOv8 models? + +Using TorchScript for deploying YOLOv8 models offers several advantages: + +- **Portability**: Exported models can run in environments without the need for Python, such as C++ applications, embedded systems, or mobile devices. +- **Optimization**: TorchScript supports static graph execution and Just-In-Time (JIT) compilation, which can optimize model performance. +- **Cross-Language Integration**: TorchScript models can be integrated into other programming languages, enhancing flexibility and expandability. +- **Serialization**: Models can be serialized, allowing for platform-independent loading and inference. + +For more insights into deployment, visit the [PyTorch Mobile Documentation](https://pytorch.org/mobile/home/), [TorchServe Documentation](https://pytorch.org/serve/getting_started.html), and [C++ Deployment Guide](https://pytorch.org/tutorials/advanced/cpp_export.html). + +### What are the installation steps for exporting YOLOv8 models to TorchScript? + +To install the required package for exporting YOLOv8 models, use the following command: + +!!! tip "Installation" + + === "CLI" + + ```bash + # Install the required package for YOLOv8 + pip install ultralytics + ``` + +For detailed instructions, visit the [Ultralytics Installation guide](../quickstart.md). If any issues arise during installation, consult the [Common Issues guide](../guides/yolo-common-issues.md). + +### How do I deploy my exported TorchScript YOLOv8 models? + +After exporting YOLOv8 models to the TorchScript format, you can deploy them across a variety of platforms: + +- **C++ API**: Ideal for low-overhead, highly efficient production environments. +- **Mobile Deployment**: Use [PyTorch Mobile](https://pytorch.org/mobile/home/) for iOS and Android applications. +- **Cloud Deployment**: Utilize services like [TorchServe](https://pytorch.org/serve/getting_started.html) for scalable server-side deployment. + +Explore comprehensive guidelines for deploying models in these settings to take full advantage of TorchScript's capabilities. diff --git a/ultralytics/docs/en/integrations/vscode.md b/ultralytics/docs/en/integrations/vscode.md new file mode 100644 index 0000000000000000000000000000000000000000..71c4dce808a92d58d2a641c5ddd3eb983ba9c33a --- /dev/null +++ b/ultralytics/docs/en/integrations/vscode.md @@ -0,0 +1,276 @@ +--- +comments: true +description: An overview of how the Ultralytics-Snippets extension for Visual Studio Code can help developers accelerate their work with the Ultralytics Python package. +keywords: Visual Studio Code, VS Code, deep learning, convolutional neural networks, computer vision, Python, code snippets, Ultralytics, developer productivity, machine learning, YOLO, developers, productivity, efficiency, learning, programming, IDE, code editor, developer utilities, programming tools +--- + +# Ultralytics VS Code Extension + +

+
+ Snippet Prediction Preview +
+ Run example code using Ultralytics YOLO in under 20 seconds! 🚀 +

+ +## Features and Benefits + +✅ Are you a data scientist or machine learning engineer building computer vision applications with Ultralytics? + +✅ Do you despise writing the same blocks of code repeatedly? + +✅ Are you always forgetting the arguments or default values for the [export], [predict], [train], [track], or [val] methods? + +✅ Looking to get started with Ultralytics and wish you had an _easier_ way to reference or run code examples? + +✅ Want to speed up your development cycle when working with Ultralytics? + +If you use Visual Studio Code and answered 'yes' to any of the above, then the Ultralytics-snippets extension for VS Code is here to help! Read on to learn more about the extension, how to install it, and how to use it. + +## Inspired by the Ultralytics Community + +The inspiration to build this extension came from the Ultralytics Community. Questions from the Community around similar topics and examples fueled the development for this project. Additionally, as some of the Ultralytics Team also uses VS Code, we also use it as a tool to accelerate our work too ⚡. + +## Why VS Code? + +[Visual Studio Code](https://code.visualstudio.com/) is extremely popular with developers worldwide and has ranked most popular by the Stack Overflow Developer Survey in [2021], [2022], [2023], and [2024]. Due to VS Code's high level of customization, built-in features, broad compatibility, and extensibility, it's no surprise that so many developers are using it. Given the popularity in the wider developer community and within the Ultralytics [Discord], [Discourse], [Reddit], and [GitHub] Communities, it made sense to build a VS Code extension to help streamline your workflow and boost your productivity. + +Want to let us know what you use for developing code? Head over to our Discourse [community poll] and let us know! While you're there, maybe check out some of our favorite computer vision, machine learning, AI, and developer [memes], or even post your favorite! + +## Installing the Extension + +!!! note + + Any code environment that will allow for installing VS Code extensions _should be_ compatible with the Ultralytics-snippets extension. After publishing the extension, it was discovered that [neovim](https://neovim.io/) can be made compatible with VS Code extensions. To learn more see the [`neovim` install section][neovim install] of the Readme in the [Ultralytics-Snippets repository][repo]. + +### Installing in VS Code + +1. Navigate to the [Extensions menu in VS Code](https://code.visualstudio.com/docs/editor/extension-marketplace) or use the shortcut Ctrl+Shift ⇑+x, and search for Ultralytics-snippets. + +2. Click the Install button. + +

+
+ VS Code extension menu +
+

+ +### Installing from the VS Code Extension Marketplace + +1. Visit the [VS Code Extension Marketplace](https://marketplace.visualstudio.com/VSCode) and search for Ultralytics-snippets or go straight to the [extension page on the VS Code marketplace]. + +2. Click the Install button and allow your browser to launch a VS Code session. + +3. Follow any prompts to install the extension. + +

+
+ VS Code marketplace extension install +
+ Visual Studio Code Extension Marketplace page for Ultralytics-Snippets +

+ +## Using the Ultralytics-Snippets Extension + +- 🧠 **Intelligent Code Completion:** Write code faster and more accurately with advanced code completion suggestions tailored to the Ultralytics API. + +- ⌛ **Increased Development Speed:** Save time by eliminating repetitive coding tasks and leveraging pre-built code block snippets. + +- 🔬 **Improved Code Quality:** Write cleaner, more consistent, and error-free code with intelligent code completion. + +- 💎 **Streamlined Workflow:** Stay focused on the core logic of your project by automating common tasks. + +### Overview + +The extension will only operate when the [Language Mode](https://code.visualstudio.com/docs/getstarted/tips-and-tricks#_change-language-mode) is configured for Python 🐍. This is to avoid snippets from being inserted when working on any other file type. All snippets have prefix starting with `ultra`, and simply typing `ultra` in your editor after installing the extension, will display a list of possible snippets to use. You can also open the VS Code [Command Palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette) using Ctrl+Shift ⇑+p and running the command `Snippets: Insert Snippet`. + +### Code Snippet Fields + +Many snippets have "fields" with default placeholder values or names. For instance, output from the [predict] method could be saved to a Python variable named `r`, `results`, `detections`, `preds` or whatever else a developer chooses, which is why snippets include "fields". Using Tab ⇥ on your keyboard after a snippet is inserted, your cursor will move between fields quickly. Once a field is selected, typing a new variable name will change that instance, but also every other instance in the snippet code for that variable! + +

+
+ Multi-update field and options +
+ After inserting snippet, renaming model as world_model updates all instances. Pressing Tab ⇥ moves to the next field, which opens a dropdown menu and allows for selection of a model scale, and moving to the next field provides another dropdown to choose either world or worldv2 model variant. +

+ +### Code Snippet Completions + +!!! tip "Even _Shorter_ Shortcuts" + + It's **not** required to type the full prefix of the snippet, or even to start typing from the start of the snippet. See example in the image below. + +The snippets are named in the most descriptive way possible, but this means there could be a lot to type and that would be counterproductive if the aim is to move _faster_. Luckily VS Code lets users type `ultra.example-yolo-predict`, `example-yolo-predict`, `yolo-predict`, or even `ex-yolo-p` and still reach the intended snippet option! If the intended snippet was _actually_ `ultra.example-yolo-predict-kwords`, then just using your keyboard arrows or to highlight the desired snippet and pressing Enter ↵ or Tab ⇥ will insert the correct block of code. + +

+
+ Incomplete Snippet Example +
+ Typing ex-yolo-p will still arrive at the correct snippet. +

+ +### Snippet Categories + +These are the current snippet categories available to the Ultralytics-snippets extension. More will be added in the future, so make sure to check for updates and to enable auto-updates for the extension. You can also [request additional snippets](#how-do-i-request-a-new-snippet) to be added if you feel there's any missing. + +| Category | Starting Prefix | Description | +| :-------- | :--------------- | :-------------------------------------------------------------------------------------------------------------------------------------------- | +| Examples | `ultra.examples` | Example code to help learn or for getting started with Ultralytics. Examples are copies of or similar to code from documentation pages. | +| Kwargs | `ultra.kwargs` | Speed up development by adding snippets for [train], [track], [predict], and [val] methods with all keyword arguments and default values. | +| Imports | `ultra.imports` | Snippets to quickly import common Ultralytics objects. | +| Models | `ultra.yolo` | Insert code blocks for initializing various [models] (`yolo`, `sam`, `rtdetr`, etc.), including dropdown configuration options. | +| Results | `ultra.result` | Code blocks for common operations when [working with inference results]. | +| Utilities | `ultra.util` | Provides quick access to common utilities that are built into the Ultralytics package, learn more about these on the [Simple Utilities page]. | + +### Learning with Examples + +The `ultra.examples` snippets are to useful for anyone looking to learn how to get started with the basics of working with Ultralytics YOLO. Example snippets are intended to run once inserted (some have dropdown options as well). An example of this is shown at the animation at the [top] of this page, where after the snippet is inserted, all code is selected and run interactively using Shift ⇑+Enter ↵. + +!!! example + + Just like the animation shows at the [top] of this page, you can use the snippet `ultra.example-yolo-predict` to insert the following code example. Once inserted, the only configurable option is for the model scale which can be any one of: `n`, `s`, `m`, `l`, or `x`. + + ```python + from ultralytics import ASSETS, YOLO + + model = YOLO("yolov8n.pt", task="detect") + results = model(source=ASSETS / "bus.jpg") + + for result in results: + print(result.boxes.data) + # result.show() # uncomment to view each result image + ``` + +### Accelerating Development + +The aim for snippets other than the `ultra.examples` are for making development easier and quicker when working with Ultralytics. A common code block to be used in many projects, is to iterate the list of `Results` returned from using the model [predict] method. The `ultra.result-loop` snippet can help with this. + +!!! example + + Using the `ultra.result-loop` will insert the following default code (including comments). + + ```python + # reference https://docs.ultralytics.com/modes/predict/#working-with-results + + for result in results: + result.boxes.data # torch.Tensor array + ``` + +However, since Ultralytics supports numerous [tasks], when [working with inference results] there are other `Results` attributes that you may wish to access, which is where the [snippet fields](#code-snippet-fields) will be powerful. + +

+
+ Results Loop Options +
+ Once tabbed to the boxes field, a dropdown menu appears to allow selection of another attribute as required. +

+ +### Keywords Arguments + +There are over 💯 keyword arguments for all of the various Ultralytics [tasks] and [modes]! That's a lot to remember and it can be easy to forget if the argument is `save_frame` or `save_frames` (it's definitely `save_frames` by the way). This is where the `ultra.kwargs` snippets can help out! + +!!! example + + To insert the [predict] method, including all [inference arguments], use `ultra.kwargs-predict`, which will insert the following code (including comments). + + ```python + model.predict( + source=src, # (str, optional) source directory for images or videos + imgsz=640, # (int | list) input images size as int or list[w,h] for predict + conf=0.25, # (float) minimum confidence threshold + iou=0.7, # (float) intersection over union (IoU) threshold for NMS + vid_stride=1, # (int) video frame-rate stride + stream_buffer=False, # (bool) buffer all streaming frames (True) or return the most recent frame (False) + visualize=False, # (bool) visualize model features + augment=False, # (bool) apply image augmentation to prediction sources + agnostic_nms=False, # (bool) class-agnostic NMS + classes=None, # (int | list[int], optional) filter results by class, i.e. classes=0, or classes=[0,2,3] + retina_masks=False, # (bool) use high-resolution segmentation masks + embed=None, # (list[int], optional) return feature vectors/embeddings from given layers + show=False, # (bool) show predicted images and videos if environment allows + save=True, # (bool) save prediction results + save_frames=False, # (bool) save predicted individual video frames + save_txt=False, # (bool) save results as .txt file + save_conf=False, # (bool) save results with confidence scores + save_crop=False, # (bool) save cropped images with results + stream=False, # (bool) for processing long videos or numerous images with reduced memory usage by returning a generator + verbose=True, # (bool) enable/disable verbose inference logging in the terminal + ) + ``` + + This snippet has fields for all the keyword arguments, but also for `model` and `src` in case you've used a different variable in your code. On each line containing a keyword argument, a brief description is included for reference. + +### All Code Snippets + +The best way to find out what snippets are available is to download and install the extension and try it out! If you're curious and want to take a look at the list beforehand, you can visit the [repo] or [extension page on the VS Code marketplace] to view the tables for all available snippets. + +## Conclusion + +The Ultralytics-Snippets extension for VS Code is designed to empower data scientists and machine learning engineers to build computer vision applications using Ultralytics YOLO more efficiently. By providing pre-built code snippets and useful examples, we help you focus on what matters most: creating innovative solutions. Please share your feedback by visiting the [extension page on the VS Code marketplace] and leaving a review. ⭐ + +## FAQ + +### How do I request a new snippet? + +New snippets can be requested using the Issues on the Ultralytics-Snippets [repo]. + +### How much does the Ultralytics-Extension Cost? + +It's 100% free! + +### Why don't I see a code snippet preview? + +VS Code uses the key combination Ctrl+Space to show more/less information in the preview window. If you're not seeing a snippet preview when you type in a code snippet prefix, using this key combination should restore the preview. + +### How do I disable the extension recommendation in Ultralytics? + +If you use VS Code and have started to see a message prompting you to install the Ultralytics-snippets extension, and don't want to see the message any more, there are two ways to disable this message. + +1. Install Ultralytics-snippets and the message will no longer be shown 😆! + +2. You can using `yolo settings vscode_msg False` to disable the message from showing without having to install the extension. You can learn more about the [Ultralytics Settings] on the [quickstart] page if you're unfamiliar. + +### I have an idea for a new Ultralytics code snippet, how can I get one added? + +Visit the Ultralytics-snippets [repo] and open an Issue or Pull Request! + +### How do I uninstall the Ultralytics-Snippets Extension? + +Like any other VS Code extension, you can uninstall it by navigating to the Extensions menu in VS Code. Find the Ultralytics-snippets extension in the menu and click the cog icon (⚙) and then click on "Uninstall" to remove the extension. + +

+
+ VS Code extension menu +
+

+ + + +[top]: #ultralytics-vs-code-extension +[export]: ../modes/export.md +[predict]: ../modes/predict.md +[track]: ../modes/track.md +[train]: ../modes/train.md +[val]: ../modes/val.md +[tasks]: ../tasks/index.md +[modes]: ../modes/index.md +[models]: ../models/index.md +[working with inference results]: ../modes/predict.md#working-with-results +[inference arguments]: ../modes/predict.md#inference-arguments +[Simple Utilities page]: ../usage/simple-utilities.md +[Ultralytics Settings]: ../quickstart.md/#ultralytics-settings +[quickstart]: ../quickstart.md +[Discord]: https://ultralytics.com/discord +[Discourse]: https://community.ultralytics.com +[Reddit]: https://reddit.com/r/Ultralytics +[GitHub]: https://github.com/ultralytics +[community poll]: https://community.ultralytics.com/t/what-do-you-use-to-write-code/89/1 +[memes]: https://community.ultralytics.com/c/off-topic/memes-jokes/11 +[repo]: https://github.com/Burhan-Q/ultralytics-snippets +[extension page on the VS Code marketplace]: https://marketplace.visualstudio.com/items?itemName=Ultralytics.ultralytics-snippets +[neovim install]: https://github.com/Burhan-Q/ultralytics-snippets?tab=readme-ov-file#use-with-neovim +[2021]: https://survey.stackoverflow.co/2021#section-most-popular-technologies-integrated-development-environment +[2022]: https://survey.stackoverflow.co/2022/#section-most-popular-technologies-integrated-development-environment +[2023]: https://survey.stackoverflow.co/2023/#section-most-popular-technologies-integrated-development-environment +[2024]: https://survey.stackoverflow.co/2024/technology/#1-integrated-development-environment diff --git a/ultralytics/docs/en/integrations/weights-biases.md b/ultralytics/docs/en/integrations/weights-biases.md new file mode 100644 index 0000000000000000000000000000000000000000..232860f92fadd8d1ee86013074ee936ec7db480d --- /dev/null +++ b/ultralytics/docs/en/integrations/weights-biases.md @@ -0,0 +1,244 @@ +--- +comments: true +description: Learn how to enhance YOLOv8 experiment tracking and visualization with Weights & Biases for better model performance and management. +keywords: YOLOv8, Weights & Biases, model training, experiment tracking, Ultralytics, machine learning, computer vision, model visualization +--- + +# Enhancing YOLOv8 Experiment Tracking and Visualization with Weights & Biases + +Object detection models like [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics) have become integral to many computer vision applications. However, training, evaluating, and deploying these complex models introduces several challenges. Tracking key training metrics, comparing model variants, analyzing model behavior, and detecting issues require substantial instrumentation and experiment management. + +

+
+ +
+ Watch: How to use Ultralytics YOLOv8 with Weights and Biases +

+ +This guide showcases Ultralytics YOLOv8 integration with Weights & Biases' for enhanced experiment tracking, model-checkpointing, and visualization of model performance. It also includes instructions for setting up the integration, training, fine-tuning, and visualizing results using Weights & Biases' interactive features. + +## Weights & Biases + +

+ Weights & Biases Overview +

+ +[Weights & Biases](https://wandb.ai/site) is a cutting-edge MLOps platform designed for tracking, visualizing, and managing machine learning experiments. It features automatic logging of training metrics for full experiment reproducibility, an interactive UI for streamlined data analysis, and efficient model management tools for deploying across various environments. + +## YOLOv8 Training with Weights & Biases + +You can use Weights & Biases to bring efficiency and automation to your YOLOv8 training process. + +## Installation + +To install the required packages, run: + +!!! tip "Installation" + + === "CLI" + + ```bash + # Install the required packages for YOLOv8 and Weights & Biases + pip install --upgrade ultralytics==8.0.186 wandb + ``` + +For detailed instructions and best practices related to the installation process, be sure to check our [YOLOv8 Installation guide](../quickstart.md). While installing the required packages for YOLOv8, if you encounter any difficulties, consult our [Common Issues guide](../guides/yolo-common-issues.md) for solutions and tips. + +## Configuring Weights & Biases + +After installing the necessary packages, the next step is to set up your Weights & Biases environment. This includes creating a Weights & Biases account and obtaining the necessary API key for a smooth connection between your development environment and the W&B platform. + +Start by initializing the Weights & Biases environment in your workspace. You can do this by running the following command and following the prompted instructions. + +!!! tip "Initial SDK Setup" + + === "CLI" + + ```bash + # Initialize your Weights & Biases environment + import wandb + wandb.login() + ``` + +Navigate to the Weights & Biases authorization page to create and retrieve your API key. Use this key to authenticate your environment with W&B. + +## Usage: Training YOLOv8 with Weights & Biases + +Before diving into the usage instructions for YOLOv8 model training with Weights & Biases, be sure to check out the range of [YOLOv8 models offered by Ultralytics](../models/index.md). This will help you choose the most appropriate model for your project requirements. + +!!! example "Usage: Training YOLOv8 with Weights & Biases" + + === "Python" + + ```python + import wandb + from wandb.integration.ultralytics import add_wandb_callback + + from ultralytics import YOLO + + # Initialize a Weights & Biases run + wandb.init(project="ultralytics", job_type="training") + + # Load a YOLO model + model = YOLO("yolov8n.pt") + + # Add W&B Callback for Ultralytics + add_wandb_callback(model, enable_model_checkpointing=True) + + # Train and Fine-Tune the Model + model.train(project="ultralytics", data="coco8.yaml", epochs=5, imgsz=640) + + # Validate the Model + model.val() + + # Perform Inference and Log Results + model(["path/to/image1", "path/to/image2"]) + + # Finalize the W&B Run + wandb.finish() + ``` + +### Understanding the Code + +Let's understand the steps showcased in the usage code snippet above. + +- **Step 1: Initialize a Weights & Biases Run**: Start by initializing a Weights & Biases run, specifying the project name and the job type. This run will track and manage the training and validation processes of your model. + +- **Step 2: Define the YOLOv8 Model and Dataset**: Specify the model variant and the dataset you wish to use. The YOLO model is then initialized with the specified model file. + +- **Step 3: Add Weights & Biases Callback for Ultralytics**: This step is crucial as it enables the automatic logging of training metrics and validation results to Weights & Biases, providing a detailed view of the model's performance. + +- **Step 4: Train and Fine-Tune the Model**: Begin training the model with the specified dataset, number of epochs, and image size. The training process includes logging of metrics and predictions at the end of each epoch, offering a comprehensive view of the model's learning progress. + +- **Step 5: Validate the Model**: After training, the model is validated. This step is crucial for assessing the model's performance on unseen data and ensuring its generalizability. + +- **Step 6: Perform Inference and Log Results**: The model performs predictions on specified images. These predictions, along with visual overlays and insights, are automatically logged in a W&B Table for interactive exploration. + +- **Step 7: Finalize the W&B Run**: This step marks the end of data logging and saves the final state of your model's training and validation process in the W&B dashboard. + +### Understanding the Output + +Upon running the usage code snippet above, you can expect the following key outputs: + +- The setup of a new run with its unique ID, indicating the start of the training process. +- A concise summary of the model's structure, including the number of layers and parameters. +- Regular updates on important metrics such as box loss, cls loss, dfl loss, precision, recall, and mAP scores during each training epoch. +- At the end of training, detailed metrics including the model's inference speed, and overall accuracy metrics are displayed. +- Links to the Weights & Biases dashboard for in-depth analysis and visualization of the training process, along with information on local log file locations. + +### Viewing the Weights & Biases Dashboard + +After running the usage code snippet, you can access the Weights & Biases (W&B) dashboard through the provided link in the output. This dashboard offers a comprehensive view of your model's training process with YOLOv8. + +## Key Features of the Weights & Biases Dashboard + +- **Real-Time Metrics Tracking**: Observe metrics like loss, accuracy, and validation scores as they evolve during the training, offering immediate insights for model tuning. [See how experiments are tracked using Weights & Biases](https://imgur.com/D6NVnmN). + +- **Hyperparameter Optimization**: Weights & Biases aids in fine-tuning critical parameters such as learning rate, batch size, and more, enhancing the performance of YOLOv8. + +- **Comparative Analysis**: The platform allows side-by-side comparisons of different training runs, essential for assessing the impact of various model configurations. + +- **Visualization of Training Progress**: Graphical representations of key metrics provide an intuitive understanding of the model's performance across epochs. [See how Weights & Biases helps you visualize validation results](https://imgur.com/a/kU5h7W4). + +- **Resource Monitoring**: Keep track of CPU, GPU, and memory usage to optimize the efficiency of the training process. + +- **Model Artifacts Management**: Access and share model checkpoints, facilitating easy deployment and collaboration. + +- **Viewing Inference Results with Image Overlay**: Visualize the prediction results on images using interactive overlays in Weights & Biases, providing a clear and detailed view of model performance on real-world data. For more detailed information on Weights & Biases' image overlay capabilities, check out this [link](https://docs.wandb.ai/guides/track/log/media#image-overlays). [See how Weights & Biases' image overlays helps visualize model inferences](https://imgur.com/a/UTSiufs). + +By using these features, you can effectively track, analyze, and optimize your YOLOv8 model's training, ensuring the best possible performance and efficiency. + +## Summary + +This guide helped you explore Ultralytics' YOLOv8 integration with Weights & Biases. It illustrates the ability of this integration to efficiently track and visualize model training and prediction results. + +For further details on usage, visit [Weights & Biases' official documentation](https://docs.wandb.ai/guides/integrations/ultralytics). + +Also, be sure to check out the [Ultralytics integration guide page](../integrations/index.md), to learn more about different exciting integrations. + +## FAQ + +### How do I install the required packages for YOLOv8 and Weights & Biases? + +To install the required packages for YOLOv8 and Weights & Biases, open your command line interface and run: + +```bash +pip install --upgrade ultralytics==8.0.186 wandb +``` + +For further guidance on installation steps, refer to our [YOLOv8 Installation guide](../quickstart.md). If you encounter issues, consult the [Common Issues guide](../guides/yolo-common-issues.md) for troubleshooting tips. + +### What are the benefits of integrating Ultralytics YOLOv8 with Weights & Biases? + +Integrating Ultralytics YOLOv8 with Weights & Biases offers several benefits including: + +- **Real-Time Metrics Tracking:** Observe metric changes during training for immediate insights. +- **Hyperparameter Optimization:** Improve model performance by fine-tuning learning rate, batch size, etc. +- **Comparative Analysis:** Side-by-side comparison of different training runs. +- **Resource Monitoring:** Keep track of CPU, GPU, and memory usage. +- **Model Artifacts Management:** Easy access and sharing of model checkpoints. + +Explore these features in detail in the Weights & Biases Dashboard section above. + +### How can I configure Weights & Biases for YOLOv8 training? + +To configure Weights & Biases for YOLOv8 training, follow these steps: + +1. Run the command to initialize Weights & Biases: + ```bash + import wandb + wandb.login() + ``` +2. Retrieve your API key from the Weights & Biases website. +3. Use the API key to authenticate your development environment. + +Detailed setup instructions can be found in the Configuring Weights & Biases section above. + +### How do I train a YOLOv8 model using Weights & Biases? + +For training a YOLOv8 model using Weights & Biases, use the following steps in a Python script: + +```python +import wandb +from wandb.integration.ultralytics import add_wandb_callback + +from ultralytics import YOLO + +# Initialize a Weights & Biases run +wandb.init(project="ultralytics", job_type="training") + +# Load a YOLO model +model = YOLO("yolov8n.pt") + +# Add W&B Callback for Ultralytics +add_wandb_callback(model, enable_model_checkpointing=True) + +# Train and Fine-Tune the Model +model.train(project="ultralytics", data="coco8.yaml", epochs=5, imgsz=640) + +# Validate the Model +model.val() + +# Perform Inference and Log Results +model(["path/to/image1", "path/to/image2"]) + +# Finalize the W&B Run +wandb.finish() +``` + +This script initializes Weights & Biases, sets up the model, trains it, and logs results. For more details, visit the Usage section above. + +### Why should I use Ultralytics YOLOv8 with Weights & Biases over other platforms? + +Ultralytics YOLOv8 integrated with Weights & Biases offers several unique advantages: + +- **High Efficiency:** Real-time tracking of training metrics and performance optimization. +- **Scalability:** Easily manage large-scale training jobs with robust resource monitoring and utilization tools. +- **Interactivity:** A user-friendly interactive UI for data visualization and model management. +- **Community and Support:** Strong integration documentation and community support with flexible customization and enhancement options. + +For comparisons with other platforms like Comet and ClearML, refer to [Ultralytics integrations](../integrations/index.md).