`ultralytics 8.0.79` expand Docs reference section (#2053)

Co-authored-by: Ayush Chaurasia <ayush.chaurarsia@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Fri3dChicken <87434761+AmoghDhaliwal@users.noreply.github.com>
single_channel
Glenn Jocher 2 years ago committed by GitHub
parent 47bd8b433b
commit 31db8ed163
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -41,7 +41,7 @@ ENV OMP_NUM_THREADS=1
# t=ultralytics/ultralytics:latest && sudo docker build -f docker/Dockerfile -t $t . && sudo docker push $t # t=ultralytics/ultralytics:latest && sudo docker build -f docker/Dockerfile -t $t . && sudo docker push $t
# Pull and Run # Pull and Run
# t=ultralytics/ultralytics:latest && sudo docker pull $t && sudo docker run -it --ipc=host $t # t=ultralytics/ultralytics:latest && sudo docker pull $t && sudo docker run -it --ipc=host --gpus all $t
# Pull and Run with local directory access # 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)"/datasets:/usr/src/datasets $t # t=ultralytics/ultralytics:latest && sudo docker pull $t && sudo docker run -it --ipc=host --gpus all -v "$(pwd)"/datasets:/usr/src/datasets $t

@ -14,10 +14,6 @@ RUN apt update \
&& apt install --no-install-recommends -y gcc git zip curl htop libgl1-mesa-glx libglib2.0-0 libpython3-dev gnupg g++ && apt install --no-install-recommends -y gcc git zip curl htop libgl1-mesa-glx libglib2.0-0 libpython3-dev gnupg g++
# RUN alias python=python3 # RUN alias python=python3
# Security updates
# https://security.snyk.io/vuln/SNYK-UBUNTU1804-OPENSSL-3314796
RUN apt upgrade --no-install-recommends -y openssl tar
# Create working directory # Create working directory
RUN mkdir -p /usr/src/ultralytics RUN mkdir -p /usr/src/ultralytics
WORKDIR /usr/src/ultralytics WORKDIR /usr/src/ultralytics
@ -38,7 +34,7 @@ ENV OMP_NUM_THREADS=1
# Usage Examples ------------------------------------------------------------------------------------------------------- # Usage Examples -------------------------------------------------------------------------------------------------------
# Build and Push # Build and Push
# t=ultralytics/ultralytics:jetson && sudo docker build -f docker/Dockerfile -t $t . && sudo docker push $t # t=ultralytics/ultralytics:latest-jetson && sudo docker build --platform linux/arm64 -f docker/Dockerfile-jetson -t $t . && sudo docker push $t
# Pull and Run # Pull and Run
# t=ultralytics/ultralytics:jetson && sudo docker pull $t && sudo docker run -it --ipc=host $t # t=ultralytics/ultralytics:jetson && sudo docker pull $t && sudo docker run -it --ipc=host --gpus all $t

@ -0,0 +1,108 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license
"""
Helper file to build Ultralytics Docs reference section. Recursively walks through ultralytics dir and builds an MkDocs
reference section of *.md files composed of classes and functions, and also creates a nav menu for use in mkdocs.yaml.
Note: Must be run from repository root directory. Do not run from docs directory.
"""
import os
import re
from collections import defaultdict
from pathlib import Path
TARGET_DIR = Path('..')
def extract_classes_and_functions(filepath):
with open(filepath, 'r') as file:
content = file.read()
class_pattern = r"(?:^|\n)class\s(\w+)(?:\(|:)"
func_pattern = r"(?:^|\n)def\s(\w+)\("
classes = re.findall(class_pattern, content)
functions = re.findall(func_pattern, content)
return classes, functions
def create_markdown(py_filepath, module_path, classes, functions):
md_filepath = py_filepath.with_suffix('.md')
md_content = [f"# {class_name}\n---\n:::{module_path}.{class_name}\n<br><br>\n" for class_name in classes]
md_content.extend(f"# {func_name}\n---\n:::{module_path}.{func_name}\n<br><br>\n" for func_name in functions)
md_content = "\n".join(md_content)
os.makedirs(os.path.dirname(md_filepath), exist_ok=True)
with open(md_filepath, 'w') as file:
file.write(md_content)
return md_filepath.relative_to(TARGET_DIR)
def nested_dict():
return defaultdict(nested_dict)
def sort_nested_dict(d):
return {
key: sort_nested_dict(value) if isinstance(value, dict) else value
for key, value in sorted(d.items())
}
def create_nav_menu_yaml(nav_items):
nav_tree = nested_dict()
for item_str in nav_items:
item = Path(item_str)
parts = item.parts
current_level = nav_tree['reference']
for part in parts[2:-1]: # skip the first two parts (docs and reference) and the last part (filename)
current_level = current_level[part]
md_file_name = parts[-1].replace('.md', '')
current_level[md_file_name] = item
nav_tree_sorted = sort_nested_dict(nav_tree)
def _dict_to_yaml(d, level=0):
yaml_str = ""
indent = " " * level
for k, v in d.items():
if isinstance(v, dict):
yaml_str += f"{indent}- {k}:\n{_dict_to_yaml(v, level + 1)}"
else:
yaml_str += f"{indent}- {k}: {str(v).replace('docs/', '')}\n"
return yaml_str
with open(TARGET_DIR / 'nav_menu_updated.yml', 'w') as file:
yaml_str = _dict_to_yaml(nav_tree_sorted)
file.write(yaml_str)
def main():
source_dir = Path("../ultralytics")
target_dir = Path("reference")
nav_items = []
for root, _, files in os.walk(source_dir):
for file in files:
if file.endswith(".py") and file != "__init__.py":
py_filepath = Path(root) / file
classes, functions = extract_classes_and_functions(py_filepath)
if classes or functions:
py_filepath_rel = py_filepath.relative_to(source_dir)
md_filepath = target_dir / py_filepath_rel
module_path = f"ultralytics.{py_filepath_rel.with_suffix('').as_posix().replace('/', '.')}"
md_rel_filepath = create_markdown(md_filepath, module_path, classes, functions)
nav_items.append(str(md_rel_filepath))
create_nav_menu_yaml(nav_items)
if __name__ == "__main__":
main()

@ -202,7 +202,7 @@ operations are cached, meaning they're only calculated once per object, and thos
results[0].probs # cls prob, (num_class, ) results[0].probs # cls prob, (num_class, )
``` ```
Class reference documentation for `Results` module and its components can be found [here](../reference/results.md) Class reference documentation for `Results` module and its components can be found [here](../reference/yolo/engine/results.md)
## Plotting results ## Plotting results

@ -25,7 +25,7 @@ See the `ultralytics` [requirements.txt](https://github.com/ultralytics/ultralyt
PyTorch requirements vary by operating system and CUDA requirements, so it's recommended to install PyTorch first following instructions at [https://pytorch.org/get-started/locally](https://pytorch.org/get-started/locally). PyTorch requirements vary by operating system and CUDA requirements, so it's recommended to install PyTorch first following instructions at [https://pytorch.org/get-started/locally](https://pytorch.org/get-started/locally).
<a href="https://pytorch.org/get-started/locally/"> <a href="https://pytorch.org/get-started/locally/">
<img width="100%" alt="PyTorch Installation Instructions" src="https://user-images.githubusercontent.com/26833433/228650108-ab0ec98a-b328-4f40-a40d-95355e8a84e3.png"> <img width="800" alt="PyTorch Installation Instructions" src="https://user-images.githubusercontent.com/26833433/228650108-ab0ec98a-b328-4f40-a40d-95355e8a84e3.png">
</a> </a>

@ -1,8 +0,0 @@
All task Predictors are inherited from `BasePredictors` class that contains the model validation routine boilerplate.
You can override any function of these Trainers to suit your needs.
---
### BasePredictor API Reference
:::ultralytics.yolo.engine.predictor.BasePredictor

@ -1,8 +0,0 @@
All task Trainers are inherited from `BaseTrainer` class that contains the model training and optimization routine
boilerplate. You can override any function of these Trainers to suit your needs.
---
### BaseTrainer API Reference
:::ultralytics.yolo.engine.trainer.BaseTrainer

@ -1,8 +0,0 @@
All task Validators are inherited from `BaseValidator` class that contains the model validation routine boilerplate. You
can override any function of these Trainers to suit your needs.
---
### BaseValidator API Reference
:::ultralytics.yolo.engine.validator.BaseValidator

@ -1,3 +0,0 @@
### Exporter API Reference
:::ultralytics.yolo.engine.exporter.Exporter

@ -0,0 +1,4 @@
# Auth
---
:::ultralytics.hub.auth.Auth
<br><br>

@ -0,0 +1,4 @@
# HUBTrainingSession
---
:::ultralytics.hub.session.HUBTrainingSession
<br><br>

@ -0,0 +1,24 @@
# Traces
---
:::ultralytics.hub.utils.Traces
<br><br>
# check_dataset_disk_space
---
:::ultralytics.hub.utils.check_dataset_disk_space
<br><br>
# request_with_credentials
---
:::ultralytics.hub.utils.request_with_credentials
<br><br>
# requests_with_progress
---
:::ultralytics.hub.utils.requests_with_progress
<br><br>
# smart_request
---
:::ultralytics.hub.utils.smart_request
<br><br>

@ -1 +0,0 @@
::: ultralytics.yolo.engine.model

@ -1,19 +0,0 @@
# nn Module
Ultralytics nn module contains 3 main components:
1. **AutoBackend**: A module that can run inference on all popular model formats
2. **BaseModel**: `BaseModel` class defines the operations supported by tasks like Detection and Segmentation
3. **modules**: Optimized and reusable neural network blocks built on PyTorch.
## AutoBackend
:::ultralytics.nn.autobackend.AutoBackend
## BaseModel
:::ultralytics.nn.tasks.BaseModel
## Modules
TODO

@ -0,0 +1,9 @@
# AutoBackend
---
:::ultralytics.nn.autobackend.AutoBackend
<br><br>
# check_class_names
---
:::ultralytics.nn.autobackend.check_class_names
<br><br>

@ -0,0 +1,9 @@
# AutoShape
---
:::ultralytics.nn.autoshape.AutoShape
<br><br>
# Detections
---
:::ultralytics.nn.autoshape.Detections
<br><br>

@ -0,0 +1,159 @@
# Conv
---
:::ultralytics.nn.modules.Conv
<br><br>
# DWConv
---
:::ultralytics.nn.modules.DWConv
<br><br>
# DWConvTranspose2d
---
:::ultralytics.nn.modules.DWConvTranspose2d
<br><br>
# ConvTranspose
---
:::ultralytics.nn.modules.ConvTranspose
<br><br>
# DFL
---
:::ultralytics.nn.modules.DFL
<br><br>
# TransformerLayer
---
:::ultralytics.nn.modules.TransformerLayer
<br><br>
# TransformerBlock
---
:::ultralytics.nn.modules.TransformerBlock
<br><br>
# Bottleneck
---
:::ultralytics.nn.modules.Bottleneck
<br><br>
# BottleneckCSP
---
:::ultralytics.nn.modules.BottleneckCSP
<br><br>
# C3
---
:::ultralytics.nn.modules.C3
<br><br>
# C2
---
:::ultralytics.nn.modules.C2
<br><br>
# C2f
---
:::ultralytics.nn.modules.C2f
<br><br>
# ChannelAttention
---
:::ultralytics.nn.modules.ChannelAttention
<br><br>
# SpatialAttention
---
:::ultralytics.nn.modules.SpatialAttention
<br><br>
# CBAM
---
:::ultralytics.nn.modules.CBAM
<br><br>
# C1
---
:::ultralytics.nn.modules.C1
<br><br>
# C3x
---
:::ultralytics.nn.modules.C3x
<br><br>
# C3TR
---
:::ultralytics.nn.modules.C3TR
<br><br>
# C3Ghost
---
:::ultralytics.nn.modules.C3Ghost
<br><br>
# SPP
---
:::ultralytics.nn.modules.SPP
<br><br>
# SPPF
---
:::ultralytics.nn.modules.SPPF
<br><br>
# Focus
---
:::ultralytics.nn.modules.Focus
<br><br>
# GhostConv
---
:::ultralytics.nn.modules.GhostConv
<br><br>
# GhostBottleneck
---
:::ultralytics.nn.modules.GhostBottleneck
<br><br>
# Concat
---
:::ultralytics.nn.modules.Concat
<br><br>
# Proto
---
:::ultralytics.nn.modules.Proto
<br><br>
# Ensemble
---
:::ultralytics.nn.modules.Ensemble
<br><br>
# Detect
---
:::ultralytics.nn.modules.Detect
<br><br>
# Segment
---
:::ultralytics.nn.modules.Segment
<br><br>
# Pose
---
:::ultralytics.nn.modules.Pose
<br><br>
# Classify
---
:::ultralytics.nn.modules.Classify
<br><br>
# autopad
---
:::ultralytics.nn.modules.autopad
<br><br>

@ -0,0 +1,59 @@
# BaseModel
---
:::ultralytics.nn.tasks.BaseModel
<br><br>
# DetectionModel
---
:::ultralytics.nn.tasks.DetectionModel
<br><br>
# SegmentationModel
---
:::ultralytics.nn.tasks.SegmentationModel
<br><br>
# PoseModel
---
:::ultralytics.nn.tasks.PoseModel
<br><br>
# ClassificationModel
---
:::ultralytics.nn.tasks.ClassificationModel
<br><br>
# torch_safe_load
---
:::ultralytics.nn.tasks.torch_safe_load
<br><br>
# attempt_load_weights
---
:::ultralytics.nn.tasks.attempt_load_weights
<br><br>
# attempt_load_one_weight
---
:::ultralytics.nn.tasks.attempt_load_one_weight
<br><br>
# parse_model
---
:::ultralytics.nn.tasks.parse_model
<br><br>
# yaml_model_load
---
:::ultralytics.nn.tasks.yaml_model_load
<br><br>
# guess_model_scale
---
:::ultralytics.nn.tasks.guess_model_scale
<br><br>
# guess_model_task
---
:::ultralytics.nn.tasks.guess_model_task
<br><br>

@ -1,208 +0,0 @@
This module contains optimized deep learning related operations used in the Ultralytics YOLO framework
## Non-max suppression
:::ultralytics.yolo.utils.ops.non_max_suppression
handler: python
options:
show_source: false
show_root_toc_entry: false
---
## Scale boxes
:::ultralytics.yolo.utils.ops.scale_boxes
handler: python
options:
show_source: false
show_root_toc_entry: false
---
## Scale image
:::ultralytics.yolo.utils.ops.scale_image
handler: python
options:
show_source: false
show_root_toc_entry: false
---
## clip boxes
:::ultralytics.yolo.utils.ops.clip_boxes
handler: python
options:
show_source: false
show_root_toc_entry: false
---
# Box Format Conversion
## xyxy2xywh
:::ultralytics.yolo.utils.ops.xyxy2xywh
handler: python
options:
show_source: false
show_root_toc_entry: false
---
## xywh2xyxy
:::ultralytics.yolo.utils.ops.xywh2xyxy
handler: python
options:
show_source: false
show_root_toc_entry: false
---
## xywhn2xyxy
:::ultralytics.yolo.utils.ops.xywhn2xyxy
handler: python
options:
show_source: false
show_root_toc_entry: false
---
## xyxy2xywhn
:::ultralytics.yolo.utils.ops.xyxy2xywhn
handler: python
options:
show_source: false
show_root_toc_entry: false
---
## xyn2xy
:::ultralytics.yolo.utils.ops.xyn2xy
handler: python
options:
show_source: false
show_root_toc_entry: false
---
## xywh2ltwh
:::ultralytics.yolo.utils.ops.xywh2ltwh
handler: python
options:
show_source: false
show_root_toc_entry: false
---
## xyxy2ltwh
:::ultralytics.yolo.utils.ops.xyxy2ltwh
handler: python
options:
show_source: false
show_root_toc_entry: false
---
## ltwh2xywh
:::ultralytics.yolo.utils.ops.ltwh2xywh
handler: python
options:
show_source: false
show_root_toc_entry: false
---
## ltwh2xyxy
:::ultralytics.yolo.utils.ops.ltwh2xyxy
handler: python
options:
show_source: false
show_root_toc_entry: false
---
## segment2box
:::ultralytics.yolo.utils.ops.segment2box
handler: python
options:
show_source: false
show_root_toc_entry: false
---
# Mask Operations
## resample_segments
:::ultralytics.yolo.utils.ops.resample_segments
handler: python
options:
show_source: false
show_root_toc_entry: false
---
## crop_mask
:::ultralytics.yolo.utils.ops.crop_mask
handler: python
options:
show_source: false
show_root_toc_entry: false
---
## process_mask_upsample
:::ultralytics.yolo.utils.ops.process_mask_upsample
handler: python
options:
show_source: false
show_root_toc_entry: false
---
## process_mask
:::ultralytics.yolo.utils.ops.process_mask
handler: python
options:
show_source: false
show_root_toc_entry: false
---
## process_mask_native
:::ultralytics.yolo.utils.ops.process_mask_native
handler: python
options:
show_source: false
show_root_toc_entry: false
---
## scale_coords
:::ultralytics.yolo.utils.ops.scale_coords
handler: python
options:
show_source: false
show_root_toc_entry: false
---
## masks2segments
:::ultralytics.yolo.utils.ops.masks2segments
handler: python
options:
show_source: false
show_root_toc_entry: false
---
## clip_coords
:::ultralytics.yolo.utils.ops.clip_coords
handler: python
options:
show_source: false
show_root_toc_entry: false
---

@ -1,11 +0,0 @@
### Results API Reference
:::ultralytics.yolo.engine.results.Results
### Boxes API Reference
:::ultralytics.yolo.engine.results.Boxes
### Masks API Reference
:::ultralytics.yolo.engine.results.Masks

@ -0,0 +1,14 @@
# on_predict_start
---
:::ultralytics.tracker.track.on_predict_start
<br><br>
# on_predict_postprocess_end
---
:::ultralytics.tracker.track.on_predict_postprocess_end
<br><br>
# register_tracker
---
:::ultralytics.tracker.track.register_tracker
<br><br>

@ -0,0 +1,9 @@
# TrackState
---
:::ultralytics.tracker.trackers.basetrack.TrackState
<br><br>
# BaseTrack
---
:::ultralytics.tracker.trackers.basetrack.BaseTrack
<br><br>

@ -0,0 +1,9 @@
# BOTrack
---
:::ultralytics.tracker.trackers.bot_sort.BOTrack
<br><br>
# BOTSORT
---
:::ultralytics.tracker.trackers.bot_sort.BOTSORT
<br><br>

@ -0,0 +1,9 @@
# STrack
---
:::ultralytics.tracker.trackers.byte_tracker.STrack
<br><br>
# BYTETracker
---
:::ultralytics.tracker.trackers.byte_tracker.BYTETracker
<br><br>

@ -0,0 +1,4 @@
# GMC
---
:::ultralytics.tracker.utils.gmc.GMC
<br><br>

@ -0,0 +1,9 @@
# KalmanFilterXYAH
---
:::ultralytics.tracker.utils.kalman_filter.KalmanFilterXYAH
<br><br>
# KalmanFilterXYWH
---
:::ultralytics.tracker.utils.kalman_filter.KalmanFilterXYWH
<br><br>

@ -0,0 +1,59 @@
# merge_matches
---
:::ultralytics.tracker.utils.matching.merge_matches
<br><br>
# _indices_to_matches
---
:::ultralytics.tracker.utils.matching._indices_to_matches
<br><br>
# linear_assignment
---
:::ultralytics.tracker.utils.matching.linear_assignment
<br><br>
# ious
---
:::ultralytics.tracker.utils.matching.ious
<br><br>
# iou_distance
---
:::ultralytics.tracker.utils.matching.iou_distance
<br><br>
# v_iou_distance
---
:::ultralytics.tracker.utils.matching.v_iou_distance
<br><br>
# embedding_distance
---
:::ultralytics.tracker.utils.matching.embedding_distance
<br><br>
# gate_cost_matrix
---
:::ultralytics.tracker.utils.matching.gate_cost_matrix
<br><br>
# fuse_motion
---
:::ultralytics.tracker.utils.matching.fuse_motion
<br><br>
# fuse_iou
---
:::ultralytics.tracker.utils.matching.fuse_iou
<br><br>
# fuse_score
---
:::ultralytics.tracker.utils.matching.fuse_score
<br><br>
# bbox_ious
---
:::ultralytics.tracker.utils.matching.bbox_ious
<br><br>

@ -0,0 +1,89 @@
# BaseTransform
---
:::ultralytics.yolo.data.augment.BaseTransform
<br><br>
# Compose
---
:::ultralytics.yolo.data.augment.Compose
<br><br>
# BaseMixTransform
---
:::ultralytics.yolo.data.augment.BaseMixTransform
<br><br>
# Mosaic
---
:::ultralytics.yolo.data.augment.Mosaic
<br><br>
# MixUp
---
:::ultralytics.yolo.data.augment.MixUp
<br><br>
# RandomPerspective
---
:::ultralytics.yolo.data.augment.RandomPerspective
<br><br>
# RandomHSV
---
:::ultralytics.yolo.data.augment.RandomHSV
<br><br>
# RandomFlip
---
:::ultralytics.yolo.data.augment.RandomFlip
<br><br>
# LetterBox
---
:::ultralytics.yolo.data.augment.LetterBox
<br><br>
# CopyPaste
---
:::ultralytics.yolo.data.augment.CopyPaste
<br><br>
# Albumentations
---
:::ultralytics.yolo.data.augment.Albumentations
<br><br>
# Format
---
:::ultralytics.yolo.data.augment.Format
<br><br>
# ClassifyLetterBox
---
:::ultralytics.yolo.data.augment.ClassifyLetterBox
<br><br>
# CenterCrop
---
:::ultralytics.yolo.data.augment.CenterCrop
<br><br>
# ToTensor
---
:::ultralytics.yolo.data.augment.ToTensor
<br><br>
# v8_transforms
---
:::ultralytics.yolo.data.augment.v8_transforms
<br><br>
# classify_transforms
---
:::ultralytics.yolo.data.augment.classify_transforms
<br><br>
# classify_albumentations
---
:::ultralytics.yolo.data.augment.classify_albumentations
<br><br>

@ -0,0 +1,4 @@
# BaseDataset
---
:::ultralytics.yolo.data.base.BaseDataset
<br><br>

@ -0,0 +1,34 @@
# InfiniteDataLoader
---
:::ultralytics.yolo.data.build.InfiniteDataLoader
<br><br>
# _RepeatSampler
---
:::ultralytics.yolo.data.build._RepeatSampler
<br><br>
# seed_worker
---
:::ultralytics.yolo.data.build.seed_worker
<br><br>
# build_dataloader
---
:::ultralytics.yolo.data.build.build_dataloader
<br><br>
# build_classification_dataloader
---
:::ultralytics.yolo.data.build.build_classification_dataloader
<br><br>
# check_source
---
:::ultralytics.yolo.data.build.check_source
<br><br>
# load_inference_source
---
:::ultralytics.yolo.data.build.load_inference_source
<br><br>

@ -0,0 +1,34 @@
# SourceTypes
---
:::ultralytics.yolo.data.dataloaders.stream_loaders.SourceTypes
<br><br>
# LoadStreams
---
:::ultralytics.yolo.data.dataloaders.stream_loaders.LoadStreams
<br><br>
# LoadScreenshots
---
:::ultralytics.yolo.data.dataloaders.stream_loaders.LoadScreenshots
<br><br>
# LoadImages
---
:::ultralytics.yolo.data.dataloaders.stream_loaders.LoadImages
<br><br>
# LoadPilAndNumpy
---
:::ultralytics.yolo.data.dataloaders.stream_loaders.LoadPilAndNumpy
<br><br>
# LoadTensor
---
:::ultralytics.yolo.data.dataloaders.stream_loaders.LoadTensor
<br><br>
# autocast_list
---
:::ultralytics.yolo.data.dataloaders.stream_loaders.autocast_list
<br><br>

@ -0,0 +1,84 @@
# Albumentations
---
:::ultralytics.yolo.data.dataloaders.v5augmentations.Albumentations
<br><br>
# LetterBox
---
:::ultralytics.yolo.data.dataloaders.v5augmentations.LetterBox
<br><br>
# CenterCrop
---
:::ultralytics.yolo.data.dataloaders.v5augmentations.CenterCrop
<br><br>
# ToTensor
---
:::ultralytics.yolo.data.dataloaders.v5augmentations.ToTensor
<br><br>
# normalize
---
:::ultralytics.yolo.data.dataloaders.v5augmentations.normalize
<br><br>
# denormalize
---
:::ultralytics.yolo.data.dataloaders.v5augmentations.denormalize
<br><br>
# augment_hsv
---
:::ultralytics.yolo.data.dataloaders.v5augmentations.augment_hsv
<br><br>
# hist_equalize
---
:::ultralytics.yolo.data.dataloaders.v5augmentations.hist_equalize
<br><br>
# replicate
---
:::ultralytics.yolo.data.dataloaders.v5augmentations.replicate
<br><br>
# letterbox
---
:::ultralytics.yolo.data.dataloaders.v5augmentations.letterbox
<br><br>
# random_perspective
---
:::ultralytics.yolo.data.dataloaders.v5augmentations.random_perspective
<br><br>
# copy_paste
---
:::ultralytics.yolo.data.dataloaders.v5augmentations.copy_paste
<br><br>
# cutout
---
:::ultralytics.yolo.data.dataloaders.v5augmentations.cutout
<br><br>
# mixup
---
:::ultralytics.yolo.data.dataloaders.v5augmentations.mixup
<br><br>
# box_candidates
---
:::ultralytics.yolo.data.dataloaders.v5augmentations.box_candidates
<br><br>
# classify_albumentations
---
:::ultralytics.yolo.data.dataloaders.v5augmentations.classify_albumentations
<br><br>
# classify_transforms
---
:::ultralytics.yolo.data.dataloaders.v5augmentations.classify_transforms
<br><br>

@ -0,0 +1,89 @@
# InfiniteDataLoader
---
:::ultralytics.yolo.data.dataloaders.v5loader.InfiniteDataLoader
<br><br>
# _RepeatSampler
---
:::ultralytics.yolo.data.dataloaders.v5loader._RepeatSampler
<br><br>
# LoadScreenshots
---
:::ultralytics.yolo.data.dataloaders.v5loader.LoadScreenshots
<br><br>
# LoadImages
---
:::ultralytics.yolo.data.dataloaders.v5loader.LoadImages
<br><br>
# LoadStreams
---
:::ultralytics.yolo.data.dataloaders.v5loader.LoadStreams
<br><br>
# LoadImagesAndLabels
---
:::ultralytics.yolo.data.dataloaders.v5loader.LoadImagesAndLabels
<br><br>
# ClassificationDataset
---
:::ultralytics.yolo.data.dataloaders.v5loader.ClassificationDataset
<br><br>
# get_hash
---
:::ultralytics.yolo.data.dataloaders.v5loader.get_hash
<br><br>
# exif_size
---
:::ultralytics.yolo.data.dataloaders.v5loader.exif_size
<br><br>
# exif_transpose
---
:::ultralytics.yolo.data.dataloaders.v5loader.exif_transpose
<br><br>
# seed_worker
---
:::ultralytics.yolo.data.dataloaders.v5loader.seed_worker
<br><br>
# create_dataloader
---
:::ultralytics.yolo.data.dataloaders.v5loader.create_dataloader
<br><br>
# img2label_paths
---
:::ultralytics.yolo.data.dataloaders.v5loader.img2label_paths
<br><br>
# flatten_recursive
---
:::ultralytics.yolo.data.dataloaders.v5loader.flatten_recursive
<br><br>
# extract_boxes
---
:::ultralytics.yolo.data.dataloaders.v5loader.extract_boxes
<br><br>
# autosplit
---
:::ultralytics.yolo.data.dataloaders.v5loader.autosplit
<br><br>
# verify_image_label
---
:::ultralytics.yolo.data.dataloaders.v5loader.verify_image_label
<br><br>
# create_classification_dataloader
---
:::ultralytics.yolo.data.dataloaders.v5loader.create_classification_dataloader
<br><br>

@ -0,0 +1,14 @@
# YOLODataset
---
:::ultralytics.yolo.data.dataset.YOLODataset
<br><br>
# ClassificationDataset
---
:::ultralytics.yolo.data.dataset.ClassificationDataset
<br><br>
# SemanticDataset
---
:::ultralytics.yolo.data.dataset.SemanticDataset
<br><br>

@ -0,0 +1,4 @@
# MixAndRectDataset
---
:::ultralytics.yolo.data.dataset_wrappers.MixAndRectDataset
<br><br>

@ -0,0 +1,64 @@
# HUBDatasetStats
---
:::ultralytics.yolo.data.utils.HUBDatasetStats
<br><br>
# img2label_paths
---
:::ultralytics.yolo.data.utils.img2label_paths
<br><br>
# get_hash
---
:::ultralytics.yolo.data.utils.get_hash
<br><br>
# exif_size
---
:::ultralytics.yolo.data.utils.exif_size
<br><br>
# verify_image_label
---
:::ultralytics.yolo.data.utils.verify_image_label
<br><br>
# polygon2mask
---
:::ultralytics.yolo.data.utils.polygon2mask
<br><br>
# polygons2masks
---
:::ultralytics.yolo.data.utils.polygons2masks
<br><br>
# polygons2masks_overlap
---
:::ultralytics.yolo.data.utils.polygons2masks_overlap
<br><br>
# check_det_dataset
---
:::ultralytics.yolo.data.utils.check_det_dataset
<br><br>
# check_cls_dataset
---
:::ultralytics.yolo.data.utils.check_cls_dataset
<br><br>
# compress_one_image
---
:::ultralytics.yolo.data.utils.compress_one_image
<br><br>
# delete_dsstore
---
:::ultralytics.yolo.data.utils.delete_dsstore
<br><br>
# zip_directory
---
:::ultralytics.yolo.data.utils.zip_directory
<br><br>

@ -0,0 +1,29 @@
# iOSDetectModel
---
:::ultralytics.yolo.engine.exporter.iOSDetectModel
<br><br>
# Exporter
---
:::ultralytics.yolo.engine.exporter.Exporter
<br><br>
# export_formats
---
:::ultralytics.yolo.engine.exporter.export_formats
<br><br>
# gd_outputs
---
:::ultralytics.yolo.engine.exporter.gd_outputs
<br><br>
# try_export
---
:::ultralytics.yolo.engine.exporter.try_export
<br><br>
# export
---
:::ultralytics.yolo.engine.exporter.export
<br><br>

@ -0,0 +1,4 @@
# YOLO
---
:::ultralytics.yolo.engine.model.YOLO
<br><br>

@ -0,0 +1,4 @@
# BasePredictor
---
:::ultralytics.yolo.engine.predictor.BasePredictor
<br><br>

@ -0,0 +1,19 @@
# BaseTensor
---
:::ultralytics.yolo.engine.results.BaseTensor
<br><br>
# Results
---
:::ultralytics.yolo.engine.results.Results
<br><br>
# Boxes
---
:::ultralytics.yolo.engine.results.Boxes
<br><br>
# Masks
---
:::ultralytics.yolo.engine.results.Masks
<br><br>

@ -0,0 +1,9 @@
# BaseTrainer
---
:::ultralytics.yolo.engine.trainer.BaseTrainer
<br><br>
# check_amp
---
:::ultralytics.yolo.engine.trainer.check_amp
<br><br>

@ -0,0 +1,4 @@
# BaseValidator
---
:::ultralytics.yolo.engine.validator.BaseValidator
<br><br>

@ -0,0 +1,9 @@
# check_train_batch_size
---
:::ultralytics.yolo.utils.autobatch.check_train_batch_size
<br><br>
# autobatch
---
:::ultralytics.yolo.utils.autobatch.autobatch
<br><br>

@ -0,0 +1,4 @@
# benchmark
---
:::ultralytics.yolo.utils.benchmarks.benchmark
<br><br>

@ -0,0 +1,134 @@
# on_pretrain_routine_start
---
:::ultralytics.yolo.utils.callbacks.base.on_pretrain_routine_start
<br><br>
# on_pretrain_routine_end
---
:::ultralytics.yolo.utils.callbacks.base.on_pretrain_routine_end
<br><br>
# on_train_start
---
:::ultralytics.yolo.utils.callbacks.base.on_train_start
<br><br>
# on_train_epoch_start
---
:::ultralytics.yolo.utils.callbacks.base.on_train_epoch_start
<br><br>
# on_train_batch_start
---
:::ultralytics.yolo.utils.callbacks.base.on_train_batch_start
<br><br>
# optimizer_step
---
:::ultralytics.yolo.utils.callbacks.base.optimizer_step
<br><br>
# on_before_zero_grad
---
:::ultralytics.yolo.utils.callbacks.base.on_before_zero_grad
<br><br>
# on_train_batch_end
---
:::ultralytics.yolo.utils.callbacks.base.on_train_batch_end
<br><br>
# on_train_epoch_end
---
:::ultralytics.yolo.utils.callbacks.base.on_train_epoch_end
<br><br>
# on_fit_epoch_end
---
:::ultralytics.yolo.utils.callbacks.base.on_fit_epoch_end
<br><br>
# on_model_save
---
:::ultralytics.yolo.utils.callbacks.base.on_model_save
<br><br>
# on_train_end
---
:::ultralytics.yolo.utils.callbacks.base.on_train_end
<br><br>
# on_params_update
---
:::ultralytics.yolo.utils.callbacks.base.on_params_update
<br><br>
# teardown
---
:::ultralytics.yolo.utils.callbacks.base.teardown
<br><br>
# on_val_start
---
:::ultralytics.yolo.utils.callbacks.base.on_val_start
<br><br>
# on_val_batch_start
---
:::ultralytics.yolo.utils.callbacks.base.on_val_batch_start
<br><br>
# on_val_batch_end
---
:::ultralytics.yolo.utils.callbacks.base.on_val_batch_end
<br><br>
# on_val_end
---
:::ultralytics.yolo.utils.callbacks.base.on_val_end
<br><br>
# on_predict_start
---
:::ultralytics.yolo.utils.callbacks.base.on_predict_start
<br><br>
# on_predict_batch_start
---
:::ultralytics.yolo.utils.callbacks.base.on_predict_batch_start
<br><br>
# on_predict_batch_end
---
:::ultralytics.yolo.utils.callbacks.base.on_predict_batch_end
<br><br>
# on_predict_postprocess_end
---
:::ultralytics.yolo.utils.callbacks.base.on_predict_postprocess_end
<br><br>
# on_predict_end
---
:::ultralytics.yolo.utils.callbacks.base.on_predict_end
<br><br>
# on_export_start
---
:::ultralytics.yolo.utils.callbacks.base.on_export_start
<br><br>
# on_export_end
---
:::ultralytics.yolo.utils.callbacks.base.on_export_end
<br><br>
# get_default_callbacks
---
:::ultralytics.yolo.utils.callbacks.base.get_default_callbacks
<br><br>
# add_integration_callbacks
---
:::ultralytics.yolo.utils.callbacks.base.add_integration_callbacks
<br><br>

@ -0,0 +1,34 @@
# _log_debug_samples
---
:::ultralytics.yolo.utils.callbacks.clearml._log_debug_samples
<br><br>
# _log_plot
---
:::ultralytics.yolo.utils.callbacks.clearml._log_plot
<br><br>
# on_pretrain_routine_start
---
:::ultralytics.yolo.utils.callbacks.clearml.on_pretrain_routine_start
<br><br>
# on_train_epoch_end
---
:::ultralytics.yolo.utils.callbacks.clearml.on_train_epoch_end
<br><br>
# on_fit_epoch_end
---
:::ultralytics.yolo.utils.callbacks.clearml.on_fit_epoch_end
<br><br>
# on_val_end
---
:::ultralytics.yolo.utils.callbacks.clearml.on_val_end
<br><br>
# on_train_end
---
:::ultralytics.yolo.utils.callbacks.clearml.on_train_end
<br><br>

@ -0,0 +1,84 @@
# _get_experiment_type
---
:::ultralytics.yolo.utils.callbacks.comet._get_experiment_type
<br><br>
# _create_experiment
---
:::ultralytics.yolo.utils.callbacks.comet._create_experiment
<br><br>
# _fetch_trainer_metadata
---
:::ultralytics.yolo.utils.callbacks.comet._fetch_trainer_metadata
<br><br>
# _scale_bounding_box_to_original_image_shape
---
:::ultralytics.yolo.utils.callbacks.comet._scale_bounding_box_to_original_image_shape
<br><br>
# _format_ground_truth_annotations_for_detection
---
:::ultralytics.yolo.utils.callbacks.comet._format_ground_truth_annotations_for_detection
<br><br>
# _format_prediction_annotations_for_detection
---
:::ultralytics.yolo.utils.callbacks.comet._format_prediction_annotations_for_detection
<br><br>
# _fetch_annotations
---
:::ultralytics.yolo.utils.callbacks.comet._fetch_annotations
<br><br>
# _create_prediction_metadata_map
---
:::ultralytics.yolo.utils.callbacks.comet._create_prediction_metadata_map
<br><br>
# _log_confusion_matrix
---
:::ultralytics.yolo.utils.callbacks.comet._log_confusion_matrix
<br><br>
# _log_images
---
:::ultralytics.yolo.utils.callbacks.comet._log_images
<br><br>
# _log_image_predictions
---
:::ultralytics.yolo.utils.callbacks.comet._log_image_predictions
<br><br>
# _log_plots
---
:::ultralytics.yolo.utils.callbacks.comet._log_plots
<br><br>
# _log_model
---
:::ultralytics.yolo.utils.callbacks.comet._log_model
<br><br>
# on_pretrain_routine_start
---
:::ultralytics.yolo.utils.callbacks.comet.on_pretrain_routine_start
<br><br>
# on_train_epoch_end
---
:::ultralytics.yolo.utils.callbacks.comet.on_train_epoch_end
<br><br>
# on_fit_epoch_end
---
:::ultralytics.yolo.utils.callbacks.comet.on_fit_epoch_end
<br><br>
# on_train_end
---
:::ultralytics.yolo.utils.callbacks.comet.on_train_end
<br><br>

@ -0,0 +1,39 @@
# on_pretrain_routine_end
---
:::ultralytics.yolo.utils.callbacks.hub.on_pretrain_routine_end
<br><br>
# on_fit_epoch_end
---
:::ultralytics.yolo.utils.callbacks.hub.on_fit_epoch_end
<br><br>
# on_model_save
---
:::ultralytics.yolo.utils.callbacks.hub.on_model_save
<br><br>
# on_train_end
---
:::ultralytics.yolo.utils.callbacks.hub.on_train_end
<br><br>
# on_train_start
---
:::ultralytics.yolo.utils.callbacks.hub.on_train_start
<br><br>
# on_val_start
---
:::ultralytics.yolo.utils.callbacks.hub.on_val_start
<br><br>
# on_predict_start
---
:::ultralytics.yolo.utils.callbacks.hub.on_predict_start
<br><br>
# on_export_start
---
:::ultralytics.yolo.utils.callbacks.hub.on_export_start
<br><br>

@ -0,0 +1,19 @@
# on_pretrain_routine_end
---
:::ultralytics.yolo.utils.callbacks.mlflow.on_pretrain_routine_end
<br><br>
# on_fit_epoch_end
---
:::ultralytics.yolo.utils.callbacks.mlflow.on_fit_epoch_end
<br><br>
# on_model_save
---
:::ultralytics.yolo.utils.callbacks.mlflow.on_model_save
<br><br>
# on_train_end
---
:::ultralytics.yolo.utils.callbacks.mlflow.on_train_end
<br><br>

@ -0,0 +1,4 @@
# on_fit_epoch_end
---
:::ultralytics.yolo.utils.callbacks.raytune.on_fit_epoch_end
<br><br>

@ -0,0 +1,19 @@
# _log_scalars
---
:::ultralytics.yolo.utils.callbacks.tensorboard._log_scalars
<br><br>
# on_pretrain_routine_start
---
:::ultralytics.yolo.utils.callbacks.tensorboard.on_pretrain_routine_start
<br><br>
# on_batch_end
---
:::ultralytics.yolo.utils.callbacks.tensorboard.on_batch_end
<br><br>
# on_fit_epoch_end
---
:::ultralytics.yolo.utils.callbacks.tensorboard.on_fit_epoch_end
<br><br>

@ -0,0 +1,19 @@
# on_pretrain_routine_start
---
:::ultralytics.yolo.utils.callbacks.wb.on_pretrain_routine_start
<br><br>
# on_fit_epoch_end
---
:::ultralytics.yolo.utils.callbacks.wb.on_fit_epoch_end
<br><br>
# on_train_epoch_end
---
:::ultralytics.yolo.utils.callbacks.wb.on_train_epoch_end
<br><br>
# on_train_end
---
:::ultralytics.yolo.utils.callbacks.wb.on_train_end
<br><br>

@ -0,0 +1,79 @@
# is_ascii
---
:::ultralytics.yolo.utils.checks.is_ascii
<br><br>
# check_imgsz
---
:::ultralytics.yolo.utils.checks.check_imgsz
<br><br>
# check_version
---
:::ultralytics.yolo.utils.checks.check_version
<br><br>
# check_latest_pypi_version
---
:::ultralytics.yolo.utils.checks.check_latest_pypi_version
<br><br>
# check_pip_update_available
---
:::ultralytics.yolo.utils.checks.check_pip_update_available
<br><br>
# check_font
---
:::ultralytics.yolo.utils.checks.check_font
<br><br>
# check_python
---
:::ultralytics.yolo.utils.checks.check_python
<br><br>
# check_requirements
---
:::ultralytics.yolo.utils.checks.check_requirements
<br><br>
# check_suffix
---
:::ultralytics.yolo.utils.checks.check_suffix
<br><br>
# check_yolov5u_filename
---
:::ultralytics.yolo.utils.checks.check_yolov5u_filename
<br><br>
# check_file
---
:::ultralytics.yolo.utils.checks.check_file
<br><br>
# check_yaml
---
:::ultralytics.yolo.utils.checks.check_yaml
<br><br>
# check_imshow
---
:::ultralytics.yolo.utils.checks.check_imshow
<br><br>
# check_yolo
---
:::ultralytics.yolo.utils.checks.check_yolo
<br><br>
# git_describe
---
:::ultralytics.yolo.utils.checks.git_describe
<br><br>
# print_args
---
:::ultralytics.yolo.utils.checks.print_args
<br><br>

@ -0,0 +1,19 @@
# find_free_network_port
---
:::ultralytics.yolo.utils.dist.find_free_network_port
<br><br>
# generate_ddp_file
---
:::ultralytics.yolo.utils.dist.generate_ddp_file
<br><br>
# generate_ddp_command
---
:::ultralytics.yolo.utils.dist.generate_ddp_command
<br><br>
# ddp_cleanup
---
:::ultralytics.yolo.utils.dist.ddp_cleanup
<br><br>

@ -0,0 +1,24 @@
# is_url
---
:::ultralytics.yolo.utils.downloads.is_url
<br><br>
# unzip_file
---
:::ultralytics.yolo.utils.downloads.unzip_file
<br><br>
# safe_download
---
:::ultralytics.yolo.utils.downloads.safe_download
<br><br>
# attempt_download_asset
---
:::ultralytics.yolo.utils.downloads.attempt_download_asset
<br><br>
# download
---
:::ultralytics.yolo.utils.downloads.download
<br><br>

@ -0,0 +1,4 @@
# HUBModelError
---
:::ultralytics.yolo.utils.errors.HUBModelError
<br><br>

@ -0,0 +1,29 @@
# WorkingDirectory
---
:::ultralytics.yolo.utils.files.WorkingDirectory
<br><br>
# increment_path
---
:::ultralytics.yolo.utils.files.increment_path
<br><br>
# file_age
---
:::ultralytics.yolo.utils.files.file_age
<br><br>
# file_date
---
:::ultralytics.yolo.utils.files.file_date
<br><br>
# file_size
---
:::ultralytics.yolo.utils.files.file_size
<br><br>
# get_latest_run
---
:::ultralytics.yolo.utils.files.get_latest_run
<br><br>

@ -0,0 +1,14 @@
# Bboxes
---
:::ultralytics.yolo.utils.instance.Bboxes
<br><br>
# Instances
---
:::ultralytics.yolo.utils.instance.Instances
<br><br>
# _ntuple
---
:::ultralytics.yolo.utils.instance._ntuple
<br><br>

@ -0,0 +1,14 @@
# VarifocalLoss
---
:::ultralytics.yolo.utils.loss.VarifocalLoss
<br><br>
# BboxLoss
---
:::ultralytics.yolo.utils.loss.BboxLoss
<br><br>
# KeypointLoss
---
:::ultralytics.yolo.utils.loss.KeypointLoss
<br><br>

@ -0,0 +1,94 @@
# FocalLoss
---
:::ultralytics.yolo.utils.metrics.FocalLoss
<br><br>
# ConfusionMatrix
---
:::ultralytics.yolo.utils.metrics.ConfusionMatrix
<br><br>
# Metric
---
:::ultralytics.yolo.utils.metrics.Metric
<br><br>
# DetMetrics
---
:::ultralytics.yolo.utils.metrics.DetMetrics
<br><br>
# SegmentMetrics
---
:::ultralytics.yolo.utils.metrics.SegmentMetrics
<br><br>
# PoseMetrics
---
:::ultralytics.yolo.utils.metrics.PoseMetrics
<br><br>
# ClassifyMetrics
---
:::ultralytics.yolo.utils.metrics.ClassifyMetrics
<br><br>
# box_area
---
:::ultralytics.yolo.utils.metrics.box_area
<br><br>
# bbox_ioa
---
:::ultralytics.yolo.utils.metrics.bbox_ioa
<br><br>
# box_iou
---
:::ultralytics.yolo.utils.metrics.box_iou
<br><br>
# bbox_iou
---
:::ultralytics.yolo.utils.metrics.bbox_iou
<br><br>
# mask_iou
---
:::ultralytics.yolo.utils.metrics.mask_iou
<br><br>
# kpt_iou
---
:::ultralytics.yolo.utils.metrics.kpt_iou
<br><br>
# smooth_BCE
---
:::ultralytics.yolo.utils.metrics.smooth_BCE
<br><br>
# smooth
---
:::ultralytics.yolo.utils.metrics.smooth
<br><br>
# plot_pr_curve
---
:::ultralytics.yolo.utils.metrics.plot_pr_curve
<br><br>
# plot_mc_curve
---
:::ultralytics.yolo.utils.metrics.plot_mc_curve
<br><br>
# compute_ap
---
:::ultralytics.yolo.utils.metrics.compute_ap
<br><br>
# ap_per_class
---
:::ultralytics.yolo.utils.metrics.ap_per_class
<br><br>

@ -0,0 +1,134 @@
# Profile
---
:::ultralytics.yolo.utils.ops.Profile
<br><br>
# coco80_to_coco91_class
---
:::ultralytics.yolo.utils.ops.coco80_to_coco91_class
<br><br>
# segment2box
---
:::ultralytics.yolo.utils.ops.segment2box
<br><br>
# scale_boxes
---
:::ultralytics.yolo.utils.ops.scale_boxes
<br><br>
# make_divisible
---
:::ultralytics.yolo.utils.ops.make_divisible
<br><br>
# non_max_suppression
---
:::ultralytics.yolo.utils.ops.non_max_suppression
<br><br>
# clip_boxes
---
:::ultralytics.yolo.utils.ops.clip_boxes
<br><br>
# clip_coords
---
:::ultralytics.yolo.utils.ops.clip_coords
<br><br>
# scale_image
---
:::ultralytics.yolo.utils.ops.scale_image
<br><br>
# xyxy2xywh
---
:::ultralytics.yolo.utils.ops.xyxy2xywh
<br><br>
# xywh2xyxy
---
:::ultralytics.yolo.utils.ops.xywh2xyxy
<br><br>
# xywhn2xyxy
---
:::ultralytics.yolo.utils.ops.xywhn2xyxy
<br><br>
# xyxy2xywhn
---
:::ultralytics.yolo.utils.ops.xyxy2xywhn
<br><br>
# xyn2xy
---
:::ultralytics.yolo.utils.ops.xyn2xy
<br><br>
# xywh2ltwh
---
:::ultralytics.yolo.utils.ops.xywh2ltwh
<br><br>
# xyxy2ltwh
---
:::ultralytics.yolo.utils.ops.xyxy2ltwh
<br><br>
# ltwh2xywh
---
:::ultralytics.yolo.utils.ops.ltwh2xywh
<br><br>
# ltwh2xyxy
---
:::ultralytics.yolo.utils.ops.ltwh2xyxy
<br><br>
# segments2boxes
---
:::ultralytics.yolo.utils.ops.segments2boxes
<br><br>
# resample_segments
---
:::ultralytics.yolo.utils.ops.resample_segments
<br><br>
# crop_mask
---
:::ultralytics.yolo.utils.ops.crop_mask
<br><br>
# process_mask_upsample
---
:::ultralytics.yolo.utils.ops.process_mask_upsample
<br><br>
# process_mask
---
:::ultralytics.yolo.utils.ops.process_mask
<br><br>
# process_mask_native
---
:::ultralytics.yolo.utils.ops.process_mask_native
<br><br>
# scale_coords
---
:::ultralytics.yolo.utils.ops.scale_coords
<br><br>
# masks2segments
---
:::ultralytics.yolo.utils.ops.masks2segments
<br><br>
# clean_str
---
:::ultralytics.yolo.utils.ops.clean_str
<br><br>

@ -0,0 +1,34 @@
# Colors
---
:::ultralytics.yolo.utils.plotting.Colors
<br><br>
# Annotator
---
:::ultralytics.yolo.utils.plotting.Annotator
<br><br>
# plot_labels
---
:::ultralytics.yolo.utils.plotting.plot_labels
<br><br>
# save_one_box
---
:::ultralytics.yolo.utils.plotting.save_one_box
<br><br>
# plot_images
---
:::ultralytics.yolo.utils.plotting.plot_images
<br><br>
# plot_results
---
:::ultralytics.yolo.utils.plotting.plot_results
<br><br>
# output_to_target
---
:::ultralytics.yolo.utils.plotting.output_to_target
<br><br>

@ -0,0 +1,29 @@
# TaskAlignedAssigner
---
:::ultralytics.yolo.utils.tal.TaskAlignedAssigner
<br><br>
# select_candidates_in_gts
---
:::ultralytics.yolo.utils.tal.select_candidates_in_gts
<br><br>
# select_highest_overlaps
---
:::ultralytics.yolo.utils.tal.select_highest_overlaps
<br><br>
# make_anchors
---
:::ultralytics.yolo.utils.tal.make_anchors
<br><br>
# dist2bbox
---
:::ultralytics.yolo.utils.tal.dist2bbox
<br><br>
# bbox2dist
---
:::ultralytics.yolo.utils.tal.bbox2dist
<br><br>

@ -0,0 +1,119 @@
# ModelEMA
---
:::ultralytics.yolo.utils.torch_utils.ModelEMA
<br><br>
# EarlyStopping
---
:::ultralytics.yolo.utils.torch_utils.EarlyStopping
<br><br>
# torch_distributed_zero_first
---
:::ultralytics.yolo.utils.torch_utils.torch_distributed_zero_first
<br><br>
# smart_inference_mode
---
:::ultralytics.yolo.utils.torch_utils.smart_inference_mode
<br><br>
# select_device
---
:::ultralytics.yolo.utils.torch_utils.select_device
<br><br>
# time_sync
---
:::ultralytics.yolo.utils.torch_utils.time_sync
<br><br>
# fuse_conv_and_bn
---
:::ultralytics.yolo.utils.torch_utils.fuse_conv_and_bn
<br><br>
# fuse_deconv_and_bn
---
:::ultralytics.yolo.utils.torch_utils.fuse_deconv_and_bn
<br><br>
# model_info
---
:::ultralytics.yolo.utils.torch_utils.model_info
<br><br>
# get_num_params
---
:::ultralytics.yolo.utils.torch_utils.get_num_params
<br><br>
# get_num_gradients
---
:::ultralytics.yolo.utils.torch_utils.get_num_gradients
<br><br>
# get_flops
---
:::ultralytics.yolo.utils.torch_utils.get_flops
<br><br>
# initialize_weights
---
:::ultralytics.yolo.utils.torch_utils.initialize_weights
<br><br>
# scale_img
---
:::ultralytics.yolo.utils.torch_utils.scale_img
<br><br>
# make_divisible
---
:::ultralytics.yolo.utils.torch_utils.make_divisible
<br><br>
# copy_attr
---
:::ultralytics.yolo.utils.torch_utils.copy_attr
<br><br>
# get_latest_opset
---
:::ultralytics.yolo.utils.torch_utils.get_latest_opset
<br><br>
# intersect_dicts
---
:::ultralytics.yolo.utils.torch_utils.intersect_dicts
<br><br>
# is_parallel
---
:::ultralytics.yolo.utils.torch_utils.is_parallel
<br><br>
# de_parallel
---
:::ultralytics.yolo.utils.torch_utils.de_parallel
<br><br>
# one_cycle
---
:::ultralytics.yolo.utils.torch_utils.one_cycle
<br><br>
# init_seeds
---
:::ultralytics.yolo.utils.torch_utils.init_seeds
<br><br>
# strip_optimizer
---
:::ultralytics.yolo.utils.torch_utils.strip_optimizer
<br><br>
# profile
---
:::ultralytics.yolo.utils.torch_utils.profile
<br><br>

@ -0,0 +1,9 @@
# ClassificationPredictor
---
:::ultralytics.yolo.v8.classify.predict.ClassificationPredictor
<br><br>
# predict
---
:::ultralytics.yolo.v8.classify.predict.predict
<br><br>

@ -0,0 +1,9 @@
# ClassificationTrainer
---
:::ultralytics.yolo.v8.classify.train.ClassificationTrainer
<br><br>
# train
---
:::ultralytics.yolo.v8.classify.train.train
<br><br>

@ -0,0 +1,9 @@
# ClassificationValidator
---
:::ultralytics.yolo.v8.classify.val.ClassificationValidator
<br><br>
# val
---
:::ultralytics.yolo.v8.classify.val.val
<br><br>

@ -0,0 +1,9 @@
# DetectionPredictor
---
:::ultralytics.yolo.v8.detect.predict.DetectionPredictor
<br><br>
# predict
---
:::ultralytics.yolo.v8.detect.predict.predict
<br><br>

@ -0,0 +1,14 @@
# DetectionTrainer
---
:::ultralytics.yolo.v8.detect.train.DetectionTrainer
<br><br>
# Loss
---
:::ultralytics.yolo.v8.detect.train.Loss
<br><br>
# train
---
:::ultralytics.yolo.v8.detect.train.train
<br><br>

@ -0,0 +1,9 @@
# DetectionValidator
---
:::ultralytics.yolo.v8.detect.val.DetectionValidator
<br><br>
# val
---
:::ultralytics.yolo.v8.detect.val.val
<br><br>

@ -0,0 +1,9 @@
# PosePredictor
---
:::ultralytics.yolo.v8.pose.predict.PosePredictor
<br><br>
# predict
---
:::ultralytics.yolo.v8.pose.predict.predict
<br><br>

@ -0,0 +1,14 @@
# PoseTrainer
---
:::ultralytics.yolo.v8.pose.train.PoseTrainer
<br><br>
# PoseLoss
---
:::ultralytics.yolo.v8.pose.train.PoseLoss
<br><br>
# train
---
:::ultralytics.yolo.v8.pose.train.train
<br><br>

@ -0,0 +1,9 @@
# PoseValidator
---
:::ultralytics.yolo.v8.pose.val.PoseValidator
<br><br>
# val
---
:::ultralytics.yolo.v8.pose.val.val
<br><br>

@ -0,0 +1,9 @@
# SegmentationPredictor
---
:::ultralytics.yolo.v8.segment.predict.SegmentationPredictor
<br><br>
# predict
---
:::ultralytics.yolo.v8.segment.predict.predict
<br><br>

@ -0,0 +1,14 @@
# SegmentationTrainer
---
:::ultralytics.yolo.v8.segment.train.SegmentationTrainer
<br><br>
# SegLoss
---
:::ultralytics.yolo.v8.segment.train.SegLoss
<br><br>
# train
---
:::ultralytics.yolo.v8.segment.train.train
<br><br>

@ -0,0 +1,9 @@
# SegmentationValidator
---
:::ultralytics.yolo.v8.segment.val.SegmentationValidator
<br><br>
# val
---
:::ultralytics.yolo.v8.segment.val.val
<br><br>

@ -9,7 +9,7 @@ custom model and dataloader by just overriding these functions:
* `get_model(cfg, weights)` - The function that builds the model to be trained * `get_model(cfg, weights)` - The function that builds the model to be trained
* `get_dataloder()` - The function that builds the dataloader * `get_dataloder()` - The function that builds the dataloader
More details and source code can be found in [`BaseTrainer` Reference](../reference/base_trainer.md) More details and source code can be found in [`BaseTrainer` Reference](../reference/yolo/engine/trainer.md)
## DetectionTrainer ## DetectionTrainer

@ -37,8 +37,9 @@ theme:
- search.share - search.share
- search.suggest - search.suggest
- toc.follow - toc.follow
- toc.integrate
- navigation.top - navigation.top
- navigation.expand - navigation.tabs
- navigation.footer - navigation.footer
- navigation.tracking - navigation.tracking
- navigation.instant - navigation.instant
@ -143,16 +144,88 @@ nav:
- Advanced Customization: usage/engine.md - Advanced Customization: usage/engine.md
- Ultralytics HUB: hub.md - Ultralytics HUB: hub.md
- iOS and Android App: app.md - iOS and Android App: app.md
- Reference: - Reference:
- Engine: - hub:
- Model: reference/model.md - auth: reference/hub/auth.md
- Trainer: reference/base_trainer.md - session: reference/hub/session.md
- Validator: reference/base_val.md - utils: reference/hub/utils.md
- Predictor: reference/base_pred.md - nn:
- Exporter: reference/exporter.md - autobackend: reference/nn/autobackend.md
- Results: reference/results.md - autoshape: reference/nn/autoshape.md
- ultralytics.nn: reference/nn.md - modules: reference/nn/modules.md
- Operations: reference/ops.md - tasks: reference/nn/tasks.md
- tracker:
- track: reference/tracker/track.md
- trackers:
- basetrack: reference/tracker/trackers/basetrack.md
- bot_sort: reference/tracker/trackers/bot_sort.md
- byte_tracker: reference/tracker/trackers/byte_tracker.md
- utils:
- gmc: reference/tracker/utils/gmc.md
- kalman_filter: reference/tracker/utils/kalman_filter.md
- matching: reference/tracker/utils/matching.md
- yolo:
- data:
- augment: reference/yolo/data/augment.md
- base: reference/yolo/data/base.md
- build: reference/yolo/data/build.md
- dataloaders:
- stream_loaders: reference/yolo/data/dataloaders/stream_loaders.md
- v5augmentations: reference/yolo/data/dataloaders/v5augmentations.md
- v5loader: reference/yolo/data/dataloaders/v5loader.md
- dataset: reference/yolo/data/dataset.md
- dataset_wrappers: reference/yolo/data/dataset_wrappers.md
- utils: reference/yolo/data/utils.md
- engine:
- exporter: reference/yolo/engine/exporter.md
- model: reference/yolo/engine/model.md
- predictor: reference/yolo/engine/predictor.md
- results: reference/yolo/engine/results.md
- trainer: reference/yolo/engine/trainer.md
- validator: reference/yolo/engine/validator.md
- utils:
- autobatch: reference/yolo/utils/autobatch.md
- benchmarks: reference/yolo/utils/benchmarks.md
- callbacks:
- base: reference/yolo/utils/callbacks/base.md
- clearml: reference/yolo/utils/callbacks/clearml.md
- comet: reference/yolo/utils/callbacks/comet.md
- hub: reference/yolo/utils/callbacks/hub.md
- mlflow: reference/yolo/utils/callbacks/mlflow.md
- raytune: reference/yolo/utils/callbacks/raytune.md
- tensorboard: reference/yolo/utils/callbacks/tensorboard.md
- wb: reference/yolo/utils/callbacks/wb.md
- checks: reference/yolo/utils/checks.md
- dist: reference/yolo/utils/dist.md
- downloads: reference/yolo/utils/downloads.md
- errors: reference/yolo/utils/errors.md
- files: reference/yolo/utils/files.md
- instance: reference/yolo/utils/instance.md
- loss: reference/yolo/utils/loss.md
- metrics: reference/yolo/utils/metrics.md
- ops: reference/yolo/utils/ops.md
- plotting: reference/yolo/utils/plotting.md
- tal: reference/yolo/utils/tal.md
- torch_utils: reference/yolo/utils/torch_utils.md
- v8:
- classify:
- predict: reference/yolo/v8/classify/predict.md
- train: reference/yolo/v8/classify/train.md
- val: reference/yolo/v8/classify/val.md
- detect:
- predict: reference/yolo/v8/detect/predict.md
- train: reference/yolo/v8/detect/train.md
- val: reference/yolo/v8/detect/val.md
- pose:
- predict: reference/yolo/v8/pose/predict.md
- train: reference/yolo/v8/pose/train.md
- val: reference/yolo/v8/pose/val.md
- segment:
- predict: reference/yolo/v8/segment/predict.md
- train: reference/yolo/v8/segment/train.md
- val: reference/yolo/v8/segment/val.md
- YOLOv5: - YOLOv5:
- yolov5/index.md - yolov5/index.md
- Train Custom Data: yolov5/train_custom_data.md - Train Custom Data: yolov5/train_custom_data.md
@ -171,5 +244,4 @@ nav:
- Neural Magic's DeepSparse: yolov5/neural_magic.md - Neural Magic's DeepSparse: yolov5/neural_magic.md
- Comet Logging: yolov5/comet.md - Comet Logging: yolov5/comet.md
- Clearml Logging: yolov5/clearml.md - Clearml Logging: yolov5/clearml.md
- Security: SECURITY.md - Security: SECURITY.md

@ -1,6 +1,6 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license # Ultralytics YOLO 🚀, AGPL-3.0 license
__version__ = '8.0.78' __version__ = '8.0.79'
from ultralytics.hub import start from ultralytics.hub import start
from ultralytics.yolo.engine.model import YOLO from ultralytics.yolo.engine.model import YOLO

@ -111,7 +111,7 @@ class Auth:
Get the authentication header for making API requests. Get the authentication header for making API requests.
Returns: Returns:
dict: The authentication header if id_token or API key is set, None otherwise. (dict): The authentication header if id_token or API key is set, None otherwise.
""" """
if self.id_token: if self.id_token:
return {'authorization': f'Bearer {self.id_token}'} return {'authorization': f'Bearer {self.id_token}'}

@ -30,7 +30,7 @@ def check_dataset_disk_space(url='https://ultralytics.com/assets/coco128.zip', s
sf (float, optional): Safety factor, the multiplier for the required free space. Defaults to 2.0. sf (float, optional): Safety factor, the multiplier for the required free space. Defaults to 2.0.
Returns: Returns:
bool: True if there is sufficient disk space, False otherwise. (bool): True if there is sufficient disk space, False otherwise.
""" """
gib = 1 << 30 # bytes per GiB gib = 1 << 30 # bytes per GiB
data = int(requests.head(url).headers['Content-Length']) / gib # dataset size (GB) data = int(requests.head(url).headers['Content-Length']) / gib # dataset size (GB)
@ -51,7 +51,7 @@ def request_with_credentials(url: str) -> any:
url (str): The URL to make the request to. url (str): The URL to make the request to.
Returns: Returns:
any: The response data from the AJAX request. (any): The response data from the AJAX request.
Raises: Raises:
OSError: If the function is not run in a Google Colab environment. OSError: If the function is not run in a Google Colab environment.
@ -87,11 +87,14 @@ def requests_with_progress(method, url, **kwargs):
Args: Args:
method (str): The HTTP method to use (e.g. 'GET', 'POST'). method (str): The HTTP method to use (e.g. 'GET', 'POST').
url (str): The URL to send the request to. url (str): The URL to send the request to.
progress (bool, optional): Whether to display a progress bar. Defaults to False. **kwargs (dict): Additional keyword arguments to pass to the underlying `requests.request` function.
**kwargs: Additional keyword arguments to pass to the underlying `requests.request` function.
Returns: Returns:
requests.Response: The response from the HTTP request. (requests.Response): The response object from the HTTP request.
Note:
If 'progress' is set to True, the progress bar will display the download progress
for responses with a known content length.
""" """
progress = kwargs.pop('progress', False) progress = kwargs.pop('progress', False)
if not progress: if not progress:
@ -118,10 +121,10 @@ def smart_request(method, url, retry=3, timeout=30, thread=True, code=-1, verbos
code (int, optional): An identifier for the request, used for logging purposes. Default is -1. code (int, optional): An identifier for the request, used for logging purposes. Default is -1.
verbose (bool, optional): A flag to determine whether to print out to console or not. Default is True. verbose (bool, optional): A flag to determine whether to print out to console or not. Default is True.
progress (bool, optional): Whether to show a progress bar during the request. Default is False. progress (bool, optional): Whether to show a progress bar during the request. Default is False.
**kwargs: Keyword arguments to be passed to the requests function specified in method. **kwargs (dict): Keyword arguments to be passed to the requests function specified in method.
Returns: Returns:
requests.Response: The HTTP response object. If the request is executed in a separate thread, returns None. (requests.Response): The HTTP response object. If the request is executed in a separate thread, returns None.
""" """
retry_codes = (408, 500) # retry only these codes retry_codes = (408, 500) # retry only these codes

@ -337,7 +337,7 @@ def torch_safe_load(weight):
weight (str): The file path of the PyTorch model. weight (str): The file path of the PyTorch model.
Returns: Returns:
The loaded PyTorch model. (dict): The loaded PyTorch model.
""" """
from ultralytics.yolo.utils.downloads import attempt_download_asset from ultralytics.yolo.utils.downloads import attempt_download_asset
@ -398,7 +398,7 @@ def attempt_load_weights(weights, device=None, inplace=True, fuse=False):
for k in 'names', 'nc', 'yaml': for k in 'names', 'nc', 'yaml':
setattr(ensemble, k, getattr(ensemble[0], k)) setattr(ensemble, k, getattr(ensemble[0], k))
ensemble.stride = ensemble[torch.argmax(torch.tensor([m.stride.max() for m in ensemble])).int()].stride ensemble.stride = ensemble[torch.argmax(torch.tensor([m.stride.max() for m in ensemble])).int()].stride
assert all(ensemble[0].nc == m.nc for m in ensemble), f'Models differ in class counts: {[m.nc for m in ensemble]}' assert all(ensemble[0].nc == m.nc for m in ensemble), f'Models differ in class counts {[m.nc for m in ensemble]}'
return ensemble return ensemble
@ -520,7 +520,7 @@ def guess_model_scale(model_path):
which is denoted by n, s, m, l, or x. The function returns the size character of the model scale as a string. which is denoted by n, s, m, l, or x. The function returns the size character of the model scale as a string.
Args: Args:
model_path (str or Path): The path to the YOLO model's YAML file. model_path (str) or (Path): The path to the YOLO model's YAML file.
Returns: Returns:
(str): The size character of the model's scale, which can be n, s, m, l, or x. (str): The size character of the model's scale, which can be n, s, m, l, or x.
@ -539,7 +539,7 @@ def guess_model_task(model):
model (nn.Module) or (dict): PyTorch model or model configuration in YAML format. model (nn.Module) or (dict): PyTorch model or model configuration in YAML format.
Returns: Returns:
str: Task of the model ('detect', 'segment', 'classify', 'pose'). (str): Task of the model ('detect', 'segment', 'classify', 'pose').
Raises: Raises:
SyntaxError: If the task of the model could not be determined. SyntaxError: If the task of the model could not be determined.

@ -190,11 +190,24 @@ def fuse_score(cost_matrix, detections):
def bbox_ious(box1, box2, eps=1e-7): def bbox_ious(box1, box2, eps=1e-7):
"""Boxes are x1y1x2y2
box1: np.array of shape(nx4)
box2: np.array of shape(mx4)
returns: np.array of shape(nxm)
""" """
Calculate the Intersection over Union (IoU) between pairs of bounding boxes.
Args:
box1 (np.array): A numpy array of shape (n, 4) representing 'n' bounding boxes.
Each row is in the format (x1, y1, x2, y2).
box2 (np.array): A numpy array of shape (m, 4) representing 'm' bounding boxes.
Each row is in the format (x1, y1, x2, y2).
eps (float, optional): A small constant to prevent division by zero. Defaults to 1e-7.
Returns:
(np.array): A numpy array of shape (n, m) representing the IoU scores for each pair
of bounding boxes from box1 and box2.
Note:
The bounding box coordinates are expected to be in the format (x1, y1, x2, y2).
"""
# Get the coordinates of bounding boxes # Get the coordinates of bounding boxes
b1_x1, b1_y1, b1_x2, b1_y2 = box1.T b1_x1, b1_y1, b1_x2, b1_y2 = box1.T
b2_x1, b2_y1, b2_x2, b2_y2 = box2.T b2_x1, b2_y1, b2_x2, b2_y2 = box2.T

@ -262,13 +262,15 @@ class RandomPerspective:
return img, M, s return img, M, s
def apply_bboxes(self, bboxes, M): def apply_bboxes(self, bboxes, M):
"""apply affine to bboxes only. """
Apply affine to bboxes only.
Args: Args:
bboxes(ndarray): list of bboxes, xyxy format, with shape (num_bboxes, 4). bboxes (ndarray): list of bboxes, xyxy format, with shape (num_bboxes, 4).
M(ndarray): affine matrix. M (ndarray): affine matrix.
Returns: Returns:
new_bboxes(ndarray): bboxes after affine, [num_bboxes, 4]. new_bboxes (ndarray): bboxes after affine, [num_bboxes, 4].
""" """
n = len(bboxes) n = len(bboxes)
if n == 0: if n == 0:
@ -285,14 +287,16 @@ class RandomPerspective:
return np.concatenate((x.min(1), y.min(1), x.max(1), y.max(1)), dtype=bboxes.dtype).reshape(4, n).T return np.concatenate((x.min(1), y.min(1), x.max(1), y.max(1)), dtype=bboxes.dtype).reshape(4, n).T
def apply_segments(self, segments, M): def apply_segments(self, segments, M):
"""apply affine to segments and generate new bboxes from segments. """
Apply affine to segments and generate new bboxes from segments.
Args: Args:
segments(ndarray): list of segments, [num_samples, 500, 2]. segments (ndarray): list of segments, [num_samples, 500, 2].
M(ndarray): affine matrix. M (ndarray): affine matrix.
Returns: Returns:
new_segments(ndarray): list of segments after affine, [num_samples, 500, 2]. new_segments (ndarray): list of segments after affine, [num_samples, 500, 2].
new_bboxes(ndarray): bboxes after affine, [N, 4]. new_bboxes (ndarray): bboxes after affine, [N, 4].
""" """
n, num = segments.shape[:2] n, num = segments.shape[:2]
if n == 0: if n == 0:
@ -308,13 +312,15 @@ class RandomPerspective:
return bboxes, segments return bboxes, segments
def apply_keypoints(self, keypoints, M): def apply_keypoints(self, keypoints, M):
"""apply affine to keypoints. """
Apply affine to keypoints.
Args: Args:
keypoints(ndarray): keypoints, [N, 17, 3]. keypoints (ndarray): keypoints, [N, 17, 3].
M(ndarray): affine matrix. M (ndarray): affine matrix.
Return: Return:
new_keypoints(ndarray): keypoints after affine, [N, 17, 3]. new_keypoints (ndarray): keypoints after affine, [N, 17, 3].
""" """
n, nkpt = keypoints.shape[:2] n, nkpt = keypoints.shape[:2]
if n == 0: if n == 0:
@ -333,7 +339,7 @@ class RandomPerspective:
Affine images and targets. Affine images and targets.
Args: Args:
labels(Dict): a dict of `bboxes`, `segments`, `keypoints`. labels (dict): a dict of `bboxes`, `segments`, `keypoints`.
""" """
if self.pre_transform and 'mosaic_border' not in labels: if self.pre_transform and 'mosaic_border' not in labels:
labels = self.pre_transform(labels) labels = self.pre_transform(labels)

@ -18,11 +18,30 @@ from .utils import HELP_URL, IMG_FORMATS
class BaseDataset(Dataset): class BaseDataset(Dataset):
"""Base Dataset. """
Base dataset class for loading and processing image data.
Args: Args:
img_path (str): image path. img_path (str): Image path.
pipeline (dict): a dict of image transforms. imgsz (int): Target image size for resizing. Default is 640.
label_path (str): label path, this can also be an ann_file or other custom label path. cache (bool): Cache images in memory or on disk for faster loading. Default is False.
augment (bool): Apply data augmentation. Default is True.
hyp (dict): Dictionary of hyperparameters for data augmentation. Default is None.
prefix (str): Prefix for file paths. Default is an empty string.
rect (bool): Enable rectangular training. Default is False.
batch_size (int): Batch size for rectangular training. Default is None.
stride (int): Stride for rectangular training. Default is 32.
pad (float): Padding for rectangular training. Default is 0.5.
single_cls (bool): Use a single class for all labels. Default is False.
classes (list): List of included classes. Default is None.
Attributes:
im_files (list): List of image file paths.
labels (list): List of label data dictionaries.
ni (int): Number of images in the dataset.
ims (list): List of loaded images.
npy_files (list): List of numpy file paths.
transforms (callable): Image transformation function.
""" """
def __init__(self, def __init__(self,

@ -21,10 +21,7 @@ from .utils import PIN_MEMORY
class InfiniteDataLoader(dataloader.DataLoader): class InfiniteDataLoader(dataloader.DataLoader):
"""Dataloader that reuses workers """Dataloader that reuses workers. Uses same syntax as vanilla DataLoader."""
Uses same syntax as vanilla DataLoader
"""
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
@ -40,10 +37,11 @@ class InfiniteDataLoader(dataloader.DataLoader):
class _RepeatSampler: class _RepeatSampler:
"""Sampler that repeats forever """
Sampler that repeats forever.
Args: Args:
sampler (Sampler) sampler (Dataset.sampler): The sampler to repeat.
""" """
def __init__(self, sampler): def __init__(self, sampler):
@ -173,7 +171,7 @@ def load_inference_source(source=None, transforms=None, imgsz=640, vid_stride=1,
auto (bool, optional): Automatically apply pre-processing. Default is True. auto (bool, optional): Automatically apply pre-processing. Default is True.
Returns: Returns:
dataset: A dataset object for the specified input source. dataset (Dataset): A dataset object for the specified input source.
""" """
source, webcam, screenshot, from_img, in_memory, tensor = check_source(source) source, webcam, screenshot, from_img, in_memory, tensor = check_source(source)
source_type = source.source_type if in_memory else SourceTypes(webcam, screenshot, from_img, tensor) source_type = source.source_type if in_memory else SourceTypes(webcam, screenshot, from_img, tensor)

@ -178,7 +178,7 @@ class _RepeatSampler:
""" Sampler that repeats forever """ Sampler that repeats forever
Args: Args:
sampler (Sampler) sampler (Dataset.sampler): The sampler to repeat.
""" """
def __init__(self, sampler): def __init__(self, sampler):

@ -17,31 +17,31 @@ from .utils import HELP_URL, LOGGER, get_hash, img2label_paths, verify_image_lab
class YOLODataset(BaseDataset): class YOLODataset(BaseDataset):
cache_version = '1.0.2' # dataset labels *.cache version, >= 1.0.0 for YOLOv8
rand_interp_methods = [cv2.INTER_NEAREST, cv2.INTER_LINEAR, cv2.INTER_CUBIC, cv2.INTER_AREA, cv2.INTER_LANCZOS4]
""" """
Dataset class for loading images object detection and/or segmentation labels in YOLO format. Dataset class for loading object detection and/or segmentation labels in YOLO format.
Args: Args:
img_path (str): path to the folder containing images. img_path (str): Path to the folder containing images.
imgsz (int): image size (default: 640). imgsz (int, optional): Image size. Defaults to 640.
cache (bool): if True, a cache file of the labels is created to speed up future creation of dataset instances cache (bool, optional): Cache images to RAM or disk during training. Defaults to False.
(default: False). augment (bool, optional): If True, data augmentation is applied. Defaults to True.
augment (bool): if True, data augmentation is applied (default: True). hyp (dict, optional): Hyperparameters to apply data augmentation. Defaults to None.
hyp (dict): hyperparameters to apply data augmentation (default: None). prefix (str, optional): Prefix to print in log messages. Defaults to ''.
prefix (str): prefix to print in log messages (default: ''). rect (bool, optional): If True, rectangular training is used. Defaults to False.
rect (bool): if True, rectangular training is used (default: False). batch_size (int, optional): Size of batches. Defaults to None.
batch_size (int): size of batches (default: None). stride (int, optional): Stride. Defaults to 32.
stride (int): stride (default: 32). pad (float, optional): Padding. Defaults to 0.0.
pad (float): padding (default: 0.0). single_cls (bool, optional): If True, single class training is used. Defaults to False.
single_cls (bool): if True, single class training is used (default: False). use_segments (bool, optional): If True, segmentation masks are used as labels. Defaults to False.
use_segments (bool): if True, segmentation masks are used as labels (default: False). use_keypoints (bool, optional): If True, keypoints are used as labels. Defaults to False.
use_keypoints (bool): if True, keypoints are used as labels (default: False). data (dict, optional): A dataset YAML dictionary. Defaults to None.
names (dict): A dictionary of class names. (default: None). classes (list): List of included classes. Default is None.
Returns: Returns:
A PyTorch dataset object that can be used for training an object detection or segmentation model. (torch.utils.data.Dataset): A PyTorch dataset object that can be used for training an object detection model.
""" """
cache_version = '1.0.2' # dataset labels *.cache version, >= 1.0.0 for YOLOv8
rand_interp_methods = [cv2.INTER_NEAREST, cv2.INTER_LINEAR, cv2.INTER_CUBIC, cv2.INTER_AREA, cv2.INTER_LANCZOS4]
def __init__(self, def __init__(self,
img_path, img_path,

@ -7,21 +7,36 @@ from .augment import LetterBox
class MixAndRectDataset: class MixAndRectDataset:
"""A wrapper of multiple images mixed dataset. """
A dataset class that applies mosaic and mixup transformations as well as rectangular training.
Args: Attributes:
dataset (:obj:`BaseDataset`): The dataset to be mixed. dataset: The base dataset.
transforms (Sequence[dict]): config dict to be composed. imgsz: The size of the images in the dataset.
""" """
def __init__(self, dataset): def __init__(self, dataset):
"""
Args:
dataset (BaseDataset): The base dataset to apply transformations to.
"""
self.dataset = dataset self.dataset = dataset
self.imgsz = dataset.imgsz self.imgsz = dataset.imgsz
def __len__(self): def __len__(self):
"""Returns the number of items in the dataset."""
return len(self.dataset) return len(self.dataset)
def __getitem__(self, index): def __getitem__(self, index):
"""
Applies mosaic, mixup and rectangular training transformations to an item in the dataset.
Args:
index (int): Index of the item in the dataset.
Returns:
(dict): A dictionary containing the transformed item data.
"""
labels = deepcopy(self.dataset[index]) labels = deepcopy(self.dataset[index])
for transform in self.dataset.transforms.tolist(): for transform in self.dataset.transforms.tolist():
# mosaic and mixup # mosaic and mixup

@ -270,9 +270,8 @@ def check_cls_dataset(dataset: str):
""" """
Check a classification dataset such as Imagenet. Check a classification dataset such as Imagenet.
Copy code
This function takes a `dataset` name as input and returns a dictionary containing information about the dataset. This function takes a `dataset` name as input and returns a dictionary containing information about the dataset.
If the dataset is not found, it attempts to download the dataset from the internet and save it to the local file system. If the dataset is not found, it attempts to download the dataset from the internet and save it locally.
Args: Args:
dataset (str): Name of the dataset. dataset (str): Name of the dataset.
@ -306,7 +305,8 @@ def check_cls_dataset(dataset: str):
class HUBDatasetStats(): class HUBDatasetStats():
""" Class for generating HUB dataset JSON and `-hub` dataset directory """
Class for generating HUB dataset JSON and `-hub` dataset directory
Arguments Arguments
path: Path to data.yaml or data.zip (with data.yaml inside data.zip) path: Path to data.yaml or data.zip (with data.yaml inside data.zip)
@ -427,9 +427,6 @@ def compress_one_image(f, f_new=None, max_dim=1920, quality=50):
max_dim (int, optional): The maximum dimension (width or height) of the output image. Default is 1920 pixels. max_dim (int, optional): The maximum dimension (width or height) of the output image. Default is 1920 pixels.
quality (int, optional): The image compression quality as a percentage. Default is 50%. quality (int, optional): The image compression quality as a percentage. Default is 50%.
Returns:
None
Usage: Usage:
from pathlib import Path from pathlib import Path
from ultralytics.yolo.data.utils import compress_one_image from ultralytics.yolo.data.utils import compress_one_image
@ -459,9 +456,6 @@ def delete_dsstore(path):
Args: Args:
path (str, optional): The directory path where the ".DS_store" files should be deleted. path (str, optional): The directory path where the ".DS_store" files should be deleted.
Returns:
None
Usage: Usage:
from ultralytics.yolo.data.utils import delete_dsstore from ultralytics.yolo.data.utils import delete_dsstore
delete_dsstore('/Users/glennjocher/Downloads/dataset') delete_dsstore('/Users/glennjocher/Downloads/dataset')
@ -478,15 +472,13 @@ def delete_dsstore(path):
def zip_directory(dir, use_zipfile_library=True): def zip_directory(dir, use_zipfile_library=True):
"""Zips a directory and saves the archive to the specified output path. """
Zips a directory and saves the archive to the specified output path.
Args: Args:
dir (str): The path to the directory to be zipped. dir (str): The path to the directory to be zipped.
use_zipfile_library (bool): Whether to use zipfile library or shutil for zipping. use_zipfile_library (bool): Whether to use zipfile library or shutil for zipping.
Returns:
None
Usage: Usage:
from ultralytics.yolo.data.utils import zip_directory from ultralytics.yolo.data.utils import zip_directory
zip_directory('/Users/glennjocher/Downloads/playground') zip_directory('/Users/glennjocher/Downloads/playground')

@ -73,7 +73,7 @@ ARM64 = platform.machine() in ('arm64', 'aarch64')
def export_formats(): def export_formats():
# YOLOv8 export formats """YOLOv8 export formats"""
import pandas import pandas
x = [ x = [
['PyTorch', '-', '.pt', True, True], ['PyTorch', '-', '.pt', True, True],
@ -92,7 +92,7 @@ def export_formats():
def gd_outputs(gd): def gd_outputs(gd):
# TensorFlow GraphDef model output node names """TensorFlow GraphDef model output node names"""
name_list, input_list = [], [] name_list, input_list = [], []
for node in gd.node: # tensorflow.core.framework.node_def_pb2.NodeDef for node in gd.node: # tensorflow.core.framework.node_def_pb2.NodeDef
name_list.append(node.name) name_list.append(node.name)
@ -101,7 +101,7 @@ def gd_outputs(gd):
def try_export(inner_func): def try_export(inner_func):
# YOLOv8 export decorator, i..e @try_export """YOLOv8 export decorator, i..e @try_export"""
inner_args = get_default_args(inner_func) inner_args = get_default_args(inner_func)
def outer_func(*args, **kwargs): def outer_func(*args, **kwargs):
@ -118,10 +118,26 @@ def try_export(inner_func):
return outer_func return outer_func
class iOSDetectModel(torch.nn.Module):
"""Wrap an Ultralytics YOLO model for iOS export"""
def __init__(self, model, im):
super().__init__()
b, c, h, w = im.shape # batch, channel, height, width
self.model = model
self.nc = len(model.names) # number of classes
if w == h:
self.normalize = 1.0 / w # scalar
else:
self.normalize = torch.tensor([1.0 / w, 1.0 / h, 1.0 / w, 1.0 / h]) # broadcast (slower, smaller)
def forward(self, x):
xywh, cls = self.model(x)[0].transpose(0, 1).split((4, self.nc), 1)
return cls, xywh * self.normalize # confidence (3780, 80), coordinates (3780, 4)
class Exporter: class Exporter:
""" """
Exporter
A class for exporting a model. A class for exporting a model.
Attributes: Attributes:
@ -136,6 +152,7 @@ class Exporter:
Args: Args:
cfg (str, optional): Path to a configuration file. Defaults to DEFAULT_CFG. cfg (str, optional): Path to a configuration file. Defaults to DEFAULT_CFG.
overrides (dict, optional): Configuration overrides. Defaults to None. overrides (dict, optional): Configuration overrides. Defaults to None.
_callbacks (list, optional): List of callback functions. Defaults to None.
""" """
self.args = get_cfg(cfg, overrides) self.args = get_cfg(cfg, overrides)
self.callbacks = _callbacks or callbacks.get_default_callbacks() self.callbacks = _callbacks or callbacks.get_default_callbacks()
@ -385,22 +402,6 @@ class Exporter:
check_requirements('coremltools>=6.0') check_requirements('coremltools>=6.0')
import coremltools as ct # noqa import coremltools as ct # noqa
class iOSDetectModel(torch.nn.Module):
# Wrap an Ultralytics YOLO model for iOS export
def __init__(self, model, im):
super().__init__()
b, c, h, w = im.shape # batch, channel, height, width
self.model = model
self.nc = len(model.names) # number of classes
if w == h:
self.normalize = 1.0 / w # scalar
else:
self.normalize = torch.tensor([1.0 / w, 1.0 / h, 1.0 / w, 1.0 / h]) # broadcast (slower, smaller)
def forward(self, x):
xywh, cls = self.model(x)[0].transpose(0, 1).split((4, self.nc), 1)
return cls, xywh * self.normalize # confidence (3780, 80), coordinates (3780, 4)
LOGGER.info(f'\n{prefix} starting export with coremltools {ct.__version__}...') LOGGER.info(f'\n{prefix} starting export with coremltools {ct.__version__}...')
f = self.file.with_suffix('.mlmodel') f = self.file.with_suffix('.mlmodel')

@ -400,7 +400,7 @@ class YOLO:
train_args (dict, optional): Additional arguments to pass to the `train()` method. Defaults to {}. train_args (dict, optional): Additional arguments to pass to the `train()` method. Defaults to {}.
Returns: Returns:
A dictionary containing the results of the hyperparameter search. (dict): A dictionary containing the results of the hyperparameter search.
Raises: Raises:
ModuleNotFoundError: If Ray Tune is not installed. ModuleNotFoundError: If Ray Tune is not installed.

@ -127,7 +127,10 @@ class BasePredictor:
log_string += result.verbose() log_string += result.verbose()
if self.args.save or self.args.show: # Add bbox to image if self.args.save or self.args.show: # Add bbox to image
plot_args = dict(line_width=self.args.line_thickness, boxes=self.args.boxes) plot_args = dict(line_width=self.args.line_thickness,
boxes=self.args.boxes,
conf=self.args.show_conf,
labels=self.args.show_labels)
if not self.args.retina_masks: if not self.args.retina_masks:
plot_args['im_gpu'] = im[idx] plot_args['im_gpu'] = im[idx]
self.plotted_img = result.plot(**plot_args) self.plotted_img = result.plot(**plot_args)

@ -621,7 +621,7 @@ def check_amp(model):
model (nn.Module): A YOLOv8 model instance. model (nn.Module): A YOLOv8 model instance.
Returns: Returns:
bool: Returns True if the AMP functionality works correctly with YOLOv8 model, else False. (bool): Returns True if the AMP functionality works correctly with YOLOv8 model, else False.
Raises: Raises:
AssertionError: If the AMP checks fail, indicating anomalies with the AMP functionality on the system. AssertionError: If the AMP checks fail, indicating anomalies with the AMP functionality on the system.

@ -22,7 +22,7 @@ def check_train_batch_size(model, imgsz=640, amp=True):
amp (bool): If True, use automatic mixed precision (AMP) for training. amp (bool): If True, use automatic mixed precision (AMP) for training.
Returns: Returns:
int: Optimal batch size computed using the autobatch() function. (int): Optimal batch size computed using the autobatch() function.
""" """
with torch.cuda.amp.autocast(amp): with torch.cuda.amp.autocast(amp):
@ -34,13 +34,13 @@ def autobatch(model, imgsz=640, fraction=0.67, batch_size=16):
Automatically estimate the best YOLO batch size to use a fraction of the available CUDA memory. Automatically estimate the best YOLO batch size to use a fraction of the available CUDA memory.
Args: Args:
model: YOLO model to compute batch size for. model (torch.nn.module): YOLO model to compute batch size for.
imgsz (int, optional): The image size used as input for the YOLO model. Defaults to 640. imgsz (int, optional): The image size used as input for the YOLO model. Defaults to 640.
fraction (float, optional): The fraction of available CUDA memory to use. Defaults to 0.67. fraction (float, optional): The fraction of available CUDA memory to use. Defaults to 0.67.
batch_size (int, optional): The default batch size to use if an error is detected. Defaults to 16. batch_size (int, optional): The default batch size to use if an error is detected. Defaults to 16.
Returns: Returns:
int: The optimal batch size. (int): The optimal batch size.
""" """
# Check device # Check device

@ -19,14 +19,14 @@ except (ImportError, AssertionError):
clearml = None clearml = None
def _log_debug_samples(files, title='Debug Samples'): def _log_debug_samples(files, title='Debug Samples') -> None:
""" """
Log files (images) as debug samples in the ClearML task. Log files (images) as debug samples in the ClearML task.
arguments: Args:
files (List(PosixPath)) a list of file paths in PosixPath format files (list): A list of file paths in PosixPath format.
title (str) A title that groups together images with the same values title (str): A title that groups together images with the same values.
""" """
task = Task.current_task() task = Task.current_task()
if task: if task:
for f in files: for f in files:
@ -39,20 +39,23 @@ def _log_debug_samples(files, title='Debug Samples'):
iteration=iteration) iteration=iteration)
def _log_plot(title, plot_path): def _log_plot(title, plot_path) -> None:
""" """
Log image as plot in the plot section of ClearML Log an image as a plot in the plot section of ClearML.
arguments: Args:
title (str) Title of the plot title (str): The title of the plot.
plot_path (PosixPath or str) Path to the saved image file plot_path (str): The path to the saved image file.
""" """
img = mpimg.imread(plot_path) img = mpimg.imread(plot_path)
fig = plt.figure() fig = plt.figure()
ax = fig.add_axes([0, 0, 1, 1], frameon=False, aspect='auto', xticks=[], yticks=[]) # no ticks ax = fig.add_axes([0, 0, 1, 1], frameon=False, aspect='auto', xticks=[], yticks=[]) # no ticks
ax.imshow(img) ax.imshow(img)
Task.current_task().get_logger().report_matplotlib_figure(title, '', figure=fig, report_interactive=False) Task.current_task().get_logger().report_matplotlib_figure(title=title,
series='',
figure=fig,
report_interactive=False)
def on_pretrain_routine_start(trainer): def on_pretrain_routine_start(trainer):

@ -47,13 +47,13 @@ def check_imgsz(imgsz, stride=32, min_dim=1, max_dim=2, floor=0):
stride, update it to the nearest multiple of the stride that is greater than or equal to the given floor value. stride, update it to the nearest multiple of the stride that is greater than or equal to the given floor value.
Args: Args:
imgsz (int or List[int]): Image size. imgsz (int) or (cList[int]): Image size.
stride (int): Stride value. stride (int): Stride value.
min_dim (int): Minimum number of dimensions. min_dim (int): Minimum number of dimensions.
floor (int): Minimum allowed value for image size. floor (int): Minimum allowed value for image size.
Returns: Returns:
List[int]: Updated image size. (List[int]): Updated image size.
""" """
# Convert stride to integer if it is a tensor # Convert stride to integer if it is a tensor
stride = int(stride.max() if isinstance(stride, torch.Tensor) else stride) stride = int(stride.max() if isinstance(stride, torch.Tensor) else stride)
@ -106,7 +106,7 @@ def check_version(current: str = '0.0.0',
verbose (bool): If True, print warning message if minimum version is not met. verbose (bool): If True, print warning message if minimum version is not met.
Returns: Returns:
bool: True if minimum version is met, False otherwise. (bool): True if minimum version is met, False otherwise.
""" """
current, minimum = (pkg.parse_version(x) for x in (current, minimum)) current, minimum = (pkg.parse_version(x) for x in (current, minimum))
result = (current == minimum) if pinned else (current >= minimum) # bool result = (current == minimum) if pinned else (current >= minimum) # bool
@ -126,7 +126,7 @@ def check_latest_pypi_version(package_name='ultralytics'):
package_name (str): The name of the package to find the latest version for. package_name (str): The name of the package to find the latest version for.
Returns: Returns:
str: The latest version of the package. (str): The latest version of the package.
""" """
requests.packages.urllib3.disable_warnings() # Disable the InsecureRequestWarning requests.packages.urllib3.disable_warnings() # Disable the InsecureRequestWarning
response = requests.get(f'https://pypi.org/pypi/{package_name}/json', verify=False) response = requests.get(f'https://pypi.org/pypi/{package_name}/json', verify=False)
@ -140,7 +140,7 @@ def check_pip_update_available():
Checks if a new version of the ultralytics package is available on PyPI. Checks if a new version of the ultralytics package is available on PyPI.
Returns: Returns:
bool: True if an update is available, False otherwise. (bool): True if an update is available, False otherwise.
""" """
if ONLINE and is_pip_package(): if ONLINE and is_pip_package():
with contextlib.suppress(Exception): with contextlib.suppress(Exception):
@ -206,9 +206,6 @@ def check_requirements(requirements=ROOT.parent / 'requirements.txt', exclude=()
exclude (Tuple[str]): Tuple of package names to exclude from checking. exclude (Tuple[str]): Tuple of package names to exclude from checking.
install (bool): If True, attempt to auto-update packages that don't meet requirements. install (bool): If True, attempt to auto-update packages that don't meet requirements.
cmds (str): Additional commands to pass to the pip install command when auto-updating. cmds (str): Additional commands to pass to the pip install command when auto-updating.
Returns:
None
""" """
prefix = colorstr('red', 'bold', 'requirements:') prefix = colorstr('red', 'bold', 'requirements:')
check_python() # check python version check_python() # check python version

@ -67,21 +67,21 @@ def safe_download(url,
min_bytes=1E0, min_bytes=1E0,
progress=True): progress=True):
""" """
Function for downloading files from a URL, with options for retrying, unzipping, and deleting the downloaded file. Downloads files from a URL, with options for retrying, unzipping, and deleting the downloaded file.
Args: Args:
url: str: The URL of the file to be downloaded. url (str): The URL of the file to be downloaded.
file: str, optional: The filename of the downloaded file. file (str, optional): The filename of the downloaded file.
If not provided, the file will be saved with the same name as the URL. If not provided, the file will be saved with the same name as the URL.
dir: str, optional: The directory to save the downloaded file. dir (str, optional): The directory to save the downloaded file.
If not provided, the file will be saved in the current working directory. If not provided, the file will be saved in the current working directory.
unzip: bool, optional: Whether to unzip the downloaded file. Default: True. unzip (bool, optional): Whether to unzip the downloaded file. Default: True.
delete: bool, optional: Whether to delete the downloaded file after unzipping. Default: False. delete (bool, optional): Whether to delete the downloaded file after unzipping. Default: False.
curl: bool, optional: Whether to use curl command line tool for downloading. Default: False. curl (bool, optional): Whether to use curl command line tool for downloading. Default: False.
retry: int, optional: The number of times to retry the download in case of failure. Default: 3. retry (int, optional): The number of times to retry the download in case of failure. Default: 3.
min_bytes: float, optional: The minimum number of bytes that the downloaded file should have, to be considered min_bytes (float, optional): The minimum number of bytes that the downloaded file should have, to be considered
a successful download. Default: 1E0. a successful download. Default: 1E0.
progress: bool, optional: Whether to display a progress bar during the download. Default: True. progress (bool, optional): Whether to display a progress bar during the download. Default: True.
""" """
if '://' not in str(url) and Path(url).is_file(): # exists ('://' check required in Windows Python<3.10) if '://' not in str(url) and Path(url).is_file(): # exists ('://' check required in Windows Python<3.10)
f = Path(url) # filename f = Path(url) # filename

@ -30,13 +30,13 @@ def increment_path(path, exist_ok=False, sep='', mkdir=False):
directory if it does not already exist. directory if it does not already exist.
Args: Args:
path (str or pathlib.Path): Path to increment. path (str, pathlib.Path): Path to increment.
exist_ok (bool, optional): If True, the path will not be incremented and will be returned as-is. Defaults to False. exist_ok (bool, optional): If True, the path will not be incremented and returned as-is. Defaults to False.
sep (str, optional): Separator to use between the path and the incrementation number. Defaults to an empty string. sep (str, optional): Separator to use between the path and the incrementation number. Defaults to ''.
mkdir (bool, optional): If True, the path will be created as a directory if it does not exist. Defaults to False. mkdir (bool, optional): Create a directory if it does not exist. Defaults to False.
Returns: Returns:
pathlib.Path: Incremented path. (pathlib.Path): Incremented path.
""" """
path = Path(path) # os-agnostic path = Path(path) # os-agnostic
if path.exists() and not exist_ok: if path.exists() and not exist_ok:

@ -98,7 +98,7 @@ class Bboxes:
def mul(self, scale): def mul(self, scale):
""" """
Args: Args:
scale (tuple | List | int): the scale for four coords. scale (tuple) or (list) or (int): the scale for four coords.
""" """
if isinstance(scale, Number): if isinstance(scale, Number):
scale = to_4tuple(scale) scale = to_4tuple(scale)
@ -112,7 +112,7 @@ class Bboxes:
def add(self, offset): def add(self, offset):
""" """
Args: Args:
offset (tuple | List | int): the offset for four coords. offset (tuple) or (list) or (int): the offset for four coords.
""" """
if isinstance(offset, Number): if isinstance(offset, Number):
offset = to_4tuple(offset) offset = to_4tuple(offset)
@ -129,13 +129,18 @@ class Bboxes:
@classmethod @classmethod
def concatenate(cls, boxes_list: List['Bboxes'], axis=0) -> 'Bboxes': def concatenate(cls, boxes_list: List['Bboxes'], axis=0) -> 'Bboxes':
""" """
Concatenates a list of Boxes into a single Bboxes Concatenate a list of Bboxes objects into a single Bboxes object.
Arguments: Args:
boxes_list (list[Bboxes]) boxes_list (List[Bboxes]): A list of Bboxes objects to concatenate.
axis (int, optional): The axis along which to concatenate the bounding boxes.
Defaults to 0.
Returns: Returns:
Bboxes: the concatenated Boxes Bboxes: A new Bboxes object containing the concatenated bounding boxes.
Note:
The input should be a list or tuple of Bboxes objects.
""" """
assert isinstance(boxes_list, (list, tuple)) assert isinstance(boxes_list, (list, tuple))
if not boxes_list: if not boxes_list:
@ -148,11 +153,21 @@ class Bboxes:
def __getitem__(self, index) -> 'Bboxes': def __getitem__(self, index) -> 'Bboxes':
""" """
Retrieve a specific bounding box or a set of bounding boxes using indexing.
Args: Args:
index: int, slice, or a BoolArray index (int, slice, or np.ndarray): The index, slice, or boolean array to select
the desired bounding boxes.
Returns: Returns:
Bboxes: Create a new :class:`Bboxes` by indexing. Bboxes: A new Bboxes object containing the selected bounding boxes.
Raises:
AssertionError: If the indexed bounding boxes do not form a 2-dimensional matrix.
Note:
When using boolean indexing, make sure to provide a boolean array with the same
length as the number of bounding boxes.
""" """
if isinstance(index, int): if isinstance(index, int):
return Bboxes(self.bboxes[index].view(1, -1)) return Bboxes(self.bboxes[index].view(1, -1))
@ -236,11 +251,19 @@ class Instances:
def __getitem__(self, index) -> 'Instances': def __getitem__(self, index) -> 'Instances':
""" """
Retrieve a specific instance or a set of instances using indexing.
Args: Args:
index: int, slice, or a BoolArray index (int, slice, or np.ndarray): The index, slice, or boolean array to select
the desired instances.
Returns: Returns:
Instances: Create a new :class:`Instances` by indexing. Instances: A new Instances object containing the selected bounding boxes,
segments, and keypoints if present.
Note:
When using boolean indexing, make sure to provide a boolean array with the same
length as the number of instances.
""" """
segments = self.segments[index] if len(self.segments) else self.segments segments = self.segments[index] if len(self.segments) else self.segments
keypoints = self.keypoints[index] if self.keypoints is not None else None keypoints = self.keypoints[index] if self.keypoints is not None else None
@ -305,14 +328,20 @@ class Instances:
@classmethod @classmethod
def concatenate(cls, instances_list: List['Instances'], axis=0) -> 'Instances': def concatenate(cls, instances_list: List['Instances'], axis=0) -> 'Instances':
""" """
Concatenates a list of Boxes into a single Bboxes Concatenates a list of Instances objects into a single Instances object.
Arguments: Args:
instances_list (list[Bboxes]) instances_list (List[Instances]): A list of Instances objects to concatenate.
axis axis (int, optional): The axis along which the arrays will be concatenated. Defaults to 0.
Returns: Returns:
Boxes: the concatenated Boxes Instances: A new Instances object containing the concatenated bounding boxes,
segments, and keypoints if present.
Note:
The `Instances` objects in the list should have the same properties, such as
the format of the bounding boxes, whether keypoints are present, and if the
coordinates are normalized.
""" """
assert isinstance(instances_list, (list, tuple)) assert isinstance(instances_list, (list, tuple))
if not instances_list: if not instances_list:

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save