首页 > 编程语言 >Yolov8-源码解析-十-

Yolov8-源码解析-十-

时间:2024-09-05 12:07:50浏览次数:12  
标签:YOLO models Ultralytics Yolov8 源码 our model 解析 your

Yolov8 源码解析(十)


comments: true
description: Learn how to ensure thread-safe YOLO model inference in Python. Avoid race conditions and run your multi-threaded tasks reliably with best practices.
keywords: YOLO models, thread-safe, Python threading, model inference, concurrency, race conditions, multi-threaded, parallelism, Python GIL

Thread-Safe Inference with YOLO Models

Running YOLO models in a multi-threaded environment requires careful consideration to ensure thread safety. Python's threading module allows you to run several threads concurrently, but when it comes to using YOLO models across these threads, there are important safety issues to be aware of. This page will guide you through creating thread-safe YOLO model inference.

Understanding Python Threading

Python threads are a form of parallelism that allow your program to run multiple operations at once. However, Python's Global Interpreter Lock (GIL) means that only one thread can execute Python bytecode at a time.

Single vs Multi-Thread Examples

While this sounds like a limitation, threads can still provide concurrency, especially for I/O-bound operations or when using operations that release the GIL, like those performed by YOLO's underlying C libraries.

The Danger of Shared Model Instances

Instantiating a YOLO model outside your threads and sharing this instance across multiple threads can lead to race conditions, where the internal state of the model is inconsistently modified due to concurrent accesses. This is particularly problematic when the model or its components hold state that is not designed to be thread-safe.

Non-Thread-Safe Example: Single Model Instance

When using threads in Python, it's important to recognize patterns that can lead to concurrency issues. Here is what you should avoid: sharing a single YOLO model instance across multiple threads.

# Unsafe: Sharing a single model instance across threads
from threading import Thread

from ultralytics import YOLO

# Instantiate the model outside the thread
shared_model = YOLO("yolov8n.pt")


def predict(image_path):
    """Predicts objects in an image using a preloaded YOLO model, take path string to image as argument."""
    results = shared_model.predict(image_path)
    # Process results


# Starting threads that share the same model instance
Thread(target=predict, args=("image1.jpg",)).start()
Thread(target=predict, args=("image2.jpg",)).start()

In the example above, the shared_model is used by multiple threads, which can lead to unpredictable results because predict could be executed simultaneously by multiple threads.

Non-Thread-Safe Example: Multiple Model Instances

Similarly, here is an unsafe pattern with multiple YOLO model instances:

# Unsafe: Sharing multiple model instances across threads can still lead to issues
from threading import Thread

from ultralytics import YOLO

# Instantiate multiple models outside the thread
shared_model_1 = YOLO("yolov8n_1.pt")
shared_model_2 = YOLO("yolov8n_2.pt")


def predict(model, image_path):
    """Runs prediction on an image using a specified YOLO model, returning the results."""
    results = model.predict(image_path)
    # Process results


# Starting threads with individual model instances
Thread(target=predict, args=(shared_model_1, "image1.jpg")).start()
Thread(target=predict, args=(shared_model_2, "image2.jpg")).start()

Even though there are two separate model instances, the risk of concurrency issues still exists. If the internal implementation of YOLO is not thread-safe, using separate instances might not prevent race conditions, especially if these instances share any underlying resources or states that are not thread-local.

Thread-Safe Inference

To perform thread-safe inference, you should instantiate a separate YOLO model within each thread. This ensures that each thread has its own isolated model instance, eliminating the risk of race conditions.

Thread-Safe Example

Here's how to instantiate a YOLO model inside each thread for safe parallel inference:

# Safe: Instantiating a single model inside each thread
from threading import Thread

from ultralytics import YOLO


def thread_safe_predict(image_path):
    """Predict on an image using a new YOLO model instance in a thread-safe manner; takes image path as input."""
    local_model = YOLO("yolov8n.pt")
    results = local_model.predict(image_path)
    # Process results


# Starting threads that each have their own model instance
Thread(target=thread_safe_predict, args=("image1.jpg",)).start()
Thread(target=thread_safe_predict, args=("image2.jpg",)).start()

In this example, each thread creates its own YOLO instance. This prevents any thread from interfering with the model state of another, thus ensuring that each thread performs inference safely and without unexpected interactions with the other threads.

Conclusion

When using YOLO models with Python's threading, always instantiate your models within the thread that will use them to ensure thread safety. This practice avoids race conditions and makes sure that your inference tasks run reliably.

For more advanced scenarios and to further optimize your multi-threaded inference performance, consider using process-based parallelism with multiprocessing or leveraging a task queue with dedicated worker processes.

FAQ

How can I avoid race conditions when using YOLO models in a multi-threaded Python environment?

To prevent race conditions when using Ultralytics YOLO models in a multi-threaded Python environment, instantiate a separate YOLO model within each thread. This ensures that each thread has its own isolated model instance, avoiding concurrent modification of the model state.

Example:

from threading import Thread

from ultralytics import YOLO


def thread_safe_predict(image_path):
    """Predict on an image in a thread-safe manner."""
    local_model = YOLO("yolov8n.pt")
    results = local_model.predict(image_path)
    # Process results


Thread(target=thread_safe_predict, args=("image1.jpg",)).start()
Thread(target=thread_safe_predict, args=("image2.jpg",)).start()

For more information on ensuring thread safety, visit the Thread-Safe Inference with YOLO Models.

What are the best practices for running multi-threaded YOLO model inference in Python?

To run multi-threaded YOLO model inference safely in Python, follow these best practices:

  1. Instantiate YOLO models within each thread rather than sharing a single model instance across threads.
  2. Use Python's multiprocessing module for parallel processing to avoid issues related to Global Interpreter Lock (GIL).
  3. Release the GIL by using operations performed by YOLO's underlying C libraries.

Example for thread-safe model instantiation:

from threading import Thread

from ultralytics import YOLO


def thread_safe_predict(image_path):
    """Runs inference in a thread-safe manner with a new YOLO model instance."""
    model = YOLO("yolov8n.pt")
    results = model.predict(image_path)
    # Process results


# Initiate multiple threads
Thread(target=thread_safe_predict, args=("image1.jpg",)).start()
Thread(target=thread_safe_predict, args=("image2.jpg",)).start()

For additional context, refer to the section on Thread-Safe Inference.

Why should each thread have its own YOLO model instance?

Each thread should have its own YOLO model instance to prevent race conditions. When a single model instance is shared among multiple threads, concurrent accesses can lead to unpredictable behavior and modifications of the model's internal state. By using separate instances, you ensure thread isolation, making your multi-threaded tasks reliable and safe.

For detailed guidance, check the Non-Thread-Safe Example: Single Model Instance and Thread-Safe Example sections.

How does Python's Global Interpreter Lock (GIL) affect YOLO model inference?

Python's Global Interpreter Lock (GIL) allows only one thread to execute Python bytecode at a time, which can limit the performance of CPU-bound multi-threading tasks. However, for I/O-bound operations or processes that use libraries releasing the GIL, like YOLO's C libraries, you can still achieve concurrency. For enhanced performance, consider using process-based parallelism with Python's multiprocessing module.

For more about threading in Python, see the Understanding Python Threading section.

Is it safer to use process-based parallelism instead of threading for YOLO model inference?

Yes, using Python's multiprocessing module is safer and often more efficient for running YOLO model inference in parallel. Process-based parallelism creates separate memory spaces, avoiding the Global Interpreter Lock (GIL) and reducing the risk of concurrency issues. Each process will operate independently with its own YOLO model instance.

For further details on process-based parallelism with YOLO models, refer to the page on Thread-Safe Inference.


Continuous Integration (CI)

Continuous Integration (CI) is an essential aspect of software development which involves integrating changes and testing them automatically. CI allows us to maintain high-quality code by catching issues early and often in the development process. At Ultralytics, we use various CI tests to ensure the quality and integrity of our codebase.

CI Actions

Here's a brief description of our CI actions:

  • CI: This is our primary CI test that involves running unit tests, linting checks, and sometimes more comprehensive tests depending on the repository.
  • Docker Deployment: This test checks the deployment of the project using Docker to ensure the Dockerfile and related scripts are working correctly.
  • Broken Links: This test scans the codebase for any broken or dead links in our markdown or HTML files.
  • CodeQL: CodeQL is a tool from GitHub that performs semantic analysis on our code, helping to find potential security vulnerabilities and maintain high-quality code.
  • PyPI Publishing: This test checks if the project can be packaged and published to PyPi without any errors.

CI Results

Below is the table showing the status of these CI tests for our main repositories:

Repository CI Docker Deployment Broken Links CodeQL PyPI and Docs Publishing
yolov3 YOLOv3 CI Publish Docker Images Check Broken links CodeQL
yolov5 YOLOv5 CI Publish Docker Images Check Broken links CodeQL
ultralytics ultralytics CI Publish Docker Images Check Broken links CodeQL Publish to PyPI and Deploy Docs
hub HUB CI Check Broken links
docs Check Broken linksCheck Domains pages-build-deployment

Each badge shows the status of the last run of the corresponding CI test on the main branch of the respective repository. If a test fails, the badge will display a "failing" status, and if it passes, it will display a "passing" status.

If you notice a test failing, it would be a great help if you could report it through a GitHub issue in the respective repository.

Remember, a successful CI test does not mean that everything is perfect. It is always recommended to manually review the code before deployment or merging changes.

Code Coverage

Code coverage is a metric that represents the percentage of your codebase that is executed when your tests run. It provides insight into how well your tests exercise your code and can be crucial in identifying untested parts of your application. A high code coverage percentage is often associated with a lower likelihood of bugs. However, it's essential to understand that code coverage does not guarantee the absence of defects. It merely indicates which parts of the code have been executed by the tests.

Integration with codecov.io

At Ultralytics, we have integrated our repositories with codecov.io, a popular online platform for measuring and visualizing code coverage. Codecov provides detailed insights, coverage comparisons between commits, and visual overlays directly on your code, indicating which lines were covered.

By integrating with Codecov, we aim to maintain and improve the quality of our code by focusing on areas that might be prone to errors or need further testing.

Coverage Results

To quickly get a glimpse of the code coverage status of the ultralytics python package, we have included a badge and sunburst visual of the ultralytics coverage results. These images show the percentage of code covered by our tests, offering an at-a-glance metric of our testing efforts. For full details please see https://codecov.io/github/ultralytics/ultralytics.

Repository Code Coverage
ultralytics codecov

In the sunburst graphic below, the innermost circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.

Ultralytics Codecov Image

FAQ

What is Continuous Integration (CI) in Ultralytics?

Continuous Integration (CI) in Ultralytics involves automatically integrating and testing code changes to ensure high-quality standards. Our CI setup includes running unit tests, linting checks, and comprehensive tests. Additionally, we perform Docker deployment, broken link checks, CodeQL analysis for security vulnerabilities, and PyPI publishing to package and distribute our software.

Ultralytics uses a specific CI action to check for broken links within our markdown and HTML files. This helps maintain the integrity of our documentation by scanning and identifying dead or broken links, ensuring that users always have access to accurate and live resources.

Why is CodeQL analysis important for Ultralytics' codebase?

CodeQL analysis is crucial for Ultralytics as it performs semantic code analysis to find potential security vulnerabilities and maintain high-quality standards. With CodeQL, we can proactively identify and mitigate risks in our code, helping us deliver robust and secure software solutions.

How does Ultralytics utilize Docker for deployment?

Ultralytics employs Docker to validate the deployment of our projects through a dedicated CI action. This process ensures that our Dockerfile and associated scripts are functioning correctly, allowing for consistent and reproducible deployment environments which are critical for scalable and reliable AI solutions.

What is the role of automated PyPI publishing in Ultralytics?

Automated PyPI publishing ensures that our projects can be packaged and published without errors. This step is essential for distributing Ultralytics' Python packages, allowing users to easily install and use our tools via the Python Package Index (PyPI).

How does Ultralytics measure code coverage and why is it important?

Ultralytics measures code coverage by integrating with Codecov, providing insights into how much of the codebase is executed during tests. High code coverage can indicate well-tested code, helping to uncover untested areas that might be prone to bugs. Detailed code coverage metrics can be explored via badges displayed on our main repositories or directly on Codecov.


Ultralytics Individual Contributor License Agreement

Thank you for your interest in contributing to open source software projects (“Projects”) made available by Ultralytics Inc. (“Ultralytics”). This Individual Contributor License Agreement (“Agreement”) sets out the terms governing any source code, object code, bug fixes, configuration changes, tools, specifications, documentation, data, materials, feedback, information or other works of authorship that you submit or have submitted, in any form and in any manner, to Ultralytics in respect of any Projects (collectively “Contributions”). If you have any questions respecting this Agreement, please contact [email protected].

You agree that the following terms apply to all of your past, present and future Contributions. Except for the licenses granted in this Agreement, you retain all of your right, title and interest in and to your Contributions.

Copyright License. You hereby grant, and agree to grant, to Ultralytics a non-exclusive, perpetual, irrevocable, worldwide, fully-paid, royalty-free, transferable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, and distribute your Contributions and such derivative works, with the right to sublicense the foregoing rights through multiple tiers of sublicensees.

Patent License. You hereby grant, and agree to grant, to Ultralytics a non-exclusive, perpetual, irrevocable, worldwide, fully-paid, royalty-free, transferable patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer your Contributions, where such license applies only to those patent claims licensable by you that are necessarily infringed by your Contributions alone or by combination of your Contributions with the Project to which such Contributions were submitted, with the right to sublicense the foregoing rights through multiple tiers of sublicensees.

Moral Rights. To the fullest extent permitted under applicable law, you hereby waive, and agree not to assert, all of your “moral rights” in or relating to your Contributions for the benefit of Ultralytics, its assigns, and their respective direct and indirect sublicensees.

Third Party Content/Rights. If your Contribution includes or is based on any source code, object code, bug fixes, configuration changes, tools, specifications, documentation, data, materials, feedback, information or other works of authorship that were not authored by you (“Third Party Content”) or if you are aware of any third party intellectual property or proprietary rights associated with your Contribution (“Third Party Rights”), then you agree to include with the submission of your Contribution full details respecting such Third Party Content and Third Party Rights, including, without limitation, identification of which aspects of your Contribution contain Third Party Content or are associated with Third Party Rights, the owner/author of the Third Party Content and Third Party Rights, where you obtained the Third Party Content, and any applicable third party license terms or restrictions respecting the Third Party Content and Third Party Rights. For greater certainty, the foregoing obligations respecting the identification of Third Party Content and Third Party Rights do not apply to any portion of a Project that is incorporated into your Contribution to that same Project.

Representations. You represent that, other than the Third Party Content and Third Party Rights identified by you in accordance with this Agreement, you are the sole author of your Contributions and are legally entitled to grant the foregoing licenses and waivers in respect of your Contributions. If your Contributions were created in the course of your employment with your past or present employer(s), you represent that such employer(s) has authorized you to make your Contributions on behalf of such employer(s) or such employer(s) has waived all of their right, title or interest in or to your Contributions.

Disclaimer. To the fullest extent permitted under applicable law, your Contributions are provided on an "asis" basis, without any warranties or conditions, express or implied, including, without limitation, any implied warranties or conditions of non-infringement, merchantability or fitness for a particular purpose. You are not required to provide support for your Contributions, except to the extent you desire to provide support.

No Obligation. You acknowledge that Ultralytics is under no obligation to use or incorporate your Contributions into any of the Projects. The decision to use or incorporate your Contributions into any of the Projects will be made at the sole discretion of Ultralytics or its authorized delegates.

Disputes. This Agreement shall be governed by and construed in accordance with the laws of the State of New York, United States of America, without giving effect to its principles or rules regarding conflicts of laws, other than such principles directing application of New York law. The parties hereby submit to venue in, and jurisdiction of the courts located in New York, New York for purposes relating to this Agreement. In the event that any of the provisions of this Agreement shall be held by a court or other tribunal of competent jurisdiction to be unenforceable, the remaining portions hereof shall remain in full force and effect.

Assignment. You agree that Ultralytics may assign this Agreement, and all of its rights, obligations and licenses hereunder.

FAQ

What is the purpose of the Ultralytics Individual Contributor License Agreement?

The Ultralytics Individual Contributor License Agreement (ICLA) governs the terms under which you contribute to Ultralytics' open-source projects. It sets out the rights and obligations related to your contributions, including granting copyright and patent licenses, waiving moral rights, and disclosing any third-party content.

Agreeing to the Copyright License allows Ultralytics to use and distribute your contributions, including making derivative works. This ensures that your contributions can be integrated into Ultralytics projects and shared with the community, fostering collaboration and software development.

How does the Patent License benefit both contributors and Ultralytics?

The Patent License grants Ultralytics the rights to use, make, and sell contributions covered by your patents, which is crucial for product development and commercialization. In return, it allows your patented innovations to be more widely used and recognized, promoting innovation within the community.

What should I do if my contribution contains third-party content?

If your contribution includes third-party content or you are aware of any third-party intellectual property rights, you must provide full details of such content and rights when submitting your contribution. This includes identifying the third-party content, its author, and the applicable license terms. For more information on third-party content, refer to the Third Party Content/Rights section of the Agreement.

What happens if Ultralytics does not use my contributions?

Ultralytics is not obligated to use or incorporate your contributions into any projects. The decision to use or integrate contributions is at Ultralytics' sole discretion. This means that while your contributions are valuable, they may not always align with the project's current needs or directions. For further details, see the No Obligation section.


comments: true
description: Join our welcoming community! Learn about the Ultralytics Code of Conduct to ensure a harassment-free experience for all participants.
keywords: Ultralytics, Contributor Covenant, Code of Conduct, community guidelines, harassment-free, inclusive community, diversity, enforcement policy

Ultralytics Contributor Covenant Code of Conduct

Our Pledge

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socioeconomic status, nationality, personal appearance, race, religion, or sexual identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.

Our Standards

Examples of behavior that contributes to a positive environment for our community include:

  • Demonstrating empathy and kindness toward other people
  • Being respectful of differing opinions, viewpoints, and experiences
  • Giving and gracefully accepting constructive feedback
  • Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
  • Focusing on what is best not just for us as individuals, but for the overall community

Examples of unacceptable behavior include:

  • The use of sexualized language or imagery, and sexual attention or advances of any kind
  • Trolling, insulting or derogatory comments, and personal or political attacks
  • Public or private harassment
  • Publishing others' private information, such as a physical or email address, without their explicit permission
  • Other conduct which could reasonably be considered inappropriate in a professional setting

Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.

Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.

Scope

This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.

Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [email protected]. All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the reporter of any incident.

Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:

1. Correction

Community Impact: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.

Consequence: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.

2. Warning

Community Impact: A violation through a single incident or series of actions.

Consequence: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.

3. Temporary Ban

Community Impact: A serious violation of community standards, including sustained inappropriate behavior.

Consequence: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.

4. Permanent Ban

Community Impact: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.

Consequence: A permanent ban from any sort of public interaction within the community.

Attribution

This Code of Conduct is adapted from the Contributor Covenant, version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by Mozilla's code of conduct enforcement ladder.

For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.

FAQ

What is the Ultralytics Contributor Covenant Code of Conduct?

The Ultralytics Contributor Covenant Code of Conduct aims to create a harassment-free experience for everyone participating in the Ultralytics community. It applies to all community interactions, including online and offline activities. The code details expected behaviors, unacceptable behaviors, and the enforcement responsibilities of community leaders. For more detailed information, see the Enforcement Responsibilities section.

How does the enforcement process work for the Ultralytics Code of Conduct?

Enforcement of the Ultralytics Code of Conduct is managed by community leaders who can take appropriate action in response to any behavior deemed inappropriate. This could range from a private warning to a permanent ban, depending on the severity of the violation. Instances of misconduct can be reported to [email protected] for investigation. Learn more about the enforcement steps in the Enforcement Guidelines section.

Why is diversity and inclusion important in the Ultralytics community?

Ultralytics values diversity and inclusion as fundamental aspects for fostering innovation and creativity within its community. A diverse and inclusive environment allows different perspectives and experiences to contribute to an open, welcoming, and healthy community. This commitment is reflected in our Pledge to ensure a harassment-free experience for everyone regardless of their background.

How can I contribute to Ultralytics while adhering to the Code of Conduct?

Contributing to Ultralytics means engaging positively and respectfully with other community members. You can contribute by demonstrating empathy, offering and accepting constructive feedback, and taking responsibility for any mistakes. Always aim to contribute in a way that benefits the entire community. For more details on acceptable behaviors, refer to the Our Standards section.

Where can I find additional information about the Ultralytics Code of Conduct?

For more comprehensive details about the Ultralytics Code of Conduct, including reporting guidelines and enforcement policies, you can visit the Contributor Covenant homepage or check the FAQ section of Contributor Covenant. Learn more about Ultralytics' goals and initiatives on our brand page and about page.

Should you have more questions or need further assistance, check our Help Center and Contributing Guide for more information.


comments: true
description: Learn how to contribute to Ultralytics YOLO open-source repositories. Follow guidelines for pull requests, code of conduct, and bug reporting.
keywords: Ultralytics, YOLO, open-source, contribution, pull request, code of conduct, bug reporting, GitHub, CLA, Google-style docstrings

Contributing to Ultralytics Open-Source YOLO Repositories

Thank you for your interest in contributing to Ultralytics open-source YOLO repositories! Your contributions will enhance the project and benefit the entire community. This document provides guidelines and best practices to help you get started.

Table of Contents

  1. Code of Conduct
  2. Contributing via Pull Requests
  3. Reporting Bugs
  4. License
  5. Conclusion

Code of Conduct

All contributors must adhere to the Code of Conduct to ensure a welcoming and inclusive environment for everyone.

Contributing via Pull Requests

We welcome contributions in the form of pull requests. To streamline the review process, please follow these guidelines:

  1. Fork the repository: Fork the Ultralytics YOLO repository to your GitHub account.

  2. Create a branch: Create a new branch in your forked repository with a descriptive name for your changes.

  3. Make your changes: Ensure that your changes follow the project's coding style and do not introduce new errors or warnings.

  4. Test your changes: Test your changes locally to ensure they work as expected and do not introduce new issues.

  5. Commit your changes: Commit your changes with a descriptive commit message. Include any relevant issue numbers in your commit message.

  6. Create a pull request: Create a pull request from your forked repository to the main Ultralytics YOLO repository. Provide a clear explanation of your changes and how they improve the project.

CLA Signing

Before we can accept your pull request, you must sign a Contributor License Agreement (CLA). This legal document ensures that your contributions are properly licensed and that the project can continue to be distributed under the AGPL-3.0 license.

To sign the CLA, follow the instructions provided by the CLA bot after you submit your PR and add a comment in your PR saying:

I have read the CLA Document and I sign the CLA

Google-Style Docstrings

When adding new functions or classes, include a Google-style docstring to provide clear and concise documentation for other developers. This helps ensure your contributions are easy to understand and maintain.

!!! Example "Example Docstrings"

=== "Google-style"

     This example shows a Google-style docstring. Note that both input and output `types` must always be enclosed by parentheses, i.e., `(bool)`.
     ```py
     def example_function(arg1, arg2=4):
         """
         Example function that demonstrates Google-style docstrings.

         Args:
             arg1 (int): The first argument.
             arg2 (int): The second argument. Default value is 4.

         Returns:
             (bool): True if successful, False otherwise.

         Examples:
             >>> result = example_function(1, 2)  # returns False
         """
         if arg1 == arg2:
             return True
         return False
     ```

=== "Google-style with type hints"

     This example shows both a Google-style docstring and argument and return type hints, though both are not required; one can be used without the other.
     ```py
     def example_function(arg1: int, arg2: int = 4) -> bool:
         """
         Example function that demonstrates Google-style docstrings.

         Args:
             arg1: The first argument.
             arg2: The second argument. Default value is 4.

         Returns:
             True if successful, False otherwise.

         Examples:
             >>> result = example_function(1, 2)  # returns False
         """
         if arg1 == arg2:
             return True
         return False
     ```

=== "Single-line"

     Smaller or simpler functions can utilize a single-line docstring. Note the docstring must use 3 double-quotes and be a complete sentence starting with a capital letter and ending with a period.
     ```py
     def example_small_function(arg1: int, arg2: int = 4) -> bool:
         """Example function that demonstrates a single-line docstring."""
         return arg1 == arg2
     ```

GitHub Actions CI Tests

Before your pull request can be merged, all GitHub Actions Continuous Integration (CI) tests must pass. These tests include linting, unit tests, and other checks to ensure your changes meet the project's quality standards. Review the output of the GitHub Actions and fix any issues.

Reporting Bugs

We appreciate bug reports as they play a crucial role in maintaining the project's quality. When reporting bugs, it is important to provide a Minimum Reproducible Example: a clear, concise code example that replicates the issue. This helps in quick identification and resolution of the bug.

License

Ultralytics embraces the GNU Affero General Public License v3.0 (AGPL-3.0) for its repositories, promoting openness, transparency, and collaborative enhancement in software development. This strong copyleft license ensures that all users and developers retain the freedom to use, modify, and share the software. It fosters community collaboration, ensuring that any improvements remain accessible to all.

Users and developers are encouraged to familiarize themselves with the terms of AGPL-3.0 to contribute effectively and ethically to the Ultralytics open-source community.

Conclusion

Thank you for your interest in contributing to Ultralytics open-source YOLO projects. Your participation is crucial in shaping the future of our software and fostering a community of innovation and collaboration. Whether you're improving code, reporting bugs, or suggesting features, your contributions make a significant impact.

We look forward to seeing your ideas in action and appreciate your commitment to advancing object detection technology. Let's continue to grow and innovate together in this exciting open-source journey. Happy coding!

标签:YOLO,models,Ultralytics,Yolov8,源码,our,model,解析,your
From: https://www.cnblogs.com/apachecn/p/18398129

相关文章

  • Yolov8-源码解析-四-
    Yolov8源码解析(四)comments:truedescription:ExploretheCOCO-Posedatasetforadvancedposeestimation.Learnaboutdatasets,pretrainedmodels,metrics,andapplicationsfortrainingwithYOLO.keywords:COCO-Pose,poseestimation,dataset,keypoints,CO......
  • Yolov8-源码解析-十一-
    Yolov8源码解析(十一)comments:truedescription:LearnhowtoruninferenceusingtheUltralyticsHUBInferenceAPI.IncludesexamplesinPythonandcURLforquickintegration.keywords:Ultralytics,HUB,InferenceAPI,Python,cURL,RESTAPI,YOLO,imagepro......
  • Yolov8-源码解析-十四-
    Yolov8源码解析(十四)comments:truedescription:LearnhowtointegrateYOLOv8withTensorBoardforreal-timevisualinsightsintoyourmodel'strainingmetrics,performancegraphs,anddebuggingworkflows.keywords:YOLOv8,TensorBoard,modeltraining,......
  • Yolov8-源码解析-十三-
    Yolov8源码解析(十三)comments:truedescription:DiveintoourguideonYOLOv8'sintegrationwithKaggle.FindoutwhatKaggleis,itskeyfeatures,andhowtotrainaYOLOv8modelusingtheintegration.keywords:WhatisKaggle,WhatisKaggleUsedFor,......
  • Yolov8-源码解析-十七-
    Yolov8源码解析(十七)comments:truedescription:HarnessthepowerofUltralyticsYOLOv8forreal-time,high-speedinferenceonvariousdatasources.Learnaboutpredictmode,keyfeatures,andpracticalapplications.keywords:Ultralytics,YOLOv8,modelpred......
  • Yolov8-源码解析-四十一-
    Yolov8源码解析(四十一).\yolov8\ultralytics\utils\callbacks\raytune.py#UltralyticsYOLO......
  • Yolov8-源码解析-四十四-
    Yolov8源码解析(四十四).\yolov8\ultralytics\utils\triton.py#UltralyticsYOLO......
  • Yolov8-源码解析-四十三-
    Yolov8源码解析(四十三).\yolov8\ultralytics\utils\patches.py#UltralyticsYOLO......
  • Yolov8-源码解析-四十二-
    Yolov8源码解析(四十二).\yolov8\ultralytics\utils\loss.py#导入PyTorch库中需要的模块importtorchimporttorch.nnasnnimporttorch.nn.functionalasF#从Ultralytics工具包中导入一些特定的功能fromultralytics.utils.metricsimportOKS_SIGMAfromultralytics......
  • Yolov8-源码解析-一-
    Yolov8源码解析(一)comments:truedescription:LearnhowtocontributetoUltralyticsYOLOopen-sourcerepositories.Followguidelinesforpullrequests,codeofconduct,andbugreporting.keywords:Ultralytics,YOLO,open-source,contribution,pullrequest......