Fix Docs utils.plotting.Colors() previews (#22973)
This commit is contained in:
parent
42fb92cc41
commit
4e4aefff3e
@ -409,9 +409,14 @@ SECTION_ALIASES = {
|
||||
|
||||
|
||||
def _normalize_text(text: str) -> str:
|
||||
"""Collapse single newlines within paragraphs while preserving paragraph breaks."""
|
||||
"""Normalize text while preserving markdown structures like tables, admonitions, and code blocks."""
|
||||
if not text:
|
||||
return ""
|
||||
# Check if text contains markdown structures that need line preservation
|
||||
if any(marker in text for marker in ("|", "!!!", "```", "\n#", "\n- ", "\n* ", "\n1. ", "\n ")):
|
||||
# Preserve markdown formatting - just strip trailing whitespace from lines
|
||||
return "\n".join(line.rstrip() for line in text.splitlines()).strip()
|
||||
# Simple text - collapse single newlines within paragraphs
|
||||
paragraphs: list[str] = []
|
||||
current: list[str] = []
|
||||
for line in text.splitlines():
|
||||
|
||||
@ -24,17 +24,6 @@ class Colors:
|
||||
This class provides methods to work with the Ultralytics color palette, including converting hex color codes to RGB
|
||||
values and accessing predefined color schemes for object detection and pose estimation.
|
||||
|
||||
Attributes:
|
||||
palette (list[tuple]): List of RGB color tuples for general use.
|
||||
n (int): The number of colors in the palette.
|
||||
pose_palette (np.ndarray): A specific color palette array for pose estimation with dtype np.uint8.
|
||||
|
||||
Examples:
|
||||
>>> from ultralytics.utils.plotting import Colors
|
||||
>>> colors = Colors()
|
||||
>>> colors(5, True) # Returns BGR format: (221, 111, 255)
|
||||
>>> colors(5, False) # Returns RGB format: (255, 111, 221)
|
||||
|
||||
## Ultralytics Color Palette
|
||||
|
||||
| Index | Color | HEX | RGB |
|
||||
@ -89,6 +78,17 @@ class Colors:
|
||||
|
||||
For Ultralytics brand colors see [https://www.ultralytics.com/brand](https://www.ultralytics.com/brand).
|
||||
Please use the official Ultralytics colors for all marketing materials.
|
||||
|
||||
Attributes:
|
||||
palette (list[tuple]): List of RGB color tuples for general use.
|
||||
n (int): The number of colors in the palette.
|
||||
pose_palette (np.ndarray): A specific color palette array for pose estimation with dtype np.uint8.
|
||||
|
||||
Examples:
|
||||
>>> from ultralytics.utils.plotting import Colors
|
||||
>>> colors = Colors()
|
||||
>>> colors(5, True) # Returns BGR format: (221, 111, 255)
|
||||
>>> colors(5, False) # Returns RGB format: (255, 111, 221)
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user