Fix Docs pretty `__init__.py` URLs (#14550)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
pull/14554/head
Glenn Jocher 4 months ago committed by GitHub
parent 0d059bec0c
commit b3b3a15086
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 26
      docs/build_docs.py
  2. 3
      docs/build_reference.py
  3. 2
      docs/en/reference/cfg/__init__.md
  4. 2
      docs/en/reference/hub/__init__.md
  5. 2
      docs/en/reference/utils/__init__.md
  6. 4
      examples/YOLOv8-Action-Recognition/action_recognition.py
  7. 4
      examples/YOLOv8-OpenCV-int8-tflite-Python/main.py
  8. 2
      ultralytics/data/dataset.py
  9. 4
      ultralytics/data/explorer/explorer.py
  10. 2
      ultralytics/nn/modules/block.py
  11. 2
      ultralytics/nn/modules/head.py
  12. 4
      ultralytics/solutions/parking_management.py
  13. 2
      ultralytics/utils/benchmarks.py
  14. 8
      ultralytics/utils/loss.py
  15. 2
      ultralytics/utils/metrics.py
  16. 2
      ultralytics/utils/tal.py

@ -5,23 +5,23 @@ projects with multilingual content. It streamlines the workflow for generating l
and updating HTML links to ensure they are correctly formatted. and updating HTML links to ensure they are correctly formatted.
Key Features: Key Features:
- Automated building of MkDocs documentation: The script compiles both the main documentation and - Automated building of MkDocs documentation: The script compiles both the main documentation and
any localized versions specified in separate MkDocs configuration files. any localized versions specified in separate MkDocs configuration files.
- Post-processing of generated HTML files: After the documentation is built, the script updates all - Post-processing of generated HTML files: After the documentation is built, the script updates all
HTML files to remove the '.md' extension from internal links. This ensures that links in the built HTML files to remove the '.md' extension from internal links. This ensures that links in the built
HTML documentation correctly point to other HTML pages rather than Markdown files, which is crucial HTML documentation correctly point to other HTML pages rather than Markdown files, which is crucial
for proper navigation within the web-based documentation. for proper navigation within the web-based documentation.
Usage: Usage:
- Run the script from the root directory of your MkDocs project. - Run the script from the root directory of your MkDocs project.
- Ensure that MkDocs is installed and that all MkDocs configuration files (main and localized versions) - Ensure that MkDocs is installed and that all MkDocs configuration files (main and localized versions)
are present in the project directory. are present in the project directory.
- The script first builds the documentation using MkDocs, then scans the generated HTML files in the 'site' - The script first builds the documentation using MkDocs, then scans the generated HTML files in the 'site'
directory to update the internal links. directory to update the internal links.
- It's ideal for projects where the documentation is written in Markdown and needs to be served as a static website. - It's ideal for projects where the documentation is written in Markdown and needs to be served as a static website.
Note: Note:
- This script is built to be run in an environment where Python and MkDocs are installed and properly configured. - This script is built to be run in an environment where Python and MkDocs are installed and properly configured.
""" """
import os import os

@ -56,10 +56,11 @@ def create_markdown(py_filepath: Path, module_path: str, classes: list, function
module_path = module_path.replace(".", "/") module_path = module_path.replace(".", "/")
url = f"https://github.com/{GITHUB_REPO}/blob/main/{module_path}.py" url = f"https://github.com/{GITHUB_REPO}/blob/main/{module_path}.py"
edit = f"https://github.com/{GITHUB_REPO}/edit/main/{module_path}.py" edit = f"https://github.com/{GITHUB_REPO}/edit/main/{module_path}.py"
pretty = url.replace("__init__.py", "\\_\\_init\\_\\_.py") # properly display __init__.py filenames
title_content = ( title_content = (
f"# Reference for `{module_path}.py`\n\n" f"# Reference for `{module_path}.py`\n\n"
f"!!! Note\n\n" f"!!! Note\n\n"
f" This file is available at [{url}]({url}). If you spot a problem please help fix it by [contributing]" f" This file is available at [{pretty}]({url}). If you spot a problem please help fix it by [contributing]"
f"(https://docs.ultralytics.com/help/contributing/) a [Pull Request]({edit}) 🛠. Thank you 🙏!\n\n" f"(https://docs.ultralytics.com/help/contributing/) a [Pull Request]({edit}) 🛠. Thank you 🙏!\n\n"
) )
md_content = ["<br><br>\n"] + [f"## ::: {module_name}.{class_name}\n\n<br><br>\n" for class_name in classes] md_content = ["<br><br>\n"] + [f"## ::: {module_name}.{class_name}\n\n<br><br>\n" for class_name in classes]

@ -7,7 +7,7 @@ keywords: Ultralytics, YOLO, configuration, cfg2dict, get_cfg, check_cfg, save_d
!!! Note !!! Note
This file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/__init__.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/__init__.py). If you spot a problem please help fix it by [contributing](https://docs.ultralytics.com/help/contributing/) a [Pull Request](https://github.com/ultralytics/ultralytics/edit/main/ultralytics/cfg/__init__.py) 🛠. Thank you 🙏! This file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/\_\_init\_\_.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/__init__.py). If you spot a problem please help fix it by [contributing](https://docs.ultralytics.com/help/contributing/) a [Pull Request](https://github.com/ultralytics/ultralytics/edit/main/ultralytics/cfg/__init__.py) 🛠. Thank you 🙏!
<br><br> <br><br>

@ -7,7 +7,7 @@ keywords: Ultralytics HUB API, login, logout, reset model, export model, check d
!!! Note !!! Note
This file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/hub/__init__.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/hub/__init__.py). If you spot a problem please help fix it by [contributing](https://docs.ultralytics.com/help/contributing/) a [Pull Request](https://github.com/ultralytics/ultralytics/edit/main/ultralytics/hub/__init__.py) 🛠. Thank you 🙏! This file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/hub/\_\_init\_\_.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/hub/__init__.py). If you spot a problem please help fix it by [contributing](https://docs.ultralytics.com/help/contributing/) a [Pull Request](https://github.com/ultralytics/ultralytics/edit/main/ultralytics/hub/__init__.py) 🛠. Thank you 🙏!
<br><br> <br><br>

@ -7,7 +7,7 @@ keywords: Ultralytics, utils, TQDM, Python, ML, Machine Learning utilities, YOLO
!!! Note !!! Note
This file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/__init__.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/__init__.py). If you spot a problem please help fix it by [contributing](https://docs.ultralytics.com/help/contributing/) a [Pull Request](https://github.com/ultralytics/ultralytics/edit/main/ultralytics/utils/__init__.py) 🛠. Thank you 🙏! This file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/\_\_init\_\_.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/__init__.py). If you spot a problem please help fix it by [contributing](https://docs.ultralytics.com/help/contributing/) a [Pull Request](https://github.com/ultralytics/ultralytics/edit/main/ultralytics/utils/__init__.py) 🛠. Thank you 🙏!
<br><br> <br><br>

@ -18,6 +18,8 @@ from ultralytics.utils.torch_utils import select_device
class TorchVisionVideoClassifier: class TorchVisionVideoClassifier:
"""Classifies videos using pretrained TorchVision models; see https://pytorch.org/vision/stable/."""
from torchvision.models.video import ( from torchvision.models.video import (
MViT_V1_B_Weights, MViT_V1_B_Weights,
MViT_V2_S_Weights, MViT_V2_S_Weights,
@ -133,6 +135,8 @@ class TorchVisionVideoClassifier:
class HuggingFaceVideoClassifier: class HuggingFaceVideoClassifier:
"""Zero-shot video classifier using Hugging Face models for various devices."""
def __init__( def __init__(
self, self,
labels: List[str], labels: List[str],

@ -15,6 +15,8 @@ img_height = 640
class LetterBox: class LetterBox:
"""Resizes and reshapes images while maintaining aspect ratio by adding padding, suitable for YOLO models."""
def __init__( def __init__(
self, new_shape=(img_width, img_height), auto=False, scaleFill=False, scaleup=True, center=True, stride=32 self, new_shape=(img_width, img_height), auto=False, scaleFill=False, scaleup=True, center=True, stride=32
): ):
@ -86,6 +88,8 @@ class LetterBox:
class Yolov8TFLite: class Yolov8TFLite:
"""Class for performing object detection using YOLOv8 model converted to TensorFlow Lite format."""
def __init__(self, tflite_model, input_image, confidence_thres, iou_thres): def __init__(self, tflite_model, input_image, confidence_thres, iou_thres):
""" """
Initializes an instance of the Yolov8TFLite class. Initializes an instance of the Yolov8TFLite class.

@ -280,6 +280,8 @@ class YOLOMultiModalDataset(YOLODataset):
class GroundingDataset(YOLODataset): class GroundingDataset(YOLODataset):
"""Handles object detection tasks by loading annotations from a specified JSON file, supporting YOLO format."""
def __init__(self, *args, task="detect", json_file, **kwargs): def __init__(self, *args, task="detect", json_file, **kwargs):
"""Initializes a GroundingDataset for object detection, loading annotations from a specified JSON file.""" """Initializes a GroundingDataset for object detection, loading annotations from a specified JSON file."""
assert task == "detect", "`GroundingDataset` only support `detect` task for now!" assert task == "detect", "`GroundingDataset` only support `detect` task for now!"

@ -21,6 +21,8 @@ from .utils import get_sim_index_schema, get_table_schema, plot_query_result, pr
class ExplorerDataset(YOLODataset): class ExplorerDataset(YOLODataset):
"""Extends YOLODataset for advanced data exploration and manipulation in model training workflows."""
def __init__(self, *args, data: dict = None, **kwargs) -> None: def __init__(self, *args, data: dict = None, **kwargs) -> None:
"""Initializes the ExplorerDataset with the provided data arguments, extending the YOLODataset class.""" """Initializes the ExplorerDataset with the provided data arguments, extending the YOLODataset class."""
super().__init__(*args, data=data, **kwargs) super().__init__(*args, data=data, **kwargs)
@ -54,6 +56,8 @@ class ExplorerDataset(YOLODataset):
class Explorer: class Explorer:
"""Utility class for image embedding, table creation, and similarity querying using LanceDB and YOLO models."""
def __init__( def __init__(
self, self,
data: Union[str, Path] = "coco128.yaml", data: Union[str, Path] = "coco128.yaml",

@ -930,6 +930,8 @@ class PSA(nn.Module):
class SCDown(nn.Module): class SCDown(nn.Module):
"""Spatial Channel Downsample (SCDown) module for reducing spatial and channel dimensions."""
def __init__(self, c1, c2, k, s): def __init__(self, c1, c2, k, s):
""" """
Spatial Channel Downsample (SCDown) module. Spatial Channel Downsample (SCDown) module.

@ -281,6 +281,8 @@ class Classify(nn.Module):
class WorldDetect(Detect): class WorldDetect(Detect):
"""Head for integrating YOLOv8 detection models with semantic understanding from text embeddings."""
def __init__(self, nc=80, embed=512, with_bn=False, ch=()): def __init__(self, nc=80, embed=512, with_bn=False, ch=()):
"""Initialize YOLOv8 detection layer with nc classes and layer channels ch.""" """Initialize YOLOv8 detection layer with nc classes and layer channels ch."""
super().__init__(nc, ch) super().__init__(nc, ch)

@ -10,6 +10,8 @@ from ultralytics.utils.plotting import Annotator
class ParkingPtsSelection: class ParkingPtsSelection:
"""Class for selecting and managing parking zone points on images using a Tkinter-based UI."""
def __init__(self): def __init__(self):
"""Initializes the UI for selecting parking zone points in a tkinter window.""" """Initializes the UI for selecting parking zone points in a tkinter window."""
check_requirements("tkinter") check_requirements("tkinter")
@ -154,6 +156,8 @@ class ParkingPtsSelection:
class ParkingManagement: class ParkingManagement:
"""Manages parking occupancy and availability using YOLOv8 for real-time monitoring and visualization."""
def __init__( def __init__(
self, self,
model_path, model_path,

@ -164,6 +164,8 @@ def benchmark(
class RF100Benchmark: class RF100Benchmark:
"""Benchmark YOLO model performance across formats for speed and accuracy."""
def __init__(self): def __init__(self):
"""Function for initialization of RF100Benchmark.""" """Function for initialization of RF100Benchmark."""
self.ds_names = [] self.ds_names = []

@ -607,12 +607,10 @@ class v8ClassificationLoss:
class v8OBBLoss(v8DetectionLoss): class v8OBBLoss(v8DetectionLoss):
def __init__(self, model): """Calculates losses for object detection, classification, and box distribution in rotated YOLO models."""
"""
Initializes v8OBBLoss with model, assigner, and rotated bbox loss.
Note model must be de-paralleled. def __init__(self, model):
""" """Initializes v8OBBLoss with model, assigner, and rotated bbox loss; note model must be de-paralleled."""
super().__init__(model) super().__init__(model)
self.assigner = RotatedTaskAlignedAssigner(topk=10, num_classes=self.nc, alpha=0.5, beta=6.0) self.assigner = RotatedTaskAlignedAssigner(topk=10, num_classes=self.nc, alpha=0.5, beta=6.0)
self.bbox_loss = RotatedBboxLoss(self.reg_max).to(self.device) self.bbox_loss = RotatedBboxLoss(self.reg_max).to(self.device)

@ -1221,6 +1221,8 @@ class ClassifyMetrics(SimpleClass):
class OBBMetrics(SimpleClass): class OBBMetrics(SimpleClass):
"""Metrics for evaluating oriented bounding box (OBB) detection, see https://arxiv.org/pdf/2106.06072.pdf."""
def __init__(self, save_dir=Path("."), plot=False, on_plot=None, names=()) -> None: def __init__(self, save_dir=Path("."), plot=False, on_plot=None, names=()) -> None:
"""Initialize an OBBMetrics instance with directory, plotting, callback, and class names.""" """Initialize an OBBMetrics instance with directory, plotting, callback, and class names."""
self.save_dir = save_dir self.save_dir = save_dir

@ -259,6 +259,8 @@ class TaskAlignedAssigner(nn.Module):
class RotatedTaskAlignedAssigner(TaskAlignedAssigner): class RotatedTaskAlignedAssigner(TaskAlignedAssigner):
"""Assigns ground-truth objects to rotated bounding boxes using a task-aligned metric."""
def iou_calculation(self, gt_bboxes, pd_bboxes): def iou_calculation(self, gt_bboxes, pd_bboxes):
"""IoU calculation for rotated bounding boxes.""" """IoU calculation for rotated bounding boxes."""
return probiou(gt_bboxes, pd_bboxes).squeeze(-1).clamp_(0) return probiou(gt_bboxes, pd_bboxes).squeeze(-1).clamp_(0)

Loading…
Cancel
Save