├── ultralytics ├── ultralytics │ ├── engine │ │ └── __init__.py │ ├── models │ │ ├── utils │ │ │ └── __init__.py │ │ ├── sam │ │ │ ├── modules │ │ │ │ ├── __init__.py │ │ │ │ └── sam.py │ │ │ ├── __init__.py │ │ │ └── model.py │ │ ├── __init__.py │ │ ├── nas │ │ │ ├── __init__.py │ │ │ ├── val.py │ │ │ └── predict.py │ │ ├── yolo │ │ │ ├── __init__.py │ │ │ ├── pose │ │ │ │ └── __init__.py │ │ │ ├── detect │ │ │ │ ├── __init__.py │ │ │ │ └── predict.py │ │ │ ├── segment │ │ │ │ └── __init__.py │ │ │ ├── classify │ │ │ │ ├── __init__.py │ │ │ │ └── predict.py │ │ │ └── model.py │ │ ├── rtdetr │ │ │ ├── __init__.py │ │ │ └── model.py │ │ └── fastsam │ │ │ ├── __init__.py │ │ │ ├── val.py │ │ │ └── model.py │ ├── trackers │ │ ├── utils │ │ │ └── __init__.py │ │ ├── __init__.py │ │ └── basetrack.py │ ├── utils │ │ ├── callbacks │ │ │ ├── __init__.py │ │ │ └── raytune.py │ │ └── errors.py │ ├── data │ │ ├── __init__.py │ │ ├── scripts │ │ │ ├── download_weights.sh │ │ │ ├── get_coco128.sh │ │ │ ├── get_imagenet.sh │ │ │ └── get_coco.sh │ │ └── annotator.py │ ├── __init__.py │ ├── nn │ │ ├── __init__.py │ │ └── modules │ │ │ └── __init__.py │ └── cfg │ │ ├── trackers │ │ ├── bytetrack.yaml │ │ └── botsort.yaml │ │ └── models │ │ ├── v8 │ │ ├── yolov8-cls.yaml │ │ ├── yolov8-seg.yaml │ │ ├── yolov8-pose.yaml │ │ ├── yolov8-p2.yaml │ │ ├── yolov8-p6.yaml │ │ ├── yolov8.yaml │ │ ├── yolov8-seg-p6.yaml │ │ ├── yolov8-rtdetr.yaml │ │ └── yolov8-pose-p6.yaml │ │ ├── v3 │ │ ├── yolov3-tiny.yaml │ │ ├── yolov3.yaml │ │ └── yolov3-spp.yaml │ │ ├── v5 │ │ ├── yolov5.yaml │ │ └── yolov5-p6.yaml │ │ ├── v6 │ │ └── yolov6.yaml │ │ └── rt-detr │ │ ├── rtdetr-l.yaml │ │ └── rtdetr-x.yaml ├── docs │ ├── CNAME │ ├── robots.txt │ ├── assets │ │ └── favicon.ico │ ├── reference │ │ ├── utils │ │ │ ├── triton.md │ │ │ ├── tuner.md │ │ │ ├── errors.md │ │ │ ├── callbacks │ │ │ │ ├── raytune.md │ │ │ │ ├── mlflow.md │ │ │ │ ├── wb.md │ │ │ │ ├── tensorboard.md │ │ │ │ ├── clearml.md │ │ │ │ ├── hub.md │ │ │ │ ├── neptune.md │ │ │ │ └── dvc.md │ │ │ ├── benchmarks.md │ │ │ ├── autobatch.md │ │ │ ├── instance.md │ │ │ ├── patches.md │ │ │ ├── dist.md │ │ │ ├── tal.md │ │ │ ├── files.md │ │ │ ├── loss.md │ │ │ ├── plotting.md │ │ │ ├── downloads.md │ │ │ └── metrics.md │ │ ├── data │ │ │ ├── base.md │ │ │ ├── annotator.md │ │ │ ├── dataset.md │ │ │ ├── converter.md │ │ │ ├── build.md │ │ │ ├── loaders.md │ │ │ ├── utils.md │ │ │ └── augment.md │ │ ├── hub │ │ │ ├── auth.md │ │ │ ├── session.md │ │ │ ├── utils.md │ │ │ └── __init__.md │ │ ├── engine │ │ │ ├── trainer.md │ │ │ ├── predictor.md │ │ │ ├── validator.md │ │ │ ├── model.md │ │ │ ├── tuner.md │ │ │ ├── exporter.md │ │ │ └── results.md │ │ ├── models │ │ │ ├── yolo │ │ │ │ ├── model.md │ │ │ │ ├── pose │ │ │ │ │ ├── val.md │ │ │ │ │ ├── predict.md │ │ │ │ │ └── train.md │ │ │ │ ├── detect │ │ │ │ │ ├── val.md │ │ │ │ │ ├── predict.md │ │ │ │ │ └── train.md │ │ │ │ ├── segment │ │ │ │ │ ├── predict.md │ │ │ │ │ ├── train.md │ │ │ │ │ └── val.md │ │ │ │ └── classify │ │ │ │ │ ├── predict.md │ │ │ │ │ ├── train.md │ │ │ │ │ └── val.md │ │ │ ├── nas │ │ │ │ ├── model.md │ │ │ │ ├── val.md │ │ │ │ └── predict.md │ │ │ ├── fastsam │ │ │ │ ├── val.md │ │ │ │ ├── model.md │ │ │ │ ├── prompt.md │ │ │ │ ├── predict.md │ │ │ │ └── utils.md │ │ │ ├── sam │ │ │ │ ├── model.md │ │ │ │ ├── modules │ │ │ │ │ ├── sam.md │ │ │ │ │ ├── decoders.md │ │ │ │ │ ├── transformer.md │ │ │ │ │ ├── encoders.md │ │ │ │ │ └── tiny_encoder.md │ │ │ │ ├── predict.md │ │ │ │ ├── build.md │ │ │ │ └── amg.md │ │ │ ├── rtdetr │ │ │ │ ├── model.md │ │ │ │ ├── predict.md │ │ │ │ ├── train.md │ │ │ │ └── val.md │ │ │ └── utils │ │ │ │ ├── ops.md │ │ │ │ └── loss.md │ │ ├── trackers │ │ │ ├── utils │ │ │ │ ├── gmc.md │ │ │ │ ├── kalman_filter.md │ │ │ │ └── matching.md │ │ │ ├── basetrack.md │ │ │ ├── bot_sort.md │ │ │ ├── byte_tracker.md │ │ │ └── track.md │ │ ├── nn │ │ │ ├── autobackend.md │ │ │ ├── modules │ │ │ │ ├── head.md │ │ │ │ ├── utils.md │ │ │ │ ├── transformer.md │ │ │ │ ├── conv.md │ │ │ │ └── block.md │ │ │ └── tasks.md │ │ └── cfg │ │ │ └── __init__.md │ ├── overrides │ │ └── partials │ │ │ ├── source-file.html │ │ │ └── comments.html │ ├── stylesheets │ │ └── style.css │ ├── SECURITY.md │ └── help │ │ └── index.md ├── MANIFEST.in ├── .github │ ├── ISSUE_TEMPLATE │ │ ├── config.yml │ │ ├── question.yml │ │ └── feature-request.yml │ ├── dependabot.yml │ ├── translate-readme.yml │ └── workflows │ │ ├── codeql.yaml │ │ ├── cla.yml │ │ └── links.yml ├── examples │ ├── YOLOv8-OpenCV-ONNX-Python │ │ └── README.md │ ├── YOLOv8-CPP-Inference │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ └── inference.h │ ├── YOLOv8-ONNXRuntime │ │ └── README.md │ └── YOLOv8-ONNXRuntime-CPP │ │ └── inference.h ├── CITATION.cff ├── requirements.txt ├── docker │ ├── Dockerfile-runner │ ├── Dockerfile-conda │ └── Dockerfile-arm64 ├── .pre-commit-config.yaml └── setup.cfg └── README.md /ultralytics/ultralytics/engine/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ultralytics/docs/CNAME: -------------------------------------------------------------------------------- 1 | docs.ultralytics.com 2 | -------------------------------------------------------------------------------- /ultralytics/docs/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # yolov8_QAT 2 | ultralytics为yolov8的最新官方代码 3 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/models/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/models/sam/modules/__init__.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/trackers/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | -------------------------------------------------------------------------------- /ultralytics/docs/assets/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuningMangoPi/yolov8_QAT/HEAD/ultralytics/docs/assets/favicon.ico -------------------------------------------------------------------------------- /ultralytics/ultralytics/models/__init__.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | from .rtdetr import RTDETR 4 | from .sam import SAM 5 | from .yolo import YOLO 6 | 7 | __all__ = 'YOLO', 'RTDETR', 'SAM' # allow simpler import 8 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/models/nas/__init__.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | from .model import NAS 4 | from .predict import NASPredictor 5 | from .val import NASValidator 6 | 7 | __all__ = 'NASPredictor', 'NASValidator', 'NAS' 8 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/models/sam/__init__.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | from .model import SAM 4 | from .predict import Predictor 5 | 6 | # from .build import build_sam 7 | 8 | __all__ = 'SAM', 'Predictor' # tuple or list 9 | -------------------------------------------------------------------------------- /ultralytics/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include *.md 2 | include requirements.txt 3 | include LICENSE 4 | include setup.py 5 | include ultralytics/assets/bus.jpg 6 | include ultralytics/assets/zidane.jpg 7 | include tests/*.py 8 | recursive-include ultralytics *.yaml 9 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/models/yolo/__init__.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | from ultralytics.models.yolo import classify, detect, pose, segment 4 | 5 | from .model import YOLO 6 | 7 | __all__ = 'classify', 'segment', 'detect', 'pose', 'YOLO' 8 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/models/rtdetr/__init__.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | from .model import RTDETR 4 | from .predict import RTDETRPredictor 5 | from .val import RTDETRValidator 6 | 7 | __all__ = 'RTDETRPredictor', 'RTDETRValidator', 'RTDETR' 8 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/models/yolo/pose/__init__.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | from .predict import PosePredictor 4 | from .train import PoseTrainer 5 | from .val import PoseValidator 6 | 7 | __all__ = 'PoseTrainer', 'PoseValidator', 'PosePredictor' 8 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/utils/callbacks/__init__.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | from .base import add_integration_callbacks, default_callbacks, get_default_callbacks 4 | 5 | __all__ = 'add_integration_callbacks', 'default_callbacks', 'get_default_callbacks' 6 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/trackers/__init__.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | from .bot_sort import BOTSORT 4 | from .byte_tracker import BYTETracker 5 | from .track import register_tracker 6 | 7 | __all__ = 'register_tracker', 'BOTSORT', 'BYTETracker' # allow simpler import 8 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/models/yolo/detect/__init__.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | from .predict import DetectionPredictor 4 | from .train import DetectionTrainer 5 | from .val import DetectionValidator 6 | 7 | __all__ = 'DetectionPredictor', 'DetectionTrainer', 'DetectionValidator' 8 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/models/yolo/segment/__init__.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | from .predict import SegmentationPredictor 4 | from .train import SegmentationTrainer 5 | from .val import SegmentationValidator 6 | 7 | __all__ = 'SegmentationPredictor', 'SegmentationTrainer', 'SegmentationValidator' 8 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/models/fastsam/__init__.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | from .model import FastSAM 4 | from .predict import FastSAMPredictor 5 | from .prompt import FastSAMPrompt 6 | from .val import FastSAMValidator 7 | 8 | __all__ = 'FastSAMPredictor', 'FastSAM', 'FastSAMPrompt', 'FastSAMValidator' 9 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/utils/errors.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | from ultralytics.utils import emojis 4 | 5 | 6 | class HUBModelError(Exception): 7 | 8 | def __init__(self, message='Model not found. Please check model URL and try again.'): 9 | """Create an exception for when a model is not found.""" 10 | super().__init__(emojis(message)) 11 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/models/yolo/classify/__init__.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | from ultralytics.models.yolo.classify.predict import ClassificationPredictor 4 | from ultralytics.models.yolo.classify.train import ClassificationTrainer 5 | from ultralytics.models.yolo.classify.val import ClassificationValidator 6 | 7 | __all__ = 'ClassificationPredictor', 'ClassificationTrainer', 'ClassificationValidator' 8 | -------------------------------------------------------------------------------- /ultralytics/.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | contact_links: 3 | - name: 📄 Docs 4 | url: https://docs.ultralytics.com/ 5 | about: Full Ultralytics YOLOv8 Documentation 6 | - name: 💬 Forum 7 | url: https://community.ultralytics.com/ 8 | about: Ask on Ultralytics Community Forum 9 | - name: 🎧 Discord 10 | url: https://ultralytics.com/discord 11 | about: Ask on Ultralytics Discord 12 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/data/__init__.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | from .base import BaseDataset 4 | from .build import build_dataloader, build_yolo_dataset, load_inference_source 5 | from .dataset import ClassificationDataset, SemanticDataset, YOLODataset 6 | 7 | __all__ = ('BaseDataset', 'ClassificationDataset', 'SemanticDataset', 'YOLODataset', 'build_yolo_dataset', 8 | 'build_dataloader', 'load_inference_source') 9 | -------------------------------------------------------------------------------- /ultralytics/examples/YOLOv8-OpenCV-ONNX-Python/README.md: -------------------------------------------------------------------------------- 1 | # YOLOv8 - OpenCV 2 | 3 | Implementation YOLOv8 on OpenCV using ONNX Format. 4 | 5 | Just simply clone and run 6 | 7 | ```bash 8 | pip install -r requirements.txt 9 | python main.py --model yolov8n.onnx --img image.jpg 10 | ``` 11 | 12 | If you start from scratch: 13 | 14 | ```bash 15 | pip install ultralytics 16 | yolo export model=yolov8n.pt imgsz=640 format=onnx opset=12 17 | ``` 18 | 19 | _\*Make sure to include "opset=12"_ 20 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/utils/triton.md: -------------------------------------------------------------------------------- 1 | # Reference for `ultralytics/utils/triton.py` 2 | 3 | !!! note 4 | 5 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/triton.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/triton.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 6 | 7 | --- 8 | ## ::: ultralytics.utils.triton.TritonRemoteModel 9 |

10 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/__init__.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | __version__ = '8.0.195' 4 | 5 | from ultralytics.models import RTDETR, SAM, YOLO 6 | from ultralytics.models.fastsam import FastSAM 7 | from ultralytics.models.nas import NAS 8 | from ultralytics.utils import SETTINGS as settings 9 | from ultralytics.utils.checks import check_yolo as checks 10 | from ultralytics.utils.downloads import download 11 | 12 | __all__ = '__version__', 'YOLO', 'NAS', 'SAM', 'FastSAM', 'RTDETR', 'checks', 'download', 'settings' 13 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/nn/__init__.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | from .tasks import (BaseModel, ClassificationModel, DetectionModel, SegmentationModel, attempt_load_one_weight, 4 | attempt_load_weights, guess_model_scale, guess_model_task, parse_model, torch_safe_load, 5 | yaml_model_load) 6 | 7 | __all__ = ('attempt_load_one_weight', 'attempt_load_weights', 'parse_model', 'yaml_model_load', 'guess_model_task', 8 | 'guess_model_scale', 'torch_safe_load', 'DetectionModel', 'SegmentationModel', 'ClassificationModel', 9 | 'BaseModel') 10 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/data/scripts/download_weights.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Ultralytics YOLO 🚀, AGPL-3.0 license 3 | # Download latest models from https://github.com/ultralytics/assets/releases 4 | # Example usage: bash ultralytics/data/scripts/download_weights.sh 5 | # parent 6 | # └── weights 7 | # ├── yolov8n.pt ← downloads here 8 | # ├── yolov8s.pt 9 | # └── ... 10 | 11 | python - <
15 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/utils/callbacks/raytune.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | from ultralytics.utils import SETTINGS 4 | 5 | try: 6 | assert SETTINGS['raytune'] is True # verify integration is enabled 7 | import ray 8 | from ray import tune 9 | from ray.air import session 10 | 11 | except (ImportError, AssertionError): 12 | tune = None 13 | 14 | 15 | def on_fit_epoch_end(trainer): 16 | """Sends training metrics to Ray Tune at end of each epoch.""" 17 | if ray.tune.is_session_enabled(): 18 | metrics = trainer.metrics 19 | metrics['epoch'] = trainer.epoch 20 | session.report(metrics) 21 | 22 | 23 | callbacks = { 24 | 'on_fit_epoch_end': on_fit_epoch_end, } if tune else {} 25 | -------------------------------------------------------------------------------- /ultralytics/.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | # Dependabot for package version updates 3 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 4 | 5 | version: 2 6 | updates: 7 | - package-ecosystem: pip 8 | directory: "/" 9 | schedule: 10 | interval: weekly 11 | time: "04:00" 12 | open-pull-requests-limit: 10 13 | reviewers: 14 | - glenn-jocher 15 | labels: 16 | - dependencies 17 | 18 | - package-ecosystem: github-actions 19 | directory: "/" 20 | schedule: 21 | interval: weekly 22 | time: "04:00" 23 | open-pull-requests-limit: 5 24 | reviewers: 25 | - glenn-jocher 26 | labels: 27 | - dependencies 28 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/hub/auth.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Dive into the Ultralytics Auth API documentation & learn how to manage authentication in your AI & ML projects easily and effectively. 3 | keywords: Ultralytics, Auth, API documentation, User Authentication, AI, Machine Learning 4 | --- 5 | 6 | # Reference for `ultralytics/hub/auth.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/hub/auth.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/hub/auth.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.hub.auth.Auth 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/cfg/trackers/bytetrack.yaml: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | # Default YOLO tracker settings for ByteTrack tracker https://github.com/ifzhang/ByteTrack 3 | 4 | tracker_type: bytetrack # tracker type, ['botsort', 'bytetrack'] 5 | track_high_thresh: 0.5 # threshold for the first association 6 | track_low_thresh: 0.1 # threshold for the second association 7 | new_track_thresh: 0.6 # threshold for init new track if the detection does not match any tracks 8 | track_buffer: 30 # buffer to calculate the time when to remove tracks 9 | match_thresh: 0.8 # threshold for matching tracks 10 | # min_box_area: 10 # threshold for min box areas(for tracker evaluation, not used for now) 11 | # mot20: False # for tracker evaluation(not used for now) 12 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/models/fastsam/val.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | from ultralytics.models.yolo.segment import SegmentationValidator 4 | from ultralytics.utils.metrics import SegmentMetrics 5 | 6 | 7 | class FastSAMValidator(SegmentationValidator): 8 | 9 | def __init__(self, dataloader=None, save_dir=None, pbar=None, args=None, _callbacks=None): 10 | """Initialize SegmentationValidator and set task to 'segment', metrics to SegmentMetrics.""" 11 | super().__init__(dataloader, save_dir, pbar, args, _callbacks) 12 | self.args.task = 'segment' 13 | self.args.plots = False # disable ConfusionMatrix and other plots to avoid errors 14 | self.metrics = SegmentMetrics(save_dir=self.save_dir, on_plot=self.on_plot) 15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/engine/trainer.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Learn about the BaseTrainer class in the Ultralytics library. From training control, customization to advanced usage. 3 | keywords: Ultralytics, BaseTrainer, Machine Learning, Training Control, Python library 4 | --- 5 | 6 | # Reference for `ultralytics/engine/trainer.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/engine/trainer.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/engine/trainer.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.engine.trainer.BaseTrainer 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/utils/tuner.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Learn to utilize the run_ray_tune function with Ultralytics. Make your machine learning tuning process easier and more efficient. 3 | keywords: Ultralytics, run_ray_tune, machine learning tuning, machine learning efficiency 4 | --- 5 | 6 | # Reference for `ultralytics/utils/tuner.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/tuner.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/tuner.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.utils.tuner.run_ray_tune 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/engine/predictor.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Learn about Ultralytics BasePredictor, an essential component of our engine that serves as the foundation for all prediction operations. 3 | keywords: Ultralytics, BasePredictor, YOLO, prediction, engine 4 | --- 5 | 6 | # Reference for `ultralytics/engine/predictor.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/engine/predictor.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/engine/predictor.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.engine.predictor.BasePredictor 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/engine/validator.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Learn about the Ultralytics BaseValidator module. Understand its principles, uses, and how it interacts with other components. 3 | keywords: Ultralytics, BaseValidator, Ultralytics engine, module, components 4 | --- 5 | 6 | # Reference for `ultralytics/engine/validator.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/engine/validator.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/engine/validator.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.engine.validator.BaseValidator 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/engine/model.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore the detailed guide on using the Ultralytics YOLO Engine Model. Learn better ways to implement, train and evaluate YOLO models. 3 | keywords: Ultralytics, YOLO, engine model, documentation, guide, implementation, training, evaluation 4 | --- 5 | 6 | # Reference for `ultralytics/engine/model.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/engine/model.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/engine/model.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.engine.model.Model 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/yolo/model.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Discover the Ultralytics YOLO model class. Learn advanced techniques, tips, and tricks for training. 3 | keywords: Ultralytics YOLO, YOLO, YOLO model, Model Training, Machine Learning, Deep Learning, Computer Vision 4 | --- 5 | 6 | # Reference for `ultralytics/models/yolo/model.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/model.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/model.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.yolo.model.YOLO 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/nas/model.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Learn how our NAS model operates in Ultralytics. Comprehensive guide with detailed examples. Master the nuances of Ultralytics NAS model. 3 | keywords: Ultralytics, NAS model, NAS guide, machine learning, model documentation 4 | --- 5 | 6 | # Reference for `ultralytics/models/nas/model.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/nas/model.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/nas/model.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.nas.model.NAS 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/hub/session.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore details about the HUBTrainingSession in Ultralytics framework. Learn to utilize this functionality for effective model training. 3 | keywords: Ultralytics, HUBTrainingSession, Documentation, Model Training, AI, Machine Learning, YOLO 4 | --- 5 | 6 | # Reference for `ultralytics/hub/session.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/hub/session.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/hub/session.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.hub.session.HUBTrainingSession 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/fastsam/val.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Learn about FastSAMValidator in Ultralytics models. Comprehensive guide to enhancing AI capabilities with Ultralytics. 3 | keywords: Ultralytics, FastSAMValidator, model, synthetic, AI, machine learning, validation 4 | --- 5 | 6 | # Reference for `ultralytics/models/fastsam/val.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/fastsam/val.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/fastsam/val.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.fastsam.val.FastSAMValidator 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/sam/model.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Dive into the SAM model details in the Ultralytics YOLO documentation. Understand, implement, and optimize your model use. 3 | keywords: Ultralytics, YOLO, SAM Model, Documentations, Machine Learning, AI, Convolutional neural network 4 | --- 5 | 6 | # Reference for `ultralytics/models/sam/model.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/sam/model.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/sam/model.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.sam.model.SAM 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/utils/errors.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Learn about the HUBModelError in Ultralytics. Enhance your understanding, troubleshoot errors and optimize your machine learning projects. 3 | keywords: Ultralytics, HUBModelError, Machine Learning, Error troubleshooting, Ultralytics documentation 4 | --- 5 | 6 | # Reference for `ultralytics/utils/errors.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/errors.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/errors.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.utils.errors.HUBModelError 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/data/annotator.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Enhance your machine learning model with Ultralytics’ auto_annotate function. Simplify data annotation for improved model training. 3 | keywords: Ultralytics, Auto-Annotate, Machine Learning, AI, Annotation, Data Processing, Model Training 4 | --- 5 | 6 | # Reference for `ultralytics/data/annotator.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/data/annotator.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/data/annotator.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.data.annotator.auto_annotate 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/nas/val.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore the utilities and functions of the Ultralytics NASValidator. Find out how it benefits allocation and optimization in AI models. 3 | keywords: Ultralytics, NASValidator, models.nas.val.NASValidator, AI models, allocation, optimization 4 | --- 5 | 6 | # Reference for `ultralytics/models/nas/val.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/nas/val.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/nas/val.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.nas.val.NASValidator 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/yolo/pose/val.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore the PoseValidator—review how Ultralytics YOLO validates poses for object detection. Improve your understanding of YOLO. 3 | keywords: PoseValidator, Ultralytics, YOLO, Object detection, Pose validation 4 | --- 5 | 6 | # Reference for `ultralytics/models/yolo/pose/val.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/pose/val.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/pose/val.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.yolo.pose.val.PoseValidator 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/fastsam/model.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Learn all about Ultralytics FastSAM model. Dive into our comprehensive guide for seamless integration and efficient model training. 3 | keywords: Ultralytics, FastSAM model, Model documentation, Efficient model training 4 | --- 5 | 6 | # Reference for `ultralytics/models/fastsam/model.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/fastsam/model.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/fastsam/model.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.fastsam.model.FastSAM 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/rtdetr/model.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore the specifics of using the RTDETR model in Ultralytics. Detailed documentation layered with explanations and examples. 3 | keywords: Ultralytics, RTDETR model, Ultralytics models, object detection, Ultralytics documentation 4 | --- 5 | 6 | # Reference for `ultralytics/models/rtdetr/model.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/rtdetr/model.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/rtdetr/model.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.rtdetr.model.RTDETR 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/trackers/utils/gmc.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore the Ultralytics GMC tool in our comprehensive documentation. Learn how it works, best practices, and implementation advice. 3 | keywords: Ultralytics, GMC utility, Ultralytics documentation, Ultralytics tracker, machine learning tools 4 | --- 5 | 6 | # Reference for `ultralytics/trackers/utils/gmc.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/trackers/utils/gmc.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/trackers/utils/gmc.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.trackers.utils.gmc.GMC 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/nas/predict.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore Ultralytics NASPredictor. Understand high-level architecture of the model for effective implementation and efficient predictions. 3 | keywords: NASPredictor, Ultralytics, Ultralytics model, model architecture, efficient predictions 4 | --- 5 | 6 | # Reference for `ultralytics/models/nas/predict.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/nas/predict.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/nas/predict.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.nas.predict.NASPredictor 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/rtdetr/predict.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Learn how to use the RTDETRPredictor model of the Ultralytics package. Detailed documentation, usage instructions, and advice. 3 | keywords: Ultralytics, RTDETRPredictor, model documentation, guide, real-time object detection 4 | --- 5 | 6 | # Reference for `ultralytics/models/rtdetr/predict.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/rtdetr/predict.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/rtdetr/predict.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.rtdetr.predict.RTDETRPredictor 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/sam/modules/sam.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore the Sam module of Ultralytics. Discover detailed methods, classes, and information for efficient deep-learning model training!. 3 | keywords: Ultralytics, Sam module, deep learning, model training, Ultralytics documentation 4 | --- 5 | 6 | # Reference for `ultralytics/models/sam/modules/sam.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/sam/modules/sam.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/sam/modules/sam.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.sam.modules.sam.Sam 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/yolo/pose/predict.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Discover how to use PosePredictor in the Ultralytics YOLO model. Includes detailed guides, code examples, and explanations. 3 | keywords: Ultralytics, YOLO, PosePredictor, machine learning, AI, predictive models 4 | --- 5 | 6 | # Reference for `ultralytics/models/yolo/pose/predict.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/pose/predict.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/pose/predict.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.yolo.pose.predict.PosePredictor 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/.github/translate-readme.yml: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | # README translation action to translate README.md to Chinese as README.zh-CN.md on any change to README.md 3 | 4 | name: Translate README 5 | 6 | on: 7 | push: 8 | branches: 9 | - translate_readme # replace with 'main' to enable action 10 | paths: 11 | - README.md 12 | 13 | jobs: 14 | Translate: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@v3 18 | - name: Setup Node.js 19 | uses: actions/setup-node@v3 20 | with: 21 | node-version: 16 22 | # ISO Language Codes: https://cloud.google.com/translate/docs/languages 23 | - name: Adding README - Chinese Simplified 24 | uses: dephraiim/translate-readme@main 25 | with: 26 | LANG: zh-CN 27 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/fastsam/prompt.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Learn to effectively utilize FastSAMPrompt model from Ultralytics. Detailed guide to help you get the most out of your machine learning models. 3 | keywords: Ultralytics, FastSAMPrompt, machine learning, model, guide, documentation 4 | --- 5 | 6 | # Reference for `ultralytics/models/fastsam/prompt.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/fastsam/prompt.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/fastsam/prompt.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.fastsam.prompt.FastSAMPrompt 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/sam/predict.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Master the ultralytics.models.sam.predict.Predictor class with our comprehensive guide. Discover techniques to enhance your model predictions. 3 | keywords: Ultralytics, predictor, models, sam.predict.Predictor, AI, machine learning, predictive models 4 | --- 5 | 6 | # Reference for `ultralytics/models/sam/predict.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/sam/predict.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/sam/predict.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.sam.predict.Predictor 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/yolo/detect/val.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Discover function valuation of your YOLO models with the Ultralytics Detection Validator. Enhance precision and recall rates today. 3 | keywords: Ultralytics, YOLO, Detection Validator, model valuation, precision, recall 4 | --- 5 | 6 | # Reference for `ultralytics/models/yolo/detect/val.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/detect/val.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/detect/val.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.yolo.detect.val.DetectionValidator 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/yolo/segment/predict.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Discover how to utilize the YOLO Segmentation Predictor in Ultralytics. Enhance your objects detection skills with us. 3 | keywords: YOLO, Ultralytics, object detection, segmentation predictor 4 | --- 5 | 6 | # Reference for `ultralytics/models/yolo/segment/predict.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/segment/predict.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/segment/predict.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.yolo.segment.predict.SegmentationPredictor 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/yolo/pose/train.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore Ultralytics PoseTrainer for YOLO models. Get a step-by-step guide on how to train on custom pose data for more accurate AI modeling. 3 | keywords: Ultralytics, YOLO, PoseTrainer, pose training, AI modeling, custom data training 4 | --- 5 | 6 | # Reference for `ultralytics/models/yolo/pose/train.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/pose/train.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/pose/train.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.yolo.pose.train.PoseTrainer 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/yolo/detect/predict.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore the guide to using the DetectionPredictor in Ultralytics YOLO. Learn how to predict, detect and analyze objects accurately. 3 | keywords: Ultralytics, YOLO, DetectionPredictor, detect, predict, object detection, analysis 4 | --- 5 | 6 | # Reference for `ultralytics/models/yolo/detect/predict.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/detect/predict.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/detect/predict.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.yolo.detect.predict.DetectionPredictor 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/nn/autobackend.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Get to know more about Ultralytics nn.autobackend.check_class_names functionality. Optimize your YOLO models seamlessly. 3 | keywords: Ultralytics, AutoBackend, check_class_names, YOLO, YOLO models, optimization 4 | --- 5 | 6 | # Reference for `ultralytics/nn/autobackend.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/nn/autobackend.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/nn/autobackend.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.nn.autobackend.AutoBackend 14 |

15 | 16 | --- 17 | ## ::: ultralytics.nn.autobackend.check_class_names 18 |

19 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/yolo/detect/train.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Maximize your model's potential with Ultralytics YOLO Detection Trainer. Learn advanced techniques, tips, and tricks for training. 3 | keywords: Ultralytics YOLO, YOLO, Detection Trainer, Model Training, Machine Learning, Deep Learning, Computer Vision 4 | --- 5 | 6 | # Reference for `ultralytics/models/yolo/detect/train.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/detect/train.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/detect/train.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.yolo.detect.train.DetectionTrainer 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/utils/callbacks/raytune.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Discover the functionality of the on_fit_epoch_end callback in the Ultralytics YOLO framework. Learn how to end an epoch in your deep learning projects. 3 | keywords: Ultralytics, YOLO, on_fit_epoch_end, callbacks, documentation, deep learning, YOLO framework 4 | --- 5 | 6 | # Reference for `ultralytics/utils/callbacks/raytune.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/callbacks/raytune.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/callbacks/raytune.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.utils.callbacks.raytune.on_fit_epoch_end 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/rtdetr/train.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Get insights into RTDETRTrainer, a crucial component of Ultralytics for effective model training. Explore detailed documentation at Ultralytics. 3 | keywords: Ultralytics, RTDETRTrainer, model training, Ultralytics models, PyTorch models, neural networks, machine learning, deep learning 4 | --- 5 | 6 | # Reference for `ultralytics/models/rtdetr/train.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/rtdetr/train.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/rtdetr/train.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.rtdetr.train.RTDETRTrainer 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/yolo/classify/predict.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore the Ultralytics ClassificationPredictor guide for model prediction and visualization. Build powerful AI models with YOLO. 3 | keywords: Ultralytics, classification predictor, predict, YOLO, AI models, model visualization 4 | --- 5 | 6 | # Reference for `ultralytics/models/yolo/classify/predict.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/classify/predict.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/classify/predict.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.yolo.classify.predict.ClassificationPredictor 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/yolo/segment/train.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Maximize your YOLO model's performance with our SegmentationTrainer. Explore comprehensive guides and tutorials on ultralytics.com. 3 | keywords: Ultralytics, YOLO, SegmentationTrainer, image segmentation, object detection, model training, YOLO model 4 | --- 5 | 6 | # Reference for `ultralytics/models/yolo/segment/train.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/segment/train.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/segment/train.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.yolo.segment.train.SegmentationTrainer 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/yolo/segment/val.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Get practical insights about our SegmentationValidator in YOLO Ultralytics models. Discover functionality details, methods, inputs, and outputs. 3 | keywords: Ultralytics, YOLO, SegmentationValidator, model segmentation, image classification, object detection 4 | --- 5 | 6 | # Reference for `ultralytics/models/yolo/segment/val.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/segment/val.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/segment/val.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.yolo.segment.val.SegmentationValidator 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/yolo/classify/train.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Delve into Classification Trainer at Ultralytics YOLO docs and optimize your model's training process with insights from the masters!. 3 | keywords: Ultralytics, YOLO, Classification Trainer, deep learning, training process, AI models, documentation 4 | --- 5 | 6 | # Reference for `ultralytics/models/yolo/classify/train.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/classify/train.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/classify/train.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.yolo.classify.train.ClassificationTrainer 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/yolo/classify/val.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore YOLO ClassificationValidator, a key element of Ultralytics YOLO models. Learn how it validates and fine-tunes model outputs. 3 | keywords: Ultralytics, YOLO, ClassificationValidator, model validation, model fine-tuning, deep learning, computer vision 4 | --- 5 | 6 | # Reference for `ultralytics/models/yolo/classify/val.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/classify/val.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/classify/val.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.yolo.classify.val.ClassificationValidator 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/utils/benchmarks.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Discover how to profile your models using Ultralytics utilities. Enhance performance, optimize your benchmarks, and learn best practices. 3 | keywords: Ultralytics, ProfileModels, benchmarks, model profiling, performance optimization 4 | --- 5 | 6 | # Reference for `ultralytics/utils/benchmarks.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/benchmarks.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/benchmarks.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.utils.benchmarks.ProfileModels 14 |

15 | 16 | --- 17 | ## ::: ultralytics.utils.benchmarks.benchmark 18 |

19 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/fastsam/predict.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Get detailed insights about Ultralytics FastSAMPredictor. Learn to predict and optimize your AI models with our properly documented guidelines. 3 | keywords: Ultralytics, FastSAMPredictor, predictive modeling, AI optimization, machine learning, deep learning, Ultralytics documentation 4 | --- 5 | 6 | # Reference for `ultralytics/models/fastsam/predict.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/fastsam/predict.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/fastsam/predict.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.fastsam.predict.FastSAMPredictor 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/trackers/basetrack.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Get familiar with TrackState in Ultralytics. Learn how it is used in the BaseTrack of the Ultralytics tracker for enhanced functionality. 3 | keywords: Ultralytics, TrackState, BaseTrack, Ultralytics tracker, Ultralytics documentation 4 | --- 5 | 6 | # Reference for `ultralytics/trackers/basetrack.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/trackers/basetrack.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/trackers/basetrack.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.trackers.basetrack.TrackState 14 |

15 | 16 | --- 17 | ## ::: ultralytics.trackers.basetrack.BaseTrack 18 |

19 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/utils/ops.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Discover details for "HungarianMatcher" & "inverse_sigmoid" functions in Ultralytics YOLO, advanced tools supporting detection models. 3 | keywords: Ultralytics, YOLO, HungarianMatcher, inverse_sigmoid, detection models, model utilities, ops 4 | --- 5 | 6 | # Reference for `ultralytics/models/utils/ops.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/utils/ops.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/utils/ops.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.utils.ops.HungarianMatcher 14 |

15 | 16 | --- 17 | ## ::: ultralytics.models.utils.ops.get_cdn_group 18 |

19 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/rtdetr/val.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore RTDETRDataset in Ultralytics Models. Learn about the RTDETRValidator function, understand its usage in real-time object detection. 3 | keywords: Ultralytics, RTDETRDataset, RTDETRValidator, real-time object detection, models documentation 4 | --- 5 | 6 | # Reference for `ultralytics/models/rtdetr/val.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/rtdetr/val.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/rtdetr/val.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.rtdetr.val.RTDETRDataset 14 |

15 | 16 | --- 17 | ## ::: ultralytics.models.rtdetr.val.RTDETRValidator 18 |

19 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/utils/autobatch.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore Ultralytics documentation for check_train_batch_size utility in the autobatch module. Understand how it could improve your machine learning process. 3 | keywords: Ultralytics, check_train_batch_size, autobatch, utility, machine learning, documentation 4 | --- 5 | 6 | # Reference for `ultralytics/utils/autobatch.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/autobatch.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/autobatch.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.utils.autobatch.check_train_batch_size 14 |

15 | 16 | --- 17 | ## ::: ultralytics.utils.autobatch.autobatch 18 |

19 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/utils/instance.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Dive into Ultralytics detailed utility guide. Learn about Bboxes, _ntuple and more from Ultralytics utils.instance module. 3 | keywords: Ultralytics, Bboxes, _ntuple, utility, ultralytics utils.instance 4 | --- 5 | 6 | # Reference for `ultralytics/utils/instance.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/instance.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/instance.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.utils.instance.Bboxes 14 |

15 | 16 | --- 17 | ## ::: ultralytics.utils.instance.Instances 18 |

19 | 20 | --- 21 | ## ::: ultralytics.utils.instance._ntuple 22 |

23 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/engine/tuner.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore the Ultralytics Tuner, a powerful tool designed for hyperparameter tuning of YOLO models to optimize performance across various tasks like object detection, image classification, and more. 3 | keywords: Ultralytics, Tuner, YOLO, hyperparameter tuning, optimization, object detection, image classification, instance segmentation, pose estimation, multi-object tracking 4 | --- 5 | 6 | # Reference for `ultralytics/engine/tuner.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/engine/tuner.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/engine/tuner.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.engine.tuner.Tuner 14 |

15 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/trackers/bot_sort.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Master the use of Ultralytics BOTrack, a key component of the powerful Ultralytics tracking system. Learn to integrate and use BOTSORT in your projects. 3 | keywords: Ultralytics, BOTSORT, BOTrack, tracking system, official documentation, machine learning, AI tracking 4 | --- 5 | 6 | # Reference for `ultralytics/trackers/bot_sort.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/trackers/bot_sort.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/trackers/bot_sort.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.trackers.bot_sort.BOTrack 14 |

15 | 16 | --- 17 | ## ::: ultralytics.trackers.bot_sort.BOTSORT 18 |

19 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/utils/loss.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Learn to use the DETRLoss function provided by Ultralytics YOLO. Understand how to utilize loss in RTDETR detection models to improve accuracy. 3 | keywords: Ultralytics, YOLO, Documentation, DETRLoss, Detection Loss, Loss function, DETR, RTDETR Detection Models 4 | --- 5 | 6 | # Reference for `ultralytics/models/utils/loss.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/utils/loss.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/utils/loss.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.utils.loss.DETRLoss 14 |

15 | 16 | --- 17 | ## ::: ultralytics.models.utils.loss.RTDETRDetectionLoss 18 |

19 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/trackers/byte_tracker.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Step-in to explore in-depth the functionalities of Ultralytics BYTETracker under STrack. Gain advanced feature insights to streamline your operations. 3 | keywords: STrack, Ultralytics, BYTETracker, documentation, Ultralytics tracker, object tracking, YOLO 4 | --- 5 | 6 | # Reference for `ultralytics/trackers/byte_tracker.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/trackers/byte_tracker.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/trackers/byte_tracker.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.trackers.byte_tracker.STrack 14 |

15 | 16 | --- 17 | ## ::: ultralytics.trackers.byte_tracker.BYTETracker 18 |

19 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/fastsam/utils.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Learn how to adjust bounding boxes to image borders in Ultralytics models using the bbox_iou utility. Enhance your object detection performance. 3 | keywords: Ultralytics, bounding boxes, Bboxes, image borders, object detection, bbox_iou, model utilities 4 | --- 5 | 6 | # Reference for `ultralytics/models/fastsam/utils.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/fastsam/utils.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/fastsam/utils.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.fastsam.utils.adjust_bboxes_to_image_border 14 |

15 | 16 | --- 17 | ## ::: ultralytics.models.fastsam.utils.bbox_iou 18 |

19 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/trackers/utils/kalman_filter.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore KalmanFilterXYAH, a key component of Ultralytics trackers. Understand its utilities and learn to leverage it in your own projects. 3 | keywords: Ultralytics, KalmanFilterXYAH, tracker, documentation, guide 4 | --- 5 | 6 | # Reference for `ultralytics/trackers/utils/kalman_filter.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/trackers/utils/kalman_filter.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/trackers/utils/kalman_filter.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.trackers.utils.kalman_filter.KalmanFilterXYAH 14 |

15 | 16 | --- 17 | ## ::: ultralytics.trackers.utils.kalman_filter.KalmanFilterXYWH 18 |

19 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/sam/modules/decoders.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore MaskDecoder, a part of the Ultralytics models. Gain insights on how to utilize it effectively in the SAM modules decoders MLP. 3 | keywords: Ultralytics, MaskDecoder, SAM modules, decoders, MLP, YOLO, machine learning, image recognition 4 | --- 5 | 6 | # Reference for `ultralytics/models/sam/modules/decoders.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/sam/modules/decoders.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/sam/modules/decoders.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.sam.modules.decoders.MaskDecoder 14 |

15 | 16 | --- 17 | ## ::: ultralytics.models.sam.modules.decoders.MLP 18 |

19 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/trackers/track.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore Ultralytics documentation on prediction function starters & register trackers. Understand our code & its applications better. 3 | keywords: Ultralytics, YOLO, on predict start, register tracker, prediction functions, documentation 4 | --- 5 | 6 | # Reference for `ultralytics/trackers/track.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/trackers/track.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/trackers/track.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.trackers.track.on_predict_start 14 |

15 | 16 | --- 17 | ## ::: ultralytics.trackers.track.on_predict_postprocess_end 18 |

19 | 20 | --- 21 | ## ::: ultralytics.trackers.track.register_tracker 22 |

23 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/utils/patches.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Learn about Ultralytics utils patches including imread, imshow and torch_save. Enhance your image processing skills. 3 | keywords: Ultralytics, Utils, Patches, imread, imshow, torch_save, image processing 4 | --- 5 | 6 | # Reference for `ultralytics/utils/patches.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/patches.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/patches.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.utils.patches.imread 14 |

15 | 16 | --- 17 | ## ::: ultralytics.utils.patches.imwrite 18 |

19 | 20 | --- 21 | ## ::: ultralytics.utils.patches.imshow 22 |

23 | 24 | --- 25 | ## ::: ultralytics.utils.patches.torch_save 26 |

27 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/cfg/trackers/botsort.yaml: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | # Default YOLO tracker settings for BoT-SORT tracker https://github.com/NirAharon/BoT-SORT 3 | 4 | tracker_type: botsort # tracker type, ['botsort', 'bytetrack'] 5 | track_high_thresh: 0.5 # threshold for the first association 6 | track_low_thresh: 0.1 # threshold for the second association 7 | new_track_thresh: 0.6 # threshold for init new track if the detection does not match any tracks 8 | track_buffer: 30 # buffer to calculate the time when to remove tracks 9 | match_thresh: 0.8 # threshold for matching tracks 10 | # min_box_area: 10 # threshold for min box areas(for tracker evaluation, not used for now) 11 | # mot20: False # for tracker evaluation(not used for now) 12 | 13 | # BoT-SORT settings 14 | gmc_method: sparseOptFlow # method of global motion compensation 15 | # ReID model related thresh (not supported yet) 16 | proximity_thresh: 0.5 17 | appearance_thresh: 0.25 18 | with_reid: False 19 | -------------------------------------------------------------------------------- /ultralytics/docs/overrides/partials/source-file.html: -------------------------------------------------------------------------------- 1 | {% import "partials/language.html" as lang with context %} 2 | 3 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | {% if page.meta.git_revision_date_localized %} 12 | 📅 {{ lang.t("source.file.date.updated") }}: 13 | {{ page.meta.git_revision_date_localized }} 14 | {% if page.meta.git_creation_date_localized %} 15 |
16 | 🎂 {{ lang.t("source.file.date.created") }}: 17 | {{ page.meta.git_creation_date_localized }} 18 | {% endif %} 19 | 20 | 21 | {% elif page.meta.revision_date %} 22 | 📅 {{ lang.t("source.file.date.updated") }}: 23 | {{ page.meta.revision_date }} 24 | {% endif %} 25 |
26 |
27 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/utils/callbacks/mlflow.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Understand routines at the end of pre-training and training in Ultralytics. Elevate your MLflow callbacks expertise. 3 | keywords: Ultralytics, MLflow, Callbacks, on_pretrain_routine_end, on_train_end, Machine Learning, Training 4 | --- 5 | 6 | # Reference for `ultralytics/utils/callbacks/mlflow.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/callbacks/mlflow.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/callbacks/mlflow.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.utils.callbacks.mlflow.on_pretrain_routine_end 14 |

15 | 16 | --- 17 | ## ::: ultralytics.utils.callbacks.mlflow.on_fit_epoch_end 18 |

19 | 20 | --- 21 | ## ::: ultralytics.utils.callbacks.mlflow.on_train_end 22 |

23 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/models/nas/val.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | import torch 4 | 5 | from ultralytics.models.yolo.detect import DetectionValidator 6 | from ultralytics.utils import ops 7 | 8 | __all__ = ['NASValidator'] 9 | 10 | 11 | class NASValidator(DetectionValidator): 12 | 13 | def postprocess(self, preds_in): 14 | """Apply Non-maximum suppression to prediction outputs.""" 15 | boxes = ops.xyxy2xywh(preds_in[0][0]) 16 | preds = torch.cat((boxes, preds_in[0][1]), -1).permute(0, 2, 1) 17 | return ops.non_max_suppression(preds, 18 | self.args.conf, 19 | self.args.iou, 20 | labels=self.lb, 21 | multi_label=False, 22 | agnostic=self.args.single_cls, 23 | max_det=self.args.max_det, 24 | max_time_img=0.5) 25 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/sam/modules/transformer.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Learn about TwoWayTransformer and Attention modules in Ultralytics. Leverage these tools to enhance your AI models. 3 | keywords: Ultralytics, TwoWayTransformer, Attention, AI models, transformers 4 | --- 5 | 6 | # Reference for `ultralytics/models/sam/modules/transformer.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/sam/modules/transformer.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/sam/modules/transformer.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.sam.modules.transformer.TwoWayTransformer 14 |

15 | 16 | --- 17 | ## ::: ultralytics.models.sam.modules.transformer.TwoWayAttentionBlock 18 |

19 | 20 | --- 21 | ## ::: ultralytics.models.sam.modules.transformer.Attention 22 |

23 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/hub/utils.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore Ultralytics docs for various Events, including "request_with_credentials" and "requests_with_progress". Also, understand the use of the "smart_request". 3 | keywords: Ultralytics, Events, request_with_credentials, smart_request, Ultralytics hub utils, requests_with_progress 4 | --- 5 | 6 | # Reference for `ultralytics/hub/utils.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/hub/utils.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/hub/utils.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.hub.utils.Events 14 |

15 | 16 | --- 17 | ## ::: ultralytics.hub.utils.request_with_credentials 18 |

19 | 20 | --- 21 | ## ::: ultralytics.hub.utils.requests_with_progress 22 |

23 | 24 | --- 25 | ## ::: ultralytics.hub.utils.smart_request 26 |

27 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/utils/dist.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Discover the role of dist.find_free_network_port & dist.generate_ddp_command in Ultralytics DDP utilities. Use our guide for efficient deployment. 3 | keywords: Ultralytics, DDP, DDP utility functions, Distributed Data Processing, find free network port, generate DDP command 4 | --- 5 | 6 | # Reference for `ultralytics/utils/dist.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/dist.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/dist.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.utils.dist.find_free_network_port 14 |

15 | 16 | --- 17 | ## ::: ultralytics.utils.dist.generate_ddp_file 18 |

19 | 20 | --- 21 | ## ::: ultralytics.utils.dist.generate_ddp_command 22 |

23 | 24 | --- 25 | ## ::: ultralytics.utils.dist.ddp_cleanup 26 |

27 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/cfg/models/v8/yolov8-cls.yaml: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | # YOLOv8-cls image classification model. For Usage examples see https://docs.ultralytics.com/tasks/classify 3 | 4 | # Parameters 5 | nc: 1000 # number of classes 6 | scales: # model compound scaling constants, i.e. 'model=yolov8n-cls.yaml' will call yolov8-cls.yaml with scale 'n' 7 | # [depth, width, max_channels] 8 | n: [0.33, 0.25, 1024] 9 | s: [0.33, 0.50, 1024] 10 | m: [0.67, 0.75, 1024] 11 | l: [1.00, 1.00, 1024] 12 | x: [1.00, 1.25, 1024] 13 | 14 | # YOLOv8.0n backbone 15 | backbone: 16 | # [from, repeats, module, args] 17 | - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2 18 | - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4 19 | - [-1, 3, C2f, [128, True]] 20 | - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8 21 | - [-1, 6, C2f, [256, True]] 22 | - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16 23 | - [-1, 6, C2f, [512, True]] 24 | - [-1, 1, Conv, [1024, 3, 2]] # 7-P5/32 25 | - [-1, 3, C2f, [1024, True]] 26 | 27 | # YOLOv8.0n head 28 | head: 29 | - [-1, 1, Classify, [nc]] # Classify 30 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/nn/modules/head.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore docs covering Ultralytics YOLO detection, pose & RTDETRDecoder. Comprehensive guides to help you understand Ultralytics nn modules. 3 | keywords: Ultralytics, YOLO, Detection, Pose, RTDETRDecoder, nn modules, guides 4 | --- 5 | 6 | # Reference for `ultralytics/nn/modules/head.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/nn/modules/head.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/nn/modules/head.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.nn.modules.head.Detect 14 |

15 | 16 | --- 17 | ## ::: ultralytics.nn.modules.head.Segment 18 |

19 | 20 | --- 21 | ## ::: ultralytics.nn.modules.head.Pose 22 |

23 | 24 | --- 25 | ## ::: ultralytics.nn.modules.head.Classify 26 |

27 | 28 | --- 29 | ## ::: ultralytics.nn.modules.head.RTDETRDecoder 30 |

31 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/engine/exporter.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore the exporter functionality of Ultralytics. Learn about exporting formats, IOSDetectModel, and try exporting with examples. 3 | keywords: Ultralytics, Exporter, IOSDetectModel, Export Formats, Try export 4 | --- 5 | 6 | # Reference for `ultralytics/engine/exporter.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/engine/exporter.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/engine/exporter.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.engine.exporter.Exporter 14 |

15 | 16 | --- 17 | ## ::: ultralytics.engine.exporter.IOSDetectModel 18 |

19 | 20 | --- 21 | ## ::: ultralytics.engine.exporter.export_formats 22 |

23 | 24 | --- 25 | ## ::: ultralytics.engine.exporter.gd_outputs 26 |

27 | 28 | --- 29 | ## ::: ultralytics.engine.exporter.try_export 30 |

31 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/engine/results.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Master Ultralytics engine results including base tensors, boxes, and keypoints with our thorough documentation. 3 | keywords: Ultralytics, engine, results, base tensor, boxes, keypoints 4 | --- 5 | 6 | # Reference for `ultralytics/engine/results.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/engine/results.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/engine/results.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.engine.results.BaseTensor 14 |

15 | 16 | --- 17 | ## ::: ultralytics.engine.results.Results 18 |

19 | 20 | --- 21 | ## ::: ultralytics.engine.results.Boxes 22 |

23 | 24 | --- 25 | ## ::: ultralytics.engine.results.Masks 26 |

27 | 28 | --- 29 | ## ::: ultralytics.engine.results.Keypoints 30 |

31 | 32 | --- 33 | ## ::: ultralytics.engine.results.Probs 34 |

35 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/data/dataset.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore the YOLODataset and SemanticDataset classes in YOLO data. Learn how to efficiently handle and manipulate your data with Ultralytics. 3 | keywords: Ultralytics, YOLO, YOLODataset, SemanticDataset, data handling, data manipulation 4 | --- 5 | 6 | # Reference for `ultralytics/data/dataset.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/data/dataset.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/data/dataset.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.data.dataset.YOLODataset 14 |

15 | 16 | --- 17 | ## ::: ultralytics.data.dataset.ClassificationDataset 18 |

19 | 20 | --- 21 | ## ::: ultralytics.data.dataset.SemanticDataset 22 |

23 | 24 | --- 25 | ## ::: ultralytics.data.dataset.load_dataset_cache_file 26 |

27 | 28 | --- 29 | ## ::: ultralytics.data.dataset.save_dataset_cache_file 30 |

31 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/utils/callbacks/wb.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Deep dive into Ultralytics callbacks. Learn how to use the _log_plots, on_fit_epoch_end, and on_train_end functions effectively. 3 | keywords: Ultralytics, callbacks, _log_plots, on_fit_epoch_end, on_train_end 4 | --- 5 | 6 | # Reference for `ultralytics/utils/callbacks/wb.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/callbacks/wb.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/callbacks/wb.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.utils.callbacks.wb._log_plots 14 |

15 | 16 | --- 17 | ## ::: ultralytics.utils.callbacks.wb.on_pretrain_routine_start 18 |

19 | 20 | --- 21 | ## ::: ultralytics.utils.callbacks.wb.on_fit_epoch_end 22 |

23 | 24 | --- 25 | ## ::: ultralytics.utils.callbacks.wb.on_train_epoch_end 26 |

27 | 28 | --- 29 | ## ::: ultralytics.utils.callbacks.wb.on_train_end 30 |

31 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/hub/__init__.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore Ultralytics hub functions for model resetting, checking datasets, model exporting and more. Easy-to-follow instructions provided. 3 | keywords: Ultralytics, hub functions, model export, dataset check, reset model, YOLO Docs 4 | --- 5 | 6 | # Reference for `ultralytics/hub/__init__.py` 7 | 8 | !!! note 9 | 10 | Full source code for 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). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.hub.login 14 |

15 | 16 | --- 17 | ## ::: ultralytics.hub.logout 18 |

19 | 20 | --- 21 | ## ::: ultralytics.hub.reset_model 22 |

23 | 24 | --- 25 | ## ::: ultralytics.hub.export_fmts_hub 26 |

27 | 28 | --- 29 | ## ::: ultralytics.hub.export_model 30 |

31 | 32 | --- 33 | ## ::: ultralytics.hub.get_export 34 |

35 | 36 | --- 37 | ## ::: ultralytics.hub.check_dataset 38 |

39 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/nn/modules/utils.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore Ultralytics neural network utils, such as bias_init_with_prob, inverse_sigmoid and multi_scale_deformable_attn_pytorch functions. 3 | keywords: Ultralytics, neural network, nn.modules.utils, bias_init_with_prob, inverse_sigmoid, multi_scale_deformable_attn_pytorch 4 | --- 5 | 6 | # Reference for `ultralytics/nn/modules/utils.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/nn/modules/utils.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/nn/modules/utils.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.nn.modules.utils._get_clones 14 |

15 | 16 | --- 17 | ## ::: ultralytics.nn.modules.utils.bias_init_with_prob 18 |

19 | 20 | --- 21 | ## ::: ultralytics.nn.modules.utils.linear_init_ 22 |

23 | 24 | --- 25 | ## ::: ultralytics.nn.modules.utils.inverse_sigmoid 26 |

27 | 28 | --- 29 | ## ::: ultralytics.nn.modules.utils.multi_scale_deformable_attn_pytorch 30 |

31 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/trackers/utils/matching.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore in-depth guidance for using Ultralytics trackers utils matching, including merge_matches, linear_assignment, iou_distance, embedding_distance, fuse_motion, and fuse_score. 3 | keywords: Ultralytics, Trackers Utils, Matching, merge_matches, linear_assignment, iou_distance, embedding_distance, fuse_motion, fuse_score, documentation 4 | --- 5 | 6 | # Reference for `ultralytics/trackers/utils/matching.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/trackers/utils/matching.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/trackers/utils/matching.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.trackers.utils.matching.linear_assignment 14 |

15 | 16 | --- 17 | ## ::: ultralytics.trackers.utils.matching.iou_distance 18 |

19 | 20 | --- 21 | ## ::: ultralytics.trackers.utils.matching.embedding_distance 22 |

23 | 24 | --- 25 | ## ::: ultralytics.trackers.utils.matching.fuse_score 26 |

27 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/utils/tal.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore Ultralytics utilities for optimized task assignment, bounding box creation, and distance calculation. Learn more about algorithm implementations. 3 | keywords: Ultralytics, task aligned assigner, select highest overlaps, make anchors, dist2bbox, bbox2dist, utilities, algorithm 4 | --- 5 | 6 | # Reference for `ultralytics/utils/tal.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/tal.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/tal.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.utils.tal.TaskAlignedAssigner 14 |

15 | 16 | --- 17 | ## ::: ultralytics.utils.tal.select_candidates_in_gts 18 |

19 | 20 | --- 21 | ## ::: ultralytics.utils.tal.select_highest_overlaps 22 |

23 | 24 | --- 25 | ## ::: ultralytics.utils.tal.make_anchors 26 |

27 | 28 | --- 29 | ## ::: ultralytics.utils.tal.dist2bbox 30 |

31 | 32 | --- 33 | ## ::: ultralytics.utils.tal.bbox2dist 34 |

35 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/models/fastsam/model.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | from pathlib import Path 4 | 5 | from ultralytics.engine.model import Model 6 | 7 | from .predict import FastSAMPredictor 8 | from .val import FastSAMValidator 9 | 10 | 11 | class FastSAM(Model): 12 | """ 13 | FastSAM model interface. 14 | 15 | Example: 16 | ```python 17 | from ultralytics import FastSAM 18 | 19 | model = FastSAM('last.pt') 20 | results = model.predict('ultralytics/assets/bus.jpg') 21 | ``` 22 | """ 23 | 24 | def __init__(self, model='FastSAM-x.pt'): 25 | """Call the __init__ method of the parent class (YOLO) with the updated default model.""" 26 | if str(model) == 'FastSAM.pt': 27 | model = 'FastSAM-x.pt' 28 | assert Path(model).suffix not in ('.yaml', '.yml'), 'FastSAM models only support pre-trained models.' 29 | super().__init__(model=model, task='segment') 30 | 31 | @property 32 | def task_map(self): 33 | """Returns a dictionary mapping segment task to corresponding predictor and validator classes.""" 34 | return {'segment': {'predictor': FastSAMPredictor, 'validator': FastSAMValidator}} 35 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/models/rtdetr/model.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | """RT-DETR model interface.""" 3 | from ultralytics.engine.model import Model 4 | from ultralytics.nn.tasks import RTDETRDetectionModel 5 | 6 | from .predict import RTDETRPredictor 7 | from .train import RTDETRTrainer 8 | from .val import RTDETRValidator 9 | 10 | 11 | class RTDETR(Model): 12 | """RTDETR model interface.""" 13 | 14 | def __init__(self, model='rtdetr-l.pt') -> None: 15 | """Initializes the RTDETR model with the given model file, defaulting to 'rtdetr-l.pt'.""" 16 | if model and model.split('.')[-1] not in ('pt', 'yaml', 'yml'): 17 | raise NotImplementedError('RT-DETR only supports creating from *.pt file or *.yaml file.') 18 | super().__init__(model=model, task='detect') 19 | 20 | @property 21 | def task_map(self): 22 | """Returns a dictionary mapping task names to corresponding Ultralytics task classes for RTDETR model.""" 23 | return { 24 | 'detect': { 25 | 'predictor': RTDETRPredictor, 26 | 'validator': RTDETRValidator, 27 | 'trainer': RTDETRTrainer, 28 | 'model': RTDETRDetectionModel}} 29 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/sam/build.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Master building SAM ViT models with Ultralytics. Discover steps to leverage the power of SAM and Vision Transformer sessions. 3 | keywords: Ultralytics, SAM, build sam, vision transformer, vits, build_sam_vit_l, build_sam_vit_b, build_sam 4 | --- 5 | 6 | # Reference for `ultralytics/models/sam/build.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/sam/build.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/sam/build.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.sam.build.build_sam_vit_h 14 |

15 | 16 | --- 17 | ## ::: ultralytics.models.sam.build.build_sam_vit_l 18 |

19 | 20 | --- 21 | ## ::: ultralytics.models.sam.build.build_sam_vit_b 22 |

23 | 24 | --- 25 | ## ::: ultralytics.models.sam.build.build_mobile_sam 26 |

27 | 28 | --- 29 | ## ::: ultralytics.models.sam.build._build_sam 30 |

31 | 32 | --- 33 | ## ::: ultralytics.models.sam.build.build_sam 34 |

35 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/data/converter.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore Ultralytics data converter functions like coco91_to_coco80_class, merge_multi_segment, rle2polygon for efficient data handling. 3 | keywords: Ultralytics, Data Converter, coco91_to_coco80_class, merge_multi_segment, rle2polygon 4 | --- 5 | 6 | # Reference for `ultralytics/data/converter.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/data/converter.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/data/converter.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.data.converter.coco91_to_coco80_class 14 |

15 | 16 | --- 17 | ## ::: ultralytics.data.converter.coco80_to_coco91_class 18 |

19 | 20 | --- 21 | ## ::: ultralytics.data.converter.convert_coco 22 |

23 | 24 | --- 25 | ## ::: ultralytics.data.converter.convert_dota_to_yolo_obb 26 |

27 | 28 | --- 29 | ## ::: ultralytics.data.converter.min_index 30 |

31 | 32 | --- 33 | ## ::: ultralytics.data.converter.merge_multi_segment 34 |

35 | -------------------------------------------------------------------------------- /ultralytics/docs/stylesheets/style.css: -------------------------------------------------------------------------------- 1 | /* Table format like GitHub ----------------------------------------------------------------------------------------- */ 2 | th, td { 3 | border: 1px solid var(--md-typeset-table-color); 4 | border-spacing: 0; 5 | border-bottom: none; 6 | border-left: none; 7 | border-top: none; 8 | } 9 | 10 | .md-typeset__table { 11 | line-height: 1; 12 | } 13 | 14 | .md-typeset__table table:not([class]) { 15 | font-size: .74rem; 16 | border-right: none; 17 | } 18 | 19 | .md-typeset__table table:not([class]) td, 20 | .md-typeset__table table:not([class]) th { 21 | padding: 9px; 22 | } 23 | 24 | /* light mode alternating table bg colors */ 25 | .md-typeset__table tr:nth-child(2n) { 26 | background-color: #f8f8f8; 27 | } 28 | 29 | /* dark mode alternating table bg colors */ 30 | [data-md-color-scheme="slate"] .md-typeset__table tr:nth-child(2n) { 31 | background-color: hsla(var(--md-hue),25%,25%,1) 32 | } 33 | /* Table format like GitHub ----------------------------------------------------------------------------------------- */ 34 | 35 | /* Code block vertical scroll */ 36 | div.highlight { 37 | max-height: 20rem; 38 | overflow-y: auto; /* for adding a scrollbar when needed */ 39 | } 40 | 41 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/data/build.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore the Ultralytics YOLO v3 data build procedures, including the InfiniteDataLoader, seed_worker, build_dataloader, and load_inference_source. 3 | keywords: Ultralytics, YOLO v3, Data build, DataLoader, InfiniteDataLoader, seed_worker, build_dataloader, load_inference_source 4 | --- 5 | 6 | # Reference for `ultralytics/data/build.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/data/build.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/data/build.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.data.build.InfiniteDataLoader 14 |

15 | 16 | --- 17 | ## ::: ultralytics.data.build._RepeatSampler 18 |

19 | 20 | --- 21 | ## ::: ultralytics.data.build.seed_worker 22 |

23 | 24 | --- 25 | ## ::: ultralytics.data.build.build_yolo_dataset 26 |

27 | 28 | --- 29 | ## ::: ultralytics.data.build.build_dataloader 30 |

31 | 32 | --- 33 | ## ::: ultralytics.data.build.check_source 34 |

35 | 36 | --- 37 | ## ::: ultralytics.data.build.load_inference_source 38 |

39 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/utils/files.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Discover how to use Ultralytics utility functions for file-related operations including incrementing paths, finding file age, checking file size and creating directories. 3 | keywords: Ultralytics, utility functions, file operations, working directory, file age, file size, create directories 4 | --- 5 | 6 | # Reference for `ultralytics/utils/files.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/files.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/files.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.utils.files.WorkingDirectory 14 |

15 | 16 | --- 17 | ## ::: ultralytics.utils.files.spaces_in_path 18 |

19 | 20 | --- 21 | ## ::: ultralytics.utils.files.increment_path 22 |

23 | 24 | --- 25 | ## ::: ultralytics.utils.files.file_age 26 |

27 | 28 | --- 29 | ## ::: ultralytics.utils.files.file_date 30 |

31 | 32 | --- 33 | ## ::: ultralytics.utils.files.file_size 34 |

35 | 36 | --- 37 | ## ::: ultralytics.utils.files.get_latest_run 38 |

39 | -------------------------------------------------------------------------------- /ultralytics/.github/ISSUE_TEMPLATE/question.yml: -------------------------------------------------------------------------------- 1 | name: ❓ Question 2 | description: Ask a YOLOv8 question 3 | # title: " " 4 | labels: [question] 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | Thank you for asking a YOLOv8 ❓ Question! 10 | 11 | - type: checkboxes 12 | attributes: 13 | label: Search before asking 14 | description: > 15 | Please search the [issues](https://github.com/ultralytics/ultralytics/issues) and [discussions](https://github.com/ultralytics/ultralytics/discussions) to see if a similar question already exists. 16 | options: 17 | - label: > 18 | I have searched the YOLOv8 [issues](https://github.com/ultralytics/ultralytics/issues) and [discussions](https://github.com/ultralytics/ultralytics/discussions) and found no similar questions. 19 | required: true 20 | 21 | - type: textarea 22 | attributes: 23 | label: Question 24 | description: What is your question? 25 | placeholder: | 26 | 💡 ProTip! Include as much information as possible (screenshots, logs, tracebacks etc.) to receive the most helpful response. 27 | validations: 28 | required: true 29 | 30 | - type: textarea 31 | attributes: 32 | label: Additional 33 | description: Anything else you would like to share? 34 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/data/loaders.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Find detailed guides on Ultralytics YOLO data loaders, including LoadStreams, LoadImages and LoadTensor. Learn how to get the best YouTube URLs. 3 | keywords: Ultralytics, data loaders, LoadStreams, LoadImages, LoadTensor, YOLO, YouTube URLs 4 | --- 5 | 6 | # Reference for `ultralytics/data/loaders.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/data/loaders.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/data/loaders.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.data.loaders.SourceTypes 14 |

15 | 16 | --- 17 | ## ::: ultralytics.data.loaders.LoadStreams 18 |

19 | 20 | --- 21 | ## ::: ultralytics.data.loaders.LoadScreenshots 22 |

23 | 24 | --- 25 | ## ::: ultralytics.data.loaders.LoadImages 26 |

27 | 28 | --- 29 | ## ::: ultralytics.data.loaders.LoadPilAndNumpy 30 |

31 | 32 | --- 33 | ## ::: ultralytics.data.loaders.LoadTensor 34 |

35 | 36 | --- 37 | ## ::: ultralytics.data.loaders.autocast_list 38 |

39 | 40 | --- 41 | ## ::: ultralytics.data.loaders.get_best_youtube_url 42 |

43 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/utils/loss.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore Ultralytics' versatile loss functions - VarifocalLoss, BboxLoss, v8DetectionLoss, v8PoseLoss. Improve your accuracy on YOLO implementations. 3 | keywords: Ultralytics, Loss functions, VarifocalLoss, BboxLoss, v8DetectionLoss, v8PoseLoss, YOLO, Ultralytics Documentation 4 | --- 5 | 6 | # Reference for `ultralytics/utils/loss.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/loss.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/loss.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.utils.loss.VarifocalLoss 14 |

15 | 16 | --- 17 | ## ::: ultralytics.utils.loss.FocalLoss 18 |

19 | 20 | --- 21 | ## ::: ultralytics.utils.loss.BboxLoss 22 |

23 | 24 | --- 25 | ## ::: ultralytics.utils.loss.KeypointLoss 26 |

27 | 28 | --- 29 | ## ::: ultralytics.utils.loss.v8DetectionLoss 30 |

31 | 32 | --- 33 | ## ::: ultralytics.utils.loss.v8SegmentationLoss 34 |

35 | 36 | --- 37 | ## ::: ultralytics.utils.loss.v8PoseLoss 38 |

39 | 40 | --- 41 | ## ::: ultralytics.utils.loss.v8ClassificationLoss 42 |

43 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/utils/callbacks/tensorboard.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore Ultralytics YOLO Docs for a deep understanding of log_scalars, on_batch_end & other callback utilities embedded in the tensorboard module. 3 | keywords: Ultralytics, YOLO, documentation, callback utilities, log_scalars, on_batch_end, tensorboard 4 | --- 5 | 6 | # Reference for `ultralytics/utils/callbacks/tensorboard.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/callbacks/tensorboard.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/callbacks/tensorboard.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.utils.callbacks.tensorboard._log_scalars 14 |

15 | 16 | --- 17 | ## ::: ultralytics.utils.callbacks.tensorboard._log_tensorboard_graph 18 |

19 | 20 | --- 21 | ## ::: ultralytics.utils.callbacks.tensorboard.on_pretrain_routine_start 22 |

23 | 24 | --- 25 | ## ::: ultralytics.utils.callbacks.tensorboard.on_train_start 26 |

27 | 28 | --- 29 | ## ::: ultralytics.utils.callbacks.tensorboard.on_batch_end 30 |

31 | 32 | --- 33 | ## ::: ultralytics.utils.callbacks.tensorboard.on_fit_epoch_end 34 |

35 | -------------------------------------------------------------------------------- /ultralytics/.github/workflows/codeql.yaml: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | name: "CodeQL" 4 | 5 | on: 6 | schedule: 7 | - cron: '0 0 1 * *' 8 | workflow_dispatch: 9 | 10 | jobs: 11 | analyze: 12 | name: Analyze 13 | runs-on: ${{ 'ubuntu-latest' }} 14 | permissions: 15 | actions: read 16 | contents: read 17 | security-events: write 18 | 19 | strategy: 20 | fail-fast: false 21 | matrix: 22 | language: [ 'python' ] 23 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] 24 | 25 | steps: 26 | - name: Checkout repository 27 | uses: actions/checkout@v4 28 | 29 | # Initializes the CodeQL tools for scanning. 30 | - name: Initialize CodeQL 31 | uses: github/codeql-action/init@v2 32 | with: 33 | languages: ${{ matrix.language }} 34 | # If you wish to specify custom queries, you can do so here or in a config file. 35 | # By default, queries listed here will override any specified in a config file. 36 | # Prefix the list here with "+" to use these queries and those in the config file. 37 | # queries: security-extended,security-and-quality 38 | 39 | - name: Perform CodeQL Analysis 40 | uses: github/codeql-action/analyze@v2 41 | with: 42 | category: "/language:${{matrix.language}}" 43 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/utils/callbacks/clearml.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Uncover the specifics of Ultralytics ClearML callbacks, from pretrain routine start to training end. Boost your ML model performance. 3 | keywords: Ultralytics, clearML, callbacks, pretrain routine start, validation end, train epoch end, training end 4 | --- 5 | 6 | # Reference for `ultralytics/utils/callbacks/clearml.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/callbacks/clearml.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/callbacks/clearml.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.utils.callbacks.clearml._log_debug_samples 14 |

15 | 16 | --- 17 | ## ::: ultralytics.utils.callbacks.clearml._log_plot 18 |

19 | 20 | --- 21 | ## ::: ultralytics.utils.callbacks.clearml.on_pretrain_routine_start 22 |

23 | 24 | --- 25 | ## ::: ultralytics.utils.callbacks.clearml.on_train_epoch_end 26 |

27 | 28 | --- 29 | ## ::: ultralytics.utils.callbacks.clearml.on_fit_epoch_end 30 |

31 | 32 | --- 33 | ## ::: ultralytics.utils.callbacks.clearml.on_val_end 34 |

35 | 36 | --- 37 | ## ::: ultralytics.utils.callbacks.clearml.on_train_end 38 |

39 | -------------------------------------------------------------------------------- /ultralytics/requirements.txt: -------------------------------------------------------------------------------- 1 | # Ultralytics requirements 2 | # Example: pip install -r requirements.txt 3 | 4 | # Base ---------------------------------------- 5 | matplotlib>=3.3.0 6 | numpy>=1.22.2 # pinned by Snyk to avoid a vulnerability 7 | opencv-python>=4.6.0 8 | pillow>=7.1.2 9 | pyyaml>=5.3.1 10 | requests>=2.23.0 11 | scipy>=1.4.1 12 | torch>=1.8.0 13 | torchvision>=0.9.0 14 | tqdm>=4.64.0 15 | 16 | # Logging ------------------------------------- 17 | # tensorboard>=2.13.0 18 | # dvclive>=2.12.0 19 | # clearml 20 | # comet 21 | 22 | # Plotting ------------------------------------ 23 | pandas>=1.1.4 24 | seaborn>=0.11.0 25 | 26 | # Export -------------------------------------- 27 | # coremltools>=7.0 # CoreML export 28 | # onnx>=1.12.0 # ONNX export 29 | # onnxsim>=0.4.1 # ONNX simplifier 30 | # nvidia-pyindex # TensorRT export 31 | # nvidia-tensorrt # TensorRT export 32 | # scikit-learn==0.19.2 # CoreML quantization 33 | # tensorflow>=2.4.1 # TF exports (-cpu, -aarch64, -macos) 34 | # tflite-support 35 | # tensorflowjs>=3.9.0 # TF.js export 36 | # openvino-dev>=2023.0 # OpenVINO export 37 | 38 | # Extras -------------------------------------- 39 | psutil # system utilization 40 | py-cpuinfo # display CPU info 41 | thop>=0.1.1 # FLOPs computation 42 | # ipython # interactive notebook 43 | # albumentations>=1.0.3 # training augmentations 44 | # pycocotools>=2.0.6 # COCO mAP 45 | # roboflow 46 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/cfg/models/v3/yolov3-tiny.yaml: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | # YOLOv3-tiny object detection model with P4-P5 outputs. For details see https://docs.ultralytics.com/models/yolov3 3 | 4 | # Parameters 5 | nc: 80 # number of classes 6 | depth_multiple: 1.0 # model depth multiple 7 | width_multiple: 1.0 # layer channel multiple 8 | 9 | # YOLOv3-tiny backbone 10 | backbone: 11 | # [from, number, module, args] 12 | [[-1, 1, Conv, [16, 3, 1]], # 0 13 | [-1, 1, nn.MaxPool2d, [2, 2, 0]], # 1-P1/2 14 | [-1, 1, Conv, [32, 3, 1]], 15 | [-1, 1, nn.MaxPool2d, [2, 2, 0]], # 3-P2/4 16 | [-1, 1, Conv, [64, 3, 1]], 17 | [-1, 1, nn.MaxPool2d, [2, 2, 0]], # 5-P3/8 18 | [-1, 1, Conv, [128, 3, 1]], 19 | [-1, 1, nn.MaxPool2d, [2, 2, 0]], # 7-P4/16 20 | [-1, 1, Conv, [256, 3, 1]], 21 | [-1, 1, nn.MaxPool2d, [2, 2, 0]], # 9-P5/32 22 | [-1, 1, Conv, [512, 3, 1]], 23 | [-1, 1, nn.ZeroPad2d, [[0, 1, 0, 1]]], # 11 24 | [-1, 1, nn.MaxPool2d, [2, 1, 0]], # 12 25 | ] 26 | 27 | # YOLOv3-tiny head 28 | head: 29 | [[-1, 1, Conv, [1024, 3, 1]], 30 | [-1, 1, Conv, [256, 1, 1]], 31 | [-1, 1, Conv, [512, 3, 1]], # 15 (P5/32-large) 32 | 33 | [-2, 1, Conv, [128, 1, 1]], 34 | [-1, 1, nn.Upsample, [None, 2, 'nearest']], 35 | [[-1, 8], 1, Concat, [1]], # cat backbone P4 36 | [-1, 1, Conv, [256, 3, 1]], # 19 (P4/16-medium) 37 | 38 | [[19, 15], 1, Detect, [nc]], # Detect(P4, P5) 39 | ] 40 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/utils/callbacks/hub.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore the detailed information on key Ultralytics callbacks such as on_pretrain_routine_end, on_model_save, on_train_start, and on_predict_start. 3 | keywords: Ultralytics, callbacks, on_pretrain_routine_end, on_model_save, on_train_start, on_predict_start, hub, training 4 | --- 5 | 6 | # Reference for `ultralytics/utils/callbacks/hub.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/callbacks/hub.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/callbacks/hub.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.utils.callbacks.hub.on_pretrain_routine_end 14 |

15 | 16 | --- 17 | ## ::: ultralytics.utils.callbacks.hub.on_fit_epoch_end 18 |

19 | 20 | --- 21 | ## ::: ultralytics.utils.callbacks.hub.on_model_save 22 |

23 | 24 | --- 25 | ## ::: ultralytics.utils.callbacks.hub.on_train_end 26 |

27 | 28 | --- 29 | ## ::: ultralytics.utils.callbacks.hub.on_train_start 30 |

31 | 32 | --- 33 | ## ::: ultralytics.utils.callbacks.hub.on_val_start 34 |

35 | 36 | --- 37 | ## ::: ultralytics.utils.callbacks.hub.on_predict_start 38 |

39 | 40 | --- 41 | ## ::: ultralytics.utils.callbacks.hub.on_export_start 42 |

43 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/utils/callbacks/neptune.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore exhaustive details about Ultralytics callbacks in Neptune, with specifics about scalar logging, routine start, and more. 3 | keywords: Ultralytics, Neptune callbacks, on_train_epoch_end, on_val_end, _log_plot, _log_images, on_pretrain_routine_start, on_fit_epoch_end, on_train_end 4 | --- 5 | 6 | # Reference for `ultralytics/utils/callbacks/neptune.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/callbacks/neptune.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/callbacks/neptune.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.utils.callbacks.neptune._log_scalars 14 |

15 | 16 | --- 17 | ## ::: ultralytics.utils.callbacks.neptune._log_images 18 |

19 | 20 | --- 21 | ## ::: ultralytics.utils.callbacks.neptune._log_plot 22 |

23 | 24 | --- 25 | ## ::: ultralytics.utils.callbacks.neptune.on_pretrain_routine_start 26 |

27 | 28 | --- 29 | ## ::: ultralytics.utils.callbacks.neptune.on_train_epoch_end 30 |

31 | 32 | --- 33 | ## ::: ultralytics.utils.callbacks.neptune.on_fit_epoch_end 34 |

35 | 36 | --- 37 | ## ::: ultralytics.utils.callbacks.neptune.on_val_end 38 |

39 | 40 | --- 41 | ## ::: ultralytics.utils.callbacks.neptune.on_train_end 42 |

43 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/utils/plotting.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Master advanced plotting utils from Ultralytics including color annotations, label and image plotting, and feature visualization. 3 | keywords: Ultralytics, plotting, utils, color annotation, label plotting, image plotting, feature visualization 4 | --- 5 | 6 | # Reference for `ultralytics/utils/plotting.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/plotting.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/plotting.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.utils.plotting.Colors 14 |

15 | 16 | --- 17 | ## ::: ultralytics.utils.plotting.Annotator 18 |

19 | 20 | --- 21 | ## ::: ultralytics.utils.plotting.plot_labels 22 |

23 | 24 | --- 25 | ## ::: ultralytics.utils.plotting.save_one_box 26 |

27 | 28 | --- 29 | ## ::: ultralytics.utils.plotting.plot_images 30 |

31 | 32 | --- 33 | ## ::: ultralytics.utils.plotting.plot_results 34 |

35 | 36 | --- 37 | ## ::: ultralytics.utils.plotting.plt_color_scatter 38 |

39 | 40 | --- 41 | ## ::: ultralytics.utils.plotting.plot_tune_results 42 |

43 | 44 | --- 45 | ## ::: ultralytics.utils.plotting.output_to_target 46 |

47 | 48 | --- 49 | ## ::: ultralytics.utils.plotting.feature_visualization 50 |

51 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/utils/callbacks/dvc.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Browse through Ultralytics YOLO docs to learn about important logging and callback functions used in training and pretraining models. 3 | keywords: Ultralytics, YOLO, callbacks, logger, training, pretraining, machine learning, models 4 | --- 5 | 6 | # Reference for `ultralytics/utils/callbacks/dvc.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/callbacks/dvc.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/callbacks/dvc.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.utils.callbacks.dvc._log_images 14 |

15 | 16 | --- 17 | ## ::: ultralytics.utils.callbacks.dvc._log_plots 18 |

19 | 20 | --- 21 | ## ::: ultralytics.utils.callbacks.dvc._log_confusion_matrix 22 |

23 | 24 | --- 25 | ## ::: ultralytics.utils.callbacks.dvc.on_pretrain_routine_start 26 |

27 | 28 | --- 29 | ## ::: ultralytics.utils.callbacks.dvc.on_pretrain_routine_end 30 |

31 | 32 | --- 33 | ## ::: ultralytics.utils.callbacks.dvc.on_train_start 34 |

35 | 36 | --- 37 | ## ::: ultralytics.utils.callbacks.dvc.on_train_epoch_start 38 |

39 | 40 | --- 41 | ## ::: ultralytics.utils.callbacks.dvc.on_fit_epoch_end 42 |

43 | 44 | --- 45 | ## ::: ultralytics.utils.callbacks.dvc.on_train_end 46 |

47 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/models/nas/predict.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | import torch 4 | 5 | from ultralytics.engine.predictor import BasePredictor 6 | from ultralytics.engine.results import Results 7 | from ultralytics.utils import ops 8 | 9 | 10 | class NASPredictor(BasePredictor): 11 | 12 | def postprocess(self, preds_in, img, orig_imgs): 13 | """Postprocess predictions and returns a list of Results objects.""" 14 | 15 | # Cat boxes and class scores 16 | boxes = ops.xyxy2xywh(preds_in[0][0]) 17 | preds = torch.cat((boxes, preds_in[0][1]), -1).permute(0, 2, 1) 18 | 19 | preds = ops.non_max_suppression(preds, 20 | self.args.conf, 21 | self.args.iou, 22 | agnostic=self.args.agnostic_nms, 23 | max_det=self.args.max_det, 24 | classes=self.args.classes) 25 | 26 | if not isinstance(orig_imgs, list): # input images are a torch.Tensor, not a list 27 | orig_imgs = ops.convert_torch2numpy_batch(orig_imgs) 28 | 29 | results = [] 30 | for i, pred in enumerate(preds): 31 | orig_img = orig_imgs[i] 32 | pred[:, :4] = ops.scale_boxes(img.shape[2:], pred[:, :4], orig_img.shape) 33 | img_path = self.batch[0][i] 34 | results.append(Results(orig_img, path=img_path, names=self.model.names, boxes=pred)) 35 | return results 36 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/nn/tasks.md: -------------------------------------------------------------------------------- 1 | # Reference for `ultralytics/nn/tasks.py` 2 | 3 | !!! note 4 | 5 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/nn/tasks.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/nn/tasks.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 6 | 7 | --- 8 | ## ::: ultralytics.nn.tasks.BaseModel 9 |

10 | 11 | --- 12 | ## ::: ultralytics.nn.tasks.DetectionModel 13 |

14 | 15 | --- 16 | ## ::: ultralytics.nn.tasks.SegmentationModel 17 |

18 | 19 | --- 20 | ## ::: ultralytics.nn.tasks.PoseModel 21 |

22 | 23 | --- 24 | ## ::: ultralytics.nn.tasks.ClassificationModel 25 |

26 | 27 | --- 28 | ## ::: ultralytics.nn.tasks.RTDETRDetectionModel 29 |

30 | 31 | --- 32 | ## ::: ultralytics.nn.tasks.Ensemble 33 |

34 | 35 | --- 36 | ## ::: ultralytics.nn.tasks.temporary_modules 37 |

38 | 39 | --- 40 | ## ::: ultralytics.nn.tasks.torch_safe_load 41 |

42 | 43 | --- 44 | ## ::: ultralytics.nn.tasks.attempt_load_weights 45 |

46 | 47 | --- 48 | ## ::: ultralytics.nn.tasks.attempt_load_one_weight 49 |

50 | 51 | --- 52 | ## ::: ultralytics.nn.tasks.parse_model 53 |

54 | 55 | --- 56 | ## ::: ultralytics.nn.tasks.yaml_model_load 57 |

58 | 59 | --- 60 | ## ::: ultralytics.nn.tasks.guess_model_scale 61 |

62 | 63 | --- 64 | ## ::: ultralytics.nn.tasks.guess_model_task 65 |

66 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/utils/downloads.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Learn about the download utilities in Ultralytics YOLO, featuring functions like is_url, check_disk_space, get_github_assets, and download. 3 | keywords: Ultralytics, YOLO, download utilities, is_url, check_disk_space, get_github_assets, download, documentation 4 | --- 5 | 6 | # Reference for `ultralytics/utils/downloads.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/downloads.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/downloads.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.utils.downloads.is_url 14 |

15 | 16 | --- 17 | ## ::: ultralytics.utils.downloads.delete_dsstore 18 |

19 | 20 | --- 21 | ## ::: ultralytics.utils.downloads.zip_directory 22 |

23 | 24 | --- 25 | ## ::: ultralytics.utils.downloads.unzip_file 26 |

27 | 28 | --- 29 | ## ::: ultralytics.utils.downloads.check_disk_space 30 |

31 | 32 | --- 33 | ## ::: ultralytics.utils.downloads.get_google_drive_file_info 34 |

35 | 36 | --- 37 | ## ::: ultralytics.utils.downloads.safe_download 38 |

39 | 40 | --- 41 | ## ::: ultralytics.utils.downloads.get_github_assets 42 |

43 | 44 | --- 45 | ## ::: ultralytics.utils.downloads.attempt_download_asset 46 |

47 | 48 | --- 49 | ## ::: ultralytics.utils.downloads.download 50 |

51 | -------------------------------------------------------------------------------- /ultralytics/examples/YOLOv8-ONNXRuntime/README.md: -------------------------------------------------------------------------------- 1 | # YOLOv8 - ONNX Runtime 2 | 3 | This project implements YOLOv8 using ONNX Runtime. 4 | 5 | ## Installation 6 | 7 | To run this project, you need to install the required dependencies. The following instructions will guide you through the installation process. 8 | 9 | ### Installing Required Dependencies 10 | 11 | You can install the required dependencies by running the following command: 12 | 13 | ```bash 14 | pip install -r requirements.txt 15 | ``` 16 | 17 | ### Installing `onnxruntime-gpu` 18 | 19 | If you have an NVIDIA GPU and want to leverage GPU acceleration, you can install the onnxruntime-gpu package using the following command: 20 | 21 | ```bash 22 | pip install onnxruntime-gpu 23 | ``` 24 | 25 | Note: Make sure you have the appropriate GPU drivers installed on your system. 26 | 27 | ### Installing `onnxruntime` (CPU version) 28 | 29 | If you don't have an NVIDIA GPU or prefer to use the CPU version of onnxruntime, you can install the onnxruntime package using the following command: 30 | 31 | ```bash 32 | pip install onnxruntime 33 | ``` 34 | 35 | ### Usage 36 | 37 | After successfully installing the required packages, you can run the YOLOv8 implementation using the following command: 38 | 39 | ```bash 40 | python main.py --model yolov8n.onnx --img image.jpg --conf-thres 0.5 --iou-thres 0.5 41 | ``` 42 | 43 | Make sure to replace yolov8n.onnx with the path to your YOLOv8 ONNX model file, image.jpg with the path to your input image, and adjust the confidence threshold (conf-thres) and IoU threshold (iou-thres) values as needed. 44 | -------------------------------------------------------------------------------- /ultralytics/.github/workflows/cla.yml: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | name: CLA Assistant 4 | on: 5 | issue_comment: 6 | types: 7 | - created 8 | pull_request_target: 9 | types: 10 | - reopened 11 | - opened 12 | - synchronize 13 | 14 | jobs: 15 | CLA: 16 | if: github.repository == 'ultralytics/ultralytics' 17 | runs-on: ubuntu-latest 18 | steps: 19 | - name: CLA Assistant 20 | if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I sign the CLA') || github.event_name == 'pull_request_target' 21 | uses: contributor-assistant/github-action@v2.3.1 22 | env: 23 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 24 | # must be repository secret token 25 | PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} 26 | with: 27 | path-to-signatures: 'signatures/version1/cla.json' 28 | path-to-document: 'https://docs.ultralytics.com/help/CLA' # CLA document 29 | # branch should not be protected 30 | branch: 'main' 31 | allowlist: dependabot[bot],github-actions,[pre-commit*,pre-commit*,bot* 32 | 33 | remote-organization-name: ultralytics 34 | remote-repository-name: cla 35 | custom-pr-sign-comment: 'I have read the CLA Document and I sign the CLA' 36 | custom-allsigned-prcomment: All Contributors have signed the CLA. ✅ 37 | #custom-notsigned-prcomment: 'pull request comment with Introductory message to ask new contributors to sign' 38 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/models/yolo/model.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | from ultralytics.engine.model import Model 4 | from ultralytics.models import yolo # noqa 5 | from ultralytics.nn.tasks import ClassificationModel, DetectionModel, PoseModel, SegmentationModel 6 | 7 | 8 | class YOLO(Model): 9 | """YOLO (You Only Look Once) object detection model.""" 10 | 11 | @property 12 | def task_map(self): 13 | """Map head to model, trainer, validator, and predictor classes.""" 14 | return { 15 | 'classify': { 16 | 'model': ClassificationModel, 17 | 'trainer': yolo.classify.ClassificationTrainer, 18 | 'validator': yolo.classify.ClassificationValidator, 19 | 'predictor': yolo.classify.ClassificationPredictor, }, 20 | 'detect': { 21 | 'model': DetectionModel, 22 | 'trainer': yolo.detect.DetectionTrainer, 23 | 'validator': yolo.detect.DetectionValidator, 24 | 'predictor': yolo.detect.DetectionPredictor, }, 25 | 'segment': { 26 | 'model': SegmentationModel, 27 | 'trainer': yolo.segment.SegmentationTrainer, 28 | 'validator': yolo.segment.SegmentationValidator, 29 | 'predictor': yolo.segment.SegmentationPredictor, }, 30 | 'pose': { 31 | 'model': PoseModel, 32 | 'trainer': yolo.pose.PoseTrainer, 33 | 'validator': yolo.pose.PoseValidator, 34 | 'predictor': yolo.pose.PosePredictor, }, } 35 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/cfg/__init__.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore Ultralytics cfg functions like cfg2dict, handle_deprecation, merge_equal_args & more to handle YOLO settings and configurations efficiently. 3 | keywords: Ultralytics, YOLO, Configuration, cfg2dict, handle_deprecation, merge_equals_args, handle_yolo_settings, copy_default_cfg, Image Detection 4 | --- 5 | 6 | # Reference for `ultralytics/cfg/__init__.py` 7 | 8 | !!! note 9 | 10 | Full source code for 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). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.cfg.cfg2dict 14 |

15 | 16 | --- 17 | ## ::: ultralytics.cfg.get_cfg 18 |

19 | 20 | --- 21 | ## ::: ultralytics.cfg.get_save_dir 22 |

23 | 24 | --- 25 | ## ::: ultralytics.cfg._handle_deprecation 26 |

27 | 28 | --- 29 | ## ::: ultralytics.cfg.check_dict_alignment 30 |

31 | 32 | --- 33 | ## ::: ultralytics.cfg.merge_equals_args 34 |

35 | 36 | --- 37 | ## ::: ultralytics.cfg.handle_yolo_hub 38 |

39 | 40 | --- 41 | ## ::: ultralytics.cfg.handle_yolo_settings 42 |

43 | 44 | --- 45 | ## ::: ultralytics.cfg.parse_key_value_pair 46 |

47 | 48 | --- 49 | ## ::: ultralytics.cfg.smart_value 50 |

51 | 52 | --- 53 | ## ::: ultralytics.cfg.entrypoint 54 |

55 | 56 | --- 57 | ## ::: ultralytics.cfg.copy_default_cfg 58 |

59 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/sam/amg.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore Ultralytics methods for mask data processing, transformation and encoding. Deepen your understanding of RLE encoding, image cropping and more. 3 | keywords: Ultralytics, Mask Data, Transformation, Encoding, RLE encoding, Image cropping, Pytorch, SAM, AMG, Ultralytics model 4 | --- 5 | 6 | # Reference for `ultralytics/models/sam/amg.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/sam/amg.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/sam/amg.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.sam.amg.is_box_near_crop_edge 14 |

15 | 16 | --- 17 | ## ::: ultralytics.models.sam.amg.batch_iterator 18 |

19 | 20 | --- 21 | ## ::: ultralytics.models.sam.amg.calculate_stability_score 22 |

23 | 24 | --- 25 | ## ::: ultralytics.models.sam.amg.build_point_grid 26 |

27 | 28 | --- 29 | ## ::: ultralytics.models.sam.amg.build_all_layer_point_grids 30 |

31 | 32 | --- 33 | ## ::: ultralytics.models.sam.amg.generate_crop_boxes 34 |

35 | 36 | --- 37 | ## ::: ultralytics.models.sam.amg.uncrop_boxes_xyxy 38 |

39 | 40 | --- 41 | ## ::: ultralytics.models.sam.amg.uncrop_points 42 |

43 | 44 | --- 45 | ## ::: ultralytics.models.sam.amg.uncrop_masks 46 |

47 | 48 | --- 49 | ## ::: ultralytics.models.sam.amg.remove_small_regions 50 |

51 | 52 | --- 53 | ## ::: ultralytics.models.sam.amg.batched_mask_to_box 54 |

55 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/cfg/models/v8/yolov8-seg.yaml: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | # YOLOv8-seg instance segmentation model. For Usage examples see https://docs.ultralytics.com/tasks/segment 3 | 4 | # Parameters 5 | nc: 80 # number of classes 6 | scales: # model compound scaling constants, i.e. 'model=yolov8n-seg.yaml' will call yolov8-seg.yaml with scale 'n' 7 | # [depth, width, max_channels] 8 | n: [0.33, 0.25, 1024] 9 | s: [0.33, 0.50, 1024] 10 | m: [0.67, 0.75, 768] 11 | l: [1.00, 1.00, 512] 12 | x: [1.00, 1.25, 512] 13 | 14 | # YOLOv8.0n backbone 15 | backbone: 16 | # [from, repeats, module, args] 17 | - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2 18 | - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4 19 | - [-1, 3, C2f, [128, True]] 20 | - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8 21 | - [-1, 6, C2f, [256, True]] 22 | - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16 23 | - [-1, 6, C2f, [512, True]] 24 | - [-1, 1, Conv, [1024, 3, 2]] # 7-P5/32 25 | - [-1, 3, C2f, [1024, True]] 26 | - [-1, 1, SPPF, [1024, 5]] # 9 27 | 28 | # YOLOv8.0n head 29 | head: 30 | - [-1, 1, nn.Upsample, [None, 2, 'nearest']] 31 | - [[-1, 6], 1, Concat, [1]] # cat backbone P4 32 | - [-1, 3, C2f, [512]] # 12 33 | 34 | - [-1, 1, nn.Upsample, [None, 2, 'nearest']] 35 | - [[-1, 4], 1, Concat, [1]] # cat backbone P3 36 | - [-1, 3, C2f, [256]] # 15 (P3/8-small) 37 | 38 | - [-1, 1, Conv, [256, 3, 2]] 39 | - [[-1, 12], 1, Concat, [1]] # cat head P4 40 | - [-1, 3, C2f, [512]] # 18 (P4/16-medium) 41 | 42 | - [-1, 1, Conv, [512, 3, 2]] 43 | - [[-1, 9], 1, Concat, [1]] # cat head P5 44 | - [-1, 3, C2f, [1024]] # 21 (P5/32-large) 45 | 46 | - [[15, 18, 21], 1, Segment, [nc, 32, 256]] # Segment(P3, P4, P5) 47 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/nn/modules/transformer.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Learn about Ultralytics transformer encoder, layer, MLP block, LayerNorm2d and the deformable transformer decoder layer. Expand your understanding of these crucial AI modules. 3 | keywords: Ultralytics, Ultralytics documentation, TransformerEncoderLayer, TransformerLayer, MLPBlock, LayerNorm2d, DeformableTransformerDecoderLayer 4 | --- 5 | 6 | # Reference for `ultralytics/nn/modules/transformer.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/nn/modules/transformer.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/nn/modules/transformer.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.nn.modules.transformer.TransformerEncoderLayer 14 |

15 | 16 | --- 17 | ## ::: ultralytics.nn.modules.transformer.AIFI 18 |

19 | 20 | --- 21 | ## ::: ultralytics.nn.modules.transformer.TransformerLayer 22 |

23 | 24 | --- 25 | ## ::: ultralytics.nn.modules.transformer.TransformerBlock 26 |

27 | 28 | --- 29 | ## ::: ultralytics.nn.modules.transformer.MLPBlock 30 |

31 | 32 | --- 33 | ## ::: ultralytics.nn.modules.transformer.MLP 34 |

35 | 36 | --- 37 | ## ::: ultralytics.nn.modules.transformer.LayerNorm2d 38 |

39 | 40 | --- 41 | ## ::: ultralytics.nn.modules.transformer.MSDeformAttn 42 |

43 | 44 | --- 45 | ## ::: ultralytics.nn.modules.transformer.DeformableTransformerDecoderLayer 46 |

47 | 48 | --- 49 | ## ::: ultralytics.nn.modules.transformer.DeformableTransformerDecoder 50 |

51 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/cfg/models/v3/yolov3.yaml: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | # YOLOv3 object detection model with P3-P5 outputs. For details see https://docs.ultralytics.com/models/yolov3 3 | 4 | # Parameters 5 | nc: 80 # number of classes 6 | depth_multiple: 1.0 # model depth multiple 7 | width_multiple: 1.0 # layer channel multiple 8 | 9 | # darknet53 backbone 10 | backbone: 11 | # [from, number, module, args] 12 | [[-1, 1, Conv, [32, 3, 1]], # 0 13 | [-1, 1, Conv, [64, 3, 2]], # 1-P1/2 14 | [-1, 1, Bottleneck, [64]], 15 | [-1, 1, Conv, [128, 3, 2]], # 3-P2/4 16 | [-1, 2, Bottleneck, [128]], 17 | [-1, 1, Conv, [256, 3, 2]], # 5-P3/8 18 | [-1, 8, Bottleneck, [256]], 19 | [-1, 1, Conv, [512, 3, 2]], # 7-P4/16 20 | [-1, 8, Bottleneck, [512]], 21 | [-1, 1, Conv, [1024, 3, 2]], # 9-P5/32 22 | [-1, 4, Bottleneck, [1024]], # 10 23 | ] 24 | 25 | # YOLOv3 head 26 | head: 27 | [[-1, 1, Bottleneck, [1024, False]], 28 | [-1, 1, Conv, [512, 1, 1]], 29 | [-1, 1, Conv, [1024, 3, 1]], 30 | [-1, 1, Conv, [512, 1, 1]], 31 | [-1, 1, Conv, [1024, 3, 1]], # 15 (P5/32-large) 32 | 33 | [-2, 1, Conv, [256, 1, 1]], 34 | [-1, 1, nn.Upsample, [None, 2, 'nearest']], 35 | [[-1, 8], 1, Concat, [1]], # cat backbone P4 36 | [-1, 1, Bottleneck, [512, False]], 37 | [-1, 1, Bottleneck, [512, False]], 38 | [-1, 1, Conv, [256, 1, 1]], 39 | [-1, 1, Conv, [512, 3, 1]], # 22 (P4/16-medium) 40 | 41 | [-2, 1, Conv, [128, 1, 1]], 42 | [-1, 1, nn.Upsample, [None, 2, 'nearest']], 43 | [[-1, 6], 1, Concat, [1]], # cat backbone P3 44 | [-1, 1, Bottleneck, [256, False]], 45 | [-1, 2, Bottleneck, [256, False]], # 27 (P3/8-small) 46 | 47 | [[27, 22, 15], 1, Detect, [nc]], # Detect(P3, P4, P5) 48 | ] 49 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/cfg/models/v3/yolov3-spp.yaml: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | # YOLOv3-SPP object detection model with P3-P5 outputs. For details see https://docs.ultralytics.com/models/yolov3 3 | 4 | # Parameters 5 | nc: 80 # number of classes 6 | depth_multiple: 1.0 # model depth multiple 7 | width_multiple: 1.0 # layer channel multiple 8 | 9 | # darknet53 backbone 10 | backbone: 11 | # [from, number, module, args] 12 | [[-1, 1, Conv, [32, 3, 1]], # 0 13 | [-1, 1, Conv, [64, 3, 2]], # 1-P1/2 14 | [-1, 1, Bottleneck, [64]], 15 | [-1, 1, Conv, [128, 3, 2]], # 3-P2/4 16 | [-1, 2, Bottleneck, [128]], 17 | [-1, 1, Conv, [256, 3, 2]], # 5-P3/8 18 | [-1, 8, Bottleneck, [256]], 19 | [-1, 1, Conv, [512, 3, 2]], # 7-P4/16 20 | [-1, 8, Bottleneck, [512]], 21 | [-1, 1, Conv, [1024, 3, 2]], # 9-P5/32 22 | [-1, 4, Bottleneck, [1024]], # 10 23 | ] 24 | 25 | # YOLOv3-SPP head 26 | head: 27 | [[-1, 1, Bottleneck, [1024, False]], 28 | [-1, 1, SPP, [512, [5, 9, 13]]], 29 | [-1, 1, Conv, [1024, 3, 1]], 30 | [-1, 1, Conv, [512, 1, 1]], 31 | [-1, 1, Conv, [1024, 3, 1]], # 15 (P5/32-large) 32 | 33 | [-2, 1, Conv, [256, 1, 1]], 34 | [-1, 1, nn.Upsample, [None, 2, 'nearest']], 35 | [[-1, 8], 1, Concat, [1]], # cat backbone P4 36 | [-1, 1, Bottleneck, [512, False]], 37 | [-1, 1, Bottleneck, [512, False]], 38 | [-1, 1, Conv, [256, 1, 1]], 39 | [-1, 1, Conv, [512, 3, 1]], # 22 (P4/16-medium) 40 | 41 | [-2, 1, Conv, [128, 1, 1]], 42 | [-1, 1, nn.Upsample, [None, 2, 'nearest']], 43 | [[-1, 6], 1, Concat, [1]], # cat backbone P3 44 | [-1, 1, Bottleneck, [256, False]], 45 | [-1, 2, Bottleneck, [256, False]], # 27 (P3/8-small) 46 | 47 | [[27, 22, 15], 1, Detect, [nc]], # Detect(P3, P4, P5) 48 | ] 49 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/cfg/models/v5/yolov5.yaml: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | # YOLOv5 object detection model with P3-P5 outputs. For details see https://docs.ultralytics.com/models/yolov5 3 | 4 | # Parameters 5 | nc: 80 # number of classes 6 | scales: # model compound scaling constants, i.e. 'model=yolov5n.yaml' will call yolov5.yaml with scale 'n' 7 | # [depth, width, max_channels] 8 | n: [0.33, 0.25, 1024] 9 | s: [0.33, 0.50, 1024] 10 | m: [0.67, 0.75, 1024] 11 | l: [1.00, 1.00, 1024] 12 | x: [1.33, 1.25, 1024] 13 | 14 | # YOLOv5 v6.0 backbone 15 | backbone: 16 | # [from, number, module, args] 17 | [[-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2 18 | [-1, 1, Conv, [128, 3, 2]], # 1-P2/4 19 | [-1, 3, C3, [128]], 20 | [-1, 1, Conv, [256, 3, 2]], # 3-P3/8 21 | [-1, 6, C3, [256]], 22 | [-1, 1, Conv, [512, 3, 2]], # 5-P4/16 23 | [-1, 9, C3, [512]], 24 | [-1, 1, Conv, [1024, 3, 2]], # 7-P5/32 25 | [-1, 3, C3, [1024]], 26 | [-1, 1, SPPF, [1024, 5]], # 9 27 | ] 28 | 29 | # YOLOv5 v6.0 head 30 | head: 31 | [[-1, 1, Conv, [512, 1, 1]], 32 | [-1, 1, nn.Upsample, [None, 2, 'nearest']], 33 | [[-1, 6], 1, Concat, [1]], # cat backbone P4 34 | [-1, 3, C3, [512, False]], # 13 35 | 36 | [-1, 1, Conv, [256, 1, 1]], 37 | [-1, 1, nn.Upsample, [None, 2, 'nearest']], 38 | [[-1, 4], 1, Concat, [1]], # cat backbone P3 39 | [-1, 3, C3, [256, False]], # 17 (P3/8-small) 40 | 41 | [-1, 1, Conv, [256, 3, 2]], 42 | [[-1, 14], 1, Concat, [1]], # cat head P4 43 | [-1, 3, C3, [512, False]], # 20 (P4/16-medium) 44 | 45 | [-1, 1, Conv, [512, 3, 2]], 46 | [[-1, 10], 1, Concat, [1]], # cat head P5 47 | [-1, 3, C3, [1024, False]], # 23 (P5/32-large) 48 | 49 | [[17, 20, 23], 1, Detect, [nc]], # Detect(P3, P4, P5) 50 | ] 51 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/sam/modules/encoders.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Discover detailed information on ImageEncoderViT, PositionEmbeddingRandom, Attention, window_partition, get_rel_pos and more in Ultralytics models encoders documentation. 3 | keywords: Ultralytics, Encoders, Modules, Documentation, ImageEncoderViT, PositionEmbeddingRandom, Attention, window_partition, get_rel_pos 4 | --- 5 | 6 | # Reference for `ultralytics/models/sam/modules/encoders.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/sam/modules/encoders.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/sam/modules/encoders.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.sam.modules.encoders.ImageEncoderViT 14 |

15 | 16 | --- 17 | ## ::: ultralytics.models.sam.modules.encoders.PromptEncoder 18 |

19 | 20 | --- 21 | ## ::: ultralytics.models.sam.modules.encoders.PositionEmbeddingRandom 22 |

23 | 24 | --- 25 | ## ::: ultralytics.models.sam.modules.encoders.Block 26 |

27 | 28 | --- 29 | ## ::: ultralytics.models.sam.modules.encoders.Attention 30 |

31 | 32 | --- 33 | ## ::: ultralytics.models.sam.modules.encoders.PatchEmbed 34 |

35 | 36 | --- 37 | ## ::: ultralytics.models.sam.modules.encoders.window_partition 38 |

39 | 40 | --- 41 | ## ::: ultralytics.models.sam.modules.encoders.window_unpartition 42 |

43 | 44 | --- 45 | ## ::: ultralytics.models.sam.modules.encoders.get_rel_pos 46 |

47 | 48 | --- 49 | ## ::: ultralytics.models.sam.modules.encoders.add_decomposed_rel_pos 50 |

51 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/cfg/models/v8/yolov8-pose.yaml: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | # YOLOv8-pose keypoints/pose estimation model. For Usage examples see https://docs.ultralytics.com/tasks/pose 3 | 4 | # Parameters 5 | nc: 1 # number of classes 6 | kpt_shape: [17, 3] # number of keypoints, number of dims (2 for x,y or 3 for x,y,visible) 7 | scales: # model compound scaling constants, i.e. 'model=yolov8n-pose.yaml' will call yolov8-pose.yaml with scale 'n' 8 | # [depth, width, max_channels] 9 | n: [0.33, 0.25, 1024] 10 | s: [0.33, 0.50, 1024] 11 | m: [0.67, 0.75, 768] 12 | l: [1.00, 1.00, 512] 13 | x: [1.00, 1.25, 512] 14 | 15 | # YOLOv8.0n backbone 16 | backbone: 17 | # [from, repeats, module, args] 18 | - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2 19 | - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4 20 | - [-1, 3, C2f, [128, True]] 21 | - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8 22 | - [-1, 6, C2f, [256, True]] 23 | - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16 24 | - [-1, 6, C2f, [512, True]] 25 | - [-1, 1, Conv, [1024, 3, 2]] # 7-P5/32 26 | - [-1, 3, C2f, [1024, True]] 27 | - [-1, 1, SPPF, [1024, 5]] # 9 28 | 29 | # YOLOv8.0n head 30 | head: 31 | - [-1, 1, nn.Upsample, [None, 2, 'nearest']] 32 | - [[-1, 6], 1, Concat, [1]] # cat backbone P4 33 | - [-1, 3, C2f, [512]] # 12 34 | 35 | - [-1, 1, nn.Upsample, [None, 2, 'nearest']] 36 | - [[-1, 4], 1, Concat, [1]] # cat backbone P3 37 | - [-1, 3, C2f, [256]] # 15 (P3/8-small) 38 | 39 | - [-1, 1, Conv, [256, 3, 2]] 40 | - [[-1, 12], 1, Concat, [1]] # cat head P4 41 | - [-1, 3, C2f, [512]] # 18 (P4/16-medium) 42 | 43 | - [-1, 1, Conv, [512, 3, 2]] 44 | - [[-1, 9], 1, Concat, [1]] # cat head P5 45 | - [-1, 3, C2f, [1024]] # 21 (P5/32-large) 46 | 47 | - [[15, 18, 21], 1, Pose, [nc, kpt_shape]] # Pose(P3, P4, P5) 48 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/nn/modules/conv.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore various Ultralytics convolution modules including Conv2, DWConv, ConvTranspose, GhostConv, Channel Attention and more. 3 | keywords: Ultralytics, Convolution Modules, Conv2, DWConv, ConvTranspose, GhostConv, ChannelAttention, CBAM, autopad 4 | --- 5 | 6 | # Reference for `ultralytics/nn/modules/conv.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/nn/modules/conv.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/nn/modules/conv.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.nn.modules.conv.Conv 14 |

15 | 16 | --- 17 | ## ::: ultralytics.nn.modules.conv.Conv2 18 |

19 | 20 | --- 21 | ## ::: ultralytics.nn.modules.conv.LightConv 22 |

23 | 24 | --- 25 | ## ::: ultralytics.nn.modules.conv.DWConv 26 |

27 | 28 | --- 29 | ## ::: ultralytics.nn.modules.conv.DWConvTranspose2d 30 |

31 | 32 | --- 33 | ## ::: ultralytics.nn.modules.conv.ConvTranspose 34 |

35 | 36 | --- 37 | ## ::: ultralytics.nn.modules.conv.Focus 38 |

39 | 40 | --- 41 | ## ::: ultralytics.nn.modules.conv.GhostConv 42 |

43 | 44 | --- 45 | ## ::: ultralytics.nn.modules.conv.RepConv 46 |

47 | 48 | --- 49 | ## ::: ultralytics.nn.modules.conv.ChannelAttention 50 |

51 | 52 | --- 53 | ## ::: ultralytics.nn.modules.conv.SpatialAttention 54 |

55 | 56 | --- 57 | ## ::: ultralytics.nn.modules.conv.CBAM 58 |

59 | 60 | --- 61 | ## ::: ultralytics.nn.modules.conv.Concat 62 |

63 | 64 | --- 65 | ## ::: ultralytics.nn.modules.conv.autopad 66 |

67 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/nn/modules/__init__.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | """ 3 | Ultralytics modules. 4 | 5 | Example: 6 | Visualize a module with Netron. 7 | ```python 8 | from ultralytics.nn.modules import * 9 | import torch 10 | import os 11 | 12 | x = torch.ones(1, 128, 40, 40) 13 | m = Conv(128, 128) 14 | f = f'{m._get_name()}.onnx' 15 | torch.onnx.export(m, x, f) 16 | os.system(f'onnxsim {f} {f} && open {f}') 17 | ``` 18 | """ 19 | 20 | from .block import (C1, C2, C3, C3TR, DFL, SPP, SPPF, Bottleneck, BottleneckCSP, C2f, C3Ghost, C3x, GhostBottleneck, 21 | HGBlock, HGStem, Proto, RepC3) 22 | from .conv import (CBAM, ChannelAttention, Concat, Conv, Conv2, ConvTranspose, DWConv, DWConvTranspose2d, Focus, 23 | GhostConv, LightConv, RepConv, SpatialAttention) 24 | from .head import Classify, Detect, Pose, RTDETRDecoder, Segment 25 | from .transformer import (AIFI, MLP, DeformableTransformerDecoder, DeformableTransformerDecoderLayer, LayerNorm2d, 26 | MLPBlock, MSDeformAttn, TransformerBlock, TransformerEncoderLayer, TransformerLayer) 27 | 28 | __all__ = ('Conv', 'Conv2', 'LightConv', 'RepConv', 'DWConv', 'DWConvTranspose2d', 'ConvTranspose', 'Focus', 29 | 'GhostConv', 'ChannelAttention', 'SpatialAttention', 'CBAM', 'Concat', 'TransformerLayer', 30 | 'TransformerBlock', 'MLPBlock', 'LayerNorm2d', 'DFL', 'HGBlock', 'HGStem', 'SPP', 'SPPF', 'C1', 'C2', 'C3', 31 | 'C2f', 'C3x', 'C3TR', 'C3Ghost', 'GhostBottleneck', 'Bottleneck', 'BottleneckCSP', 'Proto', 'Detect', 32 | 'Segment', 'Pose', 'Classify', 'TransformerEncoderLayer', 'RepC3', 'RTDETRDecoder', 'AIFI', 33 | 'DeformableTransformerDecoder', 'DeformableTransformerDecoderLayer', 'MSDeformAttn', 'MLP') 34 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/models/yolo/detect/predict.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | from ultralytics.engine.predictor import BasePredictor 4 | from ultralytics.engine.results import Results 5 | from ultralytics.utils import ops 6 | 7 | 8 | class DetectionPredictor(BasePredictor): 9 | """ 10 | A class extending the BasePredictor class for prediction based on a detection model. 11 | 12 | Example: 13 | ```python 14 | from ultralytics.utils import ASSETS 15 | from ultralytics.models.yolo.detect import DetectionPredictor 16 | 17 | args = dict(model='yolov8n.pt', source=ASSETS) 18 | predictor = DetectionPredictor(overrides=args) 19 | predictor.predict_cli() 20 | ``` 21 | """ 22 | 23 | def postprocess(self, preds, img, orig_imgs): 24 | """Post-processes predictions and returns a list of Results objects.""" 25 | preds = ops.non_max_suppression(preds, 26 | self.args.conf, 27 | self.args.iou, 28 | agnostic=self.args.agnostic_nms, 29 | max_det=self.args.max_det, 30 | classes=self.args.classes) 31 | 32 | if not isinstance(orig_imgs, list): # input images are a torch.Tensor, not a list 33 | orig_imgs = ops.convert_torch2numpy_batch(orig_imgs) 34 | 35 | results = [] 36 | for i, pred in enumerate(preds): 37 | orig_img = orig_imgs[i] 38 | pred[:, :4] = ops.scale_boxes(img.shape[2:], pred[:, :4], orig_img.shape) 39 | img_path = self.batch[0][i] 40 | results.append(Results(orig_img, path=img_path, names=self.model.names, boxes=pred)) 41 | return results 42 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/data/utils.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Uncover a detailed guide to Ultralytics data utilities. Learn functions from img2label_paths to autosplit, all boosting your YOLO model’s efficiency. 3 | keywords: Ultralytics, data utils, YOLO, img2label_paths, exif_size, polygon2mask, polygons2masks_overlap, check_cls_dataset, delete_dsstore, autosplit 4 | --- 5 | 6 | # Reference for `ultralytics/data/utils.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/data/utils.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/data/utils.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.data.utils.HUBDatasetStats 14 |

15 | 16 | --- 17 | ## ::: ultralytics.data.utils.img2label_paths 18 |

19 | 20 | --- 21 | ## ::: ultralytics.data.utils.get_hash 22 |

23 | 24 | --- 25 | ## ::: ultralytics.data.utils.exif_size 26 |

27 | 28 | --- 29 | ## ::: ultralytics.data.utils.verify_image 30 |

31 | 32 | --- 33 | ## ::: ultralytics.data.utils.verify_image_label 34 |

35 | 36 | --- 37 | ## ::: ultralytics.data.utils.polygon2mask 38 |

39 | 40 | --- 41 | ## ::: ultralytics.data.utils.polygons2masks 42 |

43 | 44 | --- 45 | ## ::: ultralytics.data.utils.polygons2masks_overlap 46 |

47 | 48 | --- 49 | ## ::: ultralytics.data.utils.find_dataset_yaml 50 |

51 | 52 | --- 53 | ## ::: ultralytics.data.utils.check_det_dataset 54 |

55 | 56 | --- 57 | ## ::: ultralytics.data.utils.check_cls_dataset 58 |

59 | 60 | --- 61 | ## ::: ultralytics.data.utils.compress_one_image 62 |

63 | 64 | --- 65 | ## ::: ultralytics.data.utils.autosplit 66 |

67 | -------------------------------------------------------------------------------- /ultralytics/docker/Dockerfile-runner: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | # Builds GitHub actions CI runner image for deployment to DockerHub https://hub.docker.com/r/ultralytics/ultralytics 3 | # Image is CUDA-optimized for YOLOv8 single/multi-GPU training and inference tests 4 | 5 | # Start FROM Ultralytics GPU image 6 | FROM ultralytics/ultralytics:latest 7 | 8 | # Set the working directory 9 | WORKDIR /actions-runner 10 | 11 | # Download and unpack the latest runner from https://github.com/actions/runner 12 | RUN FILENAME=actions-runner-linux-x64-2.309.0.tar.gz && \ 13 | curl -o $FILENAME -L https://github.com/actions/runner/releases/download/v2.309.0/$FILENAME && \ 14 | tar xzf $FILENAME && \ 15 | rm $FILENAME 16 | 17 | # Install runner dependencies 18 | ENV RUNNER_ALLOW_RUNASROOT=1 19 | ENV DEBIAN_FRONTEND=noninteractive 20 | RUN ./bin/installdependencies.sh && \ 21 | apt-get -y install libicu-dev 22 | 23 | # Inline ENTRYPOINT command to configure and start runner with default TOKEN and NAME 24 | ENTRYPOINT sh -c './config.sh --url https://github.com/ultralytics/ultralytics \ 25 | --token ${GITHUB_RUNNER_TOKEN:-TOKEN} \ 26 | --name ${GITHUB_RUNNER_NAME:-NAME} \ 27 | --labels gpu-latest \ 28 | --replace && \ 29 | ./run.sh' 30 | 31 | 32 | # Usage Examples ------------------------------------------------------------------------------------------------------- 33 | 34 | # Build and Push 35 | # t=ultralytics/ultralytics:latest-runner && sudo docker build -f docker/Dockerfile-runner -t $t . && sudo docker push $t 36 | 37 | # Pull and Run in detached mode with access to GPUs 0 and 1 38 | # t=ultralytics/ultralytics:latest-runner && sudo docker run -d -e GITHUB_RUNNER_TOKEN=TOKEN -e GITHUB_RUNNER_NAME=NAME --ipc=host --gpus '"device=0,1"' $t 39 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/data/scripts/get_imagenet.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Ultralytics YOLO 🚀, AGPL-3.0 license 3 | # Download ILSVRC2012 ImageNet dataset https://image-net.org 4 | # Example usage: bash data/scripts/get_imagenet.sh 5 | # parent 6 | # ├── ultralytics 7 | # └── datasets 8 | # └── imagenet ← downloads here 9 | 10 | # Arguments (optional) Usage: bash data/scripts/get_imagenet.sh --train --val 11 | if [ "$#" -gt 0 ]; then 12 | for opt in "$@"; do 13 | case "${opt}" in 14 | --train) train=true ;; 15 | --val) val=true ;; 16 | esac 17 | done 18 | else 19 | train=true 20 | val=true 21 | fi 22 | 23 | # Make dir 24 | d='../datasets/imagenet' # unzip directory 25 | mkdir -p $d && cd $d 26 | 27 | # Download/unzip train 28 | if [ "$train" == "true" ]; then 29 | wget https://image-net.org/data/ILSVRC/2012/ILSVRC2012_img_train.tar # download 138G, 1281167 images 30 | mkdir train && mv ILSVRC2012_img_train.tar train/ && cd train 31 | tar -xf ILSVRC2012_img_train.tar && rm -f ILSVRC2012_img_train.tar 32 | find . -name "*.tar" | while read NAME; do 33 | mkdir -p "${NAME%.tar}" 34 | tar -xf "${NAME}" -C "${NAME%.tar}" 35 | rm -f "${NAME}" 36 | done 37 | cd .. 38 | fi 39 | 40 | # Download/unzip val 41 | if [ "$val" == "true" ]; then 42 | wget https://image-net.org/data/ILSVRC/2012/ILSVRC2012_img_val.tar # download 6.3G, 50000 images 43 | mkdir val && mv ILSVRC2012_img_val.tar val/ && cd val && tar -xf ILSVRC2012_img_val.tar 44 | wget -qO- https://raw.githubusercontent.com/soumith/imagenetloader.torch/master/valprep.sh | bash # move into subdirs 45 | fi 46 | 47 | # Delete corrupted image (optional: PNG under JPEG name that may cause dataloaders to fail) 48 | # rm train/n04266014/n04266014_10835.JPEG 49 | 50 | # TFRecords (optional) 51 | # wget https://raw.githubusercontent.com/tensorflow/models/master/research/slim/datasets/imagenet_lsvrc_2015_synsets.txt 52 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/models/sam/modules/tiny_encoder.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Get in-depth insights about Ultralytics Tiny Encoder Modules such as Conv2d_BN, MBConv, ConvLayer, Attention, BasicLayer, and TinyViT. Improve your understanding of machine learning model components. 3 | keywords: Ultralytics, Tiny Encoder, Conv2d_BN, MBConv, ConvLayer, Attention, BasicLayer, TinyViT, Machine learning modules, Ultralytics models 4 | --- 5 | 6 | # Reference for `ultralytics/models/sam/modules/tiny_encoder.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/sam/modules/tiny_encoder.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/sam/modules/tiny_encoder.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.models.sam.modules.tiny_encoder.Conv2d_BN 14 |

15 | 16 | --- 17 | ## ::: ultralytics.models.sam.modules.tiny_encoder.PatchEmbed 18 |

19 | 20 | --- 21 | ## ::: ultralytics.models.sam.modules.tiny_encoder.MBConv 22 |

23 | 24 | --- 25 | ## ::: ultralytics.models.sam.modules.tiny_encoder.PatchMerging 26 |

27 | 28 | --- 29 | ## ::: ultralytics.models.sam.modules.tiny_encoder.ConvLayer 30 |

31 | 32 | --- 33 | ## ::: ultralytics.models.sam.modules.tiny_encoder.Mlp 34 |

35 | 36 | --- 37 | ## ::: ultralytics.models.sam.modules.tiny_encoder.Attention 38 |

39 | 40 | --- 41 | ## ::: ultralytics.models.sam.modules.tiny_encoder.TinyViTBlock 42 |

43 | 44 | --- 45 | ## ::: ultralytics.models.sam.modules.tiny_encoder.BasicLayer 46 |

47 | 48 | --- 49 | ## ::: ultralytics.models.sam.modules.tiny_encoder.LayerNorm2d 50 |

51 | 52 | --- 53 | ## ::: ultralytics.models.sam.modules.tiny_encoder.TinyViT 54 |

55 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/trackers/basetrack.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | from collections import OrderedDict 4 | 5 | import numpy as np 6 | 7 | 8 | class TrackState: 9 | """Enumeration of possible object tracking states.""" 10 | 11 | New = 0 12 | Tracked = 1 13 | Lost = 2 14 | Removed = 3 15 | 16 | 17 | class BaseTrack: 18 | """Base class for object tracking, handling basic track attributes and operations.""" 19 | 20 | _count = 0 21 | 22 | track_id = 0 23 | is_activated = False 24 | state = TrackState.New 25 | 26 | history = OrderedDict() 27 | features = [] 28 | curr_feature = None 29 | score = 0 30 | start_frame = 0 31 | frame_id = 0 32 | time_since_update = 0 33 | 34 | # Multi-camera 35 | location = (np.inf, np.inf) 36 | 37 | @property 38 | def end_frame(self): 39 | """Return the last frame ID of the track.""" 40 | return self.frame_id 41 | 42 | @staticmethod 43 | def next_id(): 44 | """Increment and return the global track ID counter.""" 45 | BaseTrack._count += 1 46 | return BaseTrack._count 47 | 48 | def activate(self, *args): 49 | """Activate the track with the provided arguments.""" 50 | raise NotImplementedError 51 | 52 | def predict(self): 53 | """Predict the next state of the track.""" 54 | raise NotImplementedError 55 | 56 | def update(self, *args, **kwargs): 57 | """Update the track with new observations.""" 58 | raise NotImplementedError 59 | 60 | def mark_lost(self): 61 | """Mark the track as lost.""" 62 | self.state = TrackState.Lost 63 | 64 | def mark_removed(self): 65 | """Mark the track as removed.""" 66 | self.state = TrackState.Removed 67 | 68 | @staticmethod 69 | def reset_id(): 70 | """Reset the global track ID counter.""" 71 | BaseTrack._count = 0 72 | -------------------------------------------------------------------------------- /ultralytics/docs/overrides/partials/comments.html: -------------------------------------------------------------------------------- 1 | {% if page.meta.comments %} 2 |

{{ lang.t("meta.comments") }}

3 | 4 | 5 | 20 | 21 | 22 | 50 | {% endif %} 51 | -------------------------------------------------------------------------------- /ultralytics/docker/Dockerfile-conda: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | # Builds ultralytics/ultralytics:latest-conda image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics 3 | # Image is optimized for Ultralytics Anaconda (https://anaconda.org/conda-forge/ultralytics) installation and usage 4 | 5 | # Start FROM miniconda3 image https://hub.docker.com/r/continuumio/miniconda3 6 | FROM continuumio/miniconda3:latest 7 | 8 | # Downloads to user config dir 9 | ADD https://ultralytics.com/assets/Arial.ttf https://ultralytics.com/assets/Arial.Unicode.ttf /root/.config/Ultralytics/ 10 | 11 | # Install linux packages 12 | RUN apt update \ 13 | && apt install --no-install-recommends -y libgl1-mesa-glx 14 | 15 | # Copy contents 16 | ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n.pt . 17 | 18 | # Install conda packages 19 | # mkl required to fix 'OSError: libmkl_intel_lp64.so.2: cannot open shared object file: No such file or directory' 20 | RUN conda config --set solver libmamba && \ 21 | conda install pytorch torchvision pytorch-cuda=11.8 -c pytorch -c nvidia && \ 22 | conda install -c conda-forge ultralytics mkl 23 | # conda install -c pytorch -c nvidia -c conda-forge pytorch torchvision pytorch-cuda=11.8 ultralytics mkl 24 | 25 | 26 | # Usage Examples ------------------------------------------------------------------------------------------------------- 27 | 28 | # Build and Push 29 | # t=ultralytics/ultralytics:latest-conda && sudo docker build -f docker/Dockerfile-cpu -t $t . && sudo docker push $t 30 | 31 | # Run 32 | # t=ultralytics/ultralytics:latest-conda && sudo docker run -it --ipc=host $t 33 | 34 | # Pull and Run 35 | # t=ultralytics/ultralytics:latest-conda && sudo docker pull $t && sudo docker run -it --ipc=host $t 36 | 37 | # Pull and Run with local volume mounted 38 | # t=ultralytics/ultralytics:latest-conda && sudo docker pull $t && sudo docker run -it --ipc=host -v "$(pwd)"/datasets:/usr/src/datasets $t 39 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/cfg/models/v6/yolov6.yaml: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | # YOLOv6 object detection model with P3-P5 outputs. For Usage examples see https://docs.ultralytics.com/models/yolov6 3 | 4 | # Parameters 5 | nc: 80 # number of classes 6 | activation: nn.ReLU() # (optional) model default activation function 7 | scales: # model compound scaling constants, i.e. 'model=yolov6n.yaml' will call yolov8.yaml with scale 'n' 8 | # [depth, width, max_channels] 9 | n: [0.33, 0.25, 1024] 10 | s: [0.33, 0.50, 1024] 11 | m: [0.67, 0.75, 768] 12 | l: [1.00, 1.00, 512] 13 | x: [1.00, 1.25, 512] 14 | 15 | # YOLOv6-3.0s backbone 16 | backbone: 17 | # [from, repeats, module, args] 18 | - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2 19 | - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4 20 | - [-1, 6, Conv, [128, 3, 1]] 21 | - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8 22 | - [-1, 12, Conv, [256, 3, 1]] 23 | - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16 24 | - [-1, 18, Conv, [512, 3, 1]] 25 | - [-1, 1, Conv, [1024, 3, 2]] # 7-P5/32 26 | - [-1, 6, Conv, [1024, 3, 1]] 27 | - [-1, 1, SPPF, [1024, 5]] # 9 28 | 29 | # YOLOv6-3.0s head 30 | head: 31 | - [-1, 1, Conv, [256, 1, 1]] 32 | - [-1, 1, nn.ConvTranspose2d, [256, 2, 2, 0]] 33 | - [[-1, 6], 1, Concat, [1]] # cat backbone P4 34 | - [-1, 1, Conv, [256, 3, 1]] 35 | - [-1, 9, Conv, [256, 3, 1]] # 14 36 | 37 | - [-1, 1, Conv, [128, 1, 1]] 38 | - [-1, 1, nn.ConvTranspose2d, [128, 2, 2, 0]] 39 | - [[-1, 4], 1, Concat, [1]] # cat backbone P3 40 | - [-1, 1, Conv, [128, 3, 1]] 41 | - [-1, 9, Conv, [128, 3, 1]] # 19 42 | 43 | - [-1, 1, Conv, [128, 3, 2]] 44 | - [[-1, 15], 1, Concat, [1]] # cat head P4 45 | - [-1, 1, Conv, [256, 3, 1]] 46 | - [-1, 9, Conv, [256, 3, 1]] # 23 47 | 48 | - [-1, 1, Conv, [256, 3, 2]] 49 | - [[-1, 10], 1, Concat, [1]] # cat head P5 50 | - [-1, 1, Conv, [512, 3, 1]] 51 | - [-1, 9, Conv, [512, 3, 1]] # 27 52 | 53 | - [[19, 23, 27], 1, Detect, [nc]] # Detect(P3, P4, P5) 54 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/data/scripts/get_coco.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Ultralytics YOLO 🚀, AGPL-3.0 license 3 | # Download COCO 2017 dataset http://cocodataset.org 4 | # Example usage: bash data/scripts/get_coco.sh 5 | # parent 6 | # ├── ultralytics 7 | # └── datasets 8 | # └── coco ← downloads here 9 | 10 | # Arguments (optional) Usage: bash data/scripts/get_coco.sh --train --val --test --segments 11 | if [ "$#" -gt 0 ]; then 12 | for opt in "$@"; do 13 | case "${opt}" in 14 | --train) train=true ;; 15 | --val) val=true ;; 16 | --test) test=true ;; 17 | --segments) segments=true ;; 18 | --sama) sama=true ;; 19 | esac 20 | done 21 | else 22 | train=true 23 | val=true 24 | test=false 25 | segments=false 26 | sama=false 27 | fi 28 | 29 | # Download/unzip labels 30 | d='../datasets' # unzip directory 31 | url=https://github.com/ultralytics/yolov5/releases/download/v1.0/ 32 | if [ "$segments" == "true" ]; then 33 | f='coco2017labels-segments.zip' # 169 MB 34 | elif [ "$sama" == "true" ]; then 35 | f='coco2017labels-segments-sama.zip' # 199 MB https://www.sama.com/sama-coco-dataset/ 36 | else 37 | f='coco2017labels.zip' # 46 MB 38 | fi 39 | echo 'Downloading' $url$f ' ...' 40 | curl -L $url$f -o $f -# && unzip -q $f -d $d && rm $f & 41 | 42 | # Download/unzip images 43 | d='../datasets/coco/images' # unzip directory 44 | url=http://images.cocodataset.org/zips/ 45 | if [ "$train" == "true" ]; then 46 | f='train2017.zip' # 19G, 118k images 47 | echo 'Downloading' $url$f '...' 48 | curl -L $url$f -o $f -# && unzip -q $f -d $d && rm $f & 49 | fi 50 | if [ "$val" == "true" ]; then 51 | f='val2017.zip' # 1G, 5k images 52 | echo 'Downloading' $url$f '...' 53 | curl -L $url$f -o $f -# && unzip -q $f -d $d && rm $f & 54 | fi 55 | if [ "$test" == "true" ]; then 56 | f='test2017.zip' # 7G, 41k images (optional) 57 | echo 'Downloading' $url$f '...' 58 | curl -L $url$f -o $f -# && unzip -q $f -d $d && rm $f & 59 | fi 60 | wait # finish background tasks 61 | -------------------------------------------------------------------------------- /ultralytics/.github/workflows/links.yml: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | # YOLO Continuous Integration (CI) GitHub Actions tests broken link checker 3 | # Accept 429(Instagram, 'too many requests'), 999(LinkedIn, 'unknown status code'), Timeout(Twitter) 4 | 5 | name: Check Broken links 6 | 7 | on: 8 | workflow_dispatch: 9 | schedule: 10 | - cron: '0 0 * * *' # runs at 00:00 UTC every day 11 | 12 | jobs: 13 | Links: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v4 17 | 18 | - name: Download and install lychee 19 | run: | 20 | LYCHEE_URL=$(curl -s https://api.github.com/repos/lycheeverse/lychee/releases/latest | grep "browser_download_url" | grep "x86_64-unknown-linux-gnu.tar.gz" | cut -d '"' -f 4) 21 | curl -L $LYCHEE_URL -o lychee.tar.gz 22 | tar xzf lychee.tar.gz 23 | sudo mv lychee /usr/local/bin 24 | 25 | - name: Test Markdown and HTML links with retry 26 | uses: nick-invision/retry@v2 27 | with: 28 | timeout_minutes: 5 29 | retry_wait_seconds: 60 30 | max_attempts: 3 31 | command: lychee --accept 429,999 --exclude-loopback --exclude 'https?://(www\.)?(linkedin\.com|twitter\.com|instagram\.com|kaggle\.com)' --exclude-path '**/ci.yaml' --exclude-mail --github-token ${{ secrets.GITHUB_TOKEN }} './**/*.md' './**/*.html' 32 | 33 | - name: Test Markdown, HTML, YAML, Python and Notebook links with retry 34 | if: github.event_name == 'workflow_dispatch' 35 | uses: nick-invision/retry@v2 36 | with: 37 | timeout_minutes: 5 38 | retry_wait_seconds: 60 39 | max_attempts: 3 40 | command: lychee --accept 429,999 --exclude-loopback --exclude 'https?://(www\.)?(linkedin\.com|twitter\.com|instagram\.com|kaggle\.com|url\.com)' --exclude-path '**/ci.yaml' --exclude-mail --github-token ${{ secrets.GITHUB_TOKEN }} './**/*.md' './**/*.html' './**/*.yml' './**/*.yaml' './**/*.py' './**/*.ipynb' 41 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/cfg/models/v8/yolov8-p2.yaml: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | # YOLOv8 object detection model with P2-P5 outputs. For Usage examples see https://docs.ultralytics.com/tasks/detect 3 | 4 | # Parameters 5 | nc: 80 # number of classes 6 | scales: # model compound scaling constants, i.e. 'model=yolov8n.yaml' will call yolov8.yaml with scale 'n' 7 | # [depth, width, max_channels] 8 | n: [0.33, 0.25, 1024] 9 | s: [0.33, 0.50, 1024] 10 | m: [0.67, 0.75, 768] 11 | l: [1.00, 1.00, 512] 12 | x: [1.00, 1.25, 512] 13 | 14 | # YOLOv8.0 backbone 15 | backbone: 16 | # [from, repeats, module, args] 17 | - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2 18 | - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4 19 | - [-1, 3, C2f, [128, True]] 20 | - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8 21 | - [-1, 6, C2f, [256, True]] 22 | - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16 23 | - [-1, 6, C2f, [512, True]] 24 | - [-1, 1, Conv, [1024, 3, 2]] # 7-P5/32 25 | - [-1, 3, C2f, [1024, True]] 26 | - [-1, 1, SPPF, [1024, 5]] # 9 27 | 28 | # YOLOv8.0-p2 head 29 | head: 30 | - [-1, 1, nn.Upsample, [None, 2, 'nearest']] 31 | - [[-1, 6], 1, Concat, [1]] # cat backbone P4 32 | - [-1, 3, C2f, [512]] # 12 33 | 34 | - [-1, 1, nn.Upsample, [None, 2, 'nearest']] 35 | - [[-1, 4], 1, Concat, [1]] # cat backbone P3 36 | - [-1, 3, C2f, [256]] # 15 (P3/8-small) 37 | 38 | - [-1, 1, nn.Upsample, [None, 2, 'nearest']] 39 | - [[-1, 2], 1, Concat, [1]] # cat backbone P2 40 | - [-1, 3, C2f, [128]] # 18 (P2/4-xsmall) 41 | 42 | - [-1, 1, Conv, [128, 3, 2]] 43 | - [[-1, 15], 1, Concat, [1]] # cat head P3 44 | - [-1, 3, C2f, [256]] # 21 (P3/8-small) 45 | 46 | - [-1, 1, Conv, [256, 3, 2]] 47 | - [[-1, 12], 1, Concat, [1]] # cat head P4 48 | - [-1, 3, C2f, [512]] # 24 (P4/16-medium) 49 | 50 | - [-1, 1, Conv, [512, 3, 2]] 51 | - [[-1, 9], 1, Concat, [1]] # cat head P5 52 | - [-1, 3, C2f, [1024]] # 27 (P5/32-large) 53 | 54 | - [[18, 21, 24, 27], 1, Detect, [nc]] # Detect(P2, P3, P4, P5) 55 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/models/sam/modules/sam.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | # Copyright (c) Meta Platforms, Inc. and affiliates. 4 | # All rights reserved. 5 | 6 | # This source code is licensed under the license found in the 7 | # LICENSE file in the root directory of this source tree. 8 | 9 | from typing import List 10 | 11 | import torch 12 | from torch import nn 13 | 14 | from .decoders import MaskDecoder 15 | from .encoders import ImageEncoderViT, PromptEncoder 16 | 17 | 18 | class Sam(nn.Module): 19 | mask_threshold: float = 0.0 20 | image_format: str = 'RGB' 21 | 22 | def __init__( 23 | self, 24 | image_encoder: ImageEncoderViT, 25 | prompt_encoder: PromptEncoder, 26 | mask_decoder: MaskDecoder, 27 | pixel_mean: List[float] = (123.675, 116.28, 103.53), 28 | pixel_std: List[float] = (58.395, 57.12, 57.375) 29 | ) -> None: 30 | """ 31 | SAM predicts object masks from an image and input prompts. 32 | 33 | Note: 34 | All forward() operations moved to SAMPredictor. 35 | 36 | Args: 37 | image_encoder (ImageEncoderViT): The backbone used to encode the image into image embeddings that allow for 38 | efficient mask prediction. 39 | prompt_encoder (PromptEncoder): Encodes various types of input prompts. 40 | mask_decoder (MaskDecoder): Predicts masks from the image embeddings and encoded prompts. 41 | pixel_mean (list(float)): Mean values for normalizing pixels in the input image. 42 | pixel_std (list(float)): Std values for normalizing pixels in the input image. 43 | """ 44 | super().__init__() 45 | self.image_encoder = image_encoder 46 | self.prompt_encoder = prompt_encoder 47 | self.mask_decoder = mask_decoder 48 | self.register_buffer('pixel_mean', torch.Tensor(pixel_mean).view(-1, 1, 1), False) 49 | self.register_buffer('pixel_std', torch.Tensor(pixel_std).view(-1, 1, 1), False) 50 | -------------------------------------------------------------------------------- /ultralytics/.github/ISSUE_TEMPLATE/feature-request.yml: -------------------------------------------------------------------------------- 1 | name: 🚀 Feature Request 2 | description: Suggest a YOLOv8 idea 3 | # title: " " 4 | labels: [enhancement] 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | Thank you for submitting a YOLOv8 🚀 Feature Request! 10 | 11 | - type: checkboxes 12 | attributes: 13 | label: Search before asking 14 | description: > 15 | Please search the [issues](https://github.com/ultralytics/ultralytics/issues) to see if a similar feature request already exists. 16 | options: 17 | - label: > 18 | I have searched the YOLOv8 [issues](https://github.com/ultralytics/ultralytics/issues) and found no similar feature requests. 19 | required: true 20 | 21 | - type: textarea 22 | attributes: 23 | label: Description 24 | description: A short description of your feature. 25 | placeholder: | 26 | What new feature would you like to see in YOLOv8? 27 | validations: 28 | required: true 29 | 30 | - type: textarea 31 | attributes: 32 | label: Use case 33 | description: | 34 | Describe the use case of your feature request. It will help us understand and prioritize the feature request. 35 | placeholder: | 36 | How would this feature be used, and who would use it? 37 | 38 | - type: textarea 39 | attributes: 40 | label: Additional 41 | description: Anything else you would like to share? 42 | 43 | - type: checkboxes 44 | attributes: 45 | label: Are you willing to submit a PR? 46 | description: > 47 | (Optional) We encourage you to submit a [Pull Request](https://github.com/ultralytics/ultralytics/pulls) (PR) to help improve YOLOv8 for everyone, especially if you have a good understanding of how to implement a fix or feature. 48 | See the YOLOv8 [Contributing Guide](https://docs.ultralytics.com/help/contributing) to get started. 49 | options: 50 | - label: Yes I'd like to help by submitting a PR! 51 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/nn/modules/block.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore Ultralytics YOLO neural network modules, Proto to BottleneckCSP. Detailed explanation of each module with easy-to-follow code examples. 3 | keywords: YOLO, Ultralytics, neural network, nn.modules.block, Proto, HGBlock, SPPF, C2, C3, RepC3, C3Ghost, Bottleneck, BottleneckCSP 4 | --- 5 | 6 | # Reference for `ultralytics/nn/modules/block.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/nn/modules/block.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/nn/modules/block.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.nn.modules.block.DFL 14 |

15 | 16 | --- 17 | ## ::: ultralytics.nn.modules.block.Proto 18 |

19 | 20 | --- 21 | ## ::: ultralytics.nn.modules.block.HGStem 22 |

23 | 24 | --- 25 | ## ::: ultralytics.nn.modules.block.HGBlock 26 |

27 | 28 | --- 29 | ## ::: ultralytics.nn.modules.block.SPP 30 |

31 | 32 | --- 33 | ## ::: ultralytics.nn.modules.block.SPPF 34 |

35 | 36 | --- 37 | ## ::: ultralytics.nn.modules.block.C1 38 |

39 | 40 | --- 41 | ## ::: ultralytics.nn.modules.block.C2 42 |

43 | 44 | --- 45 | ## ::: ultralytics.nn.modules.block.C2f 46 |

47 | 48 | --- 49 | ## ::: ultralytics.nn.modules.block.C3 50 |

51 | 52 | --- 53 | ## ::: ultralytics.nn.modules.block.C3x 54 |

55 | 56 | --- 57 | ## ::: ultralytics.nn.modules.block.RepC3 58 |

59 | 60 | --- 61 | ## ::: ultralytics.nn.modules.block.C3TR 62 |

63 | 64 | --- 65 | ## ::: ultralytics.nn.modules.block.C3Ghost 66 |

67 | 68 | --- 69 | ## ::: ultralytics.nn.modules.block.GhostBottleneck 70 |

71 | 72 | --- 73 | ## ::: ultralytics.nn.modules.block.Bottleneck 74 |

75 | 76 | --- 77 | ## ::: ultralytics.nn.modules.block.BottleneckCSP 78 |

79 | -------------------------------------------------------------------------------- /ultralytics/examples/YOLOv8-CPP-Inference/README.md: -------------------------------------------------------------------------------- 1 | # YOLOv8/YOLOv5 Inference C++ 2 | 3 | This example demonstrates how to perform inference using YOLOv8 and YOLOv5 models in C++ with OpenCV's DNN API. 4 | 5 | ## Usage 6 | 7 | ```bash 8 | git clone ultralytics 9 | cd ultralytics 10 | pip install . 11 | cd examples/YOLOv8-CPP-Inference 12 | 13 | # Add a **yolov8\_.onnx** and/or **yolov5\_.onnx** model(s) to the ultralytics folder. 14 | # Edit the **main.cpp** to change the **projectBasePath** to match your user. 15 | 16 | # Note that by default the CMake file will try and import the CUDA library to be used with the OpenCVs dnn (cuDNN) GPU Inference. 17 | # If your OpenCV build does not use CUDA/cuDNN you can remove that import call and run the example on CPU. 18 | 19 | mkdir build 20 | cd build 21 | cmake .. 22 | make 23 | ./Yolov8CPPInference 24 | ``` 25 | 26 | ## Exporting YOLOv8 and YOLOv5 Models 27 | 28 | To export YOLOv8 models: 29 | 30 | ```commandline 31 | yolo export model=yolov8s.pt imgsz=480,640 format=onnx opset=12 32 | ``` 33 | 34 | To export YOLOv5 models: 35 | 36 | ```commandline 37 | python3 export.py --weights yolov5s.pt --img 480 640 --include onnx --opset 12 38 | ``` 39 | 40 | yolov8s.onnx: 41 | 42 | ![image](https://user-images.githubusercontent.com/40023722/217356132-a4cecf2e-2729-4acb-b80a-6559022d7707.png) 43 | 44 | yolov5s.onnx: 45 | 46 | ![image](https://user-images.githubusercontent.com/40023722/217357005-07464492-d1da-42e3-98a7-fc753f87d5e6.png) 47 | 48 | This repository utilizes OpenCV's DNN API to run ONNX exported models of YOLOv5 and YOLOv8. In theory, it should work for YOLOv6 and YOLOv7 as well, but they have not been tested. Note that the example networks are exported with rectangular (640x480) resolutions, but any exported resolution will work. You may want to use the letterbox approach for square images, depending on your use case. 49 | 50 | The **main** branch version uses Qt as a GUI wrapper. The primary focus here is the **Inference** class file, which demonstrates how to transpose YOLOv8 models to work as YOLOv5 models. 51 | -------------------------------------------------------------------------------- /ultralytics/docs/SECURITY.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Discover how Ultralytics ensures the safety of user data and systems. Check out the measures we have implemented, including Snyk and GitHub CodeQL Scanning. 3 | keywords: Ultralytics, Security Policy, data security, open-source projects, Snyk scanning, CodeQL scanning, vulnerability detection, threat prevention 4 | --- 5 | 6 | # Security Policy 7 | 8 | At [Ultralytics](https://ultralytics.com), the security of our users' data and systems is of utmost importance. To ensure the safety and security of our [open-source projects](https://github.com/ultralytics), we have implemented several measures to detect and prevent security vulnerabilities. 9 | 10 | ## Snyk Scanning 11 | 12 | We use [Snyk](https://snyk.io/advisor/python/ultralytics) to regularly scan all Ultralytics repositories for vulnerabilities and security issues. Our goal is to identify and remediate any potential threats as soon as possible, to minimize any risks to our users. 13 | 14 | [![ultralytics](https://snyk.io/advisor/python/ultralytics/badge.svg)](https://snyk.io/advisor/python/ultralytics) 15 | 16 | ## GitHub CodeQL Scanning 17 | 18 | In addition to our Snyk scans, we also use GitHub's [CodeQL](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/about-code-scanning-with-codeql) scans to proactively identify and address security vulnerabilities across all Ultralytics repositories. 19 | 20 | [![CodeQL](https://github.com/ultralytics/ultralytics/actions/workflows/codeql.yaml/badge.svg)](https://github.com/ultralytics/ultralytics/actions/workflows/codeql.yaml) 21 | 22 | ## Reporting Security Issues 23 | 24 | If you suspect or discover a security vulnerability in any of our repositories, please let us know immediately. You can reach out to us directly via our [contact form](https://ultralytics.com/contact) or via [security@ultralytics.com](mailto:security@ultralytics.com). Our security team will investigate and respond as soon as possible. 25 | 26 | We appreciate your help in keeping all Ultralytics open-source projects secure and safe for everyone. 27 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/cfg/models/v8/yolov8-p6.yaml: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | # YOLOv8 object detection model with P3-P6 outputs. For Usage examples see https://docs.ultralytics.com/tasks/detect 3 | 4 | # Parameters 5 | nc: 80 # number of classes 6 | scales: # model compound scaling constants, i.e. 'model=yolov8n-p6.yaml' will call yolov8-p6.yaml with scale 'n' 7 | # [depth, width, max_channels] 8 | n: [0.33, 0.25, 1024] 9 | s: [0.33, 0.50, 1024] 10 | m: [0.67, 0.75, 768] 11 | l: [1.00, 1.00, 512] 12 | x: [1.00, 1.25, 512] 13 | 14 | # YOLOv8.0x6 backbone 15 | backbone: 16 | # [from, repeats, module, args] 17 | - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2 18 | - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4 19 | - [-1, 3, C2f, [128, True]] 20 | - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8 21 | - [-1, 6, C2f, [256, True]] 22 | - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16 23 | - [-1, 6, C2f, [512, True]] 24 | - [-1, 1, Conv, [768, 3, 2]] # 7-P5/32 25 | - [-1, 3, C2f, [768, True]] 26 | - [-1, 1, Conv, [1024, 3, 2]] # 9-P6/64 27 | - [-1, 3, C2f, [1024, True]] 28 | - [-1, 1, SPPF, [1024, 5]] # 11 29 | 30 | # YOLOv8.0x6 head 31 | head: 32 | - [-1, 1, nn.Upsample, [None, 2, 'nearest']] 33 | - [[-1, 8], 1, Concat, [1]] # cat backbone P5 34 | - [-1, 3, C2, [768, False]] # 14 35 | 36 | - [-1, 1, nn.Upsample, [None, 2, 'nearest']] 37 | - [[-1, 6], 1, Concat, [1]] # cat backbone P4 38 | - [-1, 3, C2, [512, False]] # 17 39 | 40 | - [-1, 1, nn.Upsample, [None, 2, 'nearest']] 41 | - [[-1, 4], 1, Concat, [1]] # cat backbone P3 42 | - [-1, 3, C2, [256, False]] # 20 (P3/8-small) 43 | 44 | - [-1, 1, Conv, [256, 3, 2]] 45 | - [[-1, 17], 1, Concat, [1]] # cat head P4 46 | - [-1, 3, C2, [512, False]] # 23 (P4/16-medium) 47 | 48 | - [-1, 1, Conv, [512, 3, 2]] 49 | - [[-1, 14], 1, Concat, [1]] # cat head P5 50 | - [-1, 3, C2, [768, False]] # 26 (P5/32-large) 51 | 52 | - [-1, 1, Conv, [768, 3, 2]] 53 | - [[-1, 11], 1, Concat, [1]] # cat head P6 54 | - [-1, 3, C2, [1024, False]] # 29 (P6/64-xlarge) 55 | 56 | - [[20, 23, 26, 29], 1, Detect, [nc]] # Detect(P3, P4, P5, P6) 57 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/cfg/models/v8/yolov8.yaml: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | # YOLOv8 object detection model with P3-P5 outputs. For Usage examples see https://docs.ultralytics.com/tasks/detect 3 | 4 | # Parameters 5 | nc: 80 # number of classes 6 | scales: # model compound scaling constants, i.e. 'model=yolov8n.yaml' will call yolov8.yaml with scale 'n' 7 | # [depth, width, max_channels] 8 | n: [0.33, 0.25, 1024] # YOLOv8n summary: 225 layers, 3157200 parameters, 3157184 gradients, 8.9 GFLOPs 9 | s: [0.33, 0.50, 1024] # YOLOv8s summary: 225 layers, 11166560 parameters, 11166544 gradients, 28.8 GFLOPs 10 | m: [0.67, 0.75, 768] # YOLOv8m summary: 295 layers, 25902640 parameters, 25902624 gradients, 79.3 GFLOPs 11 | l: [1.00, 1.00, 512] # YOLOv8l summary: 365 layers, 43691520 parameters, 43691504 gradients, 165.7 GFLOPs 12 | x: [1.00, 1.25, 512] # YOLOv8x summary: 365 layers, 68229648 parameters, 68229632 gradients, 258.5 GFLOPs 13 | 14 | # YOLOv8.0n backbone 15 | backbone: 16 | # [from, repeats, module, args] 17 | - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2 18 | - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4 19 | - [-1, 3, C2f, [128, True]] 20 | - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8 21 | - [-1, 6, C2f, [256, True]] 22 | - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16 23 | - [-1, 6, C2f, [512, True]] 24 | - [-1, 1, Conv, [1024, 3, 2]] # 7-P5/32 25 | - [-1, 3, C2f, [1024, True]] 26 | - [-1, 1, SPPF, [1024, 5]] # 9 27 | 28 | # YOLOv8.0n head 29 | head: 30 | - [-1, 1, nn.Upsample, [None, 2, 'nearest']] 31 | - [[-1, 6], 1, Concat, [1]] # cat backbone P4 32 | - [-1, 3, C2f, [512]] # 12 33 | 34 | - [-1, 1, nn.Upsample, [None, 2, 'nearest']] 35 | - [[-1, 4], 1, Concat, [1]] # cat backbone P3 36 | - [-1, 3, C2f, [256]] # 15 (P3/8-small) 37 | 38 | - [-1, 1, Conv, [256, 3, 2]] 39 | - [[-1, 12], 1, Concat, [1]] # cat head P4 40 | - [-1, 3, C2f, [512]] # 18 (P4/16-medium) 41 | 42 | - [-1, 1, Conv, [512, 3, 2]] 43 | - [[-1, 9], 1, Concat, [1]] # cat head P5 44 | - [-1, 3, C2f, [1024]] # 21 (P5/32-large) 45 | 46 | - [[15, 18, 21], 1, Detect, [nc]] # Detect(P3, P4, P5) 47 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/utils/metrics.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Explore Ultralytics YOLO metrics tools - from confusion matrix, detection metrics, pose metrics to box IOU. Learn how to compute and plot precision-recall curves. 3 | keywords: Ultralytics, YOLO, YOLOv3, YOLOv4, metrics, confusion matrix, detection metrics, pose metrics, box IOU, mask IOU, plot precision-recall curves, compute average precision 4 | --- 5 | 6 | # Reference for `ultralytics/utils/metrics.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/metrics.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/metrics.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.utils.metrics.ConfusionMatrix 14 |

15 | 16 | --- 17 | ## ::: ultralytics.utils.metrics.Metric 18 |

19 | 20 | --- 21 | ## ::: ultralytics.utils.metrics.DetMetrics 22 |

23 | 24 | --- 25 | ## ::: ultralytics.utils.metrics.SegmentMetrics 26 |

27 | 28 | --- 29 | ## ::: ultralytics.utils.metrics.PoseMetrics 30 |

31 | 32 | --- 33 | ## ::: ultralytics.utils.metrics.ClassifyMetrics 34 |

35 | 36 | --- 37 | ## ::: ultralytics.utils.metrics.bbox_ioa 38 |

39 | 40 | --- 41 | ## ::: ultralytics.utils.metrics.box_iou 42 |

43 | 44 | --- 45 | ## ::: ultralytics.utils.metrics.bbox_iou 46 |

47 | 48 | --- 49 | ## ::: ultralytics.utils.metrics.mask_iou 50 |

51 | 52 | --- 53 | ## ::: ultralytics.utils.metrics.kpt_iou 54 |

55 | 56 | --- 57 | ## ::: ultralytics.utils.metrics.smooth_BCE 58 |

59 | 60 | --- 61 | ## ::: ultralytics.utils.metrics.smooth 62 |

63 | 64 | --- 65 | ## ::: ultralytics.utils.metrics.plot_pr_curve 66 |

67 | 68 | --- 69 | ## ::: ultralytics.utils.metrics.plot_mc_curve 70 |

71 | 72 | --- 73 | ## ::: ultralytics.utils.metrics.compute_ap 74 |

75 | 76 | --- 77 | ## ::: ultralytics.utils.metrics.ap_per_class 78 |

79 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/cfg/models/v8/yolov8-seg-p6.yaml: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | # YOLOv8-seg-p6 instance segmentation model. For Usage examples see https://docs.ultralytics.com/tasks/segment 3 | 4 | # Parameters 5 | nc: 80 # number of classes 6 | scales: # model compound scaling constants, i.e. 'model=yolov8n-seg-p6.yaml' will call yolov8-seg-p6.yaml with scale 'n' 7 | # [depth, width, max_channels] 8 | n: [0.33, 0.25, 1024] 9 | s: [0.33, 0.50, 1024] 10 | m: [0.67, 0.75, 768] 11 | l: [1.00, 1.00, 512] 12 | x: [1.00, 1.25, 512] 13 | 14 | # YOLOv8.0x6 backbone 15 | backbone: 16 | # [from, repeats, module, args] 17 | - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2 18 | - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4 19 | - [-1, 3, C2f, [128, True]] 20 | - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8 21 | - [-1, 6, C2f, [256, True]] 22 | - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16 23 | - [-1, 6, C2f, [512, True]] 24 | - [-1, 1, Conv, [768, 3, 2]] # 7-P5/32 25 | - [-1, 3, C2f, [768, True]] 26 | - [-1, 1, Conv, [1024, 3, 2]] # 9-P6/64 27 | - [-1, 3, C2f, [1024, True]] 28 | - [-1, 1, SPPF, [1024, 5]] # 11 29 | 30 | # YOLOv8.0x6 head 31 | head: 32 | - [-1, 1, nn.Upsample, [None, 2, 'nearest']] 33 | - [[-1, 8], 1, Concat, [1]] # cat backbone P5 34 | - [-1, 3, C2, [768, False]] # 14 35 | 36 | - [-1, 1, nn.Upsample, [None, 2, 'nearest']] 37 | - [[-1, 6], 1, Concat, [1]] # cat backbone P4 38 | - [-1, 3, C2, [512, False]] # 17 39 | 40 | - [-1, 1, nn.Upsample, [None, 2, 'nearest']] 41 | - [[-1, 4], 1, Concat, [1]] # cat backbone P3 42 | - [-1, 3, C2, [256, False]] # 20 (P3/8-small) 43 | 44 | - [-1, 1, Conv, [256, 3, 2]] 45 | - [[-1, 17], 1, Concat, [1]] # cat head P4 46 | - [-1, 3, C2, [512, False]] # 23 (P4/16-medium) 47 | 48 | - [-1, 1, Conv, [512, 3, 2]] 49 | - [[-1, 14], 1, Concat, [1]] # cat head P5 50 | - [-1, 3, C2, [768, False]] # 26 (P5/32-large) 51 | 52 | - [-1, 1, Conv, [768, 3, 2]] 53 | - [[-1, 11], 1, Concat, [1]] # cat head P6 54 | - [-1, 3, C2, [1024, False]] # 29 (P6/64-xlarge) 55 | 56 | - [[20, 23, 26, 29], 1, Segment, [nc, 32, 256]] # Pose(P3, P4, P5, P6) 57 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/cfg/models/v8/yolov8-rtdetr.yaml: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | # YOLOv8 object detection model with P3-P5 outputs. For Usage examples see https://docs.ultralytics.com/tasks/detect 3 | 4 | # Parameters 5 | nc: 80 # number of classes 6 | scales: # model compound scaling constants, i.e. 'model=yolov8n.yaml' will call yolov8.yaml with scale 'n' 7 | # [depth, width, max_channels] 8 | n: [0.33, 0.25, 1024] # YOLOv8n summary: 225 layers, 3157200 parameters, 3157184 gradients, 8.9 GFLOPs 9 | s: [0.33, 0.50, 1024] # YOLOv8s summary: 225 layers, 11166560 parameters, 11166544 gradients, 28.8 GFLOPs 10 | m: [0.67, 0.75, 768] # YOLOv8m summary: 295 layers, 25902640 parameters, 25902624 gradients, 79.3 GFLOPs 11 | l: [1.00, 1.00, 512] # YOLOv8l summary: 365 layers, 43691520 parameters, 43691504 gradients, 165.7 GFLOPs 12 | x: [1.00, 1.25, 512] # YOLOv8x summary: 365 layers, 68229648 parameters, 68229632 gradients, 258.5 GFLOPs 13 | 14 | # YOLOv8.0n backbone 15 | backbone: 16 | # [from, repeats, module, args] 17 | - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2 18 | - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4 19 | - [-1, 3, C2f, [128, True]] 20 | - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8 21 | - [-1, 6, C2f, [256, True]] 22 | - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16 23 | - [-1, 6, C2f, [512, True]] 24 | - [-1, 1, Conv, [1024, 3, 2]] # 7-P5/32 25 | - [-1, 3, C2f, [1024, True]] 26 | - [-1, 1, SPPF, [1024, 5]] # 9 27 | 28 | # YOLOv8.0n head 29 | head: 30 | - [-1, 1, nn.Upsample, [None, 2, 'nearest']] 31 | - [[-1, 6], 1, Concat, [1]] # cat backbone P4 32 | - [-1, 3, C2f, [512]] # 12 33 | 34 | - [-1, 1, nn.Upsample, [None, 2, 'nearest']] 35 | - [[-1, 4], 1, Concat, [1]] # cat backbone P3 36 | - [-1, 3, C2f, [256]] # 15 (P3/8-small) 37 | 38 | - [-1, 1, Conv, [256, 3, 2]] 39 | - [[-1, 12], 1, Concat, [1]] # cat head P4 40 | - [-1, 3, C2f, [512]] # 18 (P4/16-medium) 41 | 42 | - [-1, 1, Conv, [512, 3, 2]] 43 | - [[-1, 9], 1, Concat, [1]] # cat head P5 44 | - [-1, 3, C2f, [1024]] # 21 (P5/32-large) 45 | 46 | - [[15, 18, 21], 1, RTDETRDecoder, [nc]] # Detect(P3, P4, P5) 47 | -------------------------------------------------------------------------------- /ultralytics/examples/YOLOv8-ONNXRuntime-CPP/inference.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define RET_OK nullptr 4 | 5 | #ifdef _WIN32 6 | #include 7 | #include 8 | #include 9 | #endif 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "onnxruntime_cxx_api.h" 16 | 17 | #ifdef USE_CUDA 18 | #include 19 | #endif 20 | 21 | 22 | enum MODEL_TYPE { 23 | //FLOAT32 MODEL 24 | YOLO_ORIGIN_V5 = 0, 25 | YOLO_ORIGIN_V8 = 1,//only support v8 detector currently 26 | YOLO_POSE_V8 = 2, 27 | YOLO_CLS_V8 = 3, 28 | YOLO_ORIGIN_V8_HALF = 4, 29 | YOLO_POSE_V8_HALF = 5, 30 | YOLO_CLS_V8_HALF = 6 31 | }; 32 | 33 | 34 | typedef struct _DCSP_INIT_PARAM { 35 | std::string ModelPath; 36 | MODEL_TYPE ModelType = YOLO_ORIGIN_V8; 37 | std::vector imgSize = {640, 640}; 38 | float RectConfidenceThreshold = 0.6; 39 | float iouThreshold = 0.5; 40 | bool CudaEnable = false; 41 | int LogSeverityLevel = 3; 42 | int IntraOpNumThreads = 1; 43 | } DCSP_INIT_PARAM; 44 | 45 | 46 | typedef struct _DCSP_RESULT { 47 | int classId; 48 | float confidence; 49 | cv::Rect box; 50 | } DCSP_RESULT; 51 | 52 | 53 | class DCSP_CORE { 54 | public: 55 | DCSP_CORE(); 56 | 57 | ~DCSP_CORE(); 58 | 59 | public: 60 | char *CreateSession(DCSP_INIT_PARAM &iParams); 61 | 62 | char *RunSession(cv::Mat &iImg, std::vector &oResult); 63 | 64 | char *WarmUpSession(); 65 | 66 | template 67 | char *TensorProcess(clock_t &starttime_1, cv::Mat &iImg, N &blob, std::vector &inputNodeDims, 68 | std::vector &oResult); 69 | 70 | std::vector classes{}; 71 | 72 | private: 73 | Ort::Env env; 74 | Ort::Session *session; 75 | bool cudaEnable; 76 | Ort::RunOptions options; 77 | std::vector inputNodeNames; 78 | std::vector outputNodeNames; 79 | 80 | MODEL_TYPE modelType; 81 | std::vector imgSize; 82 | float rectConfidenceThreshold; 83 | float iouThreshold; 84 | }; 85 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/cfg/models/rt-detr/rtdetr-l.yaml: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | # RT-DETR-l object detection model with P3-P5 outputs. For details see https://docs.ultralytics.com/models/rtdetr 3 | 4 | # Parameters 5 | nc: 80 # number of classes 6 | scales: # model compound scaling constants, i.e. 'model=yolov8n-cls.yaml' will call yolov8-cls.yaml with scale 'n' 7 | # [depth, width, max_channels] 8 | l: [1.00, 1.00, 1024] 9 | 10 | backbone: 11 | # [from, repeats, module, args] 12 | - [-1, 1, HGStem, [32, 48]] # 0-P2/4 13 | - [-1, 6, HGBlock, [48, 128, 3]] # stage 1 14 | 15 | - [-1, 1, DWConv, [128, 3, 2, 1, False]] # 2-P3/8 16 | - [-1, 6, HGBlock, [96, 512, 3]] # stage 2 17 | 18 | - [-1, 1, DWConv, [512, 3, 2, 1, False]] # 4-P3/16 19 | - [-1, 6, HGBlock, [192, 1024, 5, True, False]] # cm, c2, k, light, shortcut 20 | - [-1, 6, HGBlock, [192, 1024, 5, True, True]] 21 | - [-1, 6, HGBlock, [192, 1024, 5, True, True]] # stage 3 22 | 23 | - [-1, 1, DWConv, [1024, 3, 2, 1, False]] # 8-P4/32 24 | - [-1, 6, HGBlock, [384, 2048, 5, True, False]] # stage 4 25 | 26 | head: 27 | - [-1, 1, Conv, [256, 1, 1, None, 1, 1, False]] # 10 input_proj.2 28 | - [-1, 1, AIFI, [1024, 8]] 29 | - [-1, 1, Conv, [256, 1, 1]] # 12, Y5, lateral_convs.0 30 | 31 | - [-1, 1, nn.Upsample, [None, 2, 'nearest']] 32 | - [7, 1, Conv, [256, 1, 1, None, 1, 1, False]] # 14 input_proj.1 33 | - [[-2, -1], 1, Concat, [1]] 34 | - [-1, 3, RepC3, [256]] # 16, fpn_blocks.0 35 | - [-1, 1, Conv, [256, 1, 1]] # 17, Y4, lateral_convs.1 36 | 37 | - [-1, 1, nn.Upsample, [None, 2, 'nearest']] 38 | - [3, 1, Conv, [256, 1, 1, None, 1, 1, False]] # 19 input_proj.0 39 | - [[-2, -1], 1, Concat, [1]] # cat backbone P4 40 | - [-1, 3, RepC3, [256]] # X3 (21), fpn_blocks.1 41 | 42 | - [-1, 1, Conv, [256, 3, 2]] # 22, downsample_convs.0 43 | - [[-1, 17], 1, Concat, [1]] # cat Y4 44 | - [-1, 3, RepC3, [256]] # F4 (24), pan_blocks.0 45 | 46 | - [-1, 1, Conv, [256, 3, 2]] # 25, downsample_convs.1 47 | - [[-1, 12], 1, Concat, [1]] # cat Y5 48 | - [-1, 3, RepC3, [256]] # F5 (27), pan_blocks.1 49 | 50 | - [[21, 24, 27], 1, RTDETRDecoder, [nc]] # Detect(P3, P4, P5) 51 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/cfg/models/v5/yolov5-p6.yaml: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | # YOLOv5 object detection model with P3-P6 outputs. For details see https://docs.ultralytics.com/models/yolov5 3 | 4 | # Parameters 5 | nc: 80 # number of classes 6 | scales: # model compound scaling constants, i.e. 'model=yolov5n-p6.yaml' will call yolov5-p6.yaml with scale 'n' 7 | # [depth, width, max_channels] 8 | n: [0.33, 0.25, 1024] 9 | s: [0.33, 0.50, 1024] 10 | m: [0.67, 0.75, 1024] 11 | l: [1.00, 1.00, 1024] 12 | x: [1.33, 1.25, 1024] 13 | 14 | # YOLOv5 v6.0 backbone 15 | backbone: 16 | # [from, number, module, args] 17 | [[-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2 18 | [-1, 1, Conv, [128, 3, 2]], # 1-P2/4 19 | [-1, 3, C3, [128]], 20 | [-1, 1, Conv, [256, 3, 2]], # 3-P3/8 21 | [-1, 6, C3, [256]], 22 | [-1, 1, Conv, [512, 3, 2]], # 5-P4/16 23 | [-1, 9, C3, [512]], 24 | [-1, 1, Conv, [768, 3, 2]], # 7-P5/32 25 | [-1, 3, C3, [768]], 26 | [-1, 1, Conv, [1024, 3, 2]], # 9-P6/64 27 | [-1, 3, C3, [1024]], 28 | [-1, 1, SPPF, [1024, 5]], # 11 29 | ] 30 | 31 | # YOLOv5 v6.0 head 32 | head: 33 | [[-1, 1, Conv, [768, 1, 1]], 34 | [-1, 1, nn.Upsample, [None, 2, 'nearest']], 35 | [[-1, 8], 1, Concat, [1]], # cat backbone P5 36 | [-1, 3, C3, [768, False]], # 15 37 | 38 | [-1, 1, Conv, [512, 1, 1]], 39 | [-1, 1, nn.Upsample, [None, 2, 'nearest']], 40 | [[-1, 6], 1, Concat, [1]], # cat backbone P4 41 | [-1, 3, C3, [512, False]], # 19 42 | 43 | [-1, 1, Conv, [256, 1, 1]], 44 | [-1, 1, nn.Upsample, [None, 2, 'nearest']], 45 | [[-1, 4], 1, Concat, [1]], # cat backbone P3 46 | [-1, 3, C3, [256, False]], # 23 (P3/8-small) 47 | 48 | [-1, 1, Conv, [256, 3, 2]], 49 | [[-1, 20], 1, Concat, [1]], # cat head P4 50 | [-1, 3, C3, [512, False]], # 26 (P4/16-medium) 51 | 52 | [-1, 1, Conv, [512, 3, 2]], 53 | [[-1, 16], 1, Concat, [1]], # cat head P5 54 | [-1, 3, C3, [768, False]], # 29 (P5/32-large) 55 | 56 | [-1, 1, Conv, [768, 3, 2]], 57 | [[-1, 12], 1, Concat, [1]], # cat head P6 58 | [-1, 3, C3, [1024, False]], # 32 (P6/64-xlarge) 59 | 60 | [[23, 26, 29, 32], 1, Detect, [nc]], # Detect(P3, P4, P5, P6) 61 | ] 62 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/cfg/models/v8/yolov8-pose-p6.yaml: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | # YOLOv8-pose-p6 keypoints/pose estimation model. For Usage examples see https://docs.ultralytics.com/tasks/pose 3 | 4 | # Parameters 5 | nc: 1 # number of classes 6 | kpt_shape: [17, 3] # number of keypoints, number of dims (2 for x,y or 3 for x,y,visible) 7 | scales: # model compound scaling constants, i.e. 'model=yolov8n-p6.yaml' will call yolov8-p6.yaml with scale 'n' 8 | # [depth, width, max_channels] 9 | n: [0.33, 0.25, 1024] 10 | s: [0.33, 0.50, 1024] 11 | m: [0.67, 0.75, 768] 12 | l: [1.00, 1.00, 512] 13 | x: [1.00, 1.25, 512] 14 | 15 | # YOLOv8.0x6 backbone 16 | backbone: 17 | # [from, repeats, module, args] 18 | - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2 19 | - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4 20 | - [-1, 3, C2f, [128, True]] 21 | - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8 22 | - [-1, 6, C2f, [256, True]] 23 | - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16 24 | - [-1, 6, C2f, [512, True]] 25 | - [-1, 1, Conv, [768, 3, 2]] # 7-P5/32 26 | - [-1, 3, C2f, [768, True]] 27 | - [-1, 1, Conv, [1024, 3, 2]] # 9-P6/64 28 | - [-1, 3, C2f, [1024, True]] 29 | - [-1, 1, SPPF, [1024, 5]] # 11 30 | 31 | # YOLOv8.0x6 head 32 | head: 33 | - [-1, 1, nn.Upsample, [None, 2, 'nearest']] 34 | - [[-1, 8], 1, Concat, [1]] # cat backbone P5 35 | - [-1, 3, C2, [768, False]] # 14 36 | 37 | - [-1, 1, nn.Upsample, [None, 2, 'nearest']] 38 | - [[-1, 6], 1, Concat, [1]] # cat backbone P4 39 | - [-1, 3, C2, [512, False]] # 17 40 | 41 | - [-1, 1, nn.Upsample, [None, 2, 'nearest']] 42 | - [[-1, 4], 1, Concat, [1]] # cat backbone P3 43 | - [-1, 3, C2, [256, False]] # 20 (P3/8-small) 44 | 45 | - [-1, 1, Conv, [256, 3, 2]] 46 | - [[-1, 17], 1, Concat, [1]] # cat head P4 47 | - [-1, 3, C2, [512, False]] # 23 (P4/16-medium) 48 | 49 | - [-1, 1, Conv, [512, 3, 2]] 50 | - [[-1, 14], 1, Concat, [1]] # cat head P5 51 | - [-1, 3, C2, [768, False]] # 26 (P5/32-large) 52 | 53 | - [-1, 1, Conv, [768, 3, 2]] 54 | - [[-1, 11], 1, Concat, [1]] # cat head P6 55 | - [-1, 3, C2, [1024, False]] # 29 (P6/64-xlarge) 56 | 57 | - [[20, 23, 26, 29], 1, Pose, [nc, kpt_shape]] # Pose(P3, P4, P5, P6) 58 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/models/yolo/classify/predict.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | import torch 4 | 5 | from ultralytics.engine.predictor import BasePredictor 6 | from ultralytics.engine.results import Results 7 | from ultralytics.utils import DEFAULT_CFG, ops 8 | 9 | 10 | class ClassificationPredictor(BasePredictor): 11 | """ 12 | A class extending the BasePredictor class for prediction based on a classification model. 13 | 14 | Notes: 15 | - Torchvision classification models can also be passed to the 'model' argument, i.e. model='resnet18'. 16 | 17 | Example: 18 | ```python 19 | from ultralytics.utils import ASSETS 20 | from ultralytics.models.yolo.classify import ClassificationPredictor 21 | 22 | args = dict(model='yolov8n-cls.pt', source=ASSETS) 23 | predictor = ClassificationPredictor(overrides=args) 24 | predictor.predict_cli() 25 | ``` 26 | """ 27 | 28 | def __init__(self, cfg=DEFAULT_CFG, overrides=None, _callbacks=None): 29 | """Initializes ClassificationPredictor setting the task to 'classify'.""" 30 | super().__init__(cfg, overrides, _callbacks) 31 | self.args.task = 'classify' 32 | 33 | def preprocess(self, img): 34 | """Converts input image to model-compatible data type.""" 35 | if not isinstance(img, torch.Tensor): 36 | img = torch.stack([self.transforms(im) for im in img], dim=0) 37 | img = (img if isinstance(img, torch.Tensor) else torch.from_numpy(img)).to(self.model.device) 38 | return img.half() if self.model.fp16 else img.float() # uint8 to fp16/32 39 | 40 | def postprocess(self, preds, img, orig_imgs): 41 | """Post-processes predictions to return Results objects.""" 42 | if not isinstance(orig_imgs, list): # input images are a torch.Tensor, not a list 43 | orig_imgs = ops.convert_torch2numpy_batch(orig_imgs) 44 | 45 | results = [] 46 | for i, pred in enumerate(preds): 47 | orig_img = orig_imgs[i] 48 | img_path = self.batch[0][i] 49 | results.append(Results(orig_img, path=img_path, names=self.model.names, probs=pred)) 50 | return results 51 | -------------------------------------------------------------------------------- /ultralytics/docker/Dockerfile-arm64: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | # Builds ultralytics/ultralytics:latest-arm64 image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics 3 | # Image is aarch64-compatible for Apple M1 and other ARM architectures i.e. Jetson Nano and Raspberry Pi 4 | 5 | # Start FROM Ubuntu image https://hub.docker.com/_/ubuntu 6 | FROM arm64v8/ubuntu:22.04 7 | 8 | # Downloads to user config dir 9 | ADD https://ultralytics.com/assets/Arial.ttf https://ultralytics.com/assets/Arial.Unicode.ttf /root/.config/Ultralytics/ 10 | 11 | # Install linux packages 12 | # g++ required to build 'tflite_support' and 'lap' packages, libusb-1.0-0 required for 'tflite_support' package 13 | RUN apt update \ 14 | && apt install --no-install-recommends -y python3-pip git zip curl htop gcc libgl1-mesa-glx libglib2.0-0 libpython3-dev gnupg g++ libusb-1.0-0 15 | # RUN alias python=python3 16 | 17 | # Create working directory 18 | WORKDIR /usr/src/ultralytics 19 | 20 | # Copy contents 21 | # COPY . /usr/src/ultralytics # git permission issues inside container 22 | RUN git clone https://github.com/ultralytics/ultralytics -b main /usr/src/ultralytics 23 | ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n.pt /usr/src/ultralytics/ 24 | 25 | # Install pip packages 26 | RUN python3 -m pip install --upgrade pip wheel 27 | RUN pip install --no-cache -e . 28 | 29 | # Creates a symbolic link to make 'python' point to 'python3' 30 | RUN ln -sf /usr/bin/python3 /usr/bin/python 31 | 32 | 33 | # Usage Examples ------------------------------------------------------------------------------------------------------- 34 | 35 | # Build and Push 36 | # t=ultralytics/ultralytics:latest-arm64 && sudo docker build --platform linux/arm64 -f docker/Dockerfile-arm64 -t $t . && sudo docker push $t 37 | 38 | # Run 39 | # t=ultralytics/ultralytics:latest-arm64 && sudo docker run -it --ipc=host $t 40 | 41 | # Pull and Run 42 | # t=ultralytics/ultralytics:latest-arm64 && sudo docker pull $t && sudo docker run -it --ipc=host $t 43 | 44 | # Pull and Run with local volume mounted 45 | # t=ultralytics/ultralytics:latest-arm64 && sudo docker pull $t && sudo docker run -it --ipc=host -v "$(pwd)"/datasets:/usr/src/datasets $t 46 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/models/sam/model.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | """SAM model interface.""" 3 | 4 | from pathlib import Path 5 | 6 | from ultralytics.engine.model import Model 7 | from ultralytics.utils.torch_utils import model_info 8 | 9 | from .build import build_sam 10 | from .predict import Predictor 11 | 12 | 13 | class SAM(Model): 14 | """SAM model interface.""" 15 | 16 | def __init__(self, model='sam_b.pt') -> None: 17 | """Initializes the SAM model instance with the specified pre-trained model file.""" 18 | if model and Path(model).suffix not in ('.pt', '.pth'): 19 | raise NotImplementedError('SAM prediction requires pre-trained *.pt or *.pth model.') 20 | super().__init__(model=model, task='segment') 21 | 22 | def _load(self, weights: str, task=None): 23 | """Loads the provided weights into the SAM model.""" 24 | self.model = build_sam(weights) 25 | 26 | def predict(self, source, stream=False, bboxes=None, points=None, labels=None, **kwargs): 27 | """Predicts and returns segmentation masks for given image or video source.""" 28 | overrides = dict(conf=0.25, task='segment', mode='predict', imgsz=1024) 29 | kwargs.update(overrides) 30 | prompts = dict(bboxes=bboxes, points=points, labels=labels) 31 | return super().predict(source, stream, prompts=prompts, **kwargs) 32 | 33 | def __call__(self, source=None, stream=False, bboxes=None, points=None, labels=None, **kwargs): 34 | """Calls the 'predict' function with given arguments to perform object detection.""" 35 | return self.predict(source, stream, bboxes, points, labels, **kwargs) 36 | 37 | def info(self, detailed=False, verbose=True): 38 | """ 39 | Logs model info. 40 | 41 | Args: 42 | detailed (bool): Show detailed information about model. 43 | verbose (bool): Controls verbosity. 44 | """ 45 | return model_info(self.model, detailed=detailed, verbose=verbose) 46 | 47 | @property 48 | def task_map(self): 49 | """Returns a dictionary mapping the 'segment' task to its corresponding 'Predictor'.""" 50 | return {'segment': {'predictor': Predictor}} 51 | -------------------------------------------------------------------------------- /ultralytics/examples/YOLOv8-CPP-Inference/inference.h: -------------------------------------------------------------------------------- 1 | #ifndef INFERENCE_H 2 | #define INFERENCE_H 3 | 4 | // Cpp native 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | // OpenCV / DNN / Inference 11 | #include 12 | #include 13 | #include 14 | 15 | struct Detection 16 | { 17 | int class_id{0}; 18 | std::string className{}; 19 | float confidence{0.0}; 20 | cv::Scalar color{}; 21 | cv::Rect box{}; 22 | }; 23 | 24 | class Inference 25 | { 26 | public: 27 | Inference(const std::string &onnxModelPath, const cv::Size &modelInputShape = {640, 640}, const std::string &classesTxtFile = "", const bool &runWithCuda = true); 28 | std::vector runInference(const cv::Mat &input); 29 | 30 | private: 31 | void loadClassesFromFile(); 32 | void loadOnnxNetwork(); 33 | cv::Mat formatToSquare(const cv::Mat &source); 34 | 35 | std::string modelPath{}; 36 | std::string classesPath{}; 37 | bool cudaEnabled{}; 38 | 39 | std::vector classes{"person", "bicycle", "car", "motorcycle", "airplane", "bus", "train", "truck", "boat", "traffic light", "fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog", "horse", "sheep", "cow", "elephant", "bear", "zebra", "giraffe", "backpack", "umbrella", "handbag", "tie", "suitcase", "frisbee", "skis", "snowboard", "sports ball", "kite", "baseball bat", "baseball glove", "skateboard", "surfboard", "tennis racket", "bottle", "wine glass", "cup", "fork", "knife", "spoon", "bowl", "banana", "apple", "sandwich", "orange", "broccoli", "carrot", "hot dog", "pizza", "donut", "cake", "chair", "couch", "potted plant", "bed", "dining table", "toilet", "tv", "laptop", "mouse", "remote", "keyboard", "cell phone", "microwave", "oven", "toaster", "sink", "refrigerator", "book", "clock", "vase", "scissors", "teddy bear", "hair drier", "toothbrush"}; 40 | 41 | cv::Size2f modelShape{}; 42 | 43 | float modelConfidenceThreshold {0.25}; 44 | float modelScoreThreshold {0.45}; 45 | float modelNMSThreshold {0.50}; 46 | 47 | bool letterBoxForSquare = true; 48 | 49 | cv::dnn::Net net; 50 | }; 51 | 52 | #endif // INFERENCE_H 53 | -------------------------------------------------------------------------------- /ultralytics/docs/reference/data/augment.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Detailed exploration into Ultralytics data augmentation methods including BaseTransform, MixUp, LetterBox, ToTensor, and more for enhancing model performance. 3 | keywords: Ultralytics, Data Augmentation, BaseTransform, MixUp, RandomHSV, LetterBox, Albumentations, classify_transforms, classify_albumentations 4 | --- 5 | 6 | # Reference for `ultralytics/data/augment.py` 7 | 8 | !!! note 9 | 10 | Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/data/augment.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/data/augment.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) 🛠️. Thank you 🙏! 11 | 12 | --- 13 | ## ::: ultralytics.data.augment.BaseTransform 14 |

15 | 16 | --- 17 | ## ::: ultralytics.data.augment.Compose 18 |

19 | 20 | --- 21 | ## ::: ultralytics.data.augment.BaseMixTransform 22 |

23 | 24 | --- 25 | ## ::: ultralytics.data.augment.Mosaic 26 |

27 | 28 | --- 29 | ## ::: ultralytics.data.augment.MixUp 30 |

31 | 32 | --- 33 | ## ::: ultralytics.data.augment.RandomPerspective 34 |

35 | 36 | --- 37 | ## ::: ultralytics.data.augment.RandomHSV 38 |

39 | 40 | --- 41 | ## ::: ultralytics.data.augment.RandomFlip 42 |

43 | 44 | --- 45 | ## ::: ultralytics.data.augment.LetterBox 46 |

47 | 48 | --- 49 | ## ::: ultralytics.data.augment.CopyPaste 50 |

51 | 52 | --- 53 | ## ::: ultralytics.data.augment.Albumentations 54 |

55 | 56 | --- 57 | ## ::: ultralytics.data.augment.Format 58 |

59 | 60 | --- 61 | ## ::: ultralytics.data.augment.ClassifyLetterBox 62 |

63 | 64 | --- 65 | ## ::: ultralytics.data.augment.CenterCrop 66 |

67 | 68 | --- 69 | ## ::: ultralytics.data.augment.ToTensor 70 |

71 | 72 | --- 73 | ## ::: ultralytics.data.augment.v8_transforms 74 |

75 | 76 | --- 77 | ## ::: ultralytics.data.augment.classify_transforms 78 |

79 | 80 | --- 81 | ## ::: ultralytics.data.augment.hsv2colorjitter 82 |

83 | 84 | --- 85 | ## ::: ultralytics.data.augment.classify_albumentations 86 |

87 | -------------------------------------------------------------------------------- /ultralytics/.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | # Pre-commit hooks. For more information see https://github.com/pre-commit/pre-commit-hooks/blob/main/README.md 3 | 4 | exclude: 'docs/' 5 | # Define bot property if installed via https://github.com/marketplace/pre-commit-ci 6 | ci: 7 | autofix_prs: true 8 | autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions' 9 | autoupdate_schedule: monthly 10 | # submodules: true 11 | 12 | repos: 13 | - repo: https://github.com/pre-commit/pre-commit-hooks 14 | rev: v4.4.0 15 | hooks: 16 | - id: end-of-file-fixer 17 | - id: trailing-whitespace 18 | - id: check-case-conflict 19 | # - id: check-yaml 20 | - id: check-docstring-first 21 | - id: double-quote-string-fixer 22 | - id: detect-private-key 23 | 24 | - repo: https://github.com/asottile/pyupgrade 25 | rev: v3.14.0 26 | hooks: 27 | - id: pyupgrade 28 | name: Upgrade code 29 | 30 | - repo: https://github.com/PyCQA/isort 31 | rev: 5.12.0 32 | hooks: 33 | - id: isort 34 | name: Sort imports 35 | 36 | - repo: https://github.com/google/yapf 37 | rev: v0.40.2 38 | hooks: 39 | - id: yapf 40 | name: YAPF formatting 41 | 42 | - repo: https://github.com/executablebooks/mdformat 43 | rev: 0.7.17 44 | hooks: 45 | - id: mdformat 46 | name: MD formatting 47 | additional_dependencies: 48 | - mdformat-gfm 49 | - mdformat-black 50 | # exclude: "README.md|README.zh-CN.md|CONTRIBUTING.md" 51 | 52 | - repo: https://github.com/PyCQA/flake8 53 | rev: 6.1.0 54 | hooks: 55 | - id: flake8 56 | name: PEP8 57 | 58 | - repo: https://github.com/codespell-project/codespell 59 | rev: v2.2.6 60 | hooks: 61 | - id: codespell 62 | args: 63 | - --ignore-words-list=crate,nd,strack,dota,ane,segway,fo 64 | 65 | - repo: https://github.com/PyCQA/docformatter 66 | rev: v1.7.5 67 | hooks: 68 | - id: docformatter 69 | 70 | # - repo: https://github.com/asottile/yesqa 71 | # rev: v1.4.0 72 | # hooks: 73 | # - id: yesqa 74 | 75 | # - repo: https://github.com/asottile/dead 76 | # rev: v1.5.0 77 | # hooks: 78 | # - id: dead 79 | -------------------------------------------------------------------------------- /ultralytics/setup.cfg: -------------------------------------------------------------------------------- 1 | # Project-wide configuration file, can be used for package metadata and other toll configurations 2 | # Example usage: global configuration for PEP8 (via flake8) setting or default pytest arguments 3 | # Local usage: pip install pre-commit, pre-commit run --all-files 4 | 5 | [metadata] 6 | license_files = LICENSE 7 | description_file = README.md 8 | 9 | [tool:pytest] 10 | norecursedirs = 11 | .git 12 | dist 13 | build 14 | addopts = 15 | --doctest-modules 16 | --durations=30 17 | --color=yes 18 | 19 | [coverage:run] 20 | source = ultralytics/ 21 | data_file = tests/.coverage 22 | omit = 23 | ultralytics/utils/callbacks/* 24 | 25 | [flake8] 26 | max-line-length = 120 27 | exclude = .tox,*.egg,build,temp 28 | select = E,W,F 29 | doctests = True 30 | verbose = 2 31 | # https://pep8.readthedocs.io/en/latest/intro.html#error-codes 32 | format = pylint 33 | # see: https://www.flake8rules.com/ 34 | ignore = E731,F405,E402,W504,E501 35 | # E731: Do not assign a lambda expression, use a def 36 | # F405: name may be undefined, or defined from star imports: module 37 | # E402: module level import not at top of file 38 | # W504: line break after binary operator 39 | # E501: line too long 40 | # removed: 41 | # F401: module imported but unused 42 | # E231: missing whitespace after ‘,’, ‘;’, or ‘:’ 43 | # E127: continuation line over-indented for visual indent 44 | # F403: ‘from module import *’ used; unable to detect undefined names 45 | 46 | 47 | [isort] 48 | # https://pycqa.github.io/isort/docs/configuration/options.html 49 | line_length = 120 50 | # see: https://pycqa.github.io/isort/docs/configuration/multi_line_output_modes.html 51 | multi_line_output = 0 52 | 53 | [yapf] 54 | based_on_style = pep8 55 | spaces_before_comment = 2 56 | COLUMN_LIMIT = 120 57 | COALESCE_BRACKETS = True 58 | SPACES_AROUND_POWER_OPERATOR = True 59 | SPACE_BETWEEN_ENDING_COMMA_AND_CLOSING_BRACKET = True 60 | SPLIT_BEFORE_CLOSING_BRACKET = False 61 | SPLIT_BEFORE_FIRST_ARGUMENT = False 62 | # EACH_DICT_ENTRY_ON_SEPARATE_LINE = False 63 | 64 | [docformatter] 65 | wrap-summaries = 120 66 | wrap-descriptions = 120 67 | in-place = true 68 | make-summary-multi-line = false 69 | pre-summary-newline = true 70 | force-wrap = false 71 | close-quotes-on-newline = true 72 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/data/annotator.py: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | 3 | from pathlib import Path 4 | 5 | from ultralytics import SAM, YOLO 6 | 7 | 8 | def auto_annotate(data, det_model='yolov8x.pt', sam_model='sam_b.pt', device='', output_dir=None): 9 | """ 10 | Automatically annotates images using a YOLO object detection model and a SAM segmentation model. 11 | 12 | Args: 13 | data (str): Path to a folder containing images to be annotated. 14 | det_model (str, optional): Pre-trained YOLO detection model. Defaults to 'yolov8x.pt'. 15 | sam_model (str, optional): Pre-trained SAM segmentation model. Defaults to 'sam_b.pt'. 16 | device (str, optional): Device to run the models on. Defaults to an empty string (CPU or GPU, if available). 17 | output_dir (str | None | optional): Directory to save the annotated results. 18 | Defaults to a 'labels' folder in the same directory as 'data'. 19 | 20 | Example: 21 | ```python 22 | from ultralytics.data.annotator import auto_annotate 23 | 24 | auto_annotate(data='ultralytics/assets', det_model='yolov8n.pt', sam_model='mobile_sam.pt') 25 | ``` 26 | """ 27 | det_model = YOLO(det_model) 28 | sam_model = SAM(sam_model) 29 | 30 | data = Path(data) 31 | if not output_dir: 32 | output_dir = data.parent / f'{data.stem}_auto_annotate_labels' 33 | Path(output_dir).mkdir(exist_ok=True, parents=True) 34 | 35 | det_results = det_model(data, stream=True, device=device) 36 | 37 | for result in det_results: 38 | class_ids = result.boxes.cls.int().tolist() # noqa 39 | if len(class_ids): 40 | boxes = result.boxes.xyxy # Boxes object for bbox outputs 41 | sam_results = sam_model(result.orig_img, bboxes=boxes, verbose=False, save=False, device=device) 42 | segments = sam_results[0].masks.xyn # noqa 43 | 44 | with open(f'{str(Path(output_dir) / Path(result.path).stem)}.txt', 'w') as f: 45 | for i in range(len(segments)): 46 | s = segments[i] 47 | if len(s) == 0: 48 | continue 49 | segment = map(str, segments[i].reshape(-1).tolist()) 50 | f.write(f'{class_ids[i]} ' + ' '.join(segment) + '\n') 51 | -------------------------------------------------------------------------------- /ultralytics/ultralytics/cfg/models/rt-detr/rtdetr-x.yaml: -------------------------------------------------------------------------------- 1 | # Ultralytics YOLO 🚀, AGPL-3.0 license 2 | # RT-DETR-x object detection model with P3-P5 outputs. For details see https://docs.ultralytics.com/models/rtdetr 3 | 4 | # Parameters 5 | nc: 80 # number of classes 6 | scales: # model compound scaling constants, i.e. 'model=yolov8n-cls.yaml' will call yolov8-cls.yaml with scale 'n' 7 | # [depth, width, max_channels] 8 | x: [1.00, 1.00, 2048] 9 | 10 | backbone: 11 | # [from, repeats, module, args] 12 | - [-1, 1, HGStem, [32, 64]] # 0-P2/4 13 | - [-1, 6, HGBlock, [64, 128, 3]] # stage 1 14 | 15 | - [-1, 1, DWConv, [128, 3, 2, 1, False]] # 2-P3/8 16 | - [-1, 6, HGBlock, [128, 512, 3]] 17 | - [-1, 6, HGBlock, [128, 512, 3, False, True]] # 4-stage 2 18 | 19 | - [-1, 1, DWConv, [512, 3, 2, 1, False]] # 5-P3/16 20 | - [-1, 6, HGBlock, [256, 1024, 5, True, False]] # cm, c2, k, light, shortcut 21 | - [-1, 6, HGBlock, [256, 1024, 5, True, True]] 22 | - [-1, 6, HGBlock, [256, 1024, 5, True, True]] 23 | - [-1, 6, HGBlock, [256, 1024, 5, True, True]] 24 | - [-1, 6, HGBlock, [256, 1024, 5, True, True]] # 10-stage 3 25 | 26 | - [-1, 1, DWConv, [1024, 3, 2, 1, False]] # 11-P4/32 27 | - [-1, 6, HGBlock, [512, 2048, 5, True, False]] 28 | - [-1, 6, HGBlock, [512, 2048, 5, True, True]] # 13-stage 4 29 | 30 | head: 31 | - [-1, 1, Conv, [384, 1, 1, None, 1, 1, False]] # 14 input_proj.2 32 | - [-1, 1, AIFI, [2048, 8]] 33 | - [-1, 1, Conv, [384, 1, 1]] # 16, Y5, lateral_convs.0 34 | 35 | - [-1, 1, nn.Upsample, [None, 2, 'nearest']] 36 | - [10, 1, Conv, [384, 1, 1, None, 1, 1, False]] # 18 input_proj.1 37 | - [[-2, -1], 1, Concat, [1]] 38 | - [-1, 3, RepC3, [384]] # 20, fpn_blocks.0 39 | - [-1, 1, Conv, [384, 1, 1]] # 21, Y4, lateral_convs.1 40 | 41 | - [-1, 1, nn.Upsample, [None, 2, 'nearest']] 42 | - [4, 1, Conv, [384, 1, 1, None, 1, 1, False]] # 23 input_proj.0 43 | - [[-2, -1], 1, Concat, [1]] # cat backbone P4 44 | - [-1, 3, RepC3, [384]] # X3 (25), fpn_blocks.1 45 | 46 | - [-1, 1, Conv, [384, 3, 2]] # 26, downsample_convs.0 47 | - [[-1, 21], 1, Concat, [1]] # cat Y4 48 | - [-1, 3, RepC3, [384]] # F4 (28), pan_blocks.0 49 | 50 | - [-1, 1, Conv, [384, 3, 2]] # 29, downsample_convs.1 51 | - [[-1, 16], 1, Concat, [1]] # cat Y5 52 | - [-1, 3, RepC3, [384]] # F5 (31), pan_blocks.1 53 | 54 | - [[25, 28, 31], 1, RTDETRDecoder, [nc]] # Detect(P3, P4, P5) 55 | -------------------------------------------------------------------------------- /ultralytics/docs/help/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | comments: true 3 | description: Find comprehensive guides and documents on Ultralytics YOLO tasks. Includes FAQs, contributing guides, CI guide, CLA, MRE guide, code of conduct & more. 4 | keywords: Ultralytics, YOLO, guides, documents, FAQ, contributing, CI guide, CLA, MRE guide, code of conduct, EHS policy, security policy 5 | --- 6 | 7 | Welcome to the Ultralytics Help page! We are committed to providing you with comprehensive resources to make your experience with Ultralytics YOLO repositories as smooth and enjoyable as possible. On this page, you'll find essential links to guides and documents that will help you navigate through common tasks and address any questions you might have while using our repositories. 8 | 9 | - [Frequently Asked Questions (FAQ)](FAQ.md): Find answers to common questions and issues faced by users and contributors of Ultralytics YOLO repositories. 10 | - [Contributing Guide](contributing.md): Learn the best practices for submitting pull requests, reporting bugs, and contributing to the development of our repositories. 11 | - [Continuous Integration (CI) Guide](CI.md): Understand the CI tests we perform for each Ultralytics repository and see their current statuses. 12 | - [Contributor License Agreement (CLA)](CLA.md): Familiarize yourself with our CLA to understand the terms and conditions for contributing to Ultralytics projects. 13 | - [Minimum Reproducible Example (MRE) Guide](minimum_reproducible_example.md): Understand how to create an MRE when submitting bug reports to ensure that our team can quickly and efficiently address the issue. 14 | - [Code of Conduct](code_of_conduct.md): Learn about our community guidelines and expectations to ensure a welcoming and inclusive environment for all participants. 15 | - [Environmental, Health and Safety (EHS) Policy](environmental-health-safety.md): Explore Ultralytics' dedicated approach towards maintaining a sustainable, safe, and healthy work environment for all our stakeholders. 16 | - [Security Policy](../SECURITY.md): Understand our security practices and how to report security vulnerabilities responsibly. 17 | 18 | We highly recommend going through these guides to make the most of your collaboration with the Ultralytics community. Our goal is to maintain a welcoming and supportive environment for all users and contributors. If you need further assistance, don't hesitate to reach out to us through GitHub Issues or the official discussion forum. Happy coding! 19 | --------------------------------------------------------------------------------