+
+
+
+
+
+
+
+## 📄 Documentation
+
+See below for quickstart installation and usage examples. For comprehensive guidance on training, validation, prediction, and deployment, refer to our full [Ultralytics Docs](https://docs.ultralytics.com/).
+
+
+
+
+
+
+
+## 🤝 Contribute
+
+We thrive on community collaboration! Ultralytics YOLO wouldn't be the SOTA framework it is without contributions from developers like you. Please see our [Contributing Guide](https://docs.ultralytics.com/help/contributing/) to get started. We also welcome your feedback—share your experience by completing our [Survey](https://www.ultralytics.com/survey?utm_source=github&utm_medium=social&utm_campaign=Survey). A huge **Thank You** 🙏 to everyone who contributes!
+
+
+
+[](https://github.com/ultralytics/ultralytics/graphs/contributors)
+
+We look forward to your contributions to help make the Ultralytics ecosystem even better!
+
+## 📜 License
+
+Ultralytics offers two licensing options to suit different needs:
+
+- **AGPL-3.0 License**: This [OSI-approved](https://opensource.org/license/agpl-v3) open-source license is perfect for students, researchers, and enthusiasts. It encourages open collaboration and knowledge sharing. See the [LICENSE](https://github.com/ultralytics/ultralytics/blob/main/LICENSE) file for full details.
+- **Ultralytics Enterprise License**: Designed for commercial use, this license allows for the seamless integration of Ultralytics software and AI models into commercial products and services, bypassing the open-source requirements of AGPL-3.0. If your use case involves commercial deployment, please contact us via [Ultralytics Licensing](https://www.ultralytics.com/license).
+
+## 📞 Contact
+
+For bug reports and feature requests related to Ultralytics software, please visit [GitHub Issues](https://github.com/ultralytics/ultralytics/issues). For questions, discussions, and community support, join our active communities on [Discord](https://discord.com/invite/ultralytics), [Reddit](https://www.reddit.com/r/ultralytics/), and the [Ultralytics Community Forums](https://community.ultralytics.com/). We're here to help with all things Ultralytics!
+
+
+
+
+
+
+
+
+
+## 📄 文档
+
+请参阅下文了解快速安装和使用示例。有关训练、验证、预测和部署的全面指南,请参阅我们的完整 [Ultralytics 文档](https://docs.ultralytics.com/)。
+
+
+
+
+
+
+
+## 🤝 贡献
+
+我们依靠社区协作蓬勃发展!没有像您这样的开发者的贡献,Ultralytics YOLO 就不会成为如今最先进的框架。请参阅我们的[贡献指南](https://docs.ultralytics.com/help/contributing/)开始贡献。我们也欢迎您的反馈——通过完成我们的[调查问卷](https://www.ultralytics.com/survey?utm_source=github&utm_medium=social&utm_campaign=Survey)分享您的体验。非常**感谢** 🙏 每一位贡献者!
+
+
+
+[](https://github.com/ultralytics/ultralytics/graphs/contributors)
+
+我们期待您的贡献,帮助 Ultralytics 生态系统变得更好!
+
+## 📜 许可证
+
+Ultralytics 提供两种许可选项以满足不同需求:
+
+- **AGPL-3.0 许可证**:这种经 [OSI 批准](https://opensource.org/license/agpl-v3)的开源许可证非常适合学生、研究人员和爱好者。它鼓励开放协作和知识共享。有关完整详细信息,请参阅 [LICENSE](https://github.com/ultralytics/ultralytics/blob/main/LICENSE) 文件。
+- **Ultralytics 企业许可证**:专为商业用途设计,此许可证允许将 Ultralytics 软件和 AI 模型无缝集成到商业产品和服务中,绕过 AGPL-3.0 的开源要求。如果您的使用场景涉及商业部署,请通过 [Ultralytics 授权许可](https://www.ultralytics.com/license)与我们联系。
+
+## 📞 联系方式
+
+有关 Ultralytics 软件的错误报告和功能请求,请访问 [GitHub Issues](https://github.com/ultralytics/ultralytics/issues)。如有疑问、讨论和社区支持,请加入我们在 [Discord](https://discord.com/invite/ultralytics)、[Reddit](https://www.reddit.com/r/ultralytics/?rdt=44154) 和 [Ultralytics 社区论坛](https://community.ultralytics.com/)上的活跃社区。我们随时为您提供有关 Ultralytics 的所有帮助!
+
+ max_title_length and "-" in title_tag.text:
+ title_tag.string = title_tag.text.rsplit("-", 1)[0].strip()
+ modified = True
+
+ # Find the main content area
+ main_content = soup.find("main") or soup.find("div", class_="md-content")
+ if not main_content:
+ return str(soup) if modified else content
+
+ # Convert plaintext links to HTML hyperlinks
+ if needs_link_conversion:
+ for paragraph in main_content.select("p, li"):
+ for text_node in paragraph.find_all(string=True, recursive=False):
+ if text_node.parent.name not in {"a", "code"}:
+ new_text = LINK_PATTERN.sub(r'\1', str(text_node))
+ if " 0:
+ tail = " "
+ if tail:
+ span.insert_after(tail)
+ modified = True
+
+ highlight_labels(soup.select("main h1, main h2, main h3, main h4, main h5"))
+ highlight_labels(soup.select("nav.md-nav--secondary .md-ellipsis, nav.md-nav__list .md-ellipsis"))
+
+ if "reference" in rel_path:
+ for ellipsis in soup.select("nav.md-nav--secondary .md-ellipsis"):
+ kind = ellipsis.find(class_=lambda c: c and "doc-kind" in c.split())
+ text = str(kind.next_sibling).strip() if kind and kind.next_sibling else ellipsis.get_text(strip=True)
+ if "." not in text:
+ continue
+ ellipsis.clear()
+ short = text.rsplit(".", 1)[-1]
+ if kind:
+ ellipsis.append(kind)
+ ellipsis.append(f" {short}")
+ else:
+ ellipsis.append(short)
+ modified = True
+
+ if needs_kind_highlight and not modified and soup.select(".doc-kind"):
+ # Ensure style injection when pre-existing badges are present
+ modified = True
+
+ if modified:
+ head = soup.find("head")
+ if head and not soup.select("style[data-doc-kind]"):
+ style = soup.new_tag("style", attrs={"data-doc-kind": "true"})
+ style.string = (
+ ".doc-kind{display:inline-flex;align-items:center;gap:0.25em;padding:0.21em 0.59em;border-radius:999px;"
+ "font-weight:700;font-size:0.81em;letter-spacing:0.06em;text-transform:uppercase;"
+ "line-height:1;color:var(--doc-kind-color,#f8fafc);"
+ "background:var(--doc-kind-bg,rgba(255,255,255,0.12));}"
+ f".doc-kind-class{{--doc-kind-color:{DOC_KIND_COLORS['Class']};--doc-kind-bg:rgba(3,157,252,0.22);}}"
+ f".doc-kind-function{{--doc-kind-color:{DOC_KIND_COLORS['Function']};--doc-kind-bg:rgba(252,152,3,0.22);}}"
+ f".doc-kind-method{{--doc-kind-color:{DOC_KIND_COLORS['Method']};--doc-kind-bg:rgba(239,94,255,0.22);}}"
+ f".doc-kind-property{{--doc-kind-color:{DOC_KIND_COLORS['Property']};--doc-kind-bg:rgba(2,232,53,0.22);}}"
+ )
+ head.append(style)
+
+ return str(soup) if modified else content
+
+
+def _rewrite_md_links(content: str) -> str:
+ """Replace .md references with trailing slashes in HTML content, skipping GitHub links."""
+ if ".md" not in content:
+ return content
+
+ lines = []
+ for line in content.split("\n"):
+ if "github.com" not in line:
+ line = line.replace("index.md", "")
+ line = MD_LINK_PATTERN.sub(r"\1\2/\3", line)
+ lines.append(line)
+ return "\n".join(lines)
+
+
+# Precompiled regex patterns for minification
+HTML_COMMENT = re.compile(r"")
+HTML_PRESERVE = re.compile(r"<(pre|code|textarea|script)[^>]*>[\s\S]*?\1>", re.IGNORECASE)
+HTML_TAG_SPACE = re.compile(r">\s+<")
+HTML_MULTI_SPACE = re.compile(r"\s{2,}")
+HTML_EMPTY_LINE = re.compile(r"^\s*$\n", re.MULTILINE)
+CSS_COMMENT = re.compile(r"/\*[\s\S]*?\*/")
+
+
+def remove_comments_and_empty_lines(content: str, file_type: str) -> str:
+ """Remove comments and empty lines from a string of code, preserving newlines and URLs.
+
+ Args:
+ content (str): Code content to process.
+ file_type (str): Type of file ('html', 'css', or 'js').
+
+ Returns:
+ (str): Cleaned content with comments and empty lines removed.
+
+ Notes:
+ Typical reductions for Ultralytics Docs are:
+ - Total HTML reduction: 2.83% (1301.56 KB saved)
+ - Total CSS reduction: 1.75% (2.61 KB saved)
+ - Total JS reduction: 13.51% (99.31 KB saved)
+ """
+ if file_type == "html":
+ content = HTML_COMMENT.sub("", content) # Remove HTML comments
+ # Preserve whitespace in ,
,