From 620f3eb2181c1b686c9bdd2ee805dee483d4f116 Mon Sep 17 00:00:00 2001 From: Laughing <61612323+Laughing-q@users.noreply.github.com> Date: Sun, 16 Jul 2023 23:47:45 +0800 Subject: [PATCH] `ultralytics 8.0.136` refactor and simplify package (#3748) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Glenn Jocher --- .github/workflows/ci.yaml | 8 +- .github/workflows/publish.yml | 2 +- README.md | 4 +- README.zh-CN.md | 4 +- docs/build_reference.py | 4 +- docs/datasets/detect/argoverse.md | 6 +- docs/datasets/detect/coco.md | 6 +- docs/datasets/detect/coco8.md | 6 +- docs/datasets/detect/globalwheat2020.md | 6 +- docs/datasets/detect/index.md | 2 +- docs/datasets/detect/objects365.md | 6 +- docs/datasets/detect/sku-110k.md | 6 +- docs/datasets/detect/visdrone.md | 6 +- docs/datasets/detect/voc.md | 6 +- docs/datasets/detect/xview.md | 6 +- docs/datasets/pose/coco.md | 6 +- docs/datasets/pose/coco8-pose.md | 6 +- docs/datasets/pose/index.md | 2 +- docs/datasets/segment/coco.md | 6 +- docs/datasets/segment/coco8-seg.md | 6 +- docs/datasets/segment/index.md | 4 +- docs/hub/datasets.md | 2 +- docs/models/fast-sam.md | 2 +- docs/models/mobile-sam.md | 4 +- docs/models/sam.md | 8 +- docs/modes/benchmark.md | 2 +- docs/modes/predict.md | 4 +- docs/modes/track.md | 4 +- docs/reference/cfg/__init__.md | 44 + docs/reference/data/annotator.md | 4 + docs/reference/data/augment.md | 94 ++ docs/reference/data/base.md | 4 + docs/reference/data/build.md | 34 + docs/reference/data/converter.md | 29 + docs/reference/data/dataset.md | 14 + docs/reference/data/loaders.md | 39 + docs/reference/data/utils.md | 69 ++ docs/reference/engine/exporter.md | 29 + docs/reference/engine/model.md | 4 + docs/reference/engine/predictor.md | 4 + docs/reference/engine/results.md | 29 + docs/reference/engine/trainer.md | 4 + docs/reference/engine/validator.md | 4 + docs/reference/hub/__init__.md | 5 - docs/reference/hub/auth.md | 5 - docs/reference/hub/session.md | 5 - docs/reference/hub/utils.md | 5 - docs/reference/models/fastsam/model.md | 4 + docs/reference/models/fastsam/predict.md | 4 + docs/reference/models/fastsam/prompt.md | 4 + docs/reference/models/fastsam/utils.md | 9 + docs/reference/models/fastsam/val.md | 4 + docs/reference/models/nas/model.md | 4 + docs/reference/models/nas/predict.md | 4 + docs/reference/models/nas/val.md | 4 + docs/reference/models/rtdetr/model.md | 4 + docs/reference/models/rtdetr/predict.md | 4 + docs/reference/models/rtdetr/train.md | 9 + docs/reference/models/rtdetr/val.md | 9 + docs/reference/models/sam/amg.md | 84 ++ docs/reference/models/sam/build.md | 29 + docs/reference/models/sam/model.md | 4 + docs/reference/models/sam/modules/decoders.md | 9 + docs/reference/models/sam/modules/encoders.md | 49 ++ docs/reference/models/sam/modules/sam.md | 4 + .../models/sam/modules/tiny_encoder.md | 54 ++ .../models/sam/modules/transformer.md | 14 + docs/reference/models/sam/predict.md | 4 + docs/reference/models/utils/loss.md | 9 + docs/reference/models/utils/ops.md | 14 + .../reference/models/yolo/classify/predict.md | 9 + docs/reference/models/yolo/classify/train.md | 9 + docs/reference/models/yolo/classify/val.md | 9 + docs/reference/models/yolo/detect/predict.md | 9 + docs/reference/models/yolo/detect/train.md | 9 + docs/reference/models/yolo/detect/val.md | 9 + docs/reference/models/yolo/pose/predict.md | 9 + docs/reference/models/yolo/pose/train.md | 9 + docs/reference/models/yolo/pose/val.md | 9 + docs/reference/models/yolo/segment/predict.md | 9 + docs/reference/models/yolo/segment/train.md | 9 + docs/reference/models/yolo/segment/val.md | 9 + docs/reference/nn/autobackend.md | 5 - docs/reference/nn/modules/block.md | 5 - docs/reference/nn/modules/conv.md | 5 - docs/reference/nn/modules/head.md | 5 - docs/reference/nn/modules/transformer.md | 5 - docs/reference/nn/modules/utils.md | 5 - docs/reference/nn/tasks.md | 10 +- docs/reference/tracker/track.md | 19 - docs/reference/tracker/trackers/basetrack.md | 14 - docs/reference/tracker/trackers/bot_sort.md | 14 - .../tracker/trackers/byte_tracker.md | 14 - docs/reference/tracker/utils/gmc.md | 9 - docs/reference/tracker/utils/kalman_filter.md | 14 - docs/reference/tracker/utils/matching.md | 64 -- docs/reference/trackers/basetrack.md | 9 + docs/reference/trackers/bot_sort.md | 9 + docs/reference/trackers/byte_tracker.md | 9 + docs/reference/trackers/track.md | 14 + docs/reference/trackers/utils/gmc.md | 4 + .../reference/trackers/utils/kalman_filter.md | 9 + docs/reference/trackers/utils/matching.md | 59 ++ docs/reference/utils/__init__.md | 169 ++++ docs/reference/utils/autobatch.md | 9 + docs/reference/utils/benchmarks.md | 9 + docs/reference/utils/callbacks/base.md | 134 +++ docs/reference/utils/callbacks/clearml.md | 34 + docs/reference/utils/callbacks/comet.md | 119 +++ docs/reference/utils/callbacks/dvc.md | 49 ++ docs/reference/utils/callbacks/hub.md | 39 + docs/reference/utils/callbacks/mlflow.md | 14 + docs/reference/utils/callbacks/neptune.md | 39 + docs/reference/utils/callbacks/raytune.md | 4 + docs/reference/utils/callbacks/tensorboard.md | 19 + docs/reference/utils/callbacks/wb.md | 24 + docs/reference/utils/checks.md | 89 ++ docs/reference/utils/dist.md | 19 + docs/reference/utils/downloads.md | 34 + docs/reference/utils/errors.md | 4 + docs/reference/utils/files.md | 34 + docs/reference/utils/instance.md | 14 + docs/reference/utils/loss.md | 39 + docs/reference/utils/metrics.md | 89 ++ docs/reference/utils/ops.md | 139 +++ docs/reference/utils/patches.md | 19 + docs/reference/utils/plotting.md | 39 + docs/reference/utils/tal.md | 29 + docs/reference/utils/torch_utils.md | 134 +++ docs/reference/utils/tuner.md | 4 + docs/reference/vit/rtdetr/model.md | 9 - docs/reference/vit/rtdetr/predict.md | 9 - docs/reference/vit/rtdetr/train.md | 14 - docs/reference/vit/rtdetr/val.md | 14 - docs/reference/vit/sam/amg.md | 89 -- docs/reference/vit/sam/build.md | 34 - docs/reference/vit/sam/model.md | 9 - docs/reference/vit/sam/modules/decoders.md | 14 - docs/reference/vit/sam/modules/encoders.md | 54 -- docs/reference/vit/sam/modules/sam.md | 9 - .../reference/vit/sam/modules/tiny_encoder.md | 59 -- docs/reference/vit/sam/modules/transformer.md | 19 - docs/reference/vit/sam/predict.md | 9 - docs/reference/vit/utils/loss.md | 14 - docs/reference/vit/utils/ops.md | 19 - docs/reference/yolo/cfg/__init__.md | 49 -- docs/reference/yolo/data/annotator.md | 9 - docs/reference/yolo/data/augment.md | 99 --- docs/reference/yolo/data/base.md | 9 - docs/reference/yolo/data/build.md | 39 - docs/reference/yolo/data/converter.md | 34 - .../yolo/data/dataloaders/stream_loaders.md | 44 - docs/reference/yolo/data/dataset.md | 19 - docs/reference/yolo/data/dataset_wrappers.md | 9 - docs/reference/yolo/data/utils.md | 74 -- docs/reference/yolo/engine/exporter.md | 34 - docs/reference/yolo/engine/model.md | 9 - docs/reference/yolo/engine/predictor.md | 9 - docs/reference/yolo/engine/results.md | 34 - docs/reference/yolo/engine/trainer.md | 9 - docs/reference/yolo/engine/validator.md | 9 - docs/reference/yolo/fastsam/model.md | 9 - docs/reference/yolo/fastsam/predict.md | 9 - docs/reference/yolo/fastsam/prompt.md | 9 - docs/reference/yolo/fastsam/utils.md | 14 - docs/reference/yolo/fastsam/val.md | 9 - docs/reference/yolo/nas/model.md | 9 - docs/reference/yolo/nas/predict.md | 9 - docs/reference/yolo/nas/val.md | 9 - docs/reference/yolo/utils/__init__.md | 174 ---- docs/reference/yolo/utils/autobatch.md | 14 - docs/reference/yolo/utils/benchmarks.md | 14 - docs/reference/yolo/utils/callbacks/base.md | 139 --- .../reference/yolo/utils/callbacks/clearml.md | 39 - docs/reference/yolo/utils/callbacks/comet.md | 124 --- docs/reference/yolo/utils/callbacks/dvc.md | 54 -- docs/reference/yolo/utils/callbacks/hub.md | 44 - docs/reference/yolo/utils/callbacks/mlflow.md | 19 - .../reference/yolo/utils/callbacks/neptune.md | 44 - .../reference/yolo/utils/callbacks/raytune.md | 9 - .../yolo/utils/callbacks/tensorboard.md | 24 - docs/reference/yolo/utils/callbacks/wb.md | 29 - docs/reference/yolo/utils/checks.md | 94 -- docs/reference/yolo/utils/dist.md | 24 - docs/reference/yolo/utils/downloads.md | 39 - docs/reference/yolo/utils/errors.md | 9 - docs/reference/yolo/utils/files.md | 39 - docs/reference/yolo/utils/instance.md | 19 - docs/reference/yolo/utils/loss.md | 44 - docs/reference/yolo/utils/metrics.md | 94 -- docs/reference/yolo/utils/ops.md | 144 ---- docs/reference/yolo/utils/patches.md | 24 - docs/reference/yolo/utils/plotting.md | 44 - docs/reference/yolo/utils/tal.md | 34 - docs/reference/yolo/utils/torch_utils.md | 139 --- docs/reference/yolo/utils/tuner.md | 9 - docs/reference/yolo/v8/classify/predict.md | 14 - docs/reference/yolo/v8/classify/train.md | 14 - docs/reference/yolo/v8/classify/val.md | 14 - docs/reference/yolo/v8/detect/predict.md | 14 - docs/reference/yolo/v8/detect/train.md | 14 - docs/reference/yolo/v8/detect/val.md | 14 - docs/reference/yolo/v8/pose/predict.md | 14 - docs/reference/yolo/v8/pose/train.md | 14 - docs/reference/yolo/v8/pose/val.md | 14 - docs/reference/yolo/v8/segment/predict.md | 14 - docs/reference/yolo/v8/segment/train.md | 14 - docs/reference/yolo/v8/segment/val.md | 14 - docs/tasks/classify.md | 12 +- docs/tasks/detect.md | 10 +- docs/tasks/pose.md | 12 +- docs/tasks/segment.md | 12 +- docs/usage/callbacks.md | 2 +- docs/usage/cfg.md | 2 +- docs/usage/cli.md | 2 +- docs/usage/engine.md | 8 +- docs/usage/python.md | 4 +- examples/YOLOv8-ONNXRuntime/main.py | 4 +- examples/YOLOv8-OpenCV-ONNX-Python/main.py | 4 +- examples/tutorial.ipynb | 2 +- mkdocs.yml | 220 +++-- setup.py | 3 +- tests/test_cli.py | 2 +- tests/test_engine.py | 8 +- tests/test_python.py | 6 +- ultralytics/__init__.py | 15 +- ultralytics/cfg/__init__.py | 421 +++++++++ ultralytics/{ => cfg}/datasets/Argoverse.yaml | 2 +- .../{ => cfg}/datasets/GlobalWheat2020.yaml | 2 +- ultralytics/{ => cfg}/datasets/ImageNet.yaml | 0 .../{ => cfg}/datasets/Objects365.yaml | 6 +- ultralytics/{ => cfg}/datasets/SKU-110K.yaml | 4 +- ultralytics/{ => cfg}/datasets/VOC.yaml | 2 +- ultralytics/{ => cfg}/datasets/VisDrone.yaml | 2 +- ultralytics/{ => cfg}/datasets/coco-pose.yaml | 2 +- ultralytics/{ => cfg}/datasets/coco.yaml | 2 +- .../{ => cfg}/datasets/coco128-seg.yaml | 0 ultralytics/{ => cfg}/datasets/coco128.yaml | 0 .../{ => cfg}/datasets/coco8-pose.yaml | 0 ultralytics/{ => cfg}/datasets/coco8-seg.yaml | 0 ultralytics/{ => cfg}/datasets/coco8.yaml | 0 ultralytics/{ => cfg}/datasets/xView.yaml | 4 +- ultralytics/{yolo => }/cfg/default.yaml | 0 ultralytics/{ => cfg}/models/README.md | 0 .../{ => cfg}/models/rt-detr/rtdetr-l.yaml | 0 .../{ => cfg}/models/rt-detr/rtdetr-x.yaml | 0 .../{ => cfg}/models/v3/yolov3-spp.yaml | 0 .../{ => cfg}/models/v3/yolov3-tiny.yaml | 0 ultralytics/{ => cfg}/models/v3/yolov3.yaml | 0 .../{ => cfg}/models/v5/yolov5-p6.yaml | 0 ultralytics/{ => cfg}/models/v5/yolov5.yaml | 0 ultralytics/{ => cfg}/models/v6/yolov6.yaml | 0 .../{ => cfg}/models/v8/yolov8-cls.yaml | 0 .../{ => cfg}/models/v8/yolov8-p2.yaml | 0 .../{ => cfg}/models/v8/yolov8-p6.yaml | 0 .../{ => cfg}/models/v8/yolov8-pose-p6.yaml | 0 .../{ => cfg}/models/v8/yolov8-pose.yaml | 0 .../{ => cfg}/models/v8/yolov8-rtdetr.yaml | 0 .../{ => cfg}/models/v8/yolov8-seg.yaml | 0 ultralytics/{ => cfg}/models/v8/yolov8.yaml | 0 .../cfg => cfg/trackers}/botsort.yaml | 0 .../cfg => cfg/trackers}/bytetrack.yaml | 0 ultralytics/data/__init__.py | 8 + ultralytics/{yolo => }/data/annotator.py | 0 ultralytics/{yolo => }/data/augment.py | 11 +- ultralytics/{yolo => }/data/base.py | 3 +- ultralytics/{yolo => }/data/build.py | 10 +- ultralytics/{yolo => }/data/converter.py | 4 +- .../utils => data/dataloaders}/__init__.py | 0 ultralytics/{yolo => }/data/dataset.py | 3 +- .../stream_loaders.py => data/loaders.py} | 13 +- .../data/scripts/download_weights.sh | 6 +- .../{yolo => }/data/scripts/get_coco.sh | 0 .../{yolo => }/data/scripts/get_coco128.sh | 0 .../{yolo => }/data/scripts/get_imagenet.sh | 0 ultralytics/{yolo => }/data/utils.py | 24 +- .../data/dataloaders => engine}/__init__.py | 0 ultralytics/{yolo => }/engine/exporter.py | 16 +- ultralytics/{yolo => }/engine/model.py | 47 +- ultralytics/{yolo => }/engine/predictor.py | 14 +- ultralytics/{yolo => }/engine/results.py | 6 +- ultralytics/{yolo => }/engine/trainer.py | 20 +- ultralytics/{yolo => }/engine/validator.py | 14 +- ultralytics/hub/__init__.py | 6 +- ultralytics/hub/auth.py | 2 +- ultralytics/hub/session.py | 4 +- ultralytics/hub/utils.py | 5 +- ultralytics/{vit => models}/__init__.py | 2 - .../{yolo => models}/fastsam/__init__.py | 0 ultralytics/{yolo => models}/fastsam/model.py | 14 +- .../{yolo => models}/fastsam/predict.py | 8 +- .../{yolo => models}/fastsam/prompt.py | 2 +- ultralytics/{yolo => models}/fastsam/utils.py | 0 ultralytics/{yolo => models}/fastsam/val.py | 10 +- ultralytics/{yolo => models}/nas/__init__.py | 0 ultralytics/{yolo => models}/nas/model.py | 12 +- ultralytics/{yolo => models}/nas/predict.py | 8 +- ultralytics/{yolo => models}/nas/val.py | 6 +- .../{vit => models}/rtdetr/__init__.py | 0 ultralytics/{vit => models}/rtdetr/model.py | 12 +- ultralytics/{vit => models}/rtdetr/predict.py | 8 +- ultralytics/{vit => models}/rtdetr/train.py | 4 +- ultralytics/{vit => models}/rtdetr/val.py | 8 +- ultralytics/{vit => models}/sam/__init__.py | 0 ultralytics/{vit => models}/sam/amg.py | 0 ultralytics/{vit => models}/sam/build.py | 3 +- ultralytics/{vit => models}/sam/model.py | 4 +- .../{vit => models}/sam/modules/__init__.py | 0 .../{vit => models}/sam/modules/decoders.py | 0 .../{vit => models}/sam/modules/encoders.py | 0 .../{vit => models}/sam/modules/sam.py | 0 .../sam/modules/tiny_encoder.py | 4 +- .../sam/modules/transformer.py | 0 ultralytics/{vit => models}/sam/predict.py | 10 +- ultralytics/{vit => models}/utils/__init__.py | 0 ultralytics/{vit => models}/utils/loss.py | 7 +- ultralytics/{vit => models}/utils/ops.py | 4 +- ultralytics/models/yolo/__init__.py | 5 + ultralytics/models/yolo/classify/__init__.py | 7 + .../v8 => models/yolo}/classify/predict.py | 6 +- .../v8 => models/yolo}/classify/train.py | 14 +- .../{yolo/v8 => models/yolo}/classify/val.py | 10 +- .../v8 => models/yolo}/detect/__init__.py | 0 .../v8 => models/yolo}/detect/predict.py | 6 +- .../{yolo/v8 => models/yolo}/detect/train.py | 14 +- .../{yolo/v8 => models/yolo}/detect/val.py | 14 +- .../{yolo/v8 => models/yolo}/pose/__init__.py | 0 .../{yolo/v8 => models/yolo}/pose/predict.py | 6 +- .../{yolo/v8 => models/yolo}/pose/train.py | 10 +- .../{yolo/v8 => models/yolo}/pose/val.py | 10 +- .../v8 => models/yolo}/segment/__init__.py | 0 .../v8 => models/yolo}/segment/predict.py | 6 +- .../{yolo/v8 => models/yolo}/segment/train.py | 10 +- .../{yolo/v8 => models/yolo}/segment/val.py | 10 +- ultralytics/nn/autobackend.py | 16 +- ultralytics/nn/modules/head.py | 4 +- ultralytics/nn/tasks.py | 62 +- ultralytics/tracker/trackers/__init__.py | 6 - ultralytics/{tracker => trackers}/README.md | 6 +- ultralytics/{tracker => trackers}/__init__.py | 3 +- .../{tracker => }/trackers/basetrack.py | 0 .../{tracker => }/trackers/bot_sort.py | 6 +- .../{tracker => }/trackers/byte_tracker.py | 4 +- ultralytics/{tracker => trackers}/track.py | 7 +- ultralytics/trackers/utils/__init__.py | 0 .../{tracker => trackers}/utils/gmc.py | 2 +- .../utils/kalman_filter.py | 0 .../{tracker => trackers}/utils/matching.py | 2 +- ultralytics/utils/__init__.py | 809 +++++++++++++++++ ultralytics/{yolo => }/utils/autobatch.py | 4 +- ultralytics/{yolo => }/utils/benchmarks.py | 16 +- .../{yolo => }/utils/callbacks/__init__.py | 0 .../{yolo => }/utils/callbacks/base.py | 0 .../{yolo => }/utils/callbacks/clearml.py | 4 +- .../{yolo => }/utils/callbacks/comet.py | 4 +- ultralytics/{yolo => }/utils/callbacks/dvc.py | 4 +- ultralytics/{yolo => }/utils/callbacks/hub.py | 4 +- .../{yolo => }/utils/callbacks/mlflow.py | 2 +- .../{yolo => }/utils/callbacks/neptune.py | 4 +- .../{yolo => }/utils/callbacks/raytune.py | 0 .../{yolo => }/utils/callbacks/tensorboard.py | 2 +- ultralytics/{yolo => }/utils/callbacks/wb.py | 4 +- ultralytics/{yolo => }/utils/checks.py | 12 +- ultralytics/{yolo => }/utils/dist.py | 2 +- ultralytics/{yolo => }/utils/downloads.py | 6 +- ultralytics/{yolo => }/utils/errors.py | 2 +- ultralytics/{yolo => }/utils/files.py | 0 ultralytics/{yolo => }/utils/instance.py | 0 ultralytics/{yolo => }/utils/loss.py | 6 +- ultralytics/{yolo => }/utils/metrics.py | 2 +- ultralytics/{yolo => }/utils/ops.py | 2 +- ultralytics/{yolo => }/utils/patches.py | 0 ultralytics/{yolo => }/utils/plotting.py | 2 +- ultralytics/{yolo => }/utils/tal.py | 0 ultralytics/{yolo => }/utils/torch_utils.py | 14 +- ultralytics/{yolo => }/utils/tuner.py | 4 +- ultralytics/yolo/cfg/__init__.py | 423 +-------- ultralytics/yolo/data/__init__.py | 22 +- ultralytics/yolo/data/dataset_wrappers.py | 53 -- ultralytics/yolo/engine/__init__.py | 10 + ultralytics/yolo/utils/__init__.py | 816 +----------------- ultralytics/yolo/v8/__init__.py | 11 +- ultralytics/yolo/v8/classify/__init__.py | 7 - 383 files changed, 4213 insertions(+), 4646 deletions(-) create mode 100644 docs/reference/cfg/__init__.md create mode 100644 docs/reference/data/annotator.md create mode 100644 docs/reference/data/augment.md create mode 100644 docs/reference/data/base.md create mode 100644 docs/reference/data/build.md create mode 100644 docs/reference/data/converter.md create mode 100644 docs/reference/data/dataset.md create mode 100644 docs/reference/data/loaders.md create mode 100644 docs/reference/data/utils.md create mode 100644 docs/reference/engine/exporter.md create mode 100644 docs/reference/engine/model.md create mode 100644 docs/reference/engine/predictor.md create mode 100644 docs/reference/engine/results.md create mode 100644 docs/reference/engine/trainer.md create mode 100644 docs/reference/engine/validator.md create mode 100644 docs/reference/models/fastsam/model.md create mode 100644 docs/reference/models/fastsam/predict.md create mode 100644 docs/reference/models/fastsam/prompt.md create mode 100644 docs/reference/models/fastsam/utils.md create mode 100644 docs/reference/models/fastsam/val.md create mode 100644 docs/reference/models/nas/model.md create mode 100644 docs/reference/models/nas/predict.md create mode 100644 docs/reference/models/nas/val.md create mode 100644 docs/reference/models/rtdetr/model.md create mode 100644 docs/reference/models/rtdetr/predict.md create mode 100644 docs/reference/models/rtdetr/train.md create mode 100644 docs/reference/models/rtdetr/val.md create mode 100644 docs/reference/models/sam/amg.md create mode 100644 docs/reference/models/sam/build.md create mode 100644 docs/reference/models/sam/model.md create mode 100644 docs/reference/models/sam/modules/decoders.md create mode 100644 docs/reference/models/sam/modules/encoders.md create mode 100644 docs/reference/models/sam/modules/sam.md create mode 100644 docs/reference/models/sam/modules/tiny_encoder.md create mode 100644 docs/reference/models/sam/modules/transformer.md create mode 100644 docs/reference/models/sam/predict.md create mode 100644 docs/reference/models/utils/loss.md create mode 100644 docs/reference/models/utils/ops.md create mode 100644 docs/reference/models/yolo/classify/predict.md create mode 100644 docs/reference/models/yolo/classify/train.md create mode 100644 docs/reference/models/yolo/classify/val.md create mode 100644 docs/reference/models/yolo/detect/predict.md create mode 100644 docs/reference/models/yolo/detect/train.md create mode 100644 docs/reference/models/yolo/detect/val.md create mode 100644 docs/reference/models/yolo/pose/predict.md create mode 100644 docs/reference/models/yolo/pose/train.md create mode 100644 docs/reference/models/yolo/pose/val.md create mode 100644 docs/reference/models/yolo/segment/predict.md create mode 100644 docs/reference/models/yolo/segment/train.md create mode 100644 docs/reference/models/yolo/segment/val.md delete mode 100644 docs/reference/tracker/track.md delete mode 100644 docs/reference/tracker/trackers/basetrack.md delete mode 100644 docs/reference/tracker/trackers/bot_sort.md delete mode 100644 docs/reference/tracker/trackers/byte_tracker.md delete mode 100644 docs/reference/tracker/utils/gmc.md delete mode 100644 docs/reference/tracker/utils/kalman_filter.md delete mode 100644 docs/reference/tracker/utils/matching.md create mode 100644 docs/reference/trackers/basetrack.md create mode 100644 docs/reference/trackers/bot_sort.md create mode 100644 docs/reference/trackers/byte_tracker.md create mode 100644 docs/reference/trackers/track.md create mode 100644 docs/reference/trackers/utils/gmc.md create mode 100644 docs/reference/trackers/utils/kalman_filter.md create mode 100644 docs/reference/trackers/utils/matching.md create mode 100644 docs/reference/utils/__init__.md create mode 100644 docs/reference/utils/autobatch.md create mode 100644 docs/reference/utils/benchmarks.md create mode 100644 docs/reference/utils/callbacks/base.md create mode 100644 docs/reference/utils/callbacks/clearml.md create mode 100644 docs/reference/utils/callbacks/comet.md create mode 100644 docs/reference/utils/callbacks/dvc.md create mode 100644 docs/reference/utils/callbacks/hub.md create mode 100644 docs/reference/utils/callbacks/mlflow.md create mode 100644 docs/reference/utils/callbacks/neptune.md create mode 100644 docs/reference/utils/callbacks/raytune.md create mode 100644 docs/reference/utils/callbacks/tensorboard.md create mode 100644 docs/reference/utils/callbacks/wb.md create mode 100644 docs/reference/utils/checks.md create mode 100644 docs/reference/utils/dist.md create mode 100644 docs/reference/utils/downloads.md create mode 100644 docs/reference/utils/errors.md create mode 100644 docs/reference/utils/files.md create mode 100644 docs/reference/utils/instance.md create mode 100644 docs/reference/utils/loss.md create mode 100644 docs/reference/utils/metrics.md create mode 100644 docs/reference/utils/ops.md create mode 100644 docs/reference/utils/patches.md create mode 100644 docs/reference/utils/plotting.md create mode 100644 docs/reference/utils/tal.md create mode 100644 docs/reference/utils/torch_utils.md create mode 100644 docs/reference/utils/tuner.md delete mode 100644 docs/reference/vit/rtdetr/model.md delete mode 100644 docs/reference/vit/rtdetr/predict.md delete mode 100644 docs/reference/vit/rtdetr/train.md delete mode 100644 docs/reference/vit/rtdetr/val.md delete mode 100644 docs/reference/vit/sam/amg.md delete mode 100644 docs/reference/vit/sam/build.md delete mode 100644 docs/reference/vit/sam/model.md delete mode 100644 docs/reference/vit/sam/modules/decoders.md delete mode 100644 docs/reference/vit/sam/modules/encoders.md delete mode 100644 docs/reference/vit/sam/modules/sam.md delete mode 100644 docs/reference/vit/sam/modules/tiny_encoder.md delete mode 100644 docs/reference/vit/sam/modules/transformer.md delete mode 100644 docs/reference/vit/sam/predict.md delete mode 100644 docs/reference/vit/utils/loss.md delete mode 100644 docs/reference/vit/utils/ops.md delete mode 100644 docs/reference/yolo/cfg/__init__.md delete mode 100644 docs/reference/yolo/data/annotator.md delete mode 100644 docs/reference/yolo/data/augment.md delete mode 100644 docs/reference/yolo/data/base.md delete mode 100644 docs/reference/yolo/data/build.md delete mode 100644 docs/reference/yolo/data/converter.md delete mode 100644 docs/reference/yolo/data/dataloaders/stream_loaders.md delete mode 100644 docs/reference/yolo/data/dataset.md delete mode 100644 docs/reference/yolo/data/dataset_wrappers.md delete mode 100644 docs/reference/yolo/data/utils.md delete mode 100644 docs/reference/yolo/engine/exporter.md delete mode 100644 docs/reference/yolo/engine/model.md delete mode 100644 docs/reference/yolo/engine/predictor.md delete mode 100644 docs/reference/yolo/engine/results.md delete mode 100644 docs/reference/yolo/engine/trainer.md delete mode 100644 docs/reference/yolo/engine/validator.md delete mode 100644 docs/reference/yolo/fastsam/model.md delete mode 100644 docs/reference/yolo/fastsam/predict.md delete mode 100644 docs/reference/yolo/fastsam/prompt.md delete mode 100644 docs/reference/yolo/fastsam/utils.md delete mode 100644 docs/reference/yolo/fastsam/val.md delete mode 100644 docs/reference/yolo/nas/model.md delete mode 100644 docs/reference/yolo/nas/predict.md delete mode 100644 docs/reference/yolo/nas/val.md delete mode 100644 docs/reference/yolo/utils/__init__.md delete mode 100644 docs/reference/yolo/utils/autobatch.md delete mode 100644 docs/reference/yolo/utils/benchmarks.md delete mode 100644 docs/reference/yolo/utils/callbacks/base.md delete mode 100644 docs/reference/yolo/utils/callbacks/clearml.md delete mode 100644 docs/reference/yolo/utils/callbacks/comet.md delete mode 100644 docs/reference/yolo/utils/callbacks/dvc.md delete mode 100644 docs/reference/yolo/utils/callbacks/hub.md delete mode 100644 docs/reference/yolo/utils/callbacks/mlflow.md delete mode 100644 docs/reference/yolo/utils/callbacks/neptune.md delete mode 100644 docs/reference/yolo/utils/callbacks/raytune.md delete mode 100644 docs/reference/yolo/utils/callbacks/tensorboard.md delete mode 100644 docs/reference/yolo/utils/callbacks/wb.md delete mode 100644 docs/reference/yolo/utils/checks.md delete mode 100644 docs/reference/yolo/utils/dist.md delete mode 100644 docs/reference/yolo/utils/downloads.md delete mode 100644 docs/reference/yolo/utils/errors.md delete mode 100644 docs/reference/yolo/utils/files.md delete mode 100644 docs/reference/yolo/utils/instance.md delete mode 100644 docs/reference/yolo/utils/loss.md delete mode 100644 docs/reference/yolo/utils/metrics.md delete mode 100644 docs/reference/yolo/utils/ops.md delete mode 100644 docs/reference/yolo/utils/patches.md delete mode 100644 docs/reference/yolo/utils/plotting.md delete mode 100644 docs/reference/yolo/utils/tal.md delete mode 100644 docs/reference/yolo/utils/torch_utils.md delete mode 100644 docs/reference/yolo/utils/tuner.md delete mode 100644 docs/reference/yolo/v8/classify/predict.md delete mode 100644 docs/reference/yolo/v8/classify/train.md delete mode 100644 docs/reference/yolo/v8/classify/val.md delete mode 100644 docs/reference/yolo/v8/detect/predict.md delete mode 100644 docs/reference/yolo/v8/detect/train.md delete mode 100644 docs/reference/yolo/v8/detect/val.md delete mode 100644 docs/reference/yolo/v8/pose/predict.md delete mode 100644 docs/reference/yolo/v8/pose/train.md delete mode 100644 docs/reference/yolo/v8/pose/val.md delete mode 100644 docs/reference/yolo/v8/segment/predict.md delete mode 100644 docs/reference/yolo/v8/segment/train.md delete mode 100644 docs/reference/yolo/v8/segment/val.md create mode 100644 ultralytics/cfg/__init__.py rename ultralytics/{ => cfg}/datasets/Argoverse.yaml (97%) rename ultralytics/{ => cfg}/datasets/GlobalWheat2020.yaml (97%) rename ultralytics/{ => cfg}/datasets/ImageNet.yaml (100%) rename ultralytics/{ => cfg}/datasets/Objects365.yaml (98%) rename ultralytics/{ => cfg}/datasets/SKU-110K.yaml (95%) rename ultralytics/{ => cfg}/datasets/VOC.yaml (98%) rename ultralytics/{ => cfg}/datasets/VisDrone.yaml (98%) rename ultralytics/{ => cfg}/datasets/coco-pose.yaml (96%) rename ultralytics/{ => cfg}/datasets/coco.yaml (97%) rename ultralytics/{ => cfg}/datasets/coco128-seg.yaml (100%) rename ultralytics/{ => cfg}/datasets/coco128.yaml (100%) rename ultralytics/{ => cfg}/datasets/coco8-pose.yaml (100%) rename ultralytics/{ => cfg}/datasets/coco8-seg.yaml (100%) rename ultralytics/{ => cfg}/datasets/coco8.yaml (100%) rename ultralytics/{ => cfg}/datasets/xView.yaml (97%) rename ultralytics/{yolo => }/cfg/default.yaml (100%) rename ultralytics/{ => cfg}/models/README.md (100%) rename ultralytics/{ => cfg}/models/rt-detr/rtdetr-l.yaml (100%) rename ultralytics/{ => cfg}/models/rt-detr/rtdetr-x.yaml (100%) rename ultralytics/{ => cfg}/models/v3/yolov3-spp.yaml (100%) rename ultralytics/{ => cfg}/models/v3/yolov3-tiny.yaml (100%) rename ultralytics/{ => cfg}/models/v3/yolov3.yaml (100%) rename ultralytics/{ => cfg}/models/v5/yolov5-p6.yaml (100%) rename ultralytics/{ => cfg}/models/v5/yolov5.yaml (100%) rename ultralytics/{ => cfg}/models/v6/yolov6.yaml (100%) rename ultralytics/{ => cfg}/models/v8/yolov8-cls.yaml (100%) rename ultralytics/{ => cfg}/models/v8/yolov8-p2.yaml (100%) rename ultralytics/{ => cfg}/models/v8/yolov8-p6.yaml (100%) rename ultralytics/{ => cfg}/models/v8/yolov8-pose-p6.yaml (100%) rename ultralytics/{ => cfg}/models/v8/yolov8-pose.yaml (100%) rename ultralytics/{ => cfg}/models/v8/yolov8-rtdetr.yaml (100%) rename ultralytics/{ => cfg}/models/v8/yolov8-seg.yaml (100%) rename ultralytics/{ => cfg}/models/v8/yolov8.yaml (100%) rename ultralytics/{tracker/cfg => cfg/trackers}/botsort.yaml (100%) rename ultralytics/{tracker/cfg => cfg/trackers}/bytetrack.yaml (100%) create mode 100644 ultralytics/data/__init__.py rename ultralytics/{yolo => }/data/annotator.py (100%) rename ultralytics/{yolo => }/data/augment.py (99%) rename ultralytics/{yolo => }/data/base.py (99%) rename ultralytics/{yolo => }/data/build.py (94%) rename ultralytics/{yolo => }/data/converter.py (98%) rename ultralytics/{tracker/utils => data/dataloaders}/__init__.py (100%) rename ultralytics/{yolo => }/data/dataset.py (99%) rename ultralytics/{yolo/data/dataloaders/stream_loaders.py => data/loaders.py} (98%) rename ultralytics/{yolo => }/data/scripts/download_weights.sh (70%) rename ultralytics/{yolo => }/data/scripts/get_coco.sh (100%) rename ultralytics/{yolo => }/data/scripts/get_coco128.sh (100%) rename ultralytics/{yolo => }/data/scripts/get_imagenet.sh (100%) rename ultralytics/{yolo => }/data/utils.py (96%) rename ultralytics/{yolo/data/dataloaders => engine}/__init__.py (100%) rename ultralytics/{yolo => }/engine/exporter.py (98%) rename ultralytics/{yolo => }/engine/model.py (91%) rename ultralytics/{yolo => }/engine/predictor.py (97%) rename ultralytics/{yolo => }/engine/results.py (99%) rename ultralytics/{yolo => }/engine/trainer.py (97%) rename ultralytics/{yolo => }/engine/validator.py (95%) rename ultralytics/{vit => models}/__init__.py (69%) rename ultralytics/{yolo => models}/fastsam/__init__.py (100%) rename ultralytics/{yolo => models}/fastsam/model.py (90%) rename ultralytics/{yolo => models}/fastsam/predict.py (92%) rename ultralytics/{yolo => models}/fastsam/prompt.py (99%) rename ultralytics/{yolo => models}/fastsam/utils.py (100%) rename ultralytics/{yolo => models}/fastsam/val.py (97%) rename ultralytics/{yolo => models}/nas/__init__.py (100%) rename ultralytics/{yolo => models}/nas/model.py (92%) rename ultralytics/{yolo => models}/nas/predict.py (86%) rename ultralytics/{yolo => models}/nas/val.py (84%) rename ultralytics/{vit => models}/rtdetr/__init__.py (100%) rename ultralytics/{vit => models}/rtdetr/model.py (94%) rename ultralytics/{vit => models}/rtdetr/predict.py (89%) rename ultralytics/{vit => models}/rtdetr/train.py (95%) rename ultralytics/{vit => models}/rtdetr/val.py (96%) rename ultralytics/{vit => models}/sam/__init__.py (100%) rename ultralytics/{vit => models}/sam/amg.py (100%) rename ultralytics/{vit => models}/sam/build.py (98%) rename ultralytics/{vit => models}/sam/model.py (96%) rename ultralytics/{vit => models}/sam/modules/__init__.py (100%) rename ultralytics/{vit => models}/sam/modules/decoders.py (100%) rename ultralytics/{vit => models}/sam/modules/encoders.py (100%) rename ultralytics/{vit => models}/sam/modules/sam.py (100%) rename ultralytics/{vit => models}/sam/modules/tiny_encoder.py (99%) rename ultralytics/{vit => models}/sam/modules/transformer.py (100%) rename ultralytics/{vit => models}/sam/predict.py (98%) rename ultralytics/{vit => models}/utils/__init__.py (100%) rename ultralytics/{vit => models}/utils/loss.py (98%) rename ultralytics/{vit => models}/utils/ops.py (99%) create mode 100644 ultralytics/models/yolo/__init__.py create mode 100644 ultralytics/models/yolo/classify/__init__.py rename ultralytics/{yolo/v8 => models/yolo}/classify/predict.py (91%) rename ultralytics/{yolo/v8 => models/yolo}/classify/train.py (92%) rename ultralytics/{yolo/v8 => models/yolo}/classify/val.py (93%) rename ultralytics/{yolo/v8 => models/yolo}/detect/__init__.py (100%) rename ultralytics/{yolo/v8 => models/yolo}/detect/predict.py (90%) rename ultralytics/{yolo/v8 => models/yolo}/detect/train.py (91%) rename ultralytics/{yolo/v8 => models/yolo}/detect/val.py (96%) rename ultralytics/{yolo/v8 => models/yolo}/pose/__init__.py (100%) rename ultralytics/{yolo/v8 => models/yolo}/pose/predict.py (92%) rename ultralytics/{yolo/v8 => models/yolo}/pose/train.py (89%) rename ultralytics/{yolo/v8 => models/yolo}/pose/val.py (96%) rename ultralytics/{yolo/v8 => models/yolo}/segment/__init__.py (100%) rename ultralytics/{yolo/v8 => models/yolo}/segment/predict.py (93%) rename ultralytics/{yolo/v8 => models/yolo}/segment/train.py (87%) rename ultralytics/{yolo/v8 => models/yolo}/segment/val.py (97%) delete mode 100644 ultralytics/tracker/trackers/__init__.py rename ultralytics/{tracker => trackers}/README.md (95%) rename ultralytics/{tracker => trackers}/__init__.py (70%) rename ultralytics/{tracker => }/trackers/basetrack.py (100%) rename ultralytics/{tracker => }/trackers/bot_sort.py (98%) rename ultralytics/{tracker => }/trackers/byte_tracker.py (99%) rename ultralytics/{tracker => trackers}/track.py (92%) create mode 100644 ultralytics/trackers/utils/__init__.py rename ultralytics/{tracker => trackers}/utils/gmc.py (99%) rename ultralytics/{tracker => trackers}/utils/kalman_filter.py (100%) rename ultralytics/{tracker => trackers}/utils/matching.py (99%) create mode 100644 ultralytics/utils/__init__.py rename ultralytics/{yolo => }/utils/autobatch.py (96%) rename ultralytics/{yolo => }/utils/benchmarks.py (96%) rename ultralytics/{yolo => }/utils/callbacks/__init__.py (100%) rename ultralytics/{yolo => }/utils/callbacks/base.py (100%) rename ultralytics/{yolo => }/utils/callbacks/clearml.py (97%) rename ultralytics/{yolo => }/utils/callbacks/comet.py (98%) rename ultralytics/{yolo => }/utils/callbacks/dvc.py (97%) rename ultralytics/{yolo => }/utils/callbacks/hub.py (96%) rename ultralytics/{yolo => }/utils/callbacks/mlflow.py (97%) rename ultralytics/{yolo => }/utils/callbacks/neptune.py (96%) rename ultralytics/{yolo => }/utils/callbacks/raytune.py (100%) rename ultralytics/{yolo => }/utils/callbacks/tensorboard.py (95%) rename ultralytics/{yolo => }/utils/callbacks/wb.py (94%) rename ultralytics/{yolo => }/utils/checks.py (97%) rename ultralytics/{yolo => }/utils/dist.py (97%) rename ultralytics/{yolo => }/utils/downloads.py (98%) rename ultralytics/{yolo => }/utils/errors.py (86%) rename ultralytics/{yolo => }/utils/files.py (100%) rename ultralytics/{yolo => }/utils/instance.py (100%) rename ultralytics/{yolo => }/utils/loss.py (98%) rename ultralytics/{yolo => }/utils/metrics.py (99%) rename ultralytics/{yolo => }/utils/ops.py (99%) rename ultralytics/{yolo => }/utils/patches.py (100%) rename ultralytics/{yolo => }/utils/plotting.py (99%) rename ultralytics/{yolo => }/utils/tal.py (100%) rename ultralytics/{yolo => }/utils/torch_utils.py (97%) rename ultralytics/{yolo => }/utils/tuner.py (97%) delete mode 100644 ultralytics/yolo/data/dataset_wrappers.py delete mode 100644 ultralytics/yolo/v8/classify/__init__.py diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 700d9ef..f70d352 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -111,22 +111,22 @@ jobs: - name: Benchmark DetectionModel shell: python run: | - from ultralytics.yolo.utils.benchmarks import benchmark + from ultralytics.utils.benchmarks import benchmark benchmark(model='${{ matrix.model }}.pt', imgsz=160, half=False, hard_fail=0.26) - name: Benchmark SegmentationModel shell: python run: | - from ultralytics.yolo.utils.benchmarks import benchmark + from ultralytics.utils.benchmarks import benchmark benchmark(model='${{ matrix.model }}-seg.pt', imgsz=160, half=False, hard_fail=0.30) - name: Benchmark ClassificationModel shell: python run: | - from ultralytics.yolo.utils.benchmarks import benchmark + from ultralytics.utils.benchmarks import benchmark benchmark(model='${{ matrix.model }}-cls.pt', imgsz=160, half=False, hard_fail=0.36) - name: Benchmark PoseModel shell: python run: | - from ultralytics.yolo.utils.benchmarks import benchmark + from ultralytics.utils.benchmarks import benchmark benchmark(model='${{ matrix.model }}-pose.pt', imgsz=160, half=False, hard_fail=0.17) - name: Benchmark Summary run: | diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 72e2216..911f4bd 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -40,7 +40,7 @@ jobs: import os import pkg_resources as pkg import ultralytics - from ultralytics.yolo.utils.checks import check_latest_pypi_version + from ultralytics.utils.checks import check_latest_pypi_version v_local = pkg.parse_version(ultralytics.__version__).release v_pypi = pkg.parse_version(check_latest_pypi_version()).release diff --git a/README.md b/README.md index bf7947f..ca91b05 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ results = model("https://ultralytics.com/images/bus.jpg") # predict on an image path = model.export(format="onnx") # export the model to ONNX format ``` -[Models](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/models) download automatically from the latest Ultralytics [release](https://github.com/ultralytics/assets/releases). See YOLOv8 [Python Docs](https://docs.ultralytics.com/usage/python) for more examples. +[Models](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/cfg/models) download automatically from the latest Ultralytics [release](https://github.com/ultralytics/assets/releases). See YOLOv8 [Python Docs](https://docs.ultralytics.com/usage/python) for more examples. @@ -110,7 +110,7 @@ YOLOv8 [Detect](https://docs.ultralytics.com/tasks/detect), [Segment](https://do -All [Models](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/models) download automatically from the latest Ultralytics [release](https://github.com/ultralytics/assets/releases) on first use. +All [Models](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/cfg/models) download automatically from the latest Ultralytics [release](https://github.com/ultralytics/assets/releases) on first use.
Detection diff --git a/README.zh-CN.md b/README.zh-CN.md index 8726249..c112ad3 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -100,7 +100,7 @@ results = model("https://ultralytics.com/images/bus.jpg") # 对图像进行预 success = model.export(format="onnx") # 将模型导出为 ONNX 格式 ``` -[模型](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/models) 会自动从最新的 Ultralytics [发布版本](https://github.com/ultralytics/assets/releases)中下载。查看 YOLOv8 [Python 文档](https://docs.ultralytics.com/usage/python)以获取更多示例。 +[模型](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/cfg/models) 会自动从最新的 Ultralytics [发布版本](https://github.com/ultralytics/assets/releases)中下载。查看 YOLOv8 [Python 文档](https://docs.ultralytics.com/usage/python)以获取更多示例。
@@ -110,7 +110,7 @@ success = model.export(format="onnx") # 将模型导出为 ONNX 格式 -所有[模型](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/models)在首次使用时会自动从最新的Ultralytics [发布版本](https://github.com/ultralytics/assets/releases)下载。 +所有[模型](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/cfg/models)在首次使用时会自动从最新的Ultralytics [发布版本](https://github.com/ultralytics/assets/releases)下载。
检测 diff --git a/docs/build_reference.py b/docs/build_reference.py index 65dcc6c..f945310 100644 --- a/docs/build_reference.py +++ b/docs/build_reference.py @@ -10,7 +10,7 @@ import os import re from collections import defaultdict from pathlib import Path -from ultralytics.yolo.utils import ROOT +from ultralytics.utils import ROOT NEW_YAML_DIR = ROOT.parent CODE_DIR = ROOT @@ -39,7 +39,7 @@ def create_markdown(py_filepath, module_path, classes, functions): with open(md_filepath, 'r') as file: existing_content = file.read() header_parts = existing_content.split('---', 2) - if len(header_parts) >= 3: + if 'description:' in header_parts or 'comments:' in header_parts and len(header_parts) >= 3: header_content = f"{header_parts[0]}---{header_parts[1]}---\n\n" module_path = module_path.replace('.__init__', '') diff --git a/docs/datasets/detect/argoverse.md b/docs/datasets/detect/argoverse.md index 8d0acbc..139c920 100644 --- a/docs/datasets/detect/argoverse.md +++ b/docs/datasets/detect/argoverse.md @@ -29,12 +29,12 @@ The Argoverse dataset is widely used for training and evaluating deep learning m ## Dataset YAML -A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. For the case of the Argoverse dataset, the `Argoverse.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/Argoverse.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/Argoverse.yaml). +A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. For the case of the Argoverse dataset, the `Argoverse.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/Argoverse.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/Argoverse.yaml). -!!! example "ultralytics/datasets/Argoverse.yaml" +!!! example "ultralytics/cfg/datasets/Argoverse.yaml" ```yaml - --8<-- "ultralytics/datasets/Argoverse.yaml" + --8<-- "ultralytics/cfg/datasets/Argoverse.yaml" ``` ## Usage diff --git a/docs/datasets/detect/coco.md b/docs/datasets/detect/coco.md index 196977d..b296b7f 100644 --- a/docs/datasets/detect/coco.md +++ b/docs/datasets/detect/coco.md @@ -29,12 +29,12 @@ The COCO dataset is widely used for training and evaluating deep learning models ## Dataset YAML -A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. In the case of the COCO dataset, the `coco.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/coco.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/coco.yaml). +A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. In the case of the COCO dataset, the `coco.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco.yaml). -!!! example "ultralytics/datasets/coco.yaml" +!!! example "ultralytics/cfg/datasets/coco.yaml" ```yaml - --8<-- "ultralytics/datasets/coco.yaml" + --8<-- "ultralytics/cfg/datasets/coco.yaml" ``` ## Usage diff --git a/docs/datasets/detect/coco8.md b/docs/datasets/detect/coco8.md index 5fb2823..8cbb75a 100644 --- a/docs/datasets/detect/coco8.md +++ b/docs/datasets/detect/coco8.md @@ -19,12 +19,12 @@ and [YOLOv8](https://github.com/ultralytics/ultralytics). ## Dataset YAML -A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. In the case of the COCO8 dataset, the `coco8.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/coco8.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/coco8.yaml). +A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. In the case of the COCO8 dataset, the `coco8.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco8.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco8.yaml). -!!! example "ultralytics/datasets/coco8.yaml" +!!! example "ultralytics/cfg/datasets/coco8.yaml" ```yaml - --8<-- "ultralytics/datasets/coco8.yaml" + --8<-- "ultralytics/cfg/datasets/coco8.yaml" ``` ## Usage diff --git a/docs/datasets/detect/globalwheat2020.md b/docs/datasets/detect/globalwheat2020.md index 66ad45c..9b99974 100644 --- a/docs/datasets/detect/globalwheat2020.md +++ b/docs/datasets/detect/globalwheat2020.md @@ -28,12 +28,12 @@ The Global Wheat Head Dataset is widely used for training and evaluating deep le ## Dataset YAML -A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. For the case of the Global Wheat Head Dataset, the `GlobalWheat2020.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/GlobalWheat2020.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/GlobalWheat2020.yaml). +A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. For the case of the Global Wheat Head Dataset, the `GlobalWheat2020.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/GlobalWheat2020.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/GlobalWheat2020.yaml). -!!! example "ultralytics/datasets/GlobalWheat2020.yaml" +!!! example "ultralytics/cfg/datasets/GlobalWheat2020.yaml" ```yaml - --8<-- "ultralytics/datasets/GlobalWheat2020.yaml" + --8<-- "ultralytics/cfg/datasets/GlobalWheat2020.yaml" ``` ## Usage diff --git a/docs/datasets/detect/index.md b/docs/datasets/detect/index.md index 6a9cd61..cf29cba 100644 --- a/docs/datasets/detect/index.md +++ b/docs/datasets/detect/index.md @@ -93,7 +93,7 @@ If you have your own dataset and would like to use it for training detection mod You can easily convert labels from the popular COCO dataset format to the YOLO format using the following code snippet: ```python -from ultralytics.yolo.data.converter import convert_coco +from ultralytics.data.converter import convert_coco convert_coco(labels_dir='../coco/annotations/') ``` diff --git a/docs/datasets/detect/objects365.md b/docs/datasets/detect/objects365.md index 25a1099..85a65f1 100644 --- a/docs/datasets/detect/objects365.md +++ b/docs/datasets/detect/objects365.md @@ -28,12 +28,12 @@ The Objects365 dataset is widely used for training and evaluating deep learning ## Dataset YAML -A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. For the case of the Objects365 Dataset, the `Objects365.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/Objects365.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/Objects365.yaml). +A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. For the case of the Objects365 Dataset, the `Objects365.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/Objects365.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/Objects365.yaml). -!!! example "ultralytics/datasets/Objects365.yaml" +!!! example "ultralytics/cfg/datasets/Objects365.yaml" ```yaml - --8<-- "ultralytics/datasets/Objects365.yaml" + --8<-- "ultralytics/cfg/datasets/Objects365.yaml" ``` ## Usage diff --git a/docs/datasets/detect/sku-110k.md b/docs/datasets/detect/sku-110k.md index 1d366b3..419dc72 100644 --- a/docs/datasets/detect/sku-110k.md +++ b/docs/datasets/detect/sku-110k.md @@ -30,12 +30,12 @@ The SKU-110k dataset is widely used for training and evaluating deep learning mo ## Dataset YAML -A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. For the case of the SKU-110K dataset, the `SKU-110K.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/SKU-110K.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/SKU-110K.yaml). +A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. For the case of the SKU-110K dataset, the `SKU-110K.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/SKU-110K.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/SKU-110K.yaml). -!!! example "ultralytics/datasets/SKU-110K.yaml" +!!! example "ultralytics/cfg/datasets/SKU-110K.yaml" ```yaml - --8<-- "ultralytics/datasets/SKU-110K.yaml" + --8<-- "ultralytics/cfg/datasets/SKU-110K.yaml" ``` ## Usage diff --git a/docs/datasets/detect/visdrone.md b/docs/datasets/detect/visdrone.md index cd7a309..15b5995 100644 --- a/docs/datasets/detect/visdrone.md +++ b/docs/datasets/detect/visdrone.md @@ -26,12 +26,12 @@ The VisDrone dataset is widely used for training and evaluating deep learning mo ## Dataset YAML -A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. In the case of the Visdrone dataset, the `VisDrone.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/VisDrone.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/VisDrone.yaml). +A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. In the case of the Visdrone dataset, the `VisDrone.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/VisDrone.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/VisDrone.yaml). -!!! example "ultralytics/datasets/VisDrone.yaml" +!!! example "ultralytics/cfg/datasets/VisDrone.yaml" ```yaml - --8<-- "ultralytics/datasets/VisDrone.yaml" + --8<-- "ultralytics/cfg/datasets/VisDrone.yaml" ``` ## Usage diff --git a/docs/datasets/detect/voc.md b/docs/datasets/detect/voc.md index 4e5c546..c9f5993 100644 --- a/docs/datasets/detect/voc.md +++ b/docs/datasets/detect/voc.md @@ -29,12 +29,12 @@ The VOC dataset is widely used for training and evaluating deep learning models ## Dataset YAML -A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. In the case of the VOC dataset, the `VOC.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/VOC.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/VOC.yaml). +A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. In the case of the VOC dataset, the `VOC.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/VOC.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/VOC.yaml). -!!! example "ultralytics/datasets/VOC.yaml" +!!! example "ultralytics/cfg/datasets/VOC.yaml" ```yaml - --8<-- "ultralytics/datasets/VOC.yaml" + --8<-- "ultralytics/cfg/datasets/VOC.yaml" ``` ## Usage diff --git a/docs/datasets/detect/xview.md b/docs/datasets/detect/xview.md index 92bac2f..db956b9 100644 --- a/docs/datasets/detect/xview.md +++ b/docs/datasets/detect/xview.md @@ -32,12 +32,12 @@ The xView dataset is widely used for training and evaluating deep learning model ## Dataset YAML -A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. In the case of the xView dataset, the `xView.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/xView.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/xView.yaml). +A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. In the case of the xView dataset, the `xView.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/xView.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/xView.yaml). -!!! example "ultralytics/datasets/xView.yaml" +!!! example "ultralytics/cfg/datasets/xView.yaml" ```yaml - --8<-- "ultralytics/datasets/xView.yaml" + --8<-- "ultralytics/cfg/datasets/xView.yaml" ``` ## Usage diff --git a/docs/datasets/pose/coco.md b/docs/datasets/pose/coco.md index 217f2b0..72d6eb6 100644 --- a/docs/datasets/pose/coco.md +++ b/docs/datasets/pose/coco.md @@ -30,12 +30,12 @@ The COCO-Pose dataset is specifically used for training and evaluating deep lear ## Dataset YAML -A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. In the case of the COCO-Pose dataset, the `coco-pose.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/coco-pose.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/coco-pose.yaml). +A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. In the case of the COCO-Pose dataset, the `coco-pose.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco-pose.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco-pose.yaml). -!!! example "ultralytics/datasets/coco-pose.yaml" +!!! example "ultralytics/cfg/datasets/coco-pose.yaml" ```yaml - --8<-- "ultralytics/datasets/coco-pose.yaml" + --8<-- "ultralytics/cfg/datasets/coco-pose.yaml" ``` ## Usage diff --git a/docs/datasets/pose/coco8-pose.md b/docs/datasets/pose/coco8-pose.md index a7a115b..e13cd04 100644 --- a/docs/datasets/pose/coco8-pose.md +++ b/docs/datasets/pose/coco8-pose.md @@ -19,12 +19,12 @@ and [YOLOv8](https://github.com/ultralytics/ultralytics). ## Dataset YAML -A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. In the case of the COCO8-Pose dataset, the `coco8-pose.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/coco8-pose.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/coco8-pose.yaml). +A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. In the case of the COCO8-Pose dataset, the `coco8-pose.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco8-pose.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco8-pose.yaml). -!!! example "ultralytics/datasets/coco8-pose.yaml" +!!! example "ultralytics/cfg/datasets/coco8-pose.yaml" ```yaml - --8<-- "ultralytics/datasets/coco8-pose.yaml" + --8<-- "ultralytics/cfg/datasets/coco8-pose.yaml" ``` ## Usage diff --git a/docs/datasets/pose/index.md b/docs/datasets/pose/index.md index 27d57d8..b18012b 100644 --- a/docs/datasets/pose/index.md +++ b/docs/datasets/pose/index.md @@ -120,7 +120,7 @@ If you have your own dataset and would like to use it for training pose estimati Ultralytics provides a convenient conversion tool to convert labels from the popular COCO dataset format to YOLO format: ```python -from ultralytics.yolo.data.converter import convert_coco +from ultralytics.data.converter import convert_coco convert_coco(labels_dir='../coco/annotations/', use_keypoints=True) ``` diff --git a/docs/datasets/segment/coco.md b/docs/datasets/segment/coco.md index bfb7292..c84a818 100644 --- a/docs/datasets/segment/coco.md +++ b/docs/datasets/segment/coco.md @@ -29,12 +29,12 @@ COCO-Seg is widely used for training and evaluating deep learning models in inst ## Dataset YAML -A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. In the case of the COCO-Seg dataset, the `coco.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/coco.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/coco.yaml). +A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. In the case of the COCO-Seg dataset, the `coco.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco.yaml). -!!! example "ultralytics/datasets/coco.yaml" +!!! example "ultralytics/cfg/datasets/coco.yaml" ```yaml - --8<-- "ultralytics/datasets/coco.yaml" + --8<-- "ultralytics/cfg/datasets/coco.yaml" ``` ## Usage diff --git a/docs/datasets/segment/coco8-seg.md b/docs/datasets/segment/coco8-seg.md index 8b9721c..b35c4d5 100644 --- a/docs/datasets/segment/coco8-seg.md +++ b/docs/datasets/segment/coco8-seg.md @@ -19,12 +19,12 @@ and [YOLOv8](https://github.com/ultralytics/ultralytics). ## Dataset YAML -A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. In the case of the COCO8-Seg dataset, the `coco8-seg.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/coco8-seg.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/coco8-seg.yaml). +A YAML (Yet Another Markup Language) file is used to define the dataset configuration. It contains information about the dataset's paths, classes, and other relevant information. In the case of the COCO8-Seg dataset, the `coco8-seg.yaml` file is maintained at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco8-seg.yaml](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco8-seg.yaml). -!!! example "ultralytics/datasets/coco8-seg.yaml" +!!! example "ultralytics/cfg/datasets/coco8-seg.yaml" ```yaml - --8<-- "ultralytics/datasets/coco8-seg.yaml" + --8<-- "ultralytics/cfg/datasets/coco8-seg.yaml" ``` ## Usage diff --git a/docs/datasets/segment/index.md b/docs/datasets/segment/index.md index 5bafefe..af2dc96 100644 --- a/docs/datasets/segment/index.md +++ b/docs/datasets/segment/index.md @@ -104,7 +104,7 @@ If you have your own dataset and would like to use it for training segmentation You can easily convert labels from the popular COCO dataset format to the YOLO format using the following code snippet: ```python -from ultralytics.yolo.data.converter import convert_coco +from ultralytics.data.converter import convert_coco convert_coco(labels_dir='../coco/annotations/', use_segments=True) ``` @@ -122,7 +122,7 @@ Auto-annotation is an essential feature that allows you to generate a segmentati To auto-annotate your dataset using the Ultralytics framework, you can use the `auto_annotate` function as shown below: ```python -from ultralytics.yolo.data.annotator import auto_annotate +from ultralytics.data.annotator import auto_annotate auto_annotate(data="path/to/images", det_model="yolov8x.pt", sam_model='sam_b.pt') ``` diff --git a/docs/hub/datasets.md b/docs/hub/datasets.md index c1bdc38..77a4946 100644 --- a/docs/hub/datasets.md +++ b/docs/hub/datasets.md @@ -34,7 +34,7 @@ The dataset YAML is the same standard YOLOv5 and YOLOv8 YAML format. !!! example "coco8.yaml" ```yaml - --8<-- "ultralytics/datasets/coco8.yaml" + --8<-- "ultralytics/cfg/datasets/coco8.yaml" ``` After zipping your dataset, you should validate it before uploading it to Ultralytics HUB. Ultralytics HUB conducts the dataset validation check post-upload, so by ensuring your dataset is correctly formatted and error-free ahead of time, you can forestall any setbacks due to dataset rejection. diff --git a/docs/models/fast-sam.md b/docs/models/fast-sam.md index eefb580..c360a29 100644 --- a/docs/models/fast-sam.md +++ b/docs/models/fast-sam.md @@ -42,7 +42,7 @@ To perform object detection on an image, use the `predict` method as shown below ```python from ultralytics import FastSAM -from ultralytics.yolo.fastsam import FastSAMPrompt +from ultralytics.models.fastsam import FastSAMPrompt # Define image path and inference device IMAGE_PATH = 'ultralytics/assets/bus.jpg' diff --git a/docs/models/mobile-sam.md b/docs/models/mobile-sam.md index 94bc83d..0a7083b 100644 --- a/docs/models/mobile-sam.md +++ b/docs/models/mobile-sam.md @@ -6,9 +6,9 @@ keywords: MobileSAM, Faster Segment Anything, Segment Anything, Segment Anything ![MobileSAM Logo](https://github.com/ChaoningZhang/MobileSAM/blob/master/assets/logo2.png?raw=true) -# Faster Segment Anything (MobileSAM) +# Mobile Segment Anything (MobileSAM) -The MobileSAM paper is now available on [ResearchGate](https://www.researchgate.net/publication/371851844_Faster_Segment_Anything_Towards_Lightweight_SAM_for_Mobile_Applications) and [arXiv](https://arxiv.org/pdf/2306.14289.pdf). The most recent version will initially appear on ResearchGate due to the delayed content update on arXiv. +The MobileSAM paper is now available on [arXiv](https://arxiv.org/pdf/2306.14289.pdf). A demonstration of MobileSAM running on a CPU can be accessed at this [demo link](https://huggingface.co/spaces/dhkim2810/MobileSAM). The performance on a Mac i5 CPU takes approximately 3 seconds. On the Hugging Face demo, the interface and lower-performance CPUs contribute to a slower response, but it continues to function effectively. diff --git a/docs/models/sam.md b/docs/models/sam.md index e9f9ac0..ae334ce 100644 --- a/docs/models/sam.md +++ b/docs/models/sam.md @@ -88,7 +88,7 @@ The Segment Anything Model can be employed for a multitude of downstream tasks t === "Prompt inference" ```python - from ultralytics.vit.sam import Predictor as SAMPredictor + from ultralytics.models.sam import Predictor as SAMPredictor # Create SAMPredictor overrides = dict(conf=0.25, task='segment', mode='predict', imgsz=1024, model="mobile_sam.pt") @@ -108,7 +108,7 @@ The Segment Anything Model can be employed for a multitude of downstream tasks t === "Segment everything" ```python - from ultralytics.vit.sam import Predictor as SAMPredictor + from ultralytics.models.sam import Predictor as SAMPredictor # Create SAMPredictor overrides = dict(conf=0.25, task='segment', mode='predict', imgsz=1024, model="mobile_sam.pt") @@ -119,7 +119,7 @@ The Segment Anything Model can be employed for a multitude of downstream tasks t ``` -- More additional args for `Segment everything` see [`Predictor/generate` Reference](../reference/vit/sam/predict.md). +- More additional args for `Segment everything` see [`Predictor/generate` Reference](../reference/models/sam/predict.md). ## Available Models and Supported Tasks @@ -184,7 +184,7 @@ Auto-annotation is a key feature of SAM, allowing users to generate a [segmentat To auto-annotate your dataset with the Ultralytics framework, use the `auto_annotate` function as shown below: ```python -from ultralytics.yolo.data.annotator import auto_annotate +from ultralytics.data.annotator import auto_annotate auto_annotate(data="path/to/images", det_model="yolov8x.pt", sam_model='sam_b.pt') ``` diff --git a/docs/modes/benchmark.md b/docs/modes/benchmark.md index 0c5b35f..9ce6221 100644 --- a/docs/modes/benchmark.md +++ b/docs/modes/benchmark.md @@ -27,7 +27,7 @@ full list of export arguments. === "Python" ```python - from ultralytics.yolo.utils.benchmarks import benchmark + from ultralytics.utils.benchmarks import benchmark # Benchmark on GPU benchmark(model='yolov8n.pt', imgsz=640, half=False, device=0) diff --git a/docs/modes/predict.md b/docs/modes/predict.md index 8708933..7a6bf82 100644 --- a/docs/modes/predict.md +++ b/docs/modes/predict.md @@ -316,7 +316,7 @@ All supported arguments: ## Image and Video Formats -YOLOv8 supports various image and video formats, as specified in [yolo/data/utils.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/yolo/data/utils.py). See the tables below for the valid suffixes and example predict commands. +YOLOv8 supports various image and video formats, as specified in [data/utils.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/data/utils.py). See the tables below for the valid suffixes and example predict commands. ### Image Suffixes @@ -451,7 +451,7 @@ operations are cached, meaning they're only calculated once per object, and thos keypoints.data # raw probs tensor, (num_class, ) ``` -Class reference documentation for `Results` module and its components can be found [here](../reference/yolo/engine/results.md) +Class reference documentation for `Results` module and its components can be found [here](../reference/engine/results.md) ## Plotting results diff --git a/docs/modes/track.md b/docs/modes/track.md index 7b9a83a..e0266b9 100644 --- a/docs/modes/track.md +++ b/docs/modes/track.md @@ -79,7 +79,7 @@ to [predict page](https://docs.ultralytics.com/modes/predict/). ### Tracker We also support using a modified tracker config file, just copy a config file i.e `custom_tracker.yaml` -from [ultralytics/tracker/cfg](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/tracker/cfg) and modify +from [ultralytics/cfg/trackers](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/cfg/trackers) and modify any configurations(expect the `tracker_type`) you need to. !!! example "" @@ -97,5 +97,5 @@ any configurations(expect the `tracker_type`) you need to. yolo track model=yolov8n.pt source="https://youtu.be/Zgi9g1ksQHc" tracker='custom_tracker.yaml' ``` -Please refer to [ultralytics/tracker/cfg](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/tracker/cfg) +Please refer to [ultralytics/cfg/trackers](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/cfg/trackers) page \ No newline at end of file diff --git a/docs/reference/cfg/__init__.md b/docs/reference/cfg/__init__.md new file mode 100644 index 0000000..a30308c --- /dev/null +++ b/docs/reference/cfg/__init__.md @@ -0,0 +1,44 @@ +## cfg2dict +--- +### ::: ultralytics.cfg.cfg2dict +

+ +## get_cfg +--- +### ::: ultralytics.cfg.get_cfg +

+ +## _handle_deprecation +--- +### ::: ultralytics.cfg._handle_deprecation +

+ +## check_cfg_mismatch +--- +### ::: ultralytics.cfg.check_cfg_mismatch +

+ +## merge_equals_args +--- +### ::: ultralytics.cfg.merge_equals_args +

+ +## handle_yolo_hub +--- +### ::: ultralytics.cfg.handle_yolo_hub +

+ +## handle_yolo_settings +--- +### ::: ultralytics.cfg.handle_yolo_settings +

+ +## entrypoint +--- +### ::: ultralytics.cfg.entrypoint +

+ +## copy_default_cfg +--- +### ::: ultralytics.cfg.copy_default_cfg +

diff --git a/docs/reference/data/annotator.md b/docs/reference/data/annotator.md new file mode 100644 index 0000000..6a58074 --- /dev/null +++ b/docs/reference/data/annotator.md @@ -0,0 +1,4 @@ +## auto_annotate +--- +### ::: ultralytics.data.annotator.auto_annotate +

diff --git a/docs/reference/data/augment.md b/docs/reference/data/augment.md new file mode 100644 index 0000000..a3dbfea --- /dev/null +++ b/docs/reference/data/augment.md @@ -0,0 +1,94 @@ +## BaseTransform +--- +### ::: ultralytics.data.augment.BaseTransform +

+ +## Compose +--- +### ::: ultralytics.data.augment.Compose +

+ +## BaseMixTransform +--- +### ::: ultralytics.data.augment.BaseMixTransform +

+ +## Mosaic +--- +### ::: ultralytics.data.augment.Mosaic +

+ +## MixUp +--- +### ::: ultralytics.data.augment.MixUp +

+ +## RandomPerspective +--- +### ::: ultralytics.data.augment.RandomPerspective +

+ +## RandomHSV +--- +### ::: ultralytics.data.augment.RandomHSV +

+ +## RandomFlip +--- +### ::: ultralytics.data.augment.RandomFlip +

+ +## LetterBox +--- +### ::: ultralytics.data.augment.LetterBox +

+ +## CopyPaste +--- +### ::: ultralytics.data.augment.CopyPaste +

+ +## Albumentations +--- +### ::: ultralytics.data.augment.Albumentations +

+ +## Format +--- +### ::: ultralytics.data.augment.Format +

+ +## ClassifyLetterBox +--- +### ::: ultralytics.data.augment.ClassifyLetterBox +

+ +## CenterCrop +--- +### ::: ultralytics.data.augment.CenterCrop +

+ +## ToTensor +--- +### ::: ultralytics.data.augment.ToTensor +

+ +## v8_transforms +--- +### ::: ultralytics.data.augment.v8_transforms +

+ +## classify_transforms +--- +### ::: ultralytics.data.augment.classify_transforms +

+ +## hsv2colorjitter +--- +### ::: ultralytics.data.augment.hsv2colorjitter +

+ +## classify_albumentations +--- +### ::: ultralytics.data.augment.classify_albumentations +

diff --git a/docs/reference/data/base.md b/docs/reference/data/base.md new file mode 100644 index 0000000..65aadce --- /dev/null +++ b/docs/reference/data/base.md @@ -0,0 +1,4 @@ +## BaseDataset +--- +### ::: ultralytics.data.base.BaseDataset +

diff --git a/docs/reference/data/build.md b/docs/reference/data/build.md new file mode 100644 index 0000000..fa7e271 --- /dev/null +++ b/docs/reference/data/build.md @@ -0,0 +1,34 @@ +## InfiniteDataLoader +--- +### ::: ultralytics.data.build.InfiniteDataLoader +

+ +## _RepeatSampler +--- +### ::: ultralytics.data.build._RepeatSampler +

+ +## seed_worker +--- +### ::: ultralytics.data.build.seed_worker +

+ +## build_yolo_dataset +--- +### ::: ultralytics.data.build.build_yolo_dataset +

+ +## build_dataloader +--- +### ::: ultralytics.data.build.build_dataloader +

+ +## check_source +--- +### ::: ultralytics.data.build.check_source +

+ +## load_inference_source +--- +### ::: ultralytics.data.build.load_inference_source +

diff --git a/docs/reference/data/converter.md b/docs/reference/data/converter.md new file mode 100644 index 0000000..c38e078 --- /dev/null +++ b/docs/reference/data/converter.md @@ -0,0 +1,29 @@ +## coco91_to_coco80_class +--- +### ::: ultralytics.data.converter.coco91_to_coco80_class +

+ +## convert_coco +--- +### ::: ultralytics.data.converter.convert_coco +

+ +## rle2polygon +--- +### ::: ultralytics.data.converter.rle2polygon +

+ +## min_index +--- +### ::: ultralytics.data.converter.min_index +

+ +## merge_multi_segment +--- +### ::: ultralytics.data.converter.merge_multi_segment +

+ +## delete_dsstore +--- +### ::: ultralytics.data.converter.delete_dsstore +

diff --git a/docs/reference/data/dataset.md b/docs/reference/data/dataset.md new file mode 100644 index 0000000..6d69959 --- /dev/null +++ b/docs/reference/data/dataset.md @@ -0,0 +1,14 @@ +## YOLODataset +--- +### ::: ultralytics.data.dataset.YOLODataset +

+ +## ClassificationDataset +--- +### ::: ultralytics.data.dataset.ClassificationDataset +

+ +## SemanticDataset +--- +### ::: ultralytics.data.dataset.SemanticDataset +

diff --git a/docs/reference/data/loaders.md b/docs/reference/data/loaders.md new file mode 100644 index 0000000..3c98d8f --- /dev/null +++ b/docs/reference/data/loaders.md @@ -0,0 +1,39 @@ +## SourceTypes +--- +### ::: ultralytics.data.loaders.SourceTypes +

+ +## LoadStreams +--- +### ::: ultralytics.data.loaders.LoadStreams +

+ +## LoadScreenshots +--- +### ::: ultralytics.data.loaders.LoadScreenshots +

+ +## LoadImages +--- +### ::: ultralytics.data.loaders.LoadImages +

+ +## LoadPilAndNumpy +--- +### ::: ultralytics.data.loaders.LoadPilAndNumpy +

+ +## LoadTensor +--- +### ::: ultralytics.data.loaders.LoadTensor +

+ +## autocast_list +--- +### ::: ultralytics.data.loaders.autocast_list +

+ +## get_best_youtube_url +--- +### ::: ultralytics.data.loaders.get_best_youtube_url +

diff --git a/docs/reference/data/utils.md b/docs/reference/data/utils.md new file mode 100644 index 0000000..6d471cc --- /dev/null +++ b/docs/reference/data/utils.md @@ -0,0 +1,69 @@ +## HUBDatasetStats +--- +### ::: ultralytics.data.utils.HUBDatasetStats +

+ +## img2label_paths +--- +### ::: ultralytics.data.utils.img2label_paths +

+ +## get_hash +--- +### ::: ultralytics.data.utils.get_hash +

+ +## exif_size +--- +### ::: ultralytics.data.utils.exif_size +

+ +## verify_image_label +--- +### ::: ultralytics.data.utils.verify_image_label +

+ +## polygon2mask +--- +### ::: ultralytics.data.utils.polygon2mask +

+ +## polygons2masks +--- +### ::: ultralytics.data.utils.polygons2masks +

+ +## polygons2masks_overlap +--- +### ::: ultralytics.data.utils.polygons2masks_overlap +

+ +## check_det_dataset +--- +### ::: ultralytics.data.utils.check_det_dataset +

+ +## check_cls_dataset +--- +### ::: ultralytics.data.utils.check_cls_dataset +

+ +## compress_one_image +--- +### ::: ultralytics.data.utils.compress_one_image +

+ +## delete_dsstore +--- +### ::: ultralytics.data.utils.delete_dsstore +

+ +## zip_directory +--- +### ::: ultralytics.data.utils.zip_directory +

+ +## autosplit +--- +### ::: ultralytics.data.utils.autosplit +

diff --git a/docs/reference/engine/exporter.md b/docs/reference/engine/exporter.md new file mode 100644 index 0000000..662f74a --- /dev/null +++ b/docs/reference/engine/exporter.md @@ -0,0 +1,29 @@ +## Exporter +--- +### ::: ultralytics.engine.exporter.Exporter +

+ +## iOSDetectModel +--- +### ::: ultralytics.engine.exporter.iOSDetectModel +

+ +## export_formats +--- +### ::: ultralytics.engine.exporter.export_formats +

+ +## gd_outputs +--- +### ::: ultralytics.engine.exporter.gd_outputs +

+ +## try_export +--- +### ::: ultralytics.engine.exporter.try_export +

+ +## export +--- +### ::: ultralytics.engine.exporter.export +

diff --git a/docs/reference/engine/model.md b/docs/reference/engine/model.md new file mode 100644 index 0000000..4343325 --- /dev/null +++ b/docs/reference/engine/model.md @@ -0,0 +1,4 @@ +## YOLO +--- +### ::: ultralytics.engine.model.YOLO +

diff --git a/docs/reference/engine/predictor.md b/docs/reference/engine/predictor.md new file mode 100644 index 0000000..8c3d3c3 --- /dev/null +++ b/docs/reference/engine/predictor.md @@ -0,0 +1,4 @@ +## BasePredictor +--- +### ::: ultralytics.engine.predictor.BasePredictor +

diff --git a/docs/reference/engine/results.md b/docs/reference/engine/results.md new file mode 100644 index 0000000..ec3a09f --- /dev/null +++ b/docs/reference/engine/results.md @@ -0,0 +1,29 @@ +## BaseTensor +--- +### ::: ultralytics.engine.results.BaseTensor +

+ +## Results +--- +### ::: ultralytics.engine.results.Results +

+ +## Boxes +--- +### ::: ultralytics.engine.results.Boxes +

+ +## Masks +--- +### ::: ultralytics.engine.results.Masks +

+ +## Keypoints +--- +### ::: ultralytics.engine.results.Keypoints +

+ +## Probs +--- +### ::: ultralytics.engine.results.Probs +

diff --git a/docs/reference/engine/trainer.md b/docs/reference/engine/trainer.md new file mode 100644 index 0000000..e215a44 --- /dev/null +++ b/docs/reference/engine/trainer.md @@ -0,0 +1,4 @@ +## BaseTrainer +--- +### ::: ultralytics.engine.trainer.BaseTrainer +

diff --git a/docs/reference/engine/validator.md b/docs/reference/engine/validator.md new file mode 100644 index 0000000..1927114 --- /dev/null +++ b/docs/reference/engine/validator.md @@ -0,0 +1,4 @@ +## BaseValidator +--- +### ::: ultralytics.engine.validator.BaseValidator +

diff --git a/docs/reference/hub/__init__.md b/docs/reference/hub/__init__.md index 767ec14..93c9bef 100644 --- a/docs/reference/hub/__init__.md +++ b/docs/reference/hub/__init__.md @@ -1,8 +1,3 @@ ---- -description: Access Ultralytics HUB, manage API keys, train models, and export in various formats with ease using the HUB API. -keywords: Ultralytics, YOLO, Docs HUB, API, login, logout, reset model, export model, check dataset, HUBDatasetStats, YOLO training, YOLO model ---- - ## login --- ### ::: ultralytics.hub.login diff --git a/docs/reference/hub/auth.md b/docs/reference/hub/auth.md index 2098e8e..d293b4c 100644 --- a/docs/reference/hub/auth.md +++ b/docs/reference/hub/auth.md @@ -1,8 +1,3 @@ ---- -description: Learn how to use Ultralytics hub authentication in your projects with examples and guidelines from the Auth page on Ultralytics Docs. -keywords: Ultralytics, ultralytics hub, api keys, authentication, collab accounts, requests, hub management, monitoring ---- - ## Auth --- ### ::: ultralytics.hub.auth.Auth diff --git a/docs/reference/hub/session.md b/docs/reference/hub/session.md index 8fe82c4..6863c5a 100644 --- a/docs/reference/hub/session.md +++ b/docs/reference/hub/session.md @@ -1,8 +1,3 @@ ---- -description: Accelerate your AI development with the Ultralytics HUB Training Session. High-performance training of object detection models. -keywords: YOLOv5, object detection, HUBTrainingSession, custom models, Ultralytics Docs ---- - ## HUBTrainingSession --- ### ::: ultralytics.hub.session.HUBTrainingSession diff --git a/docs/reference/hub/utils.md b/docs/reference/hub/utils.md index 9b896b0..2d78273 100644 --- a/docs/reference/hub/utils.md +++ b/docs/reference/hub/utils.md @@ -1,8 +1,3 @@ ---- -description: Explore Ultralytics events, including 'request_with_credentials' and 'smart_request', to improve your project's performance and efficiency. -keywords: Ultralytics, Hub Utils, API Documentation, Python, requests_with_progress, Events, classes, usage, examples ---- - ## Events --- ### ::: ultralytics.hub.utils.Events diff --git a/docs/reference/models/fastsam/model.md b/docs/reference/models/fastsam/model.md new file mode 100644 index 0000000..0dd097c --- /dev/null +++ b/docs/reference/models/fastsam/model.md @@ -0,0 +1,4 @@ +## FastSAM +--- +### ::: ultralytics.models.fastsam.model.FastSAM +

diff --git a/docs/reference/models/fastsam/predict.md b/docs/reference/models/fastsam/predict.md new file mode 100644 index 0000000..59080e7 --- /dev/null +++ b/docs/reference/models/fastsam/predict.md @@ -0,0 +1,4 @@ +## FastSAMPredictor +--- +### ::: ultralytics.models.fastsam.predict.FastSAMPredictor +

diff --git a/docs/reference/models/fastsam/prompt.md b/docs/reference/models/fastsam/prompt.md new file mode 100644 index 0000000..a8e4df0 --- /dev/null +++ b/docs/reference/models/fastsam/prompt.md @@ -0,0 +1,4 @@ +## FastSAMPrompt +--- +### ::: ultralytics.models.fastsam.prompt.FastSAMPrompt +

diff --git a/docs/reference/models/fastsam/utils.md b/docs/reference/models/fastsam/utils.md new file mode 100644 index 0000000..0b6659a --- /dev/null +++ b/docs/reference/models/fastsam/utils.md @@ -0,0 +1,9 @@ +## adjust_bboxes_to_image_border +--- +### ::: ultralytics.models.fastsam.utils.adjust_bboxes_to_image_border +

+ +## bbox_iou +--- +### ::: ultralytics.models.fastsam.utils.bbox_iou +

diff --git a/docs/reference/models/fastsam/val.md b/docs/reference/models/fastsam/val.md new file mode 100644 index 0000000..b72c06a --- /dev/null +++ b/docs/reference/models/fastsam/val.md @@ -0,0 +1,4 @@ +## FastSAMValidator +--- +### ::: ultralytics.models.fastsam.val.FastSAMValidator +

diff --git a/docs/reference/models/nas/model.md b/docs/reference/models/nas/model.md new file mode 100644 index 0000000..48912a3 --- /dev/null +++ b/docs/reference/models/nas/model.md @@ -0,0 +1,4 @@ +## NAS +--- +### ::: ultralytics.models.nas.model.NAS +

diff --git a/docs/reference/models/nas/predict.md b/docs/reference/models/nas/predict.md new file mode 100644 index 0000000..e54fb3a --- /dev/null +++ b/docs/reference/models/nas/predict.md @@ -0,0 +1,4 @@ +## NASPredictor +--- +### ::: ultralytics.models.nas.predict.NASPredictor +

diff --git a/docs/reference/models/nas/val.md b/docs/reference/models/nas/val.md new file mode 100644 index 0000000..150ee0a --- /dev/null +++ b/docs/reference/models/nas/val.md @@ -0,0 +1,4 @@ +## NASValidator +--- +### ::: ultralytics.models.nas.val.NASValidator +

diff --git a/docs/reference/models/rtdetr/model.md b/docs/reference/models/rtdetr/model.md new file mode 100644 index 0000000..3ad8c65 --- /dev/null +++ b/docs/reference/models/rtdetr/model.md @@ -0,0 +1,4 @@ +## RTDETR +--- +### ::: ultralytics.models.rtdetr.model.RTDETR +

diff --git a/docs/reference/models/rtdetr/predict.md b/docs/reference/models/rtdetr/predict.md new file mode 100644 index 0000000..9fc8f5a --- /dev/null +++ b/docs/reference/models/rtdetr/predict.md @@ -0,0 +1,4 @@ +## RTDETRPredictor +--- +### ::: ultralytics.models.rtdetr.predict.RTDETRPredictor +

diff --git a/docs/reference/models/rtdetr/train.md b/docs/reference/models/rtdetr/train.md new file mode 100644 index 0000000..2c559c6 --- /dev/null +++ b/docs/reference/models/rtdetr/train.md @@ -0,0 +1,9 @@ +## RTDETRTrainer +--- +### ::: ultralytics.models.rtdetr.train.RTDETRTrainer +

+ +## train +--- +### ::: ultralytics.models.rtdetr.train.train +

diff --git a/docs/reference/models/rtdetr/val.md b/docs/reference/models/rtdetr/val.md new file mode 100644 index 0000000..bffdf4c --- /dev/null +++ b/docs/reference/models/rtdetr/val.md @@ -0,0 +1,9 @@ +## RTDETRDataset +--- +### ::: ultralytics.models.rtdetr.val.RTDETRDataset +

+ +## RTDETRValidator +--- +### ::: ultralytics.models.rtdetr.val.RTDETRValidator +

diff --git a/docs/reference/models/sam/amg.md b/docs/reference/models/sam/amg.md new file mode 100644 index 0000000..8a4e56f --- /dev/null +++ b/docs/reference/models/sam/amg.md @@ -0,0 +1,84 @@ +## MaskData +--- +### ::: ultralytics.models.sam.amg.MaskData +

+ +## is_box_near_crop_edge +--- +### ::: ultralytics.models.sam.amg.is_box_near_crop_edge +

+ +## box_xyxy_to_xywh +--- +### ::: ultralytics.models.sam.amg.box_xyxy_to_xywh +

+ +## batch_iterator +--- +### ::: ultralytics.models.sam.amg.batch_iterator +

+ +## mask_to_rle_pytorch +--- +### ::: ultralytics.models.sam.amg.mask_to_rle_pytorch +

+ +## rle_to_mask +--- +### ::: ultralytics.models.sam.amg.rle_to_mask +

+ +## area_from_rle +--- +### ::: ultralytics.models.sam.amg.area_from_rle +

+ +## calculate_stability_score +--- +### ::: ultralytics.models.sam.amg.calculate_stability_score +

+ +## build_point_grid +--- +### ::: ultralytics.models.sam.amg.build_point_grid +

+ +## build_all_layer_point_grids +--- +### ::: ultralytics.models.sam.amg.build_all_layer_point_grids +

+ +## generate_crop_boxes +--- +### ::: ultralytics.models.sam.amg.generate_crop_boxes +

+ +## uncrop_boxes_xyxy +--- +### ::: ultralytics.models.sam.amg.uncrop_boxes_xyxy +

+ +## uncrop_points +--- +### ::: ultralytics.models.sam.amg.uncrop_points +

+ +## uncrop_masks +--- +### ::: ultralytics.models.sam.amg.uncrop_masks +

+ +## remove_small_regions +--- +### ::: ultralytics.models.sam.amg.remove_small_regions +

+ +## coco_encode_rle +--- +### ::: ultralytics.models.sam.amg.coco_encode_rle +

+ +## batched_mask_to_box +--- +### ::: ultralytics.models.sam.amg.batched_mask_to_box +

diff --git a/docs/reference/models/sam/build.md b/docs/reference/models/sam/build.md new file mode 100644 index 0000000..447ffd3 --- /dev/null +++ b/docs/reference/models/sam/build.md @@ -0,0 +1,29 @@ +## build_sam_vit_h +--- +### ::: ultralytics.models.sam.build.build_sam_vit_h +

+ +## build_sam_vit_l +--- +### ::: ultralytics.models.sam.build.build_sam_vit_l +

+ +## build_sam_vit_b +--- +### ::: ultralytics.models.sam.build.build_sam_vit_b +

+ +## build_mobile_sam +--- +### ::: ultralytics.models.sam.build.build_mobile_sam +

+ +## _build_sam +--- +### ::: ultralytics.models.sam.build._build_sam +

+ +## build_sam +--- +### ::: ultralytics.models.sam.build.build_sam +

diff --git a/docs/reference/models/sam/model.md b/docs/reference/models/sam/model.md new file mode 100644 index 0000000..ed2220d --- /dev/null +++ b/docs/reference/models/sam/model.md @@ -0,0 +1,4 @@ +## SAM +--- +### ::: ultralytics.models.sam.model.SAM +

diff --git a/docs/reference/models/sam/modules/decoders.md b/docs/reference/models/sam/modules/decoders.md new file mode 100644 index 0000000..3b37aaa --- /dev/null +++ b/docs/reference/models/sam/modules/decoders.md @@ -0,0 +1,9 @@ +## MaskDecoder +--- +### ::: ultralytics.models.sam.modules.decoders.MaskDecoder +

+ +## MLP +--- +### ::: ultralytics.models.sam.modules.decoders.MLP +

diff --git a/docs/reference/models/sam/modules/encoders.md b/docs/reference/models/sam/modules/encoders.md new file mode 100644 index 0000000..82ade99 --- /dev/null +++ b/docs/reference/models/sam/modules/encoders.md @@ -0,0 +1,49 @@ +## ImageEncoderViT +--- +### ::: ultralytics.models.sam.modules.encoders.ImageEncoderViT +

+ +## PromptEncoder +--- +### ::: ultralytics.models.sam.modules.encoders.PromptEncoder +

+ +## PositionEmbeddingRandom +--- +### ::: ultralytics.models.sam.modules.encoders.PositionEmbeddingRandom +

+ +## Block +--- +### ::: ultralytics.models.sam.modules.encoders.Block +

+ +## Attention +--- +### ::: ultralytics.models.sam.modules.encoders.Attention +

+ +## PatchEmbed +--- +### ::: ultralytics.models.sam.modules.encoders.PatchEmbed +

+ +## window_partition +--- +### ::: ultralytics.models.sam.modules.encoders.window_partition +

+ +## window_unpartition +--- +### ::: ultralytics.models.sam.modules.encoders.window_unpartition +

+ +## get_rel_pos +--- +### ::: ultralytics.models.sam.modules.encoders.get_rel_pos +

+ +## add_decomposed_rel_pos +--- +### ::: ultralytics.models.sam.modules.encoders.add_decomposed_rel_pos +

diff --git a/docs/reference/models/sam/modules/sam.md b/docs/reference/models/sam/modules/sam.md new file mode 100644 index 0000000..9063f5e --- /dev/null +++ b/docs/reference/models/sam/modules/sam.md @@ -0,0 +1,4 @@ +## Sam +--- +### ::: ultralytics.models.sam.modules.sam.Sam +

diff --git a/docs/reference/models/sam/modules/tiny_encoder.md b/docs/reference/models/sam/modules/tiny_encoder.md new file mode 100644 index 0000000..813f69a --- /dev/null +++ b/docs/reference/models/sam/modules/tiny_encoder.md @@ -0,0 +1,54 @@ +## Conv2d_BN +--- +### ::: ultralytics.models.sam.modules.tiny_encoder.Conv2d_BN +

+ +## PatchEmbed +--- +### ::: ultralytics.models.sam.modules.tiny_encoder.PatchEmbed +

+ +## MBConv +--- +### ::: ultralytics.models.sam.modules.tiny_encoder.MBConv +

+ +## PatchMerging +--- +### ::: ultralytics.models.sam.modules.tiny_encoder.PatchMerging +

+ +## ConvLayer +--- +### ::: ultralytics.models.sam.modules.tiny_encoder.ConvLayer +

+ +## Mlp +--- +### ::: ultralytics.models.sam.modules.tiny_encoder.Mlp +

+ +## Attention +--- +### ::: ultralytics.models.sam.modules.tiny_encoder.Attention +

+ +## TinyViTBlock +--- +### ::: ultralytics.models.sam.modules.tiny_encoder.TinyViTBlock +

+ +## BasicLayer +--- +### ::: ultralytics.models.sam.modules.tiny_encoder.BasicLayer +

+ +## LayerNorm2d +--- +### ::: ultralytics.models.sam.modules.tiny_encoder.LayerNorm2d +

+ +## TinyViT +--- +### ::: ultralytics.models.sam.modules.tiny_encoder.TinyViT +

diff --git a/docs/reference/models/sam/modules/transformer.md b/docs/reference/models/sam/modules/transformer.md new file mode 100644 index 0000000..70fd497 --- /dev/null +++ b/docs/reference/models/sam/modules/transformer.md @@ -0,0 +1,14 @@ +## TwoWayTransformer +--- +### ::: ultralytics.models.sam.modules.transformer.TwoWayTransformer +

+ +## TwoWayAttentionBlock +--- +### ::: ultralytics.models.sam.modules.transformer.TwoWayAttentionBlock +

+ +## Attention +--- +### ::: ultralytics.models.sam.modules.transformer.Attention +

diff --git a/docs/reference/models/sam/predict.md b/docs/reference/models/sam/predict.md new file mode 100644 index 0000000..038e176 --- /dev/null +++ b/docs/reference/models/sam/predict.md @@ -0,0 +1,4 @@ +## Predictor +--- +### ::: ultralytics.models.sam.predict.Predictor +

diff --git a/docs/reference/models/utils/loss.md b/docs/reference/models/utils/loss.md new file mode 100644 index 0000000..5b4e016 --- /dev/null +++ b/docs/reference/models/utils/loss.md @@ -0,0 +1,9 @@ +## DETRLoss +--- +### ::: ultralytics.models.utils.loss.DETRLoss +

+ +## RTDETRDetectionLoss +--- +### ::: ultralytics.models.utils.loss.RTDETRDetectionLoss +

diff --git a/docs/reference/models/utils/ops.md b/docs/reference/models/utils/ops.md new file mode 100644 index 0000000..ad639b2 --- /dev/null +++ b/docs/reference/models/utils/ops.md @@ -0,0 +1,14 @@ +## HungarianMatcher +--- +### ::: ultralytics.models.utils.ops.HungarianMatcher +

+ +## get_cdn_group +--- +### ::: ultralytics.models.utils.ops.get_cdn_group +

+ +## inverse_sigmoid +--- +### ::: ultralytics.models.utils.ops.inverse_sigmoid +

diff --git a/docs/reference/models/yolo/classify/predict.md b/docs/reference/models/yolo/classify/predict.md new file mode 100644 index 0000000..ce1a554 --- /dev/null +++ b/docs/reference/models/yolo/classify/predict.md @@ -0,0 +1,9 @@ +## ClassificationPredictor +--- +### ::: ultralytics.models.yolo.classify.predict.ClassificationPredictor +

+ +## predict +--- +### ::: ultralytics.models.yolo.classify.predict.predict +

diff --git a/docs/reference/models/yolo/classify/train.md b/docs/reference/models/yolo/classify/train.md new file mode 100644 index 0000000..0b505e6 --- /dev/null +++ b/docs/reference/models/yolo/classify/train.md @@ -0,0 +1,9 @@ +## ClassificationTrainer +--- +### ::: ultralytics.models.yolo.classify.train.ClassificationTrainer +

+ +## train +--- +### ::: ultralytics.models.yolo.classify.train.train +

diff --git a/docs/reference/models/yolo/classify/val.md b/docs/reference/models/yolo/classify/val.md new file mode 100644 index 0000000..20038c5 --- /dev/null +++ b/docs/reference/models/yolo/classify/val.md @@ -0,0 +1,9 @@ +## ClassificationValidator +--- +### ::: ultralytics.models.yolo.classify.val.ClassificationValidator +

+ +## val +--- +### ::: ultralytics.models.yolo.classify.val.val +

diff --git a/docs/reference/models/yolo/detect/predict.md b/docs/reference/models/yolo/detect/predict.md new file mode 100644 index 0000000..91b5438 --- /dev/null +++ b/docs/reference/models/yolo/detect/predict.md @@ -0,0 +1,9 @@ +## DetectionPredictor +--- +### ::: ultralytics.models.yolo.detect.predict.DetectionPredictor +

+ +## predict +--- +### ::: ultralytics.models.yolo.detect.predict.predict +

diff --git a/docs/reference/models/yolo/detect/train.md b/docs/reference/models/yolo/detect/train.md new file mode 100644 index 0000000..a034a7a --- /dev/null +++ b/docs/reference/models/yolo/detect/train.md @@ -0,0 +1,9 @@ +## DetectionTrainer +--- +### ::: ultralytics.models.yolo.detect.train.DetectionTrainer +

+ +## train +--- +### ::: ultralytics.models.yolo.detect.train.train +

diff --git a/docs/reference/models/yolo/detect/val.md b/docs/reference/models/yolo/detect/val.md new file mode 100644 index 0000000..3ce0496 --- /dev/null +++ b/docs/reference/models/yolo/detect/val.md @@ -0,0 +1,9 @@ +## DetectionValidator +--- +### ::: ultralytics.models.yolo.detect.val.DetectionValidator +

+ +## val +--- +### ::: ultralytics.models.yolo.detect.val.val +

diff --git a/docs/reference/models/yolo/pose/predict.md b/docs/reference/models/yolo/pose/predict.md new file mode 100644 index 0000000..589621e --- /dev/null +++ b/docs/reference/models/yolo/pose/predict.md @@ -0,0 +1,9 @@ +## PosePredictor +--- +### ::: ultralytics.models.yolo.pose.predict.PosePredictor +

+ +## predict +--- +### ::: ultralytics.models.yolo.pose.predict.predict +

diff --git a/docs/reference/models/yolo/pose/train.md b/docs/reference/models/yolo/pose/train.md new file mode 100644 index 0000000..f407029 --- /dev/null +++ b/docs/reference/models/yolo/pose/train.md @@ -0,0 +1,9 @@ +## PoseTrainer +--- +### ::: ultralytics.models.yolo.pose.train.PoseTrainer +

+ +## train +--- +### ::: ultralytics.models.yolo.pose.train.train +

diff --git a/docs/reference/models/yolo/pose/val.md b/docs/reference/models/yolo/pose/val.md new file mode 100644 index 0000000..443cb84 --- /dev/null +++ b/docs/reference/models/yolo/pose/val.md @@ -0,0 +1,9 @@ +## PoseValidator +--- +### ::: ultralytics.models.yolo.pose.val.PoseValidator +

+ +## val +--- +### ::: ultralytics.models.yolo.pose.val.val +

diff --git a/docs/reference/models/yolo/segment/predict.md b/docs/reference/models/yolo/segment/predict.md new file mode 100644 index 0000000..39b005f --- /dev/null +++ b/docs/reference/models/yolo/segment/predict.md @@ -0,0 +1,9 @@ +## SegmentationPredictor +--- +### ::: ultralytics.models.yolo.segment.predict.SegmentationPredictor +

+ +## predict +--- +### ::: ultralytics.models.yolo.segment.predict.predict +

diff --git a/docs/reference/models/yolo/segment/train.md b/docs/reference/models/yolo/segment/train.md new file mode 100644 index 0000000..36822ed --- /dev/null +++ b/docs/reference/models/yolo/segment/train.md @@ -0,0 +1,9 @@ +## SegmentationTrainer +--- +### ::: ultralytics.models.yolo.segment.train.SegmentationTrainer +

+ +## train +--- +### ::: ultralytics.models.yolo.segment.train.train +

diff --git a/docs/reference/models/yolo/segment/val.md b/docs/reference/models/yolo/segment/val.md new file mode 100644 index 0000000..82afadd --- /dev/null +++ b/docs/reference/models/yolo/segment/val.md @@ -0,0 +1,9 @@ +## SegmentationValidator +--- +### ::: ultralytics.models.yolo.segment.val.SegmentationValidator +

+ +## val +--- +### ::: ultralytics.models.yolo.segment.val.val +

diff --git a/docs/reference/nn/autobackend.md b/docs/reference/nn/autobackend.md index ccd1077..6c4ffd1 100644 --- a/docs/reference/nn/autobackend.md +++ b/docs/reference/nn/autobackend.md @@ -1,8 +1,3 @@ ---- -description: Ensure class names match filenames for easy imports. Use AutoBackend to automatically rename and refactor model files. -keywords: AutoBackend, ultralytics, nn, autobackend, check class names, neural network ---- - ## AutoBackend --- ### ::: ultralytics.nn.autobackend.AutoBackend diff --git a/docs/reference/nn/modules/block.md b/docs/reference/nn/modules/block.md index 3f1a548..7e30b64 100644 --- a/docs/reference/nn/modules/block.md +++ b/docs/reference/nn/modules/block.md @@ -1,8 +1,3 @@ ---- -description: Explore ultralytics.nn.modules.block to build powerful YOLO object detection models. Master DFL, HGStem, SPP, CSP components and more. -keywords: Ultralytics, NN Modules, Blocks, DFL, HGStem, SPP, C1, C2f, C3x, C3TR, GhostBottleneck, BottleneckCSP, Computer Vision ---- - ## DFL --- ### ::: ultralytics.nn.modules.block.DFL diff --git a/docs/reference/nn/modules/conv.md b/docs/reference/nn/modules/conv.md index 6a5df52..8823546 100644 --- a/docs/reference/nn/modules/conv.md +++ b/docs/reference/nn/modules/conv.md @@ -1,8 +1,3 @@ ---- -description: Explore convolutional neural network modules & techniques such as LightConv, DWConv, ConvTranspose, GhostConv, CBAM & autopad with Ultralytics Docs. -keywords: Ultralytics, Convolutional Neural Network, Conv2, DWConv, ConvTranspose, GhostConv, ChannelAttention, CBAM, autopad ---- - ## Conv --- ### ::: ultralytics.nn.modules.conv.Conv diff --git a/docs/reference/nn/modules/head.md b/docs/reference/nn/modules/head.md index 7a460b5..7f055e8 100644 --- a/docs/reference/nn/modules/head.md +++ b/docs/reference/nn/modules/head.md @@ -1,8 +1,3 @@ ---- -description: 'Learn about Ultralytics YOLO modules: Segment, Classify, and RTDETRDecoder. Optimize object detection and classification in your project.' -keywords: Ultralytics, YOLO, object detection, pose estimation, RTDETRDecoder, modules, classes, documentation ---- - ## Detect --- ### ::: ultralytics.nn.modules.head.Detect diff --git a/docs/reference/nn/modules/transformer.md b/docs/reference/nn/modules/transformer.md index a927f9b..918178a 100644 --- a/docs/reference/nn/modules/transformer.md +++ b/docs/reference/nn/modules/transformer.md @@ -1,8 +1,3 @@ ---- -description: Explore the Ultralytics nn modules pages on Transformer and MLP blocks, LayerNorm2d, and Deformable Transformer Decoder Layer. -keywords: Ultralytics, NN Modules, TransformerEncoderLayer, TransformerLayer, MLPBlock, LayerNorm2d, DeformableTransformerDecoderLayer, examples, code snippets, tutorials ---- - ## TransformerEncoderLayer --- ### ::: ultralytics.nn.modules.transformer.TransformerEncoderLayer diff --git a/docs/reference/nn/modules/utils.md b/docs/reference/nn/modules/utils.md index 94c4f3e..740f58d 100644 --- a/docs/reference/nn/modules/utils.md +++ b/docs/reference/nn/modules/utils.md @@ -1,8 +1,3 @@ ---- -description: 'Learn about Ultralytics NN modules: get_clones, linear_init_, and multi_scale_deformable_attn_pytorch. Code examples and usage tips.' -keywords: Ultralytics, NN Utils, Docs, PyTorch, bias initialization, linear initialization, multi-scale deformable attention ---- - ## _get_clones --- ### ::: ultralytics.nn.modules.utils._get_clones diff --git a/docs/reference/nn/tasks.md b/docs/reference/nn/tasks.md index 010cea1..8285fa4 100644 --- a/docs/reference/nn/tasks.md +++ b/docs/reference/nn/tasks.md @@ -1,8 +1,3 @@ ---- -description: Learn how to work with Ultralytics YOLO Detection, Segmentation & Classification Models, load weights and parse models in PyTorch. -keywords: neural network, deep learning, computer vision, object detection, image segmentation, image classification, model ensemble, PyTorch ---- - ## BaseModel --- ### ::: ultralytics.nn.tasks.BaseModel @@ -38,6 +33,11 @@ keywords: neural network, deep learning, computer vision, object detection, imag ### ::: ultralytics.nn.tasks.Ensemble

+## temporary_modules +--- +### ::: ultralytics.nn.tasks.temporary_modules +

+ ## torch_safe_load --- ### ::: ultralytics.nn.tasks.torch_safe_load diff --git a/docs/reference/tracker/track.md b/docs/reference/tracker/track.md deleted file mode 100644 index 88db7f2..0000000 --- a/docs/reference/tracker/track.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -description: Learn how to register custom event-tracking and track predictions with Ultralytics YOLO via on_predict_start and register_tracker methods. -keywords: Ultralytics YOLO, tracker registration, on_predict_start, object detection ---- - -## on_predict_start ---- -### ::: ultralytics.tracker.track.on_predict_start -

- -## on_predict_postprocess_end ---- -### ::: ultralytics.tracker.track.on_predict_postprocess_end -

- -## register_tracker ---- -### ::: ultralytics.tracker.track.register_tracker -

diff --git a/docs/reference/tracker/trackers/basetrack.md b/docs/reference/tracker/trackers/basetrack.md deleted file mode 100644 index ab5cf58..0000000 --- a/docs/reference/tracker/trackers/basetrack.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -description: 'TrackState: A comprehensive guide to Ultralytics tracker''s BaseTrack for monitoring model performance. Improve your tracking capabilities now!' -keywords: object detection, object tracking, Ultralytics YOLO, TrackState, workflow improvement ---- - -## TrackState ---- -### ::: ultralytics.tracker.trackers.basetrack.TrackState -

- -## BaseTrack ---- -### ::: ultralytics.tracker.trackers.basetrack.BaseTrack -

diff --git a/docs/reference/tracker/trackers/bot_sort.md b/docs/reference/tracker/trackers/bot_sort.md deleted file mode 100644 index b53e9b1..0000000 --- a/docs/reference/tracker/trackers/bot_sort.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -description: '"Optimize tracking with Ultralytics BOTrack. Easily sort and track bots with BOTSORT. Streamline data collection for improved performance."' -keywords: BOTrack, Ultralytics YOLO Docs, features, usage ---- - -## BOTrack ---- -### ::: ultralytics.tracker.trackers.bot_sort.BOTrack -

- -## BOTSORT ---- -### ::: ultralytics.tracker.trackers.bot_sort.BOTSORT -

diff --git a/docs/reference/tracker/trackers/byte_tracker.md b/docs/reference/tracker/trackers/byte_tracker.md deleted file mode 100644 index 797be1d..0000000 --- a/docs/reference/tracker/trackers/byte_tracker.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -description: Learn how to track ByteAI model sizes and tips for model optimization with STrack, a byte tracking tool from Ultralytics. -keywords: Byte Tracker, Ultralytics STrack, application monitoring, bytes sent, bytes received, code examples, setup instructions ---- - -## STrack ---- -### ::: ultralytics.tracker.trackers.byte_tracker.STrack -

- -## BYTETracker ---- -### ::: ultralytics.tracker.trackers.byte_tracker.BYTETracker -

diff --git a/docs/reference/tracker/utils/gmc.md b/docs/reference/tracker/utils/gmc.md deleted file mode 100644 index 6441f07..0000000 --- a/docs/reference/tracker/utils/gmc.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -description: '"Track Google Marketing Campaigns in GMC with Ultralytics Tracker. Learn to set up and use GMC for detailed analytics. Get started now."' -keywords: Ultralytics, YOLO, object detection, tracker, optimization, models, documentation ---- - -## GMC ---- -### ::: ultralytics.tracker.utils.gmc.GMC -

diff --git a/docs/reference/tracker/utils/kalman_filter.md b/docs/reference/tracker/utils/kalman_filter.md deleted file mode 100644 index fbe5473..0000000 --- a/docs/reference/tracker/utils/kalman_filter.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -description: Improve object tracking with KalmanFilterXYAH in Ultralytics YOLO - an efficient and accurate algorithm for state estimation. -keywords: KalmanFilterXYAH, Ultralytics Docs, Kalman filter algorithm, object tracking, computer vision, YOLO ---- - -## KalmanFilterXYAH ---- -### ::: ultralytics.tracker.utils.kalman_filter.KalmanFilterXYAH -

- -## KalmanFilterXYWH ---- -### ::: ultralytics.tracker.utils.kalman_filter.KalmanFilterXYWH -

diff --git a/docs/reference/tracker/utils/matching.md b/docs/reference/tracker/utils/matching.md deleted file mode 100644 index 385b39c..0000000 --- a/docs/reference/tracker/utils/matching.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -description: Learn how to match and fuse object detections for accurate target tracking using Ultralytics' YOLO merge_matches, iou_distance, and embedding_distance. -keywords: Ultralytics, multi-object tracking, object tracking, detection, recognition, matching, indices, iou distance, gate cost matrix, fuse iou, bbox ious ---- - -## merge_matches ---- -### ::: ultralytics.tracker.utils.matching.merge_matches -

- -## _indices_to_matches ---- -### ::: ultralytics.tracker.utils.matching._indices_to_matches -

- -## linear_assignment ---- -### ::: ultralytics.tracker.utils.matching.linear_assignment -

- -## ious ---- -### ::: ultralytics.tracker.utils.matching.ious -

- -## iou_distance ---- -### ::: ultralytics.tracker.utils.matching.iou_distance -

- -## v_iou_distance ---- -### ::: ultralytics.tracker.utils.matching.v_iou_distance -

- -## embedding_distance ---- -### ::: ultralytics.tracker.utils.matching.embedding_distance -

- -## gate_cost_matrix ---- -### ::: ultralytics.tracker.utils.matching.gate_cost_matrix -

- -## fuse_motion ---- -### ::: ultralytics.tracker.utils.matching.fuse_motion -

- -## fuse_iou ---- -### ::: ultralytics.tracker.utils.matching.fuse_iou -

- -## fuse_score ---- -### ::: ultralytics.tracker.utils.matching.fuse_score -

- -## bbox_ious ---- -### ::: ultralytics.tracker.utils.matching.bbox_ious -

diff --git a/docs/reference/trackers/basetrack.md b/docs/reference/trackers/basetrack.md new file mode 100644 index 0000000..6118833 --- /dev/null +++ b/docs/reference/trackers/basetrack.md @@ -0,0 +1,9 @@ +## TrackState +--- +### ::: ultralytics.trackers.basetrack.TrackState +

+ +## BaseTrack +--- +### ::: ultralytics.trackers.basetrack.BaseTrack +

diff --git a/docs/reference/trackers/bot_sort.md b/docs/reference/trackers/bot_sort.md new file mode 100644 index 0000000..d0dbc69 --- /dev/null +++ b/docs/reference/trackers/bot_sort.md @@ -0,0 +1,9 @@ +## BOTrack +--- +### ::: ultralytics.trackers.bot_sort.BOTrack +

+ +## BOTSORT +--- +### ::: ultralytics.trackers.bot_sort.BOTSORT +

diff --git a/docs/reference/trackers/byte_tracker.md b/docs/reference/trackers/byte_tracker.md new file mode 100644 index 0000000..f480c5a --- /dev/null +++ b/docs/reference/trackers/byte_tracker.md @@ -0,0 +1,9 @@ +## STrack +--- +### ::: ultralytics.trackers.byte_tracker.STrack +

+ +## BYTETracker +--- +### ::: ultralytics.trackers.byte_tracker.BYTETracker +

diff --git a/docs/reference/trackers/track.md b/docs/reference/trackers/track.md new file mode 100644 index 0000000..bba3d0a --- /dev/null +++ b/docs/reference/trackers/track.md @@ -0,0 +1,14 @@ +## on_predict_start +--- +### ::: ultralytics.trackers.track.on_predict_start +

+ +## on_predict_postprocess_end +--- +### ::: ultralytics.trackers.track.on_predict_postprocess_end +

+ +## register_tracker +--- +### ::: ultralytics.trackers.track.register_tracker +

diff --git a/docs/reference/trackers/utils/gmc.md b/docs/reference/trackers/utils/gmc.md new file mode 100644 index 0000000..299458a --- /dev/null +++ b/docs/reference/trackers/utils/gmc.md @@ -0,0 +1,4 @@ +## GMC +--- +### ::: ultralytics.trackers.utils.gmc.GMC +

diff --git a/docs/reference/trackers/utils/kalman_filter.md b/docs/reference/trackers/utils/kalman_filter.md new file mode 100644 index 0000000..3502d74 --- /dev/null +++ b/docs/reference/trackers/utils/kalman_filter.md @@ -0,0 +1,9 @@ +## KalmanFilterXYAH +--- +### ::: ultralytics.trackers.utils.kalman_filter.KalmanFilterXYAH +

+ +## KalmanFilterXYWH +--- +### ::: ultralytics.trackers.utils.kalman_filter.KalmanFilterXYWH +

diff --git a/docs/reference/trackers/utils/matching.md b/docs/reference/trackers/utils/matching.md new file mode 100644 index 0000000..a90eb12 --- /dev/null +++ b/docs/reference/trackers/utils/matching.md @@ -0,0 +1,59 @@ +## merge_matches +--- +### ::: ultralytics.trackers.utils.matching.merge_matches +

+ +## _indices_to_matches +--- +### ::: ultralytics.trackers.utils.matching._indices_to_matches +

+ +## linear_assignment +--- +### ::: ultralytics.trackers.utils.matching.linear_assignment +

+ +## ious +--- +### ::: ultralytics.trackers.utils.matching.ious +

+ +## iou_distance +--- +### ::: ultralytics.trackers.utils.matching.iou_distance +

+ +## v_iou_distance +--- +### ::: ultralytics.trackers.utils.matching.v_iou_distance +

+ +## embedding_distance +--- +### ::: ultralytics.trackers.utils.matching.embedding_distance +

+ +## gate_cost_matrix +--- +### ::: ultralytics.trackers.utils.matching.gate_cost_matrix +

+ +## fuse_motion +--- +### ::: ultralytics.trackers.utils.matching.fuse_motion +

+ +## fuse_iou +--- +### ::: ultralytics.trackers.utils.matching.fuse_iou +

+ +## fuse_score +--- +### ::: ultralytics.trackers.utils.matching.fuse_score +

+ +## bbox_ious +--- +### ::: ultralytics.trackers.utils.matching.bbox_ious +

diff --git a/docs/reference/utils/__init__.md b/docs/reference/utils/__init__.md new file mode 100644 index 0000000..bdf9f6d --- /dev/null +++ b/docs/reference/utils/__init__.md @@ -0,0 +1,169 @@ +## SimpleClass +--- +### ::: ultralytics.utils.SimpleClass +

+ +## IterableSimpleNamespace +--- +### ::: ultralytics.utils.IterableSimpleNamespace +

+ +## EmojiFilter +--- +### ::: ultralytics.utils.EmojiFilter +

+ +## ThreadingLocked +--- +### ::: ultralytics.utils.ThreadingLocked +

+ +## TryExcept +--- +### ::: ultralytics.utils.TryExcept +

+ +## plt_settings +--- +### ::: ultralytics.utils.plt_settings +

+ +## set_logging +--- +### ::: ultralytics.utils.set_logging +

+ +## emojis +--- +### ::: ultralytics.utils.emojis +

+ +## yaml_save +--- +### ::: ultralytics.utils.yaml_save +

+ +## yaml_load +--- +### ::: ultralytics.utils.yaml_load +

+ +## yaml_print +--- +### ::: ultralytics.utils.yaml_print +

+ +## is_colab +--- +### ::: ultralytics.utils.is_colab +

+ +## is_kaggle +--- +### ::: ultralytics.utils.is_kaggle +

+ +## is_jupyter +--- +### ::: ultralytics.utils.is_jupyter +

+ +## is_docker +--- +### ::: ultralytics.utils.is_docker +

+ +## is_online +--- +### ::: ultralytics.utils.is_online +

+ +## is_pip_package +--- +### ::: ultralytics.utils.is_pip_package +

+ +## is_dir_writeable +--- +### ::: ultralytics.utils.is_dir_writeable +

+ +## is_pytest_running +--- +### ::: ultralytics.utils.is_pytest_running +

+ +## is_github_actions_ci +--- +### ::: ultralytics.utils.is_github_actions_ci +

+ +## is_git_dir +--- +### ::: ultralytics.utils.is_git_dir +

+ +## get_git_dir +--- +### ::: ultralytics.utils.get_git_dir +

+ +## get_git_origin_url +--- +### ::: ultralytics.utils.get_git_origin_url +

+ +## get_git_branch +--- +### ::: ultralytics.utils.get_git_branch +

+ +## get_default_args +--- +### ::: ultralytics.utils.get_default_args +

+ +## get_user_config_dir +--- +### ::: ultralytics.utils.get_user_config_dir +

+ +## colorstr +--- +### ::: ultralytics.utils.colorstr +

+ +## threaded +--- +### ::: ultralytics.utils.threaded +

+ +## set_sentry +--- +### ::: ultralytics.utils.set_sentry +

+ +## get_settings +--- +### ::: ultralytics.utils.get_settings +

+ +## set_settings +--- +### ::: ultralytics.utils.set_settings +

+ +## deprecation_warn +--- +### ::: ultralytics.utils.deprecation_warn +

+ +## clean_url +--- +### ::: ultralytics.utils.clean_url +

+ +## url2file +--- +### ::: ultralytics.utils.url2file +

diff --git a/docs/reference/utils/autobatch.md b/docs/reference/utils/autobatch.md new file mode 100644 index 0000000..f23bc20 --- /dev/null +++ b/docs/reference/utils/autobatch.md @@ -0,0 +1,9 @@ +## check_train_batch_size +--- +### ::: ultralytics.utils.autobatch.check_train_batch_size +

+ +## autobatch +--- +### ::: ultralytics.utils.autobatch.autobatch +

diff --git a/docs/reference/utils/benchmarks.md b/docs/reference/utils/benchmarks.md new file mode 100644 index 0000000..0e1d166 --- /dev/null +++ b/docs/reference/utils/benchmarks.md @@ -0,0 +1,9 @@ +## ProfileModels +--- +### ::: ultralytics.utils.benchmarks.ProfileModels +

+ +## benchmark +--- +### ::: ultralytics.utils.benchmarks.benchmark +

diff --git a/docs/reference/utils/callbacks/base.md b/docs/reference/utils/callbacks/base.md new file mode 100644 index 0000000..350d61a --- /dev/null +++ b/docs/reference/utils/callbacks/base.md @@ -0,0 +1,134 @@ +## on_pretrain_routine_start +--- +### ::: ultralytics.utils.callbacks.base.on_pretrain_routine_start +

+ +## on_pretrain_routine_end +--- +### ::: ultralytics.utils.callbacks.base.on_pretrain_routine_end +

+ +## on_train_start +--- +### ::: ultralytics.utils.callbacks.base.on_train_start +

+ +## on_train_epoch_start +--- +### ::: ultralytics.utils.callbacks.base.on_train_epoch_start +

+ +## on_train_batch_start +--- +### ::: ultralytics.utils.callbacks.base.on_train_batch_start +

+ +## optimizer_step +--- +### ::: ultralytics.utils.callbacks.base.optimizer_step +

+ +## on_before_zero_grad +--- +### ::: ultralytics.utils.callbacks.base.on_before_zero_grad +

+ +## on_train_batch_end +--- +### ::: ultralytics.utils.callbacks.base.on_train_batch_end +

+ +## on_train_epoch_end +--- +### ::: ultralytics.utils.callbacks.base.on_train_epoch_end +

+ +## on_fit_epoch_end +--- +### ::: ultralytics.utils.callbacks.base.on_fit_epoch_end +

+ +## on_model_save +--- +### ::: ultralytics.utils.callbacks.base.on_model_save +

+ +## on_train_end +--- +### ::: ultralytics.utils.callbacks.base.on_train_end +

+ +## on_params_update +--- +### ::: ultralytics.utils.callbacks.base.on_params_update +

+ +## teardown +--- +### ::: ultralytics.utils.callbacks.base.teardown +

+ +## on_val_start +--- +### ::: ultralytics.utils.callbacks.base.on_val_start +

+ +## on_val_batch_start +--- +### ::: ultralytics.utils.callbacks.base.on_val_batch_start +

+ +## on_val_batch_end +--- +### ::: ultralytics.utils.callbacks.base.on_val_batch_end +

+ +## on_val_end +--- +### ::: ultralytics.utils.callbacks.base.on_val_end +

+ +## on_predict_start +--- +### ::: ultralytics.utils.callbacks.base.on_predict_start +

+ +## on_predict_batch_start +--- +### ::: ultralytics.utils.callbacks.base.on_predict_batch_start +

+ +## on_predict_batch_end +--- +### ::: ultralytics.utils.callbacks.base.on_predict_batch_end +

+ +## on_predict_postprocess_end +--- +### ::: ultralytics.utils.callbacks.base.on_predict_postprocess_end +

+ +## on_predict_end +--- +### ::: ultralytics.utils.callbacks.base.on_predict_end +

+ +## on_export_start +--- +### ::: ultralytics.utils.callbacks.base.on_export_start +

+ +## on_export_end +--- +### ::: ultralytics.utils.callbacks.base.on_export_end +

+ +## get_default_callbacks +--- +### ::: ultralytics.utils.callbacks.base.get_default_callbacks +

+ +## add_integration_callbacks +--- +### ::: ultralytics.utils.callbacks.base.add_integration_callbacks +

diff --git a/docs/reference/utils/callbacks/clearml.md b/docs/reference/utils/callbacks/clearml.md new file mode 100644 index 0000000..39ef7cc --- /dev/null +++ b/docs/reference/utils/callbacks/clearml.md @@ -0,0 +1,34 @@ +## _log_debug_samples +--- +### ::: ultralytics.utils.callbacks.clearml._log_debug_samples +

+ +## _log_plot +--- +### ::: ultralytics.utils.callbacks.clearml._log_plot +

+ +## on_pretrain_routine_start +--- +### ::: ultralytics.utils.callbacks.clearml.on_pretrain_routine_start +

+ +## on_train_epoch_end +--- +### ::: ultralytics.utils.callbacks.clearml.on_train_epoch_end +

+ +## on_fit_epoch_end +--- +### ::: ultralytics.utils.callbacks.clearml.on_fit_epoch_end +

+ +## on_val_end +--- +### ::: ultralytics.utils.callbacks.clearml.on_val_end +

+ +## on_train_end +--- +### ::: ultralytics.utils.callbacks.clearml.on_train_end +

diff --git a/docs/reference/utils/callbacks/comet.md b/docs/reference/utils/callbacks/comet.md new file mode 100644 index 0000000..7f18c1a --- /dev/null +++ b/docs/reference/utils/callbacks/comet.md @@ -0,0 +1,119 @@ +## _get_comet_mode +--- +### ::: ultralytics.utils.callbacks.comet._get_comet_mode +

+ +## _get_comet_model_name +--- +### ::: ultralytics.utils.callbacks.comet._get_comet_model_name +

+ +## _get_eval_batch_logging_interval +--- +### ::: ultralytics.utils.callbacks.comet._get_eval_batch_logging_interval +

+ +## _get_max_image_predictions_to_log +--- +### ::: ultralytics.utils.callbacks.comet._get_max_image_predictions_to_log +

+ +## _scale_confidence_score +--- +### ::: ultralytics.utils.callbacks.comet._scale_confidence_score +

+ +## _should_log_confusion_matrix +--- +### ::: ultralytics.utils.callbacks.comet._should_log_confusion_matrix +

+ +## _should_log_image_predictions +--- +### ::: ultralytics.utils.callbacks.comet._should_log_image_predictions +

+ +## _get_experiment_type +--- +### ::: ultralytics.utils.callbacks.comet._get_experiment_type +

+ +## _create_experiment +--- +### ::: ultralytics.utils.callbacks.comet._create_experiment +

+ +## _fetch_trainer_metadata +--- +### ::: ultralytics.utils.callbacks.comet._fetch_trainer_metadata +

+ +## _scale_bounding_box_to_original_image_shape +--- +### ::: ultralytics.utils.callbacks.comet._scale_bounding_box_to_original_image_shape +

+ +## _format_ground_truth_annotations_for_detection +--- +### ::: ultralytics.utils.callbacks.comet._format_ground_truth_annotations_for_detection +

+ +## _format_prediction_annotations_for_detection +--- +### ::: ultralytics.utils.callbacks.comet._format_prediction_annotations_for_detection +

+ +## _fetch_annotations +--- +### ::: ultralytics.utils.callbacks.comet._fetch_annotations +

+ +## _create_prediction_metadata_map +--- +### ::: ultralytics.utils.callbacks.comet._create_prediction_metadata_map +

+ +## _log_confusion_matrix +--- +### ::: ultralytics.utils.callbacks.comet._log_confusion_matrix +

+ +## _log_images +--- +### ::: ultralytics.utils.callbacks.comet._log_images +

+ +## _log_image_predictions +--- +### ::: ultralytics.utils.callbacks.comet._log_image_predictions +

+ +## _log_plots +--- +### ::: ultralytics.utils.callbacks.comet._log_plots +

+ +## _log_model +--- +### ::: ultralytics.utils.callbacks.comet._log_model +

+ +## on_pretrain_routine_start +--- +### ::: ultralytics.utils.callbacks.comet.on_pretrain_routine_start +

+ +## on_train_epoch_end +--- +### ::: ultralytics.utils.callbacks.comet.on_train_epoch_end +

+ +## on_fit_epoch_end +--- +### ::: ultralytics.utils.callbacks.comet.on_fit_epoch_end +

+ +## on_train_end +--- +### ::: ultralytics.utils.callbacks.comet.on_train_end +

diff --git a/docs/reference/utils/callbacks/dvc.md b/docs/reference/utils/callbacks/dvc.md new file mode 100644 index 0000000..3d0fcef --- /dev/null +++ b/docs/reference/utils/callbacks/dvc.md @@ -0,0 +1,49 @@ +## _logger_disabled +--- +### ::: ultralytics.utils.callbacks.dvc._logger_disabled +

+ +## _log_images +--- +### ::: ultralytics.utils.callbacks.dvc._log_images +

+ +## _log_plots +--- +### ::: ultralytics.utils.callbacks.dvc._log_plots +

+ +## _log_confusion_matrix +--- +### ::: ultralytics.utils.callbacks.dvc._log_confusion_matrix +

+ +## on_pretrain_routine_start +--- +### ::: ultralytics.utils.callbacks.dvc.on_pretrain_routine_start +

+ +## on_pretrain_routine_end +--- +### ::: ultralytics.utils.callbacks.dvc.on_pretrain_routine_end +

+ +## on_train_start +--- +### ::: ultralytics.utils.callbacks.dvc.on_train_start +

+ +## on_train_epoch_start +--- +### ::: ultralytics.utils.callbacks.dvc.on_train_epoch_start +

+ +## on_fit_epoch_end +--- +### ::: ultralytics.utils.callbacks.dvc.on_fit_epoch_end +

+ +## on_train_end +--- +### ::: ultralytics.utils.callbacks.dvc.on_train_end +

diff --git a/docs/reference/utils/callbacks/hub.md b/docs/reference/utils/callbacks/hub.md new file mode 100644 index 0000000..ec99c01 --- /dev/null +++ b/docs/reference/utils/callbacks/hub.md @@ -0,0 +1,39 @@ +## on_pretrain_routine_end +--- +### ::: ultralytics.utils.callbacks.hub.on_pretrain_routine_end +

+ +## on_fit_epoch_end +--- +### ::: ultralytics.utils.callbacks.hub.on_fit_epoch_end +

+ +## on_model_save +--- +### ::: ultralytics.utils.callbacks.hub.on_model_save +

+ +## on_train_end +--- +### ::: ultralytics.utils.callbacks.hub.on_train_end +

+ +## on_train_start +--- +### ::: ultralytics.utils.callbacks.hub.on_train_start +

+ +## on_val_start +--- +### ::: ultralytics.utils.callbacks.hub.on_val_start +

+ +## on_predict_start +--- +### ::: ultralytics.utils.callbacks.hub.on_predict_start +

+ +## on_export_start +--- +### ::: ultralytics.utils.callbacks.hub.on_export_start +

diff --git a/docs/reference/utils/callbacks/mlflow.md b/docs/reference/utils/callbacks/mlflow.md new file mode 100644 index 0000000..77d11a0 --- /dev/null +++ b/docs/reference/utils/callbacks/mlflow.md @@ -0,0 +1,14 @@ +## on_pretrain_routine_end +--- +### ::: ultralytics.utils.callbacks.mlflow.on_pretrain_routine_end +

+ +## on_fit_epoch_end +--- +### ::: ultralytics.utils.callbacks.mlflow.on_fit_epoch_end +

+ +## on_train_end +--- +### ::: ultralytics.utils.callbacks.mlflow.on_train_end +

diff --git a/docs/reference/utils/callbacks/neptune.md b/docs/reference/utils/callbacks/neptune.md new file mode 100644 index 0000000..a745c6a --- /dev/null +++ b/docs/reference/utils/callbacks/neptune.md @@ -0,0 +1,39 @@ +## _log_scalars +--- +### ::: ultralytics.utils.callbacks.neptune._log_scalars +

+ +## _log_images +--- +### ::: ultralytics.utils.callbacks.neptune._log_images +

+ +## _log_plot +--- +### ::: ultralytics.utils.callbacks.neptune._log_plot +

+ +## on_pretrain_routine_start +--- +### ::: ultralytics.utils.callbacks.neptune.on_pretrain_routine_start +

+ +## on_train_epoch_end +--- +### ::: ultralytics.utils.callbacks.neptune.on_train_epoch_end +

+ +## on_fit_epoch_end +--- +### ::: ultralytics.utils.callbacks.neptune.on_fit_epoch_end +

+ +## on_val_end +--- +### ::: ultralytics.utils.callbacks.neptune.on_val_end +

+ +## on_train_end +--- +### ::: ultralytics.utils.callbacks.neptune.on_train_end +

diff --git a/docs/reference/utils/callbacks/raytune.md b/docs/reference/utils/callbacks/raytune.md new file mode 100644 index 0000000..1cb2f90 --- /dev/null +++ b/docs/reference/utils/callbacks/raytune.md @@ -0,0 +1,4 @@ +## on_fit_epoch_end +--- +### ::: ultralytics.utils.callbacks.raytune.on_fit_epoch_end +

diff --git a/docs/reference/utils/callbacks/tensorboard.md b/docs/reference/utils/callbacks/tensorboard.md new file mode 100644 index 0000000..a22d76b --- /dev/null +++ b/docs/reference/utils/callbacks/tensorboard.md @@ -0,0 +1,19 @@ +## _log_scalars +--- +### ::: ultralytics.utils.callbacks.tensorboard._log_scalars +

+ +## on_pretrain_routine_start +--- +### ::: ultralytics.utils.callbacks.tensorboard.on_pretrain_routine_start +

+ +## on_batch_end +--- +### ::: ultralytics.utils.callbacks.tensorboard.on_batch_end +

+ +## on_fit_epoch_end +--- +### ::: ultralytics.utils.callbacks.tensorboard.on_fit_epoch_end +

diff --git a/docs/reference/utils/callbacks/wb.md b/docs/reference/utils/callbacks/wb.md new file mode 100644 index 0000000..87ff134 --- /dev/null +++ b/docs/reference/utils/callbacks/wb.md @@ -0,0 +1,24 @@ +## _log_plots +--- +### ::: ultralytics.utils.callbacks.wb._log_plots +

+ +## on_pretrain_routine_start +--- +### ::: ultralytics.utils.callbacks.wb.on_pretrain_routine_start +

+ +## on_fit_epoch_end +--- +### ::: ultralytics.utils.callbacks.wb.on_fit_epoch_end +

+ +## on_train_epoch_end +--- +### ::: ultralytics.utils.callbacks.wb.on_train_epoch_end +

+ +## on_train_end +--- +### ::: ultralytics.utils.callbacks.wb.on_train_end +

diff --git a/docs/reference/utils/checks.md b/docs/reference/utils/checks.md new file mode 100644 index 0000000..bf79ed7 --- /dev/null +++ b/docs/reference/utils/checks.md @@ -0,0 +1,89 @@ +## is_ascii +--- +### ::: ultralytics.utils.checks.is_ascii +

+ +## check_imgsz +--- +### ::: ultralytics.utils.checks.check_imgsz +

+ +## check_version +--- +### ::: ultralytics.utils.checks.check_version +

+ +## check_latest_pypi_version +--- +### ::: ultralytics.utils.checks.check_latest_pypi_version +

+ +## check_pip_update_available +--- +### ::: ultralytics.utils.checks.check_pip_update_available +

+ +## check_font +--- +### ::: ultralytics.utils.checks.check_font +

+ +## check_python +--- +### ::: ultralytics.utils.checks.check_python +

+ +## check_requirements +--- +### ::: ultralytics.utils.checks.check_requirements +

+ +## check_torchvision +--- +### ::: ultralytics.utils.checks.check_torchvision +

+ +## check_suffix +--- +### ::: ultralytics.utils.checks.check_suffix +

+ +## check_yolov5u_filename +--- +### ::: ultralytics.utils.checks.check_yolov5u_filename +

+ +## check_file +--- +### ::: ultralytics.utils.checks.check_file +

+ +## check_yaml +--- +### ::: ultralytics.utils.checks.check_yaml +

+ +## check_imshow +--- +### ::: ultralytics.utils.checks.check_imshow +

+ +## check_yolo +--- +### ::: ultralytics.utils.checks.check_yolo +

+ +## check_amp +--- +### ::: ultralytics.utils.checks.check_amp +

+ +## git_describe +--- +### ::: ultralytics.utils.checks.git_describe +

+ +## print_args +--- +### ::: ultralytics.utils.checks.print_args +

diff --git a/docs/reference/utils/dist.md b/docs/reference/utils/dist.md new file mode 100644 index 0000000..c5122a3 --- /dev/null +++ b/docs/reference/utils/dist.md @@ -0,0 +1,19 @@ +## find_free_network_port +--- +### ::: ultralytics.utils.dist.find_free_network_port +

+ +## generate_ddp_file +--- +### ::: ultralytics.utils.dist.generate_ddp_file +

+ +## generate_ddp_command +--- +### ::: ultralytics.utils.dist.generate_ddp_command +

+ +## ddp_cleanup +--- +### ::: ultralytics.utils.dist.ddp_cleanup +

diff --git a/docs/reference/utils/downloads.md b/docs/reference/utils/downloads.md new file mode 100644 index 0000000..8f9da2b --- /dev/null +++ b/docs/reference/utils/downloads.md @@ -0,0 +1,34 @@ +## is_url +--- +### ::: ultralytics.utils.downloads.is_url +

+ +## unzip_file +--- +### ::: ultralytics.utils.downloads.unzip_file +

+ +## check_disk_space +--- +### ::: ultralytics.utils.downloads.check_disk_space +

+ +## safe_download +--- +### ::: ultralytics.utils.downloads.safe_download +

+ +## get_github_assets +--- +### ::: ultralytics.utils.downloads.get_github_assets +

+ +## attempt_download_asset +--- +### ::: ultralytics.utils.downloads.attempt_download_asset +

+ +## download +--- +### ::: ultralytics.utils.downloads.download +

diff --git a/docs/reference/utils/errors.md b/docs/reference/utils/errors.md new file mode 100644 index 0000000..a508c79 --- /dev/null +++ b/docs/reference/utils/errors.md @@ -0,0 +1,4 @@ +## HUBModelError +--- +### ::: ultralytics.utils.errors.HUBModelError +

diff --git a/docs/reference/utils/files.md b/docs/reference/utils/files.md new file mode 100644 index 0000000..0143b5f --- /dev/null +++ b/docs/reference/utils/files.md @@ -0,0 +1,34 @@ +## WorkingDirectory +--- +### ::: ultralytics.utils.files.WorkingDirectory +

+ +## increment_path +--- +### ::: ultralytics.utils.files.increment_path +

+ +## file_age +--- +### ::: ultralytics.utils.files.file_age +

+ +## file_date +--- +### ::: ultralytics.utils.files.file_date +

+ +## file_size +--- +### ::: ultralytics.utils.files.file_size +

+ +## get_latest_run +--- +### ::: ultralytics.utils.files.get_latest_run +

+ +## make_dirs +--- +### ::: ultralytics.utils.files.make_dirs +

diff --git a/docs/reference/utils/instance.md b/docs/reference/utils/instance.md new file mode 100644 index 0000000..03771c3 --- /dev/null +++ b/docs/reference/utils/instance.md @@ -0,0 +1,14 @@ +## Bboxes +--- +### ::: ultralytics.utils.instance.Bboxes +

+ +## Instances +--- +### ::: ultralytics.utils.instance.Instances +

+ +## _ntuple +--- +### ::: ultralytics.utils.instance._ntuple +

diff --git a/docs/reference/utils/loss.md b/docs/reference/utils/loss.md new file mode 100644 index 0000000..164db8a --- /dev/null +++ b/docs/reference/utils/loss.md @@ -0,0 +1,39 @@ +## VarifocalLoss +--- +### ::: ultralytics.utils.loss.VarifocalLoss +

+ +## FocalLoss +--- +### ::: ultralytics.utils.loss.FocalLoss +

+ +## BboxLoss +--- +### ::: ultralytics.utils.loss.BboxLoss +

+ +## KeypointLoss +--- +### ::: ultralytics.utils.loss.KeypointLoss +

+ +## v8DetectionLoss +--- +### ::: ultralytics.utils.loss.v8DetectionLoss +

+ +## v8SegmentationLoss +--- +### ::: ultralytics.utils.loss.v8SegmentationLoss +

+ +## v8PoseLoss +--- +### ::: ultralytics.utils.loss.v8PoseLoss +

+ +## v8ClassificationLoss +--- +### ::: ultralytics.utils.loss.v8ClassificationLoss +

diff --git a/docs/reference/utils/metrics.md b/docs/reference/utils/metrics.md new file mode 100644 index 0000000..4c7764a --- /dev/null +++ b/docs/reference/utils/metrics.md @@ -0,0 +1,89 @@ +## ConfusionMatrix +--- +### ::: ultralytics.utils.metrics.ConfusionMatrix +

+ +## Metric +--- +### ::: ultralytics.utils.metrics.Metric +

+ +## DetMetrics +--- +### ::: ultralytics.utils.metrics.DetMetrics +

+ +## SegmentMetrics +--- +### ::: ultralytics.utils.metrics.SegmentMetrics +

+ +## PoseMetrics +--- +### ::: ultralytics.utils.metrics.PoseMetrics +

+ +## ClassifyMetrics +--- +### ::: ultralytics.utils.metrics.ClassifyMetrics +

+ +## box_area +--- +### ::: ultralytics.utils.metrics.box_area +

+ +## bbox_ioa +--- +### ::: ultralytics.utils.metrics.bbox_ioa +

+ +## box_iou +--- +### ::: ultralytics.utils.metrics.box_iou +

+ +## bbox_iou +--- +### ::: ultralytics.utils.metrics.bbox_iou +

+ +## mask_iou +--- +### ::: ultralytics.utils.metrics.mask_iou +

+ +## kpt_iou +--- +### ::: ultralytics.utils.metrics.kpt_iou +

+ +## smooth_BCE +--- +### ::: ultralytics.utils.metrics.smooth_BCE +

+ +## smooth +--- +### ::: ultralytics.utils.metrics.smooth +

+ +## plot_pr_curve +--- +### ::: ultralytics.utils.metrics.plot_pr_curve +

+ +## plot_mc_curve +--- +### ::: ultralytics.utils.metrics.plot_mc_curve +

+ +## compute_ap +--- +### ::: ultralytics.utils.metrics.compute_ap +

+ +## ap_per_class +--- +### ::: ultralytics.utils.metrics.ap_per_class +

diff --git a/docs/reference/utils/ops.md b/docs/reference/utils/ops.md new file mode 100644 index 0000000..0ed015a --- /dev/null +++ b/docs/reference/utils/ops.md @@ -0,0 +1,139 @@ +## Profile +--- +### ::: ultralytics.utils.ops.Profile +

+ +## coco80_to_coco91_class +--- +### ::: ultralytics.utils.ops.coco80_to_coco91_class +

+ +## segment2box +--- +### ::: ultralytics.utils.ops.segment2box +

+ +## scale_boxes +--- +### ::: ultralytics.utils.ops.scale_boxes +

+ +## make_divisible +--- +### ::: ultralytics.utils.ops.make_divisible +

+ +## non_max_suppression +--- +### ::: ultralytics.utils.ops.non_max_suppression +

+ +## clip_boxes +--- +### ::: ultralytics.utils.ops.clip_boxes +

+ +## clip_coords +--- +### ::: ultralytics.utils.ops.clip_coords +

+ +## scale_image +--- +### ::: ultralytics.utils.ops.scale_image +

+ +## xyxy2xywh +--- +### ::: ultralytics.utils.ops.xyxy2xywh +

+ +## xywh2xyxy +--- +### ::: ultralytics.utils.ops.xywh2xyxy +

+ +## xywhn2xyxy +--- +### ::: ultralytics.utils.ops.xywhn2xyxy +

+ +## xyxy2xywhn +--- +### ::: ultralytics.utils.ops.xyxy2xywhn +

+ +## xyn2xy +--- +### ::: ultralytics.utils.ops.xyn2xy +

+ +## xywh2ltwh +--- +### ::: ultralytics.utils.ops.xywh2ltwh +

+ +## xyxy2ltwh +--- +### ::: ultralytics.utils.ops.xyxy2ltwh +

+ +## ltwh2xywh +--- +### ::: ultralytics.utils.ops.ltwh2xywh +

+ +## ltwh2xyxy +--- +### ::: ultralytics.utils.ops.ltwh2xyxy +

+ +## segments2boxes +--- +### ::: ultralytics.utils.ops.segments2boxes +

+ +## resample_segments +--- +### ::: ultralytics.utils.ops.resample_segments +

+ +## crop_mask +--- +### ::: ultralytics.utils.ops.crop_mask +

+ +## process_mask_upsample +--- +### ::: ultralytics.utils.ops.process_mask_upsample +

+ +## process_mask +--- +### ::: ultralytics.utils.ops.process_mask +

+ +## process_mask_native +--- +### ::: ultralytics.utils.ops.process_mask_native +

+ +## scale_masks +--- +### ::: ultralytics.utils.ops.scale_masks +

+ +## scale_coords +--- +### ::: ultralytics.utils.ops.scale_coords +

+ +## masks2segments +--- +### ::: ultralytics.utils.ops.masks2segments +

+ +## clean_str +--- +### ::: ultralytics.utils.ops.clean_str +

diff --git a/docs/reference/utils/patches.md b/docs/reference/utils/patches.md new file mode 100644 index 0000000..30ccb2b --- /dev/null +++ b/docs/reference/utils/patches.md @@ -0,0 +1,19 @@ +## imread +--- +### ::: ultralytics.utils.patches.imread +

+ +## imwrite +--- +### ::: ultralytics.utils.patches.imwrite +

+ +## imshow +--- +### ::: ultralytics.utils.patches.imshow +

+ +## torch_save +--- +### ::: ultralytics.utils.patches.torch_save +

diff --git a/docs/reference/utils/plotting.md b/docs/reference/utils/plotting.md new file mode 100644 index 0000000..fb641da --- /dev/null +++ b/docs/reference/utils/plotting.md @@ -0,0 +1,39 @@ +## Colors +--- +### ::: ultralytics.utils.plotting.Colors +

+ +## Annotator +--- +### ::: ultralytics.utils.plotting.Annotator +

+ +## plot_labels +--- +### ::: ultralytics.utils.plotting.plot_labels +

+ +## save_one_box +--- +### ::: ultralytics.utils.plotting.save_one_box +

+ +## plot_images +--- +### ::: ultralytics.utils.plotting.plot_images +

+ +## plot_results +--- +### ::: ultralytics.utils.plotting.plot_results +

+ +## output_to_target +--- +### ::: ultralytics.utils.plotting.output_to_target +

+ +## feature_visualization +--- +### ::: ultralytics.utils.plotting.feature_visualization +

diff --git a/docs/reference/utils/tal.md b/docs/reference/utils/tal.md new file mode 100644 index 0000000..99dc543 --- /dev/null +++ b/docs/reference/utils/tal.md @@ -0,0 +1,29 @@ +## TaskAlignedAssigner +--- +### ::: ultralytics.utils.tal.TaskAlignedAssigner +

+ +## select_candidates_in_gts +--- +### ::: ultralytics.utils.tal.select_candidates_in_gts +

+ +## select_highest_overlaps +--- +### ::: ultralytics.utils.tal.select_highest_overlaps +

+ +## make_anchors +--- +### ::: ultralytics.utils.tal.make_anchors +

+ +## dist2bbox +--- +### ::: ultralytics.utils.tal.dist2bbox +

+ +## bbox2dist +--- +### ::: ultralytics.utils.tal.bbox2dist +

diff --git a/docs/reference/utils/torch_utils.md b/docs/reference/utils/torch_utils.md new file mode 100644 index 0000000..2117cd9 --- /dev/null +++ b/docs/reference/utils/torch_utils.md @@ -0,0 +1,134 @@ +## ModelEMA +--- +### ::: ultralytics.utils.torch_utils.ModelEMA +

+ +## EarlyStopping +--- +### ::: ultralytics.utils.torch_utils.EarlyStopping +

+ +## torch_distributed_zero_first +--- +### ::: ultralytics.utils.torch_utils.torch_distributed_zero_first +

+ +## smart_inference_mode +--- +### ::: ultralytics.utils.torch_utils.smart_inference_mode +

+ +## get_cpu_info +--- +### ::: ultralytics.utils.torch_utils.get_cpu_info +

+ +## select_device +--- +### ::: ultralytics.utils.torch_utils.select_device +

+ +## time_sync +--- +### ::: ultralytics.utils.torch_utils.time_sync +

+ +## fuse_conv_and_bn +--- +### ::: ultralytics.utils.torch_utils.fuse_conv_and_bn +

+ +## fuse_deconv_and_bn +--- +### ::: ultralytics.utils.torch_utils.fuse_deconv_and_bn +

+ +## model_info +--- +### ::: ultralytics.utils.torch_utils.model_info +

+ +## get_num_params +--- +### ::: ultralytics.utils.torch_utils.get_num_params +

+ +## get_num_gradients +--- +### ::: ultralytics.utils.torch_utils.get_num_gradients +

+ +## model_info_for_loggers +--- +### ::: ultralytics.utils.torch_utils.model_info_for_loggers +

+ +## get_flops +--- +### ::: ultralytics.utils.torch_utils.get_flops +

+ +## get_flops_with_torch_profiler +--- +### ::: ultralytics.utils.torch_utils.get_flops_with_torch_profiler +

+ +## initialize_weights +--- +### ::: ultralytics.utils.torch_utils.initialize_weights +

+ +## scale_img +--- +### ::: ultralytics.utils.torch_utils.scale_img +

+ +## make_divisible +--- +### ::: ultralytics.utils.torch_utils.make_divisible +

+ +## copy_attr +--- +### ::: ultralytics.utils.torch_utils.copy_attr +

+ +## get_latest_opset +--- +### ::: ultralytics.utils.torch_utils.get_latest_opset +

+ +## intersect_dicts +--- +### ::: ultralytics.utils.torch_utils.intersect_dicts +

+ +## is_parallel +--- +### ::: ultralytics.utils.torch_utils.is_parallel +

+ +## de_parallel +--- +### ::: ultralytics.utils.torch_utils.de_parallel +

+ +## one_cycle +--- +### ::: ultralytics.utils.torch_utils.one_cycle +

+ +## init_seeds +--- +### ::: ultralytics.utils.torch_utils.init_seeds +

+ +## strip_optimizer +--- +### ::: ultralytics.utils.torch_utils.strip_optimizer +

+ +## profile +--- +### ::: ultralytics.utils.torch_utils.profile +

diff --git a/docs/reference/utils/tuner.md b/docs/reference/utils/tuner.md new file mode 100644 index 0000000..40263c5 --- /dev/null +++ b/docs/reference/utils/tuner.md @@ -0,0 +1,4 @@ +## run_ray_tune +--- +### ::: ultralytics.utils.tuner.run_ray_tune +

diff --git a/docs/reference/vit/rtdetr/model.md b/docs/reference/vit/rtdetr/model.md deleted file mode 100644 index f444608..0000000 --- a/docs/reference/vit/rtdetr/model.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -description: Learn about the RTDETR model in Ultralytics YOLO Docs and how it can be used for object detection with improved speed and accuracy. Find implementation details and more. -keywords: RTDETR, Ultralytics, YOLO, object detection, speed, accuracy, implementation details ---- - -## RTDETR ---- -### ::: ultralytics.vit.rtdetr.model.RTDETR -

diff --git a/docs/reference/vit/rtdetr/predict.md b/docs/reference/vit/rtdetr/predict.md deleted file mode 100644 index 032c2da..0000000 --- a/docs/reference/vit/rtdetr/predict.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -description: Learn about the RTDETRPredictor class and how to use it for vision transformer object detection with Ultralytics YOLO. -keywords: RTDETRPredictor, object detection, vision transformer, Ultralytics YOLO ---- - -## RTDETRPredictor ---- -### ::: ultralytics.vit.rtdetr.predict.RTDETRPredictor -

diff --git a/docs/reference/vit/rtdetr/train.md b/docs/reference/vit/rtdetr/train.md deleted file mode 100644 index 03f33f7..0000000 --- a/docs/reference/vit/rtdetr/train.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -description: Learn how to use RTDETRTrainer from Ultralytics YOLO Docs. Train object detection models with the latest VIT-based RTDETR system. -keywords: RTDETRTrainer, Ultralytics YOLO Docs, object detection, VIT-based RTDETR system, train ---- - -## RTDETRTrainer ---- -### ::: ultralytics.vit.rtdetr.train.RTDETRTrainer -

- -## train ---- -### ::: ultralytics.vit.rtdetr.train.train -

diff --git a/docs/reference/vit/rtdetr/val.md b/docs/reference/vit/rtdetr/val.md deleted file mode 100644 index 32359b3..0000000 --- a/docs/reference/vit/rtdetr/val.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -description: Documentation for RTDETRValidator data validation tool in Ultralytics RTDETRDataset. -keywords: RTDETRDataset, RTDETRValidator, data validation, documentation ---- - -## RTDETRDataset ---- -### ::: ultralytics.vit.rtdetr.val.RTDETRDataset -

- -## RTDETRValidator ---- -### ::: ultralytics.vit.rtdetr.val.RTDETRValidator -

diff --git a/docs/reference/vit/sam/amg.md b/docs/reference/vit/sam/amg.md deleted file mode 100644 index a5b5e4f..0000000 --- a/docs/reference/vit/sam/amg.md +++ /dev/null @@ -1,89 +0,0 @@ ---- -description: Explore and learn about functions in Ultralytics MaskData library such as mask_to_rle_pytorch, area_from_rle, generate_crop_boxes, and more. -keywords: Ultralytics, SAM, MaskData, mask_to_rle_pytorch, area_from_rle, generate_crop_boxes, batched_mask_to_box, documentation ---- - -## MaskData ---- -### ::: ultralytics.vit.sam.amg.MaskData -

- -## is_box_near_crop_edge ---- -### ::: ultralytics.vit.sam.amg.is_box_near_crop_edge -

- -## box_xyxy_to_xywh ---- -### ::: ultralytics.vit.sam.amg.box_xyxy_to_xywh -

- -## batch_iterator ---- -### ::: ultralytics.vit.sam.amg.batch_iterator -

- -## mask_to_rle_pytorch ---- -### ::: ultralytics.vit.sam.amg.mask_to_rle_pytorch -

- -## rle_to_mask ---- -### ::: ultralytics.vit.sam.amg.rle_to_mask -

- -## area_from_rle ---- -### ::: ultralytics.vit.sam.amg.area_from_rle -

- -## calculate_stability_score ---- -### ::: ultralytics.vit.sam.amg.calculate_stability_score -

- -## build_point_grid ---- -### ::: ultralytics.vit.sam.amg.build_point_grid -

- -## build_all_layer_point_grids ---- -### ::: ultralytics.vit.sam.amg.build_all_layer_point_grids -

- -## generate_crop_boxes ---- -### ::: ultralytics.vit.sam.amg.generate_crop_boxes -

- -## uncrop_boxes_xyxy ---- -### ::: ultralytics.vit.sam.amg.uncrop_boxes_xyxy -

- -## uncrop_points ---- -### ::: ultralytics.vit.sam.amg.uncrop_points -

- -## uncrop_masks ---- -### ::: ultralytics.vit.sam.amg.uncrop_masks -

- -## remove_small_regions ---- -### ::: ultralytics.vit.sam.amg.remove_small_regions -

- -## coco_encode_rle ---- -### ::: ultralytics.vit.sam.amg.coco_encode_rle -

- -## batched_mask_to_box ---- -### ::: ultralytics.vit.sam.amg.batched_mask_to_box -

diff --git a/docs/reference/vit/sam/build.md b/docs/reference/vit/sam/build.md deleted file mode 100644 index c44e48b..0000000 --- a/docs/reference/vit/sam/build.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -description: Learn how to build SAM and VIT models with Ultralytics YOLO Docs. Enhance your understanding of computer vision models today!. -keywords: SAM, VIT, computer vision models, build SAM models, build VIT models, Ultralytics YOLO Docs ---- - -## build_sam_vit_h ---- -### ::: ultralytics.vit.sam.build.build_sam_vit_h -

- -## build_sam_vit_l ---- -### ::: ultralytics.vit.sam.build.build_sam_vit_l -

- -## build_sam_vit_b ---- -### ::: ultralytics.vit.sam.build.build_sam_vit_b -

- -## build_mobile_sam ---- -### ::: ultralytics.vit.sam.build.build_mobile_sam -

- -## _build_sam ---- -### ::: ultralytics.vit.sam.build._build_sam -

- -## build_sam ---- -### ::: ultralytics.vit.sam.build.build_sam -

diff --git a/docs/reference/vit/sam/model.md b/docs/reference/vit/sam/model.md deleted file mode 100644 index 4149847..0000000 --- a/docs/reference/vit/sam/model.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -description: Learn about the Ultralytics VIT SAM model for object detection and how it can help streamline your computer vision workflow. Check out the documentation for implementation details and examples. -keywords: Ultralytics, VIT, SAM, object detection, computer vision, deep learning, implementation, examples ---- - -## SAM ---- -### ::: ultralytics.vit.sam.model.SAM -

diff --git a/docs/reference/vit/sam/modules/decoders.md b/docs/reference/vit/sam/modules/decoders.md deleted file mode 100644 index 940d720..0000000 --- a/docs/reference/vit/sam/modules/decoders.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -description: Learn about Ultralytics YOLO's MaskDecoder, Transformer architecture, MLP, mask prediction, and quality prediction. -keywords: Ultralytics YOLO, MaskDecoder, Transformer architecture, mask prediction, image embeddings, prompt embeddings, multi-mask output, MLP, mask quality prediction ---- - -## MaskDecoder ---- -### ::: ultralytics.vit.sam.modules.decoders.MaskDecoder -

- -## MLP ---- -### ::: ultralytics.vit.sam.modules.decoders.MLP -

diff --git a/docs/reference/vit/sam/modules/encoders.md b/docs/reference/vit/sam/modules/encoders.md deleted file mode 100644 index bd5760a..0000000 --- a/docs/reference/vit/sam/modules/encoders.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -description: Learn about Ultralytics ViT encoder, position embeddings, attention, window partition, and more in our comprehensive documentation. -keywords: Ultralytics YOLO, ViT Encoder, Position Embeddings, Attention, Window Partition, Rel Pos Encoding ---- - -## ImageEncoderViT ---- -### ::: ultralytics.vit.sam.modules.encoders.ImageEncoderViT -

- -## PromptEncoder ---- -### ::: ultralytics.vit.sam.modules.encoders.PromptEncoder -

- -## PositionEmbeddingRandom ---- -### ::: ultralytics.vit.sam.modules.encoders.PositionEmbeddingRandom -

- -## Block ---- -### ::: ultralytics.vit.sam.modules.encoders.Block -

- -## Attention ---- -### ::: ultralytics.vit.sam.modules.encoders.Attention -

- -## PatchEmbed ---- -### ::: ultralytics.vit.sam.modules.encoders.PatchEmbed -

- -## window_partition ---- -### ::: ultralytics.vit.sam.modules.encoders.window_partition -

- -## window_unpartition ---- -### ::: ultralytics.vit.sam.modules.encoders.window_unpartition -

- -## get_rel_pos ---- -### ::: ultralytics.vit.sam.modules.encoders.get_rel_pos -

- -## add_decomposed_rel_pos ---- -### ::: ultralytics.vit.sam.modules.encoders.add_decomposed_rel_pos -

diff --git a/docs/reference/vit/sam/modules/sam.md b/docs/reference/vit/sam/modules/sam.md deleted file mode 100644 index 7ead8cb..0000000 --- a/docs/reference/vit/sam/modules/sam.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -description: Explore the Sam module in Ultralytics VIT, a PyTorch-based vision library, and learn how to improve your image classification and segmentation tasks. -keywords: Ultralytics VIT, Sam module, PyTorch vision library, image classification, segmentation tasks ---- - -## Sam ---- -### ::: ultralytics.vit.sam.modules.sam.Sam -

diff --git a/docs/reference/vit/sam/modules/tiny_encoder.md b/docs/reference/vit/sam/modules/tiny_encoder.md deleted file mode 100644 index eb20355..0000000 --- a/docs/reference/vit/sam/modules/tiny_encoder.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -description: Learn about the Conv2d_BN, MBConv, ConvLayer, Attention, BasicLayer, and TinyViT modules. -keywords: Conv2d_BN, MBConv, ConvLayer, Attention, BasicLayer, TinyViT ---- - -## Conv2d_BN ---- -### ::: ultralytics.vit.sam.modules.tiny_encoder.Conv2d_BN -

- -## PatchEmbed ---- -### ::: ultralytics.vit.sam.modules.tiny_encoder.PatchEmbed -

- -## MBConv ---- -### ::: ultralytics.vit.sam.modules.tiny_encoder.MBConv -

- -## PatchMerging ---- -### ::: ultralytics.vit.sam.modules.tiny_encoder.PatchMerging -

- -## ConvLayer ---- -### ::: ultralytics.vit.sam.modules.tiny_encoder.ConvLayer -

- -## Mlp ---- -### ::: ultralytics.vit.sam.modules.tiny_encoder.Mlp -

- -## Attention ---- -### ::: ultralytics.vit.sam.modules.tiny_encoder.Attention -

- -## TinyViTBlock ---- -### ::: ultralytics.vit.sam.modules.tiny_encoder.TinyViTBlock -

- -## BasicLayer ---- -### ::: ultralytics.vit.sam.modules.tiny_encoder.BasicLayer -

- -## LayerNorm2d ---- -### ::: ultralytics.vit.sam.modules.tiny_encoder.LayerNorm2d -

- -## TinyViT ---- -### ::: ultralytics.vit.sam.modules.tiny_encoder.TinyViT -

diff --git a/docs/reference/vit/sam/modules/transformer.md b/docs/reference/vit/sam/modules/transformer.md deleted file mode 100644 index e0d8eeb..0000000 --- a/docs/reference/vit/sam/modules/transformer.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -description: Explore the Attention and TwoWayTransformer modules in Ultralytics YOLO documentation. Learn how to integrate them in your project efficiently. -keywords: Ultralytics YOLO, Attention module, TwoWayTransformer module, Object Detection, Deep Learning ---- - -## TwoWayTransformer ---- -### ::: ultralytics.vit.sam.modules.transformer.TwoWayTransformer -

- -## TwoWayAttentionBlock ---- -### ::: ultralytics.vit.sam.modules.transformer.TwoWayAttentionBlock -

- -## Attention ---- -### ::: ultralytics.vit.sam.modules.transformer.Attention -

diff --git a/docs/reference/vit/sam/predict.md b/docs/reference/vit/sam/predict.md deleted file mode 100644 index 3547951..0000000 --- a/docs/reference/vit/sam/predict.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -description: The VIT SAM Predictor from Ultralytics provides object detection capabilities for YOLO. Learn how to use it and speed up your object detection models. -keywords: Ultralytics, VIT SAM Predictor, object detection, YOLO ---- - -## Predictor ---- -### ::: ultralytics.vit.sam.predict.Predictor -

diff --git a/docs/reference/vit/utils/loss.md b/docs/reference/vit/utils/loss.md deleted file mode 100644 index cd45d5f..0000000 --- a/docs/reference/vit/utils/loss.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -description: DETRLoss is a method for optimizing detection of objects in images. Learn how to use it in RTDETRDetectionLoss at Ultralytics Docs. -keywords: DETRLoss, RTDETRDetectionLoss, Ultralytics, object detection, image classification, computer vision ---- - -## DETRLoss ---- -### ::: ultralytics.vit.utils.loss.DETRLoss -

- -## RTDETRDetectionLoss ---- -### ::: ultralytics.vit.utils.loss.RTDETRDetectionLoss -

diff --git a/docs/reference/vit/utils/ops.md b/docs/reference/vit/utils/ops.md deleted file mode 100644 index e4660f0..0000000 --- a/docs/reference/vit/utils/ops.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -description: Learn about HungarianMatcher and inverse_sigmoid functions in the Ultralytics YOLO Docs. Improve your object detection skills today!. -keywords: Ultralytics, YOLO, object detection, HungarianMatcher, inverse_sigmoid ---- - -## HungarianMatcher ---- -### ::: ultralytics.vit.utils.ops.HungarianMatcher -

- -## get_cdn_group ---- -### ::: ultralytics.vit.utils.ops.get_cdn_group -

- -## inverse_sigmoid ---- -### ::: ultralytics.vit.utils.ops.inverse_sigmoid -

diff --git a/docs/reference/yolo/cfg/__init__.md b/docs/reference/yolo/cfg/__init__.md deleted file mode 100644 index 26f4e54..0000000 --- a/docs/reference/yolo/cfg/__init__.md +++ /dev/null @@ -1,49 +0,0 @@ ---- -description: Explore Ultralytics YOLO's configuration functions and tools. Handle settings, manage defaults, and deal with deprecations in your YOLO configuration. -keywords: Ultralytics, YOLO, configuration, cfg2dict, get_cfg, handle_deprecation, check_cfg_mismatch, merge_equals_args, handle_yolo_hub, handle_yolo_settings, entrypoint, copy_default_cfg ---- - -## cfg2dict ---- -### ::: ultralytics.yolo.cfg.cfg2dict -

- -## get_cfg ---- -### ::: ultralytics.yolo.cfg.get_cfg -

- -## _handle_deprecation ---- -### ::: ultralytics.yolo.cfg._handle_deprecation -

- -## check_cfg_mismatch ---- -### ::: ultralytics.yolo.cfg.check_cfg_mismatch -

- -## merge_equals_args ---- -### ::: ultralytics.yolo.cfg.merge_equals_args -

- -## handle_yolo_hub ---- -### ::: ultralytics.yolo.cfg.handle_yolo_hub -

- -## handle_yolo_settings ---- -### ::: ultralytics.yolo.cfg.handle_yolo_settings -

- -## entrypoint ---- -### ::: ultralytics.yolo.cfg.entrypoint -

- -## copy_default_cfg ---- -### ::: ultralytics.yolo.cfg.copy_default_cfg -

diff --git a/docs/reference/yolo/data/annotator.md b/docs/reference/yolo/data/annotator.md deleted file mode 100644 index 0999d58..0000000 --- a/docs/reference/yolo/data/annotator.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -description: Learn how to use auto_annotate in Ultralytics YOLO to generate annotations automatically for your dataset. Simplify object detection workflows. -keywords: Ultralytics YOLO, Auto Annotator, AI, image annotation, object detection, labelling, tool ---- - -## auto_annotate ---- -### ::: ultralytics.yolo.data.annotator.auto_annotate -

diff --git a/docs/reference/yolo/data/augment.md b/docs/reference/yolo/data/augment.md deleted file mode 100644 index 634f183..0000000 --- a/docs/reference/yolo/data/augment.md +++ /dev/null @@ -1,99 +0,0 @@ ---- -description: Use Ultralytics YOLO Data Augmentation transforms with Base, MixUp, and Albumentations for object detection and classification. -keywords: YOLO, data augmentation, transforms, BaseTransform, MixUp, RandomHSV, Albumentations, ToTensor, classify_transforms, classify_albumentations ---- - -## BaseTransform ---- -### ::: ultralytics.yolo.data.augment.BaseTransform -

- -## Compose ---- -### ::: ultralytics.yolo.data.augment.Compose -

- -## BaseMixTransform ---- -### ::: ultralytics.yolo.data.augment.BaseMixTransform -

- -## Mosaic ---- -### ::: ultralytics.yolo.data.augment.Mosaic -

- -## MixUp ---- -### ::: ultralytics.yolo.data.augment.MixUp -

- -## RandomPerspective ---- -### ::: ultralytics.yolo.data.augment.RandomPerspective -

- -## RandomHSV ---- -### ::: ultralytics.yolo.data.augment.RandomHSV -

- -## RandomFlip ---- -### ::: ultralytics.yolo.data.augment.RandomFlip -

- -## LetterBox ---- -### ::: ultralytics.yolo.data.augment.LetterBox -

- -## CopyPaste ---- -### ::: ultralytics.yolo.data.augment.CopyPaste -

- -## Albumentations ---- -### ::: ultralytics.yolo.data.augment.Albumentations -

- -## Format ---- -### ::: ultralytics.yolo.data.augment.Format -

- -## ClassifyLetterBox ---- -### ::: ultralytics.yolo.data.augment.ClassifyLetterBox -

- -## CenterCrop ---- -### ::: ultralytics.yolo.data.augment.CenterCrop -

- -## ToTensor ---- -### ::: ultralytics.yolo.data.augment.ToTensor -

- -## v8_transforms ---- -### ::: ultralytics.yolo.data.augment.v8_transforms -

- -## classify_transforms ---- -### ::: ultralytics.yolo.data.augment.classify_transforms -

- -## hsv2colorjitter ---- -### ::: ultralytics.yolo.data.augment.hsv2colorjitter -

- -## classify_albumentations ---- -### ::: ultralytics.yolo.data.augment.classify_albumentations -

diff --git a/docs/reference/yolo/data/base.md b/docs/reference/yolo/data/base.md deleted file mode 100644 index 3742e67..0000000 --- a/docs/reference/yolo/data/base.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -description: Learn about BaseDataset in Ultralytics YOLO, a flexible dataset class for object detection. Maximize your YOLO performance with custom datasets. -keywords: BaseDataset, Ultralytics YOLO, object detection, real-world applications, documentation ---- - -## BaseDataset ---- -### ::: ultralytics.yolo.data.base.BaseDataset -

diff --git a/docs/reference/yolo/data/build.md b/docs/reference/yolo/data/build.md deleted file mode 100644 index cfee450..0000000 --- a/docs/reference/yolo/data/build.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -description: Maximize YOLO performance with Ultralytics' InfiniteDataLoader, seed_worker, build_dataloader, and load_inference_source functions. -keywords: Ultralytics, YOLO, object detection, data loading, build dataloader, load inference source ---- - -## InfiniteDataLoader ---- -### ::: ultralytics.yolo.data.build.InfiniteDataLoader -

- -## _RepeatSampler ---- -### ::: ultralytics.yolo.data.build._RepeatSampler -

- -## seed_worker ---- -### ::: ultralytics.yolo.data.build.seed_worker -

- -## build_yolo_dataset ---- -### ::: ultralytics.yolo.data.build.build_yolo_dataset -

- -## build_dataloader ---- -### ::: ultralytics.yolo.data.build.build_dataloader -

- -## check_source ---- -### ::: ultralytics.yolo.data.build.check_source -

- -## load_inference_source ---- -### ::: ultralytics.yolo.data.build.load_inference_source -

diff --git a/docs/reference/yolo/data/converter.md b/docs/reference/yolo/data/converter.md deleted file mode 100644 index 6fd5d7e..0000000 --- a/docs/reference/yolo/data/converter.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -description: Convert COCO-91 to COCO-80 class, RLE to polygon, and merge multi-segment images with Ultralytics YOLO data converter. Improve your object detection. -keywords: Ultralytics, YOLO, converter, COCO91, COCO80, rle2polygon, merge_multi_segment, annotations ---- - -## coco91_to_coco80_class ---- -### ::: ultralytics.yolo.data.converter.coco91_to_coco80_class -

- -## convert_coco ---- -### ::: ultralytics.yolo.data.converter.convert_coco -

- -## rle2polygon ---- -### ::: ultralytics.yolo.data.converter.rle2polygon -

- -## min_index ---- -### ::: ultralytics.yolo.data.converter.min_index -

- -## merge_multi_segment ---- -### ::: ultralytics.yolo.data.converter.merge_multi_segment -

- -## delete_dsstore ---- -### ::: ultralytics.yolo.data.converter.delete_dsstore -

diff --git a/docs/reference/yolo/data/dataloaders/stream_loaders.md b/docs/reference/yolo/data/dataloaders/stream_loaders.md deleted file mode 100644 index 40afd3d..0000000 --- a/docs/reference/yolo/data/dataloaders/stream_loaders.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -description: 'Ultralytics YOLO Docs: Learn about stream loaders for image and tensor data, as well as autocasting techniques. Check out SourceTypes and more.' -keywords: Ultralytics YOLO, data loaders, stream load images, screenshots, tensor data, autocast list, youtube URL retriever ---- - -## SourceTypes ---- -### ::: ultralytics.yolo.data.dataloaders.stream_loaders.SourceTypes -

- -## LoadStreams ---- -### ::: ultralytics.yolo.data.dataloaders.stream_loaders.LoadStreams -

- -## LoadScreenshots ---- -### ::: ultralytics.yolo.data.dataloaders.stream_loaders.LoadScreenshots -

- -## LoadImages ---- -### ::: ultralytics.yolo.data.dataloaders.stream_loaders.LoadImages -

- -## LoadPilAndNumpy ---- -### ::: ultralytics.yolo.data.dataloaders.stream_loaders.LoadPilAndNumpy -

- -## LoadTensor ---- -### ::: ultralytics.yolo.data.dataloaders.stream_loaders.LoadTensor -

- -## autocast_list ---- -### ::: ultralytics.yolo.data.dataloaders.stream_loaders.autocast_list -

- -## get_best_youtube_url ---- -### ::: ultralytics.yolo.data.dataloaders.stream_loaders.get_best_youtube_url -

diff --git a/docs/reference/yolo/data/dataset.md b/docs/reference/yolo/data/dataset.md deleted file mode 100644 index f42a0a1..0000000 --- a/docs/reference/yolo/data/dataset.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -description: Create custom YOLOv5 datasets with Ultralytics YOLODataset and SemanticDataset. Streamline your object detection and segmentation projects. -keywords: YOLODataset, SemanticDataset, Ultralytics YOLO Docs, Object Detection, Segmentation ---- - -## YOLODataset ---- -### ::: ultralytics.yolo.data.dataset.YOLODataset -

- -## ClassificationDataset ---- -### ::: ultralytics.yolo.data.dataset.ClassificationDataset -

- -## SemanticDataset ---- -### ::: ultralytics.yolo.data.dataset.SemanticDataset -

diff --git a/docs/reference/yolo/data/dataset_wrappers.md b/docs/reference/yolo/data/dataset_wrappers.md deleted file mode 100644 index c56806d..0000000 --- a/docs/reference/yolo/data/dataset_wrappers.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -description: Create a custom dataset of mixed and oriented rectangular objects with Ultralytics YOLO's MixAndRectDataset. -keywords: Ultralytics YOLO, MixAndRectDataset, dataset wrapper, image-level annotations, object-level annotations, rectangular object detection ---- - -## MixAndRectDataset ---- -### ::: ultralytics.yolo.data.dataset_wrappers.MixAndRectDataset -

diff --git a/docs/reference/yolo/data/utils.md b/docs/reference/yolo/data/utils.md deleted file mode 100644 index 248321b..0000000 --- a/docs/reference/yolo/data/utils.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -description: Efficiently handle data in YOLO with Ultralytics. Utilize HUBDatasetStats and customize dataset with these data utility functions. -keywords: YOLOv4, Object Detection, Computer Vision, Deep Learning, Convolutional Neural Network, CNN, Ultralytics Docs ---- - -## HUBDatasetStats ---- -### ::: ultralytics.yolo.data.utils.HUBDatasetStats -

- -## img2label_paths ---- -### ::: ultralytics.yolo.data.utils.img2label_paths -

- -## get_hash ---- -### ::: ultralytics.yolo.data.utils.get_hash -

- -## exif_size ---- -### ::: ultralytics.yolo.data.utils.exif_size -

- -## verify_image_label ---- -### ::: ultralytics.yolo.data.utils.verify_image_label -

- -## polygon2mask ---- -### ::: ultralytics.yolo.data.utils.polygon2mask -

- -## polygons2masks ---- -### ::: ultralytics.yolo.data.utils.polygons2masks -

- -## polygons2masks_overlap ---- -### ::: ultralytics.yolo.data.utils.polygons2masks_overlap -

- -## check_det_dataset ---- -### ::: ultralytics.yolo.data.utils.check_det_dataset -

- -## check_cls_dataset ---- -### ::: ultralytics.yolo.data.utils.check_cls_dataset -

- -## compress_one_image ---- -### ::: ultralytics.yolo.data.utils.compress_one_image -

- -## delete_dsstore ---- -### ::: ultralytics.yolo.data.utils.delete_dsstore -

- -## zip_directory ---- -### ::: ultralytics.yolo.data.utils.zip_directory -

- -## autosplit ---- -### ::: ultralytics.yolo.data.utils.autosplit -

diff --git a/docs/reference/yolo/engine/exporter.md b/docs/reference/yolo/engine/exporter.md deleted file mode 100644 index 37189d4..0000000 --- a/docs/reference/yolo/engine/exporter.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -description: Learn how to export your YOLO model in various formats using Ultralytics' exporter package - iOS, GDC, and more. -keywords: Ultralytics, YOLO, exporter, iOS detect model, gd_outputs, export ---- - -## Exporter ---- -### ::: ultralytics.yolo.engine.exporter.Exporter -

- -## iOSDetectModel ---- -### ::: ultralytics.yolo.engine.exporter.iOSDetectModel -

- -## export_formats ---- -### ::: ultralytics.yolo.engine.exporter.export_formats -

- -## gd_outputs ---- -### ::: ultralytics.yolo.engine.exporter.gd_outputs -

- -## try_export ---- -### ::: ultralytics.yolo.engine.exporter.try_export -

- -## export ---- -### ::: ultralytics.yolo.engine.exporter.export -

diff --git a/docs/reference/yolo/engine/model.md b/docs/reference/yolo/engine/model.md deleted file mode 100644 index 9ba7932..0000000 --- a/docs/reference/yolo/engine/model.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -description: Discover the YOLO model of Ultralytics engine to simplify your object detection tasks with state-of-the-art models. -keywords: YOLO, object detection, model, architecture, usage, customization, Ultralytics Docs ---- - -## YOLO ---- -### ::: ultralytics.yolo.engine.model.YOLO -

diff --git a/docs/reference/yolo/engine/predictor.md b/docs/reference/yolo/engine/predictor.md deleted file mode 100644 index f4aed3c..0000000 --- a/docs/reference/yolo/engine/predictor.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -description: '"The BasePredictor class in Ultralytics YOLO Engine predicts object detection in images and videos. Learn to implement YOLO with ease."' -keywords: Ultralytics, YOLO, BasePredictor, Object Detection, Computer Vision, Fast Model, Insights ---- - -## BasePredictor ---- -### ::: ultralytics.yolo.engine.predictor.BasePredictor -

diff --git a/docs/reference/yolo/engine/results.md b/docs/reference/yolo/engine/results.md deleted file mode 100644 index 38e568f..0000000 --- a/docs/reference/yolo/engine/results.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -description: Learn about BaseTensor & Boxes in Ultralytics YOLO Engine. Check out Ultralytics Docs for quality tutorials and resources on object detection. -keywords: YOLO, Engine, Results, Masks, Probs, Ultralytics ---- - -## BaseTensor ---- -### ::: ultralytics.yolo.engine.results.BaseTensor -

- -## Results ---- -### ::: ultralytics.yolo.engine.results.Results -

- -## Boxes ---- -### ::: ultralytics.yolo.engine.results.Boxes -

- -## Masks ---- -### ::: ultralytics.yolo.engine.results.Masks -

- -## Keypoints ---- -### ::: ultralytics.yolo.engine.results.Keypoints -

- -## Probs ---- -### ::: ultralytics.yolo.engine.results.Probs -

diff --git a/docs/reference/yolo/engine/trainer.md b/docs/reference/yolo/engine/trainer.md deleted file mode 100644 index e9a06e4..0000000 --- a/docs/reference/yolo/engine/trainer.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -description: Train faster with mixed precision. Learn how to use BaseTrainer with Advanced Mixed Precision to optimize YOLOv3 and YOLOv4 models. -keywords: Ultralytics YOLO, BaseTrainer, object detection models, training guide ---- - -## BaseTrainer ---- -### ::: ultralytics.yolo.engine.trainer.BaseTrainer -

diff --git a/docs/reference/yolo/engine/validator.md b/docs/reference/yolo/engine/validator.md deleted file mode 100644 index c9355ea..0000000 --- a/docs/reference/yolo/engine/validator.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -description: Ensure YOLOv5 models meet constraints and standards with the BaseValidator class. Learn how to use it here. -keywords: Ultralytics, YOLO, BaseValidator, models, validation, object detection ---- - -## BaseValidator ---- -### ::: ultralytics.yolo.engine.validator.BaseValidator -

diff --git a/docs/reference/yolo/fastsam/model.md b/docs/reference/yolo/fastsam/model.md deleted file mode 100644 index b84e994..0000000 --- a/docs/reference/yolo/fastsam/model.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -description: Learn how to use FastSAM in Ultralytics YOLO to improve object detection accuracy and speed. -keywords: FastSAM, object detection, accuracy, speed, Ultralytics YOLO ---- - -## FastSAM ---- -### ::: ultralytics.yolo.fastsam.model.FastSAM -

diff --git a/docs/reference/yolo/fastsam/predict.md b/docs/reference/yolo/fastsam/predict.md deleted file mode 100644 index 377ae25..0000000 --- a/docs/reference/yolo/fastsam/predict.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -description: FastSAMPredictor API reference and usage guide for the Ultralytics YOLO object detection library. -keywords: FastSAMPredictor, API, reference, usage, guide, Ultralytics, YOLO, object detection, library ---- - -## FastSAMPredictor ---- -### ::: ultralytics.yolo.fastsam.predict.FastSAMPredictor -

diff --git a/docs/reference/yolo/fastsam/prompt.md b/docs/reference/yolo/fastsam/prompt.md deleted file mode 100644 index e6fdc6d..0000000 --- a/docs/reference/yolo/fastsam/prompt.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -description: Learn how to use FastSAMPrompt in Ultralytics YOLO for fast and efficient object detection and tracking. -keywords: FastSAMPrompt, Ultralytics YOLO, object detection, tracking, fast, efficient ---- - -## FastSAMPrompt ---- -### ::: ultralytics.yolo.fastsam.prompt.FastSAMPrompt -

diff --git a/docs/reference/yolo/fastsam/utils.md b/docs/reference/yolo/fastsam/utils.md deleted file mode 100644 index 6031bbc..0000000 --- a/docs/reference/yolo/fastsam/utils.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -description: Learn how to adjust bounding boxes to the image border in Ultralytics YOLO framework. Improve object detection accuracy by accounting for image borders. -keywords: adjust_bboxes_to_image_border, Ultralytics YOLO, object detection, bounding boxes, image border ---- - -## adjust_bboxes_to_image_border ---- -### ::: ultralytics.yolo.fastsam.utils.adjust_bboxes_to_image_border -

- -## bbox_iou ---- -### ::: ultralytics.yolo.fastsam.utils.bbox_iou -

diff --git a/docs/reference/yolo/fastsam/val.md b/docs/reference/yolo/fastsam/val.md deleted file mode 100644 index e4bb547..0000000 --- a/docs/reference/yolo/fastsam/val.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -description: Learn about the FastSAMValidator module in Ultralytics YOLO. Validate and evaluate Segment Anything Model (SAM) datasets for object detection models with ease. -keywords: FastSAMValidator, Ultralytics YOLO, SAM datasets, object detection, validation, evaluation ---- - -## FastSAMValidator ---- -### ::: ultralytics.yolo.fastsam.val.FastSAMValidator -

diff --git a/docs/reference/yolo/nas/model.md b/docs/reference/yolo/nas/model.md deleted file mode 100644 index 9c34659..0000000 --- a/docs/reference/yolo/nas/model.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -description: Learn about the Neural Architecture Search (NAS) feature available in Ultralytics YOLO. Find out how NAS can improve object detection models and increase accuracy. Get started today!. -keywords: Ultralytics YOLO, object detection, NAS, Neural Architecture Search, model optimization, accuracy improvement ---- - -## NAS ---- -### ::: ultralytics.yolo.nas.model.NAS -

diff --git a/docs/reference/yolo/nas/predict.md b/docs/reference/yolo/nas/predict.md deleted file mode 100644 index fb2be3f..0000000 --- a/docs/reference/yolo/nas/predict.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -description: Learn how to use NASPredictor in Ultralytics YOLO for deploying efficient CNN models with search algorithms in neural architecture search. -keywords: Ultralytics YOLO, NASPredictor, neural architecture search, efficient CNN models, search algorithms ---- - -## NASPredictor ---- -### ::: ultralytics.yolo.nas.predict.NASPredictor -

diff --git a/docs/reference/yolo/nas/val.md b/docs/reference/yolo/nas/val.md deleted file mode 100644 index 804ced3..0000000 --- a/docs/reference/yolo/nas/val.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -description: Learn about NASValidator in the Ultralytics YOLO Docs. Properly validate YOLO neural architecture search results for optimal performance. -keywords: NASValidator, YOLO, neural architecture search, validation, performance, Ultralytics ---- - -## NASValidator ---- -### ::: ultralytics.yolo.nas.val.NASValidator -

diff --git a/docs/reference/yolo/utils/__init__.md b/docs/reference/yolo/utils/__init__.md deleted file mode 100644 index 4fa7604..0000000 --- a/docs/reference/yolo/utils/__init__.md +++ /dev/null @@ -1,174 +0,0 @@ ---- -description: Uncover utility functions in Ultralytics YOLO. Handle YAML, threading, logging, error-checking, and platform identification. Enhance your YOLO development process. -keywords: Ultralytics, YOLO, utils, SimpleClass, IterableSimpleNamespace, EmojiFilter, TryExcept, plt_settings, set_logging, emojis, yaml_save, yaml_load, yaml_print, is_colab, is_kaggle, is_jupyter, is_docker, is_online, is_pip_package, is_dir_writeable, is_pytest_running, is_github_actions_ci, is_git_dir, get_git_dir, get_git_origin_url, get_git_branch, get_default_args, get_user_config_dir, colorstr, threaded, set_sentry, get_settings, set_settings, deprecation_warn, clean_url, url2file ---- - -## SimpleClass ---- -### ::: ultralytics.yolo.utils.SimpleClass -

- -## IterableSimpleNamespace ---- -### ::: ultralytics.yolo.utils.IterableSimpleNamespace -

- -## EmojiFilter ---- -### ::: ultralytics.yolo.utils.EmojiFilter -

- -## ThreadingLocked ---- -### ::: ultralytics.yolo.utils.ThreadingLocked -

- -## TryExcept ---- -### ::: ultralytics.yolo.utils.TryExcept -

- -## plt_settings ---- -### ::: ultralytics.yolo.utils.plt_settings -

- -## set_logging ---- -### ::: ultralytics.yolo.utils.set_logging -

- -## emojis ---- -### ::: ultralytics.yolo.utils.emojis -

- -## yaml_save ---- -### ::: ultralytics.yolo.utils.yaml_save -

- -## yaml_load ---- -### ::: ultralytics.yolo.utils.yaml_load -

- -## yaml_print ---- -### ::: ultralytics.yolo.utils.yaml_print -

- -## is_colab ---- -### ::: ultralytics.yolo.utils.is_colab -

- -## is_kaggle ---- -### ::: ultralytics.yolo.utils.is_kaggle -

- -## is_jupyter ---- -### ::: ultralytics.yolo.utils.is_jupyter -

- -## is_docker ---- -### ::: ultralytics.yolo.utils.is_docker -

- -## is_online ---- -### ::: ultralytics.yolo.utils.is_online -

- -## is_pip_package ---- -### ::: ultralytics.yolo.utils.is_pip_package -

- -## is_dir_writeable ---- -### ::: ultralytics.yolo.utils.is_dir_writeable -

- -## is_pytest_running ---- -### ::: ultralytics.yolo.utils.is_pytest_running -

- -## is_github_actions_ci ---- -### ::: ultralytics.yolo.utils.is_github_actions_ci -

- -## is_git_dir ---- -### ::: ultralytics.yolo.utils.is_git_dir -

- -## get_git_dir ---- -### ::: ultralytics.yolo.utils.get_git_dir -

- -## get_git_origin_url ---- -### ::: ultralytics.yolo.utils.get_git_origin_url -

- -## get_git_branch ---- -### ::: ultralytics.yolo.utils.get_git_branch -

- -## get_default_args ---- -### ::: ultralytics.yolo.utils.get_default_args -

- -## get_user_config_dir ---- -### ::: ultralytics.yolo.utils.get_user_config_dir -

- -## colorstr ---- -### ::: ultralytics.yolo.utils.colorstr -

- -## threaded ---- -### ::: ultralytics.yolo.utils.threaded -

- -## set_sentry ---- -### ::: ultralytics.yolo.utils.set_sentry -

- -## get_settings ---- -### ::: ultralytics.yolo.utils.get_settings -

- -## set_settings ---- -### ::: ultralytics.yolo.utils.set_settings -

- -## deprecation_warn ---- -### ::: ultralytics.yolo.utils.deprecation_warn -

- -## clean_url ---- -### ::: ultralytics.yolo.utils.clean_url -

- -## url2file ---- -### ::: ultralytics.yolo.utils.url2file -

diff --git a/docs/reference/yolo/utils/autobatch.md b/docs/reference/yolo/utils/autobatch.md deleted file mode 100644 index fe9ba66..0000000 --- a/docs/reference/yolo/utils/autobatch.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -description: Dynamically adjusts input size to optimize GPU memory usage during training. Learn how to use check_train_batch_size with Ultralytics YOLO. -keywords: YOLOv5, batch size, training, Ultralytics Autobatch, object detection, model performance ---- - -## check_train_batch_size ---- -### ::: ultralytics.yolo.utils.autobatch.check_train_batch_size -

- -## autobatch ---- -### ::: ultralytics.yolo.utils.autobatch.autobatch -

diff --git a/docs/reference/yolo/utils/benchmarks.md b/docs/reference/yolo/utils/benchmarks.md deleted file mode 100644 index 7c37502..0000000 --- a/docs/reference/yolo/utils/benchmarks.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -description: Improve your YOLO's performance and measure its speed. Benchmark utility for YOLOv5. -keywords: Ultralytics YOLO, ProfileModels, benchmark, model inference, detection ---- - -## ProfileModels ---- -### ::: ultralytics.yolo.utils.benchmarks.ProfileModels -

- -## benchmark ---- -### ::: ultralytics.yolo.utils.benchmarks.benchmark -

diff --git a/docs/reference/yolo/utils/callbacks/base.md b/docs/reference/yolo/utils/callbacks/base.md deleted file mode 100644 index bdb3ae1..0000000 --- a/docs/reference/yolo/utils/callbacks/base.md +++ /dev/null @@ -1,139 +0,0 @@ ---- -description: Learn about YOLO's callback functions from on_train_start to add_integration_callbacks. See how these callbacks modify and save models. -keywords: YOLO, Ultralytics, callbacks, object detection, training, inference ---- - -## on_pretrain_routine_start ---- -### ::: ultralytics.yolo.utils.callbacks.base.on_pretrain_routine_start -

- -## on_pretrain_routine_end ---- -### ::: ultralytics.yolo.utils.callbacks.base.on_pretrain_routine_end -

- -## on_train_start ---- -### ::: ultralytics.yolo.utils.callbacks.base.on_train_start -

- -## on_train_epoch_start ---- -### ::: ultralytics.yolo.utils.callbacks.base.on_train_epoch_start -

- -## on_train_batch_start ---- -### ::: ultralytics.yolo.utils.callbacks.base.on_train_batch_start -

- -## optimizer_step ---- -### ::: ultralytics.yolo.utils.callbacks.base.optimizer_step -

- -## on_before_zero_grad ---- -### ::: ultralytics.yolo.utils.callbacks.base.on_before_zero_grad -

- -## on_train_batch_end ---- -### ::: ultralytics.yolo.utils.callbacks.base.on_train_batch_end -

- -## on_train_epoch_end ---- -### ::: ultralytics.yolo.utils.callbacks.base.on_train_epoch_end -

- -## on_fit_epoch_end ---- -### ::: ultralytics.yolo.utils.callbacks.base.on_fit_epoch_end -

- -## on_model_save ---- -### ::: ultralytics.yolo.utils.callbacks.base.on_model_save -

- -## on_train_end ---- -### ::: ultralytics.yolo.utils.callbacks.base.on_train_end -

- -## on_params_update ---- -### ::: ultralytics.yolo.utils.callbacks.base.on_params_update -

- -## teardown ---- -### ::: ultralytics.yolo.utils.callbacks.base.teardown -

- -## on_val_start ---- -### ::: ultralytics.yolo.utils.callbacks.base.on_val_start -

- -## on_val_batch_start ---- -### ::: ultralytics.yolo.utils.callbacks.base.on_val_batch_start -

- -## on_val_batch_end ---- -### ::: ultralytics.yolo.utils.callbacks.base.on_val_batch_end -

- -## on_val_end ---- -### ::: ultralytics.yolo.utils.callbacks.base.on_val_end -

- -## on_predict_start ---- -### ::: ultralytics.yolo.utils.callbacks.base.on_predict_start -

- -## on_predict_batch_start ---- -### ::: ultralytics.yolo.utils.callbacks.base.on_predict_batch_start -

- -## on_predict_batch_end ---- -### ::: ultralytics.yolo.utils.callbacks.base.on_predict_batch_end -

- -## on_predict_postprocess_end ---- -### ::: ultralytics.yolo.utils.callbacks.base.on_predict_postprocess_end -

- -## on_predict_end ---- -### ::: ultralytics.yolo.utils.callbacks.base.on_predict_end -

- -## on_export_start ---- -### ::: ultralytics.yolo.utils.callbacks.base.on_export_start -

- -## on_export_end ---- -### ::: ultralytics.yolo.utils.callbacks.base.on_export_end -

- -## get_default_callbacks ---- -### ::: ultralytics.yolo.utils.callbacks.base.get_default_callbacks -

- -## add_integration_callbacks ---- -### ::: ultralytics.yolo.utils.callbacks.base.add_integration_callbacks -

diff --git a/docs/reference/yolo/utils/callbacks/clearml.md b/docs/reference/yolo/utils/callbacks/clearml.md deleted file mode 100644 index 54b8bc6..0000000 --- a/docs/reference/yolo/utils/callbacks/clearml.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -description: Improve your YOLOv5 model training with callbacks from ClearML. Learn about log debug samples, pre-training routines, validation and more. -keywords: Ultralytics YOLO, callbacks, log plots, epoch monitoring, training end events ---- - -## _log_debug_samples ---- -### ::: ultralytics.yolo.utils.callbacks.clearml._log_debug_samples -

- -## _log_plot ---- -### ::: ultralytics.yolo.utils.callbacks.clearml._log_plot -

- -## on_pretrain_routine_start ---- -### ::: ultralytics.yolo.utils.callbacks.clearml.on_pretrain_routine_start -

- -## on_train_epoch_end ---- -### ::: ultralytics.yolo.utils.callbacks.clearml.on_train_epoch_end -

- -## on_fit_epoch_end ---- -### ::: ultralytics.yolo.utils.callbacks.clearml.on_fit_epoch_end -

- -## on_val_end ---- -### ::: ultralytics.yolo.utils.callbacks.clearml.on_val_end -

- -## on_train_end ---- -### ::: ultralytics.yolo.utils.callbacks.clearml.on_train_end -

diff --git a/docs/reference/yolo/utils/callbacks/comet.md b/docs/reference/yolo/utils/callbacks/comet.md deleted file mode 100644 index 1d45191..0000000 --- a/docs/reference/yolo/utils/callbacks/comet.md +++ /dev/null @@ -1,124 +0,0 @@ ---- -description: Learn about YOLO callbacks using the Comet.ml platform, enhancing object detection training and testing with custom logging and visualizations. -keywords: Ultralytics, YOLO, callbacks, Comet ML, log images, log predictions, log plots, fetch metadata, fetch annotations, create experiment data, format experiment data ---- - -## _get_comet_mode ---- -### ::: ultralytics.yolo.utils.callbacks.comet._get_comet_mode -

- -## _get_comet_model_name ---- -### ::: ultralytics.yolo.utils.callbacks.comet._get_comet_model_name -

- -## _get_eval_batch_logging_interval ---- -### ::: ultralytics.yolo.utils.callbacks.comet._get_eval_batch_logging_interval -

- -## _get_max_image_predictions_to_log ---- -### ::: ultralytics.yolo.utils.callbacks.comet._get_max_image_predictions_to_log -

- -## _scale_confidence_score ---- -### ::: ultralytics.yolo.utils.callbacks.comet._scale_confidence_score -

- -## _should_log_confusion_matrix ---- -### ::: ultralytics.yolo.utils.callbacks.comet._should_log_confusion_matrix -

- -## _should_log_image_predictions ---- -### ::: ultralytics.yolo.utils.callbacks.comet._should_log_image_predictions -

- -## _get_experiment_type ---- -### ::: ultralytics.yolo.utils.callbacks.comet._get_experiment_type -

- -## _create_experiment ---- -### ::: ultralytics.yolo.utils.callbacks.comet._create_experiment -

- -## _fetch_trainer_metadata ---- -### ::: ultralytics.yolo.utils.callbacks.comet._fetch_trainer_metadata -

- -## _scale_bounding_box_to_original_image_shape ---- -### ::: ultralytics.yolo.utils.callbacks.comet._scale_bounding_box_to_original_image_shape -

- -## _format_ground_truth_annotations_for_detection ---- -### ::: ultralytics.yolo.utils.callbacks.comet._format_ground_truth_annotations_for_detection -

- -## _format_prediction_annotations_for_detection ---- -### ::: ultralytics.yolo.utils.callbacks.comet._format_prediction_annotations_for_detection -

- -## _fetch_annotations ---- -### ::: ultralytics.yolo.utils.callbacks.comet._fetch_annotations -

- -## _create_prediction_metadata_map ---- -### ::: ultralytics.yolo.utils.callbacks.comet._create_prediction_metadata_map -

- -## _log_confusion_matrix ---- -### ::: ultralytics.yolo.utils.callbacks.comet._log_confusion_matrix -

- -## _log_images ---- -### ::: ultralytics.yolo.utils.callbacks.comet._log_images -

- -## _log_image_predictions ---- -### ::: ultralytics.yolo.utils.callbacks.comet._log_image_predictions -

- -## _log_plots ---- -### ::: ultralytics.yolo.utils.callbacks.comet._log_plots -

- -## _log_model ---- -### ::: ultralytics.yolo.utils.callbacks.comet._log_model -

- -## on_pretrain_routine_start ---- -### ::: ultralytics.yolo.utils.callbacks.comet.on_pretrain_routine_start -

- -## on_train_epoch_end ---- -### ::: ultralytics.yolo.utils.callbacks.comet.on_train_epoch_end -

- -## on_fit_epoch_end ---- -### ::: ultralytics.yolo.utils.callbacks.comet.on_fit_epoch_end -

- -## on_train_end ---- -### ::: ultralytics.yolo.utils.callbacks.comet.on_train_end -

diff --git a/docs/reference/yolo/utils/callbacks/dvc.md b/docs/reference/yolo/utils/callbacks/dvc.md deleted file mode 100644 index b32fc7a..0000000 --- a/docs/reference/yolo/utils/callbacks/dvc.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -description: Explore Ultralytics YOLO Utils DVC Callbacks such as logging images, plots, confusion matrices, and training progress. -keywords: Ultralytics, YOLO, Utils, DVC, Callbacks, images, plots, confusion matrices, training progress ---- - -## _logger_disabled ---- -### ::: ultralytics.yolo.utils.callbacks.dvc._logger_disabled -

- -## _log_images ---- -### ::: ultralytics.yolo.utils.callbacks.dvc._log_images -

- -## _log_plots ---- -### ::: ultralytics.yolo.utils.callbacks.dvc._log_plots -

- -## _log_confusion_matrix ---- -### ::: ultralytics.yolo.utils.callbacks.dvc._log_confusion_matrix -

- -## on_pretrain_routine_start ---- -### ::: ultralytics.yolo.utils.callbacks.dvc.on_pretrain_routine_start -

- -## on_pretrain_routine_end ---- -### ::: ultralytics.yolo.utils.callbacks.dvc.on_pretrain_routine_end -

- -## on_train_start ---- -### ::: ultralytics.yolo.utils.callbacks.dvc.on_train_start -

- -## on_train_epoch_start ---- -### ::: ultralytics.yolo.utils.callbacks.dvc.on_train_epoch_start -

- -## on_fit_epoch_end ---- -### ::: ultralytics.yolo.utils.callbacks.dvc.on_fit_epoch_end -

- -## on_train_end ---- -### ::: ultralytics.yolo.utils.callbacks.dvc.on_train_end -

diff --git a/docs/reference/yolo/utils/callbacks/hub.md b/docs/reference/yolo/utils/callbacks/hub.md deleted file mode 100644 index 7b24199..0000000 --- a/docs/reference/yolo/utils/callbacks/hub.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -description: Improve YOLOv5 model training with Ultralytics' on-train callbacks. Boost performance on-pretrain-routine-end, model-save, train/predict start. -keywords: Ultralytics, YOLO, callbacks, on_pretrain_routine_end, on_fit_epoch_end, on_train_start, on_val_start, on_predict_start, on_export_start ---- - -## on_pretrain_routine_end ---- -### ::: ultralytics.yolo.utils.callbacks.hub.on_pretrain_routine_end -

- -## on_fit_epoch_end ---- -### ::: ultralytics.yolo.utils.callbacks.hub.on_fit_epoch_end -

- -## on_model_save ---- -### ::: ultralytics.yolo.utils.callbacks.hub.on_model_save -

- -## on_train_end ---- -### ::: ultralytics.yolo.utils.callbacks.hub.on_train_end -

- -## on_train_start ---- -### ::: ultralytics.yolo.utils.callbacks.hub.on_train_start -

- -## on_val_start ---- -### ::: ultralytics.yolo.utils.callbacks.hub.on_val_start -

- -## on_predict_start ---- -### ::: ultralytics.yolo.utils.callbacks.hub.on_predict_start -

- -## on_export_start ---- -### ::: ultralytics.yolo.utils.callbacks.hub.on_export_start -

diff --git a/docs/reference/yolo/utils/callbacks/mlflow.md b/docs/reference/yolo/utils/callbacks/mlflow.md deleted file mode 100644 index 9d69d0f..0000000 --- a/docs/reference/yolo/utils/callbacks/mlflow.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -description: Track model performance and metrics with MLflow in YOLOv5. Use callbacks like on_pretrain_routine_end or on_train_end to log information. -keywords: Ultralytics, YOLO, Utils, MLflow, callbacks, on_pretrain_routine_end, on_train_end, Tracking, Model Management, training ---- - -## on_pretrain_routine_end ---- -### ::: ultralytics.yolo.utils.callbacks.mlflow.on_pretrain_routine_end -

- -## on_fit_epoch_end ---- -### ::: ultralytics.yolo.utils.callbacks.mlflow.on_fit_epoch_end -

- -## on_train_end ---- -### ::: ultralytics.yolo.utils.callbacks.mlflow.on_train_end -

diff --git a/docs/reference/yolo/utils/callbacks/neptune.md b/docs/reference/yolo/utils/callbacks/neptune.md deleted file mode 100644 index cadbfb5..0000000 --- a/docs/reference/yolo/utils/callbacks/neptune.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -description: Improve YOLOv5 training with Neptune, a powerful logging tool. Track metrics like images, plots, and epochs for better model performance. -keywords: Ultralytics, YOLO, Neptune, Callbacks, log scalars, log images, log plots, training, validation ---- - -## _log_scalars ---- -### ::: ultralytics.yolo.utils.callbacks.neptune._log_scalars -

- -## _log_images ---- -### ::: ultralytics.yolo.utils.callbacks.neptune._log_images -

- -## _log_plot ---- -### ::: ultralytics.yolo.utils.callbacks.neptune._log_plot -

- -## on_pretrain_routine_start ---- -### ::: ultralytics.yolo.utils.callbacks.neptune.on_pretrain_routine_start -

- -## on_train_epoch_end ---- -### ::: ultralytics.yolo.utils.callbacks.neptune.on_train_epoch_end -

- -## on_fit_epoch_end ---- -### ::: ultralytics.yolo.utils.callbacks.neptune.on_fit_epoch_end -

- -## on_val_end ---- -### ::: ultralytics.yolo.utils.callbacks.neptune.on_val_end -

- -## on_train_end ---- -### ::: ultralytics.yolo.utils.callbacks.neptune.on_train_end -

diff --git a/docs/reference/yolo/utils/callbacks/raytune.md b/docs/reference/yolo/utils/callbacks/raytune.md deleted file mode 100644 index 2771c2e..0000000 --- a/docs/reference/yolo/utils/callbacks/raytune.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -description: '"Improve YOLO model performance with on_fit_epoch_end callback. Learn to integrate with Ray Tune for hyperparameter tuning. Ultralytics YOLO docs."' -keywords: on_fit_epoch_end, Ultralytics YOLO, callback function, training, model tuning ---- - -## on_fit_epoch_end ---- -### ::: ultralytics.yolo.utils.callbacks.raytune.on_fit_epoch_end -

diff --git a/docs/reference/yolo/utils/callbacks/tensorboard.md b/docs/reference/yolo/utils/callbacks/tensorboard.md deleted file mode 100644 index b5eea1b..0000000 --- a/docs/reference/yolo/utils/callbacks/tensorboard.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -description: Learn how to monitor the training process with Tensorboard using Ultralytics YOLO's "_log_scalars" and "on_batch_end" methods. -keywords: TensorBoard callbacks, YOLO training, ultralytics YOLO ---- - -## _log_scalars ---- -### ::: ultralytics.yolo.utils.callbacks.tensorboard._log_scalars -

- -## on_pretrain_routine_start ---- -### ::: ultralytics.yolo.utils.callbacks.tensorboard.on_pretrain_routine_start -

- -## on_batch_end ---- -### ::: ultralytics.yolo.utils.callbacks.tensorboard.on_batch_end -

- -## on_fit_epoch_end ---- -### ::: ultralytics.yolo.utils.callbacks.tensorboard.on_fit_epoch_end -

diff --git a/docs/reference/yolo/utils/callbacks/wb.md b/docs/reference/yolo/utils/callbacks/wb.md deleted file mode 100644 index 1116adc..0000000 --- a/docs/reference/yolo/utils/callbacks/wb.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -description: Learn how to use Ultralytics YOLO's built-in callbacks `on_pretrain_routine_start` and `on_train_epoch_end` for improved training performance. -keywords: Ultralytics, YOLO, callbacks, weights, biases, training ---- - -## _log_plots ---- -### ::: ultralytics.yolo.utils.callbacks.wb._log_plots -

- -## on_pretrain_routine_start ---- -### ::: ultralytics.yolo.utils.callbacks.wb.on_pretrain_routine_start -

- -## on_fit_epoch_end ---- -### ::: ultralytics.yolo.utils.callbacks.wb.on_fit_epoch_end -

- -## on_train_epoch_end ---- -### ::: ultralytics.yolo.utils.callbacks.wb.on_train_epoch_end -

- -## on_train_end ---- -### ::: ultralytics.yolo.utils.callbacks.wb.on_train_end -

diff --git a/docs/reference/yolo/utils/checks.md b/docs/reference/yolo/utils/checks.md deleted file mode 100644 index 48fd0bd..0000000 --- a/docs/reference/yolo/utils/checks.md +++ /dev/null @@ -1,94 +0,0 @@ ---- -description: 'Check functions for YOLO utils: image size, version, font, requirements, filename suffix, YAML file, YOLO, and Git version.' -keywords: YOLO, Ultralytics, Utils, Checks, image sizing, version updates, font compatibility, Python requirements, file suffixes, YAML syntax, image showing, AMP ---- - -## is_ascii ---- -### ::: ultralytics.yolo.utils.checks.is_ascii -

- -## check_imgsz ---- -### ::: ultralytics.yolo.utils.checks.check_imgsz -

- -## check_version ---- -### ::: ultralytics.yolo.utils.checks.check_version -

- -## check_latest_pypi_version ---- -### ::: ultralytics.yolo.utils.checks.check_latest_pypi_version -

- -## check_pip_update_available ---- -### ::: ultralytics.yolo.utils.checks.check_pip_update_available -

- -## check_font ---- -### ::: ultralytics.yolo.utils.checks.check_font -

- -## check_python ---- -### ::: ultralytics.yolo.utils.checks.check_python -

- -## check_requirements ---- -### ::: ultralytics.yolo.utils.checks.check_requirements -

- -## check_torchvision ---- -### ::: ultralytics.yolo.utils.checks.check_torchvision -

- -## check_suffix ---- -### ::: ultralytics.yolo.utils.checks.check_suffix -

- -## check_yolov5u_filename ---- -### ::: ultralytics.yolo.utils.checks.check_yolov5u_filename -

- -## check_file ---- -### ::: ultralytics.yolo.utils.checks.check_file -

- -## check_yaml ---- -### ::: ultralytics.yolo.utils.checks.check_yaml -

- -## check_imshow ---- -### ::: ultralytics.yolo.utils.checks.check_imshow -

- -## check_yolo ---- -### ::: ultralytics.yolo.utils.checks.check_yolo -

- -## check_amp ---- -### ::: ultralytics.yolo.utils.checks.check_amp -

- -## git_describe ---- -### ::: ultralytics.yolo.utils.checks.git_describe -

- -## print_args ---- -### ::: ultralytics.yolo.utils.checks.print_args -

diff --git a/docs/reference/yolo/utils/dist.md b/docs/reference/yolo/utils/dist.md deleted file mode 100644 index 3e5033e..0000000 --- a/docs/reference/yolo/utils/dist.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -description: Learn how to find free network port and generate DDP (Distributed Data Parallel) command in Ultralytics YOLO with easy examples. -keywords: ultralytics, YOLO, utils, dist, distributed deep learning, DDP file, DDP cleanup ---- - -## find_free_network_port ---- -### ::: ultralytics.yolo.utils.dist.find_free_network_port -

- -## generate_ddp_file ---- -### ::: ultralytics.yolo.utils.dist.generate_ddp_file -

- -## generate_ddp_command ---- -### ::: ultralytics.yolo.utils.dist.generate_ddp_command -

- -## ddp_cleanup ---- -### ::: ultralytics.yolo.utils.dist.ddp_cleanup -

diff --git a/docs/reference/yolo/utils/downloads.md b/docs/reference/yolo/utils/downloads.md deleted file mode 100644 index 3e06f8f..0000000 --- a/docs/reference/yolo/utils/downloads.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -description: Download and unzip YOLO pretrained models. Ultralytics YOLO docs utils.downloads.unzip_file, checks disk space, downloads and attempts assets. -keywords: Ultralytics YOLO, downloads, trained models, datasets, weights, deep learning, computer vision ---- - -## is_url ---- -### ::: ultralytics.yolo.utils.downloads.is_url -

- -## unzip_file ---- -### ::: ultralytics.yolo.utils.downloads.unzip_file -

- -## check_disk_space ---- -### ::: ultralytics.yolo.utils.downloads.check_disk_space -

- -## safe_download ---- -### ::: ultralytics.yolo.utils.downloads.safe_download -

- -## get_github_assets ---- -### ::: ultralytics.yolo.utils.downloads.get_github_assets -

- -## attempt_download_asset ---- -### ::: ultralytics.yolo.utils.downloads.attempt_download_asset -

- -## download ---- -### ::: ultralytics.yolo.utils.downloads.download -

diff --git a/docs/reference/yolo/utils/errors.md b/docs/reference/yolo/utils/errors.md deleted file mode 100644 index f3ddfc4..0000000 --- a/docs/reference/yolo/utils/errors.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -description: Learn about HUBModelError in Ultralytics YOLO Docs. Resolve the error and get the most out of your YOLO model. -keywords: HUBModelError, Ultralytics YOLO, YOLO Documentation, Object detection errors, YOLO Errors, HUBModelError Solutions ---- - -## HUBModelError ---- -### ::: ultralytics.yolo.utils.errors.HUBModelError -

diff --git a/docs/reference/yolo/utils/files.md b/docs/reference/yolo/utils/files.md deleted file mode 100644 index bad47b4..0000000 --- a/docs/reference/yolo/utils/files.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -description: 'Learn about Ultralytics YOLO files and directory utilities: WorkingDirectory, file_age, file_size, and make_dirs.' -keywords: YOLO, object detection, file utils, file age, file size, working directory, make directories, Ultralytics Docs ---- - -## WorkingDirectory ---- -### ::: ultralytics.yolo.utils.files.WorkingDirectory -

- -## increment_path ---- -### ::: ultralytics.yolo.utils.files.increment_path -

- -## file_age ---- -### ::: ultralytics.yolo.utils.files.file_age -

- -## file_date ---- -### ::: ultralytics.yolo.utils.files.file_date -

- -## file_size ---- -### ::: ultralytics.yolo.utils.files.file_size -

- -## get_latest_run ---- -### ::: ultralytics.yolo.utils.files.get_latest_run -

- -## make_dirs ---- -### ::: ultralytics.yolo.utils.files.make_dirs -

diff --git a/docs/reference/yolo/utils/instance.md b/docs/reference/yolo/utils/instance.md deleted file mode 100644 index 953fe22..0000000 --- a/docs/reference/yolo/utils/instance.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -description: Learn about Bounding Boxes (Bboxes) and _ntuple in Ultralytics YOLO for object detection. Improve accuracy and speed with these powerful tools. -keywords: Ultralytics, YOLO, Bboxes, _ntuple, object detection, instance segmentation ---- - -## Bboxes ---- -### ::: ultralytics.yolo.utils.instance.Bboxes -

- -## Instances ---- -### ::: ultralytics.yolo.utils.instance.Instances -

- -## _ntuple ---- -### ::: ultralytics.yolo.utils.instance._ntuple -

diff --git a/docs/reference/yolo/utils/loss.md b/docs/reference/yolo/utils/loss.md deleted file mode 100644 index 7d89d6e..0000000 --- a/docs/reference/yolo/utils/loss.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -description: Learn about Varifocal Loss and Keypoint Loss in Ultralytics YOLO for advanced bounding box and pose estimation. Visit our docs for more. -keywords: Ultralytics, YOLO, loss functions, object detection, keypoint detection, segmentation, classification ---- - -## VarifocalLoss ---- -### ::: ultralytics.yolo.utils.loss.VarifocalLoss -

- -## FocalLoss ---- -### ::: ultralytics.yolo.utils.loss.FocalLoss -

- -## BboxLoss ---- -### ::: ultralytics.yolo.utils.loss.BboxLoss -

- -## KeypointLoss ---- -### ::: ultralytics.yolo.utils.loss.KeypointLoss -

- -## v8DetectionLoss ---- -### ::: ultralytics.yolo.utils.loss.v8DetectionLoss -

- -## v8SegmentationLoss ---- -### ::: ultralytics.yolo.utils.loss.v8SegmentationLoss -

- -## v8PoseLoss ---- -### ::: ultralytics.yolo.utils.loss.v8PoseLoss -

- -## v8ClassificationLoss ---- -### ::: ultralytics.yolo.utils.loss.v8ClassificationLoss -

diff --git a/docs/reference/yolo/utils/metrics.md b/docs/reference/yolo/utils/metrics.md deleted file mode 100644 index 204096d..0000000 --- a/docs/reference/yolo/utils/metrics.md +++ /dev/null @@ -1,94 +0,0 @@ ---- -description: Explore Ultralytics YOLO's FocalLoss, DetMetrics, PoseMetrics, ClassifyMetrics, and more with Ultralytics Metrics documentation. -keywords: YOLOv5, metrics, losses, confusion matrix, detection metrics, pose metrics, classification metrics, intersection over area, intersection over union, keypoint intersection over union, average precision, per class average precision, Ultralytics Docs ---- - -## ConfusionMatrix ---- -### ::: ultralytics.yolo.utils.metrics.ConfusionMatrix -

- -## Metric ---- -### ::: ultralytics.yolo.utils.metrics.Metric -

- -## DetMetrics ---- -### ::: ultralytics.yolo.utils.metrics.DetMetrics -

- -## SegmentMetrics ---- -### ::: ultralytics.yolo.utils.metrics.SegmentMetrics -

- -## PoseMetrics ---- -### ::: ultralytics.yolo.utils.metrics.PoseMetrics -

- -## ClassifyMetrics ---- -### ::: ultralytics.yolo.utils.metrics.ClassifyMetrics -

- -## box_area ---- -### ::: ultralytics.yolo.utils.metrics.box_area -

- -## bbox_ioa ---- -### ::: ultralytics.yolo.utils.metrics.bbox_ioa -

- -## box_iou ---- -### ::: ultralytics.yolo.utils.metrics.box_iou -

- -## bbox_iou ---- -### ::: ultralytics.yolo.utils.metrics.bbox_iou -

- -## mask_iou ---- -### ::: ultralytics.yolo.utils.metrics.mask_iou -

- -## kpt_iou ---- -### ::: ultralytics.yolo.utils.metrics.kpt_iou -

- -## smooth_BCE ---- -### ::: ultralytics.yolo.utils.metrics.smooth_BCE -

- -## smooth ---- -### ::: ultralytics.yolo.utils.metrics.smooth -

- -## plot_pr_curve ---- -### ::: ultralytics.yolo.utils.metrics.plot_pr_curve -

- -## plot_mc_curve ---- -### ::: ultralytics.yolo.utils.metrics.plot_mc_curve -

- -## compute_ap ---- -### ::: ultralytics.yolo.utils.metrics.compute_ap -

- -## ap_per_class ---- -### ::: ultralytics.yolo.utils.metrics.ap_per_class -

diff --git a/docs/reference/yolo/utils/ops.md b/docs/reference/yolo/utils/ops.md deleted file mode 100644 index ce4e4d5..0000000 --- a/docs/reference/yolo/utils/ops.md +++ /dev/null @@ -1,144 +0,0 @@ ---- -description: Learn about various utility functions in Ultralytics YOLO, including x, y, width, height conversions, non-max suppression, and more. -keywords: Ultralytics, YOLO, Utils Ops, Functions, coco80_to_coco91_class, scale_boxes, non_max_suppression, clip_coords, xyxy2xywh, xywhn2xyxy, xyn2xy, xyxy2ltwh, ltwh2xyxy, resample_segments, process_mask_upsample, process_mask_native, masks2segments, clean_str ---- - -## Profile ---- -### ::: ultralytics.yolo.utils.ops.Profile -

- -## coco80_to_coco91_class ---- -### ::: ultralytics.yolo.utils.ops.coco80_to_coco91_class -

- -## segment2box ---- -### ::: ultralytics.yolo.utils.ops.segment2box -

- -## scale_boxes ---- -### ::: ultralytics.yolo.utils.ops.scale_boxes -

- -## make_divisible ---- -### ::: ultralytics.yolo.utils.ops.make_divisible -

- -## non_max_suppression ---- -### ::: ultralytics.yolo.utils.ops.non_max_suppression -

- -## clip_boxes ---- -### ::: ultralytics.yolo.utils.ops.clip_boxes -

- -## clip_coords ---- -### ::: ultralytics.yolo.utils.ops.clip_coords -

- -## scale_image ---- -### ::: ultralytics.yolo.utils.ops.scale_image -

- -## xyxy2xywh ---- -### ::: ultralytics.yolo.utils.ops.xyxy2xywh -

- -## xywh2xyxy ---- -### ::: ultralytics.yolo.utils.ops.xywh2xyxy -

- -## xywhn2xyxy ---- -### ::: ultralytics.yolo.utils.ops.xywhn2xyxy -

- -## xyxy2xywhn ---- -### ::: ultralytics.yolo.utils.ops.xyxy2xywhn -

- -## xyn2xy ---- -### ::: ultralytics.yolo.utils.ops.xyn2xy -

- -## xywh2ltwh ---- -### ::: ultralytics.yolo.utils.ops.xywh2ltwh -

- -## xyxy2ltwh ---- -### ::: ultralytics.yolo.utils.ops.xyxy2ltwh -

- -## ltwh2xywh ---- -### ::: ultralytics.yolo.utils.ops.ltwh2xywh -

- -## ltwh2xyxy ---- -### ::: ultralytics.yolo.utils.ops.ltwh2xyxy -

- -## segments2boxes ---- -### ::: ultralytics.yolo.utils.ops.segments2boxes -

- -## resample_segments ---- -### ::: ultralytics.yolo.utils.ops.resample_segments -

- -## crop_mask ---- -### ::: ultralytics.yolo.utils.ops.crop_mask -

- -## process_mask_upsample ---- -### ::: ultralytics.yolo.utils.ops.process_mask_upsample -

- -## process_mask ---- -### ::: ultralytics.yolo.utils.ops.process_mask -

- -## process_mask_native ---- -### ::: ultralytics.yolo.utils.ops.process_mask_native -

- -## scale_masks ---- -### ::: ultralytics.yolo.utils.ops.scale_masks -

- -## scale_coords ---- -### ::: ultralytics.yolo.utils.ops.scale_coords -

- -## masks2segments ---- -### ::: ultralytics.yolo.utils.ops.masks2segments -

- -## clean_str ---- -### ::: ultralytics.yolo.utils.ops.clean_str -

diff --git a/docs/reference/yolo/utils/patches.md b/docs/reference/yolo/utils/patches.md deleted file mode 100644 index 85ceefa..0000000 --- a/docs/reference/yolo/utils/patches.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -description: Learn how to use the Ultralytics YOLO Utils package's imread and imshow functions. These functions are used for reading and writing image files. Try out our TorchSave feature today. -keywords: imread, imshow, ultralytics, YOLO, image files, torchsave ---- - -## imread ---- -### ::: ultralytics.yolo.utils.patches.imread -

- -## imwrite ---- -### ::: ultralytics.yolo.utils.patches.imwrite -

- -## imshow ---- -### ::: ultralytics.yolo.utils.patches.imshow -

- -## torch_save ---- -### ::: ultralytics.yolo.utils.patches.torch_save -

diff --git a/docs/reference/yolo/utils/plotting.md b/docs/reference/yolo/utils/plotting.md deleted file mode 100644 index 0fd0bab..0000000 --- a/docs/reference/yolo/utils/plotting.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -description: 'Discover the power of YOLO''s plotting functions: Colors, Labels and Images. Code examples to output targets and visualize features. Check it now.' -keywords: YOLO, object detection, plotting, visualization, annotator, save one box, plot results, feature visualization, Ultralytics ---- - -## Colors ---- -### ::: ultralytics.yolo.utils.plotting.Colors -

- -## Annotator ---- -### ::: ultralytics.yolo.utils.plotting.Annotator -

- -## plot_labels ---- -### ::: ultralytics.yolo.utils.plotting.plot_labels -

- -## save_one_box ---- -### ::: ultralytics.yolo.utils.plotting.save_one_box -

- -## plot_images ---- -### ::: ultralytics.yolo.utils.plotting.plot_images -

- -## plot_results ---- -### ::: ultralytics.yolo.utils.plotting.plot_results -

- -## output_to_target ---- -### ::: ultralytics.yolo.utils.plotting.output_to_target -

- -## feature_visualization ---- -### ::: ultralytics.yolo.utils.plotting.feature_visualization -

diff --git a/docs/reference/yolo/utils/tal.md b/docs/reference/yolo/utils/tal.md deleted file mode 100644 index f5a6652..0000000 --- a/docs/reference/yolo/utils/tal.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -description: Improve your YOLO models with Ultralytics' TaskAlignedAssigner, select_highest_overlaps, and dist2bbox utilities. Streamline your workflow today. -keywords: Ultrayltics, YOLO, select_candidates_in_gts, make_anchor, bbox2dist, object detection, tracking ---- - -## TaskAlignedAssigner ---- -### ::: ultralytics.yolo.utils.tal.TaskAlignedAssigner -

- -## select_candidates_in_gts ---- -### ::: ultralytics.yolo.utils.tal.select_candidates_in_gts -

- -## select_highest_overlaps ---- -### ::: ultralytics.yolo.utils.tal.select_highest_overlaps -

- -## make_anchors ---- -### ::: ultralytics.yolo.utils.tal.make_anchors -

- -## dist2bbox ---- -### ::: ultralytics.yolo.utils.tal.dist2bbox -

- -## bbox2dist ---- -### ::: ultralytics.yolo.utils.tal.bbox2dist -

diff --git a/docs/reference/yolo/utils/torch_utils.md b/docs/reference/yolo/utils/torch_utils.md deleted file mode 100644 index 727a2e1..0000000 --- a/docs/reference/yolo/utils/torch_utils.md +++ /dev/null @@ -1,139 +0,0 @@ ---- -description: Optimize your PyTorch models with Ultralytics YOLO's torch_utils functions such as ModelEMA, select_device, and is_parallel. -keywords: Ultralytics YOLO, Torch, Utils, Pytorch, Object Detection ---- - -## ModelEMA ---- -### ::: ultralytics.yolo.utils.torch_utils.ModelEMA -

- -## EarlyStopping ---- -### ::: ultralytics.yolo.utils.torch_utils.EarlyStopping -

- -## torch_distributed_zero_first ---- -### ::: ultralytics.yolo.utils.torch_utils.torch_distributed_zero_first -

- -## smart_inference_mode ---- -### ::: ultralytics.yolo.utils.torch_utils.smart_inference_mode -

- -## get_cpu_info ---- -### ::: ultralytics.yolo.utils.torch_utils.get_cpu_info -

- -## select_device ---- -### ::: ultralytics.yolo.utils.torch_utils.select_device -

- -## time_sync ---- -### ::: ultralytics.yolo.utils.torch_utils.time_sync -

- -## fuse_conv_and_bn ---- -### ::: ultralytics.yolo.utils.torch_utils.fuse_conv_and_bn -

- -## fuse_deconv_and_bn ---- -### ::: ultralytics.yolo.utils.torch_utils.fuse_deconv_and_bn -

- -## model_info ---- -### ::: ultralytics.yolo.utils.torch_utils.model_info -

- -## get_num_params ---- -### ::: ultralytics.yolo.utils.torch_utils.get_num_params -

- -## get_num_gradients ---- -### ::: ultralytics.yolo.utils.torch_utils.get_num_gradients -

- -## model_info_for_loggers ---- -### ::: ultralytics.yolo.utils.torch_utils.model_info_for_loggers -

- -## get_flops ---- -### ::: ultralytics.yolo.utils.torch_utils.get_flops -

- -## get_flops_with_torch_profiler ---- -### ::: ultralytics.yolo.utils.torch_utils.get_flops_with_torch_profiler -

- -## initialize_weights ---- -### ::: ultralytics.yolo.utils.torch_utils.initialize_weights -

- -## scale_img ---- -### ::: ultralytics.yolo.utils.torch_utils.scale_img -

- -## make_divisible ---- -### ::: ultralytics.yolo.utils.torch_utils.make_divisible -

- -## copy_attr ---- -### ::: ultralytics.yolo.utils.torch_utils.copy_attr -

- -## get_latest_opset ---- -### ::: ultralytics.yolo.utils.torch_utils.get_latest_opset -

- -## intersect_dicts ---- -### ::: ultralytics.yolo.utils.torch_utils.intersect_dicts -

- -## is_parallel ---- -### ::: ultralytics.yolo.utils.torch_utils.is_parallel -

- -## de_parallel ---- -### ::: ultralytics.yolo.utils.torch_utils.de_parallel -

- -## one_cycle ---- -### ::: ultralytics.yolo.utils.torch_utils.one_cycle -

- -## init_seeds ---- -### ::: ultralytics.yolo.utils.torch_utils.init_seeds -

- -## strip_optimizer ---- -### ::: ultralytics.yolo.utils.torch_utils.strip_optimizer -

- -## profile ---- -### ::: ultralytics.yolo.utils.torch_utils.profile -

diff --git a/docs/reference/yolo/utils/tuner.md b/docs/reference/yolo/utils/tuner.md deleted file mode 100644 index bf93000..0000000 --- a/docs/reference/yolo/utils/tuner.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -description: Optimize YOLO models' hyperparameters with Ultralytics YOLO's `run_ray_tune` function using Ray Tune and ASHA scheduler. -keywords: Ultralytics YOLO, Hyperparameter Tuning, Ray Tune, ASHAScheduler, Optimization, Object Detection ---- - -## run_ray_tune ---- -### ::: ultralytics.yolo.utils.tuner.run_ray_tune -

diff --git a/docs/reference/yolo/v8/classify/predict.md b/docs/reference/yolo/v8/classify/predict.md deleted file mode 100644 index 83bd5d6..0000000 --- a/docs/reference/yolo/v8/classify/predict.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -description: Learn how to use ClassificationPredictor in Ultralytics YOLOv8 for object classification tasks in a simple and efficient way. -keywords: Ultralytics, YOLO, v8, Classify Predictor, object detection, classification, computer vision ---- - -## ClassificationPredictor ---- -### ::: ultralytics.yolo.v8.classify.predict.ClassificationPredictor -

- -## predict ---- -### ::: ultralytics.yolo.v8.classify.predict.predict -

diff --git a/docs/reference/yolo/v8/classify/train.md b/docs/reference/yolo/v8/classify/train.md deleted file mode 100644 index f488eac..0000000 --- a/docs/reference/yolo/v8/classify/train.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -description: Train a custom image classification model using Ultralytics YOLOv8 with ClassificationTrainer. Boost accuracy and efficiency today. -keywords: Ultralytics, YOLOv8, object detection, classification, training, API ---- - -## ClassificationTrainer ---- -### ::: ultralytics.yolo.v8.classify.train.ClassificationTrainer -

- -## train ---- -### ::: ultralytics.yolo.v8.classify.train.train -

diff --git a/docs/reference/yolo/v8/classify/val.md b/docs/reference/yolo/v8/classify/val.md deleted file mode 100644 index 76fe530..0000000 --- a/docs/reference/yolo/v8/classify/val.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -description: Ensure model classification accuracy with Ultralytics YOLO's ClassificationValidator. Validate and improve your model with ease. -keywords: ClassificationValidator, Ultralytics YOLO, Validation, Data Science, Deep Learning ---- - -## ClassificationValidator ---- -### ::: ultralytics.yolo.v8.classify.val.ClassificationValidator -

- -## val ---- -### ::: ultralytics.yolo.v8.classify.val.val -

diff --git a/docs/reference/yolo/v8/detect/predict.md b/docs/reference/yolo/v8/detect/predict.md deleted file mode 100644 index 63499d3..0000000 --- a/docs/reference/yolo/v8/detect/predict.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -description: Detect and predict objects in images and videos using the Ultralytics YOLO v8 model with DetectionPredictor. -keywords: detectionpredictor, ultralytics yolo, object detection, neural network, machine learning ---- - -## DetectionPredictor ---- -### ::: ultralytics.yolo.v8.detect.predict.DetectionPredictor -

- -## predict ---- -### ::: ultralytics.yolo.v8.detect.predict.predict -

diff --git a/docs/reference/yolo/v8/detect/train.md b/docs/reference/yolo/v8/detect/train.md deleted file mode 100644 index 8cf2809..0000000 --- a/docs/reference/yolo/v8/detect/train.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -description: Train and optimize custom object detection models with Ultralytics DetectionTrainer and train functions. Get started with YOLO v8 today. -keywords: DetectionTrainer, Ultralytics YOLO, custom object detection, train models, AI applications ---- - -## DetectionTrainer ---- -### ::: ultralytics.yolo.v8.detect.train.DetectionTrainer -

- -## train ---- -### ::: ultralytics.yolo.v8.detect.train.train -

diff --git a/docs/reference/yolo/v8/detect/val.md b/docs/reference/yolo/v8/detect/val.md deleted file mode 100644 index 06ef65f..0000000 --- a/docs/reference/yolo/v8/detect/val.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -description: Validate YOLOv5 detections using this PyTorch module. Ensure model accuracy with NMS IOU threshold tuning and label mapping. -keywords: detection, validator, YOLOv5, object detection, model improvement, Ultralytics Docs ---- - -## DetectionValidator ---- -### ::: ultralytics.yolo.v8.detect.val.DetectionValidator -

- -## val ---- -### ::: ultralytics.yolo.v8.detect.val.val -

diff --git a/docs/reference/yolo/v8/pose/predict.md b/docs/reference/yolo/v8/pose/predict.md deleted file mode 100644 index f8ac26b..0000000 --- a/docs/reference/yolo/v8/pose/predict.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -description: Predict human pose coordinates and confidence scores using YOLOv5. Use on real-time video streams or static images. -keywords: Ultralytics, YOLO, v8, documentation, PosePredictor, pose prediction, pose estimation, predict method ---- - -## PosePredictor ---- -### ::: ultralytics.yolo.v8.pose.predict.PosePredictor -

- -## predict ---- -### ::: ultralytics.yolo.v8.pose.predict.predict -

diff --git a/docs/reference/yolo/v8/pose/train.md b/docs/reference/yolo/v8/pose/train.md deleted file mode 100644 index 8c988fe..0000000 --- a/docs/reference/yolo/v8/pose/train.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -description: Boost posture detection using PoseTrainer and train models using train() API. Learn PoseLoss for ultra-fast and accurate pose detection with Ultralytics YOLO. -keywords: PoseTrainer, human pose models, deep learning, computer vision, Ultralytics YOLO, v8 ---- - -## PoseTrainer ---- -### ::: ultralytics.yolo.v8.pose.train.PoseTrainer -

- -## train ---- -### ::: ultralytics.yolo.v8.pose.train.train -

diff --git a/docs/reference/yolo/v8/pose/val.md b/docs/reference/yolo/v8/pose/val.md deleted file mode 100644 index c26c255..0000000 --- a/docs/reference/yolo/v8/pose/val.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -description: Ensure proper human poses in images with YOLOv8 Pose Validation, part of the Ultralytics YOLO v8 suite. -keywords: PoseValidator, Ultralytics YOLO, object detection, pose analysis, validation ---- - -## PoseValidator ---- -### ::: ultralytics.yolo.v8.pose.val.PoseValidator -

- -## val ---- -### ::: ultralytics.yolo.v8.pose.val.val -

diff --git a/docs/reference/yolo/v8/segment/predict.md b/docs/reference/yolo/v8/segment/predict.md deleted file mode 100644 index eadf463..0000000 --- a/docs/reference/yolo/v8/segment/predict.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -description: '"Use SegmentationPredictor in YOLOv8 for efficient object detection and segmentation. Explore Ultralytics YOLO Docs for more information."' -keywords: Ultralytics YOLO, SegmentationPredictor, object detection, segmentation masks, predict ---- - -## SegmentationPredictor ---- -### ::: ultralytics.yolo.v8.segment.predict.SegmentationPredictor -

- -## predict ---- -### ::: ultralytics.yolo.v8.segment.predict.predict -

diff --git a/docs/reference/yolo/v8/segment/train.md b/docs/reference/yolo/v8/segment/train.md deleted file mode 100644 index 20bcc91..0000000 --- a/docs/reference/yolo/v8/segment/train.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -description: Learn about SegmentationTrainer and Train in Ultralytics YOLO v8 for efficient object detection models. Improve your training with Ultralytics Docs. -keywords: SegmentationTrainer, Ultralytics YOLO, object detection, segmentation, train, tutorial, guide, code examples ---- - -## SegmentationTrainer ---- -### ::: ultralytics.yolo.v8.segment.train.SegmentationTrainer -

- -## train ---- -### ::: ultralytics.yolo.v8.segment.train.train -

diff --git a/docs/reference/yolo/v8/segment/val.md b/docs/reference/yolo/v8/segment/val.md deleted file mode 100644 index 137302f..0000000 --- a/docs/reference/yolo/v8/segment/val.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -description: Ensure segmentation quality on large datasets with SegmentationValidator. Review and visualize results with ease. Learn more at Ultralytics Docs. -keywords: SegmentationValidator, YOLOv8, Ultralytics Docs, segmentation model, validation ---- - -## SegmentationValidator ---- -### ::: ultralytics.yolo.v8.segment.val.SegmentationValidator -

- -## val ---- -### ::: ultralytics.yolo.v8.segment.val.val -

diff --git a/docs/tasks/classify.md b/docs/tasks/classify.md index 8d71093..d0a6349 100644 --- a/docs/tasks/classify.md +++ b/docs/tasks/classify.md @@ -15,16 +15,16 @@ of that class are located or what their exact shape is. !!! tip "Tip" - YOLOv8 Classify models use the `-cls` suffix, i.e. `yolov8n-cls.pt` and are pretrained on [ImageNet](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/ImageNet.yaml). + YOLOv8 Classify models use the `-cls` suffix, i.e. `yolov8n-cls.pt` and are pretrained on [ImageNet](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/ImageNet.yaml). -## [Models](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/models/v8) +## [Models](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/cfg/models/v8) YOLOv8 pretrained Classify models are shown here. Detect, Segment and Pose models are pretrained on -the [COCO](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/coco.yaml) dataset, while Classify +the [COCO](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco.yaml) dataset, while Classify models are pretrained on -the [ImageNet](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/ImageNet.yaml) dataset. +the [ImageNet](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/ImageNet.yaml) dataset. -[Models](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/models) download automatically from the latest +[Models](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/cfg/models) download automatically from the latest Ultralytics [release](https://github.com/ultralytics/assets/releases) on first use. | Model | size
(pixels) | acc
top1 | acc
top5 | Speed
CPU ONNX
(ms) | Speed
A100 TensorRT
(ms) | params
(M) | FLOPs
(B) at 640 | @@ -178,4 +178,4 @@ i.e. `yolo predict model=yolov8n-cls.onnx`. Usage examples are shown for your mo | [PaddlePaddle](https://github.com/PaddlePaddle) | `paddle` | `yolov8n-cls_paddle_model/` | ✅ | `imgsz` | | [ncnn](https://github.com/Tencent/ncnn) | `ncnn` | `yolov8n-cls_ncnn_model/` | ✅ | `imgsz`, `half` | -See full `export` details in the [Export](https://docs.ultralytics.com/modes/export/) page. \ No newline at end of file +See full `export` details in the [Export](https://docs.ultralytics.com/modes/export/) page. diff --git a/docs/tasks/detect.md b/docs/tasks/detect.md index 6573b75..5c2dd07 100644 --- a/docs/tasks/detect.md +++ b/docs/tasks/detect.md @@ -12,13 +12,13 @@ The output of an object detector is a set of bounding boxes that enclose the obj !!! tip "Tip" - YOLOv8 Detect models are the default YOLOv8 models, i.e. `yolov8n.pt` and are pretrained on [COCO](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/coco.yaml). + YOLOv8 Detect models are the default YOLOv8 models, i.e. `yolov8n.pt` and are pretrained on [COCO](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco.yaml). -## [Models](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/models/v8) +## [Models](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/cfg/models/v8) -YOLOv8 pretrained Detect models are shown here. Detect, Segment and Pose models are pretrained on the [COCO](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/coco.yaml) dataset, while Classify models are pretrained on the [ImageNet](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/ImageNet.yaml) dataset. +YOLOv8 pretrained Detect models are shown here. Detect, Segment and Pose models are pretrained on the [COCO](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco.yaml) dataset, while Classify models are pretrained on the [ImageNet](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/ImageNet.yaml) dataset. -[Models](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/models) download automatically from the latest Ultralytics [release](https://github.com/ultralytics/assets/releases) on first use. +[Models](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/cfg/models) download automatically from the latest Ultralytics [release](https://github.com/ultralytics/assets/releases) on first use. | Model | size
(pixels) | mAPval
50-95 | Speed
CPU ONNX
(ms) | Speed
A100 TensorRT
(ms) | params
(M) | FLOPs
(B) | |--------------------------------------------------------------------------------------|-----------------------|----------------------|--------------------------------|-------------------------------------|--------------------|-------------------| @@ -169,4 +169,4 @@ Available YOLOv8 export formats are in the table below. You can predict or valid | [PaddlePaddle](https://github.com/PaddlePaddle) | `paddle` | `yolov8n_paddle_model/` | ✅ | `imgsz` | | [ncnn](https://github.com/Tencent/ncnn) | `ncnn` | `yolov8n_ncnn_model/` | ✅ | `imgsz`, `half` | -See full `export` details in the [Export](https://docs.ultralytics.com/modes/export/) page. \ No newline at end of file +See full `export` details in the [Export](https://docs.ultralytics.com/modes/export/) page. diff --git a/docs/tasks/pose.md b/docs/tasks/pose.md index ef8495d..9eeabed 100644 --- a/docs/tasks/pose.md +++ b/docs/tasks/pose.md @@ -17,16 +17,16 @@ parts of an object in a scene, and their location in relation to each other. !!! tip "Tip" - YOLOv8 _pose_ models use the `-pose` suffix, i.e. `yolov8n-pose.pt`. These models are trained on the [COCO keypoints](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/coco-pose.yaml) dataset and are suitable for a variety of pose estimation tasks. + YOLOv8 _pose_ models use the `-pose` suffix, i.e. `yolov8n-pose.pt`. These models are trained on the [COCO keypoints](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco-pose.yaml) dataset and are suitable for a variety of pose estimation tasks. -## [Models](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/models/v8) +## [Models](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/cfg/models/v8) YOLOv8 pretrained Pose models are shown here. Detect, Segment and Pose models are pretrained on -the [COCO](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/coco.yaml) dataset, while Classify +the [COCO](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco.yaml) dataset, while Classify models are pretrained on -the [ImageNet](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/ImageNet.yaml) dataset. +the [ImageNet](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/ImageNet.yaml) dataset. -[Models](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/models) download automatically from the latest +[Models](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/cfg/models) download automatically from the latest Ultralytics [release](https://github.com/ultralytics/assets/releases) on first use. | Model | size
(pixels) | mAPpose
50-95 | mAPpose
50 | Speed
CPU ONNX
(ms) | Speed
A100 TensorRT
(ms) | params
(M) | FLOPs
(B) | @@ -183,4 +183,4 @@ i.e. `yolo predict model=yolov8n-pose.onnx`. Usage examples are shown for your m | [PaddlePaddle](https://github.com/PaddlePaddle) | `paddle` | `yolov8n-pose_paddle_model/` | ✅ | `imgsz` | | [ncnn](https://github.com/Tencent/ncnn) | `ncnn` | `yolov8n-pose_ncnn_model/` | ✅ | `imgsz`, `half` | -See full `export` details in the [Export](https://docs.ultralytics.com/modes/export/) page. \ No newline at end of file +See full `export` details in the [Export](https://docs.ultralytics.com/modes/export/) page. diff --git a/docs/tasks/segment.md b/docs/tasks/segment.md index 659ac82..413ec7f 100644 --- a/docs/tasks/segment.md +++ b/docs/tasks/segment.md @@ -15,16 +15,16 @@ segmentation is useful when you need to know not only where objects are in an im !!! tip "Tip" - YOLOv8 Segment models use the `-seg` suffix, i.e. `yolov8n-seg.pt` and are pretrained on [COCO](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/coco.yaml). + YOLOv8 Segment models use the `-seg` suffix, i.e. `yolov8n-seg.pt` and are pretrained on [COCO](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco.yaml). -## [Models](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/models/v8) +## [Models](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/cfg/models/v8) YOLOv8 pretrained Segment models are shown here. Detect, Segment and Pose models are pretrained on -the [COCO](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/coco.yaml) dataset, while Classify +the [COCO](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco.yaml) dataset, while Classify models are pretrained on -the [ImageNet](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/datasets/ImageNet.yaml) dataset. +the [ImageNet](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/ImageNet.yaml) dataset. -[Models](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/models) download automatically from the latest +[Models](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/cfg/models) download automatically from the latest Ultralytics [release](https://github.com/ultralytics/assets/releases) on first use. | Model | size
(pixels) | mAPbox
50-95 | mAPmask
50-95 | Speed
CPU ONNX
(ms) | Speed
A100 TensorRT
(ms) | params
(M) | FLOPs
(B) | @@ -183,4 +183,4 @@ i.e. `yolo predict model=yolov8n-seg.onnx`. Usage examples are shown for your mo | [PaddlePaddle](https://github.com/PaddlePaddle) | `paddle` | `yolov8n-seg_paddle_model/` | ✅ | `imgsz` | | [ncnn](https://github.com/Tencent/ncnn) | `ncnn` | `yolov8n-seg_ncnn_model/` | ✅ | `imgsz`, `half` | -See full `export` details in the [Export](https://docs.ultralytics.com/modes/export/) page. \ No newline at end of file +See full `export` details in the [Export](https://docs.ultralytics.com/modes/export/) page. diff --git a/docs/usage/callbacks.md b/docs/usage/callbacks.md index 7968faf..ddaccbc 100644 --- a/docs/usage/callbacks.md +++ b/docs/usage/callbacks.md @@ -40,7 +40,7 @@ for (result, frame) in model.track/predict(): ## All callbacks -Here are all supported callbacks. See callbacks [source code](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/yolo/utils/callbacks/base.py) for additional details. +Here are all supported callbacks. See callbacks [source code](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/callbacks/base.py) for additional details. ### Trainer Callbacks diff --git a/docs/usage/cfg.md b/docs/usage/cfg.md index b027da3..7d54176 100644 --- a/docs/usage/cfg.md +++ b/docs/usage/cfg.md @@ -38,7 +38,7 @@ Where: - `MODE` (required) is one of `[train, val, predict, export, track, benchmark]` - `ARGS` (optional) are any number of custom `arg=value` pairs like `imgsz=320` that override defaults. For a full list of available `ARGS` see the [Configuration](cfg.md) page and `defaults.yaml` - GitHub [source](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/yolo/cfg/default.yaml). + GitHub [source](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/default.yaml). #### Tasks diff --git a/docs/usage/cli.md b/docs/usage/cli.md index 21879d7..84d9222 100644 --- a/docs/usage/cli.md +++ b/docs/usage/cli.md @@ -70,7 +70,7 @@ Where: - `MODE` (required) is one of `[train, val, predict, export, track]` - `ARGS` (optional) are any number of custom `arg=value` pairs like `imgsz=320` that override defaults. For a full list of available `ARGS` see the [Configuration](cfg.md) page and `defaults.yaml` - GitHub [source](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/yolo/cfg/default.yaml). + GitHub [source](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/default.yaml). !!! warning "Warning" diff --git a/docs/usage/engine.md b/docs/usage/engine.md index 8f64443..0ce8574 100644 --- a/docs/usage/engine.md +++ b/docs/usage/engine.md @@ -15,14 +15,14 @@ custom model and dataloader by just overriding these functions: * `get_model(cfg, weights)` - The function that builds the model to be trained * `get_dataloder()` - The function that builds the dataloader - More details and source code can be found in [`BaseTrainer` Reference](../reference/yolo/engine/trainer.md) + More details and source code can be found in [`BaseTrainer` Reference](../reference/engine/trainer.md) ## DetectionTrainer Here's how you can use the YOLOv8 `DetectionTrainer` and customize it. ```python -from ultralytics.yolo.v8.detect import DetectionTrainer +from ultralytics.models.yolo.detect import DetectionTrainer trainer = DetectionTrainer(overrides={...}) trainer.train() @@ -35,7 +35,7 @@ Let's customize the trainer **to train a custom detection model** that is not su simply overloading the existing the `get_model` functionality: ```python -from ultralytics.yolo.v8.detect import DetectionTrainer +from ultralytics.models.yolo.detect import DetectionTrainer class CustomTrainer(DetectionTrainer): @@ -54,7 +54,7 @@ You now realize that you need to customize the trainer further to: Here's how you can do it: ```python -from ultralytics.yolo.v8.detect import DetectionTrainer +from ultralytics.models.yolo.detect import DetectionTrainer from ultralytics.nn.tasks import DetectionModel diff --git a/docs/usage/python.md b/docs/usage/python.md index 2d8bb4c..7fc30e8 100644 --- a/docs/usage/python.md +++ b/docs/usage/python.md @@ -240,7 +240,7 @@ their specific use case based on their requirements for speed and accuracy. Benchmark an official YOLOv8n model across all export formats. ```python - from ultralytics.yolo.utils.benchmarks import benchmark + from ultralytics.utils.benchmarks import benchmark # Benchmark benchmark(model='yolov8n.pt', imgsz=640, half=False, device=0) @@ -256,7 +256,7 @@ from `BaseTrainer`. !!! tip "Detection Trainer Example" ```python - from ultralytics.yolo import v8 import DetectionTrainer, DetectionValidator, DetectionPredictor + from ultralytics.models.yolo import DetectionTrainer, DetectionValidator, DetectionPredictor # trainer trainer = DetectionTrainer(overrides={}) diff --git a/examples/YOLOv8-ONNXRuntime/main.py b/examples/YOLOv8-ONNXRuntime/main.py index 9c59100..3051c47 100644 --- a/examples/YOLOv8-ONNXRuntime/main.py +++ b/examples/YOLOv8-ONNXRuntime/main.py @@ -5,8 +5,8 @@ import numpy as np import onnxruntime as ort import torch -from ultralytics.yolo.utils import ROOT, yaml_load -from ultralytics.yolo.utils.checks import check_requirements, check_yaml +from ultralytics.utils import ROOT, yaml_load +from ultralytics.utils.checks import check_requirements, check_yaml class Yolov8: diff --git a/examples/YOLOv8-OpenCV-ONNX-Python/main.py b/examples/YOLOv8-OpenCV-ONNX-Python/main.py index d1f635c..3cecaca 100644 --- a/examples/YOLOv8-OpenCV-ONNX-Python/main.py +++ b/examples/YOLOv8-OpenCV-ONNX-Python/main.py @@ -3,8 +3,8 @@ import argparse import cv2.dnn import numpy as np -from ultralytics.yolo.utils import ROOT, yaml_load -from ultralytics.yolo.utils.checks import check_yaml +from ultralytics.utils import ROOT, yaml_load +from ultralytics.utils.checks import check_yaml CLASSES = yaml_load(check_yaml('coco128.yaml'))['names'] diff --git a/examples/tutorial.ipynb b/examples/tutorial.ipynb index 9f746e2..aa9b2b6 100644 --- a/examples/tutorial.ipynb +++ b/examples/tutorial.ipynb @@ -300,7 +300,7 @@ "name": "stdout", "text": [ "Ultralytics YOLOv8.0.71 🚀 Python-3.9.16 torch-2.0.0+cu118 CUDA:0 (Tesla T4, 15102MiB)\n", - "\u001b[34m\u001b[1myolo/engine/trainer: \u001b[0mtask=detect, mode=train, model=yolov8n.pt, data=coco128.yaml, epochs=3, patience=50, batch=16, imgsz=640, save=True, save_period=-1, cache=False, device=None, workers=8, project=None, name=None, exist_ok=False, pretrained=False, optimizer=SGD, verbose=True, seed=0, deterministic=True, single_cls=False, image_weights=False, rect=False, cos_lr=False, close_mosaic=0, resume=False, amp=True, overlap_mask=True, mask_ratio=4, dropout=0.0, val=True, split=val, save_json=False, save_hybrid=False, conf=None, iou=0.7, max_det=300, half=False, dnn=False, plots=True, source=None, show=False, save_txt=False, save_conf=False, save_crop=False, show_labels=True, show_conf=True, vid_stride=1, line_width=3, visualize=False, augment=False, agnostic_nms=False, classes=None, retina_masks=False, boxes=True, format=torchscript, keras=False, optimize=False, int8=False, dynamic=False, simplify=False, opset=None, workspace=4, nms=False, lr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=7.5, cls=0.5, dfl=1.5, pose=12.0, kobj=1.0, label_smoothing=0.0, nbs=64, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0, cfg=None, tracker=botsort.yaml, save_dir=runs/detect/train\n", + "\u001b[34m\u001b[1mengine/trainer: \u001b[0mtask=detect, mode=train, model=yolov8n.pt, data=coco128.yaml, epochs=3, patience=50, batch=16, imgsz=640, save=True, save_period=-1, cache=False, device=None, workers=8, project=None, name=None, exist_ok=False, pretrained=False, optimizer=SGD, verbose=True, seed=0, deterministic=True, single_cls=False, image_weights=False, rect=False, cos_lr=False, close_mosaic=0, resume=False, amp=True, overlap_mask=True, mask_ratio=4, dropout=0.0, val=True, split=val, save_json=False, save_hybrid=False, conf=None, iou=0.7, max_det=300, half=False, dnn=False, plots=True, source=None, show=False, save_txt=False, save_conf=False, save_crop=False, show_labels=True, show_conf=True, vid_stride=1, line_width=3, visualize=False, augment=False, agnostic_nms=False, classes=None, retina_masks=False, boxes=True, format=torchscript, keras=False, optimize=False, int8=False, dynamic=False, simplify=False, opset=None, workspace=4, nms=False, lr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=7.5, cls=0.5, dfl=1.5, pose=12.0, kobj=1.0, label_smoothing=0.0, nbs=64, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0, cfg=None, tracker=botsort.yaml, save_dir=runs/detect/train\n", "\n", " from n params module arguments \n", " 0 -1 1 464 ultralytics.nn.modules.Conv [3, 16, 3, 2] \n", diff --git a/mkdocs.yml b/mkdocs.yml index 19181ed..0993992 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -250,11 +250,76 @@ nav: - 'Android': hub/app/android.md - Inference API: hub/inference_api.md - Reference: + - cfg: + - __init__: reference/cfg/__init__.md + - data: + - annotator: reference/data/annotator.md + - augment: reference/data/augment.md + - base: reference/data/base.md + - build: reference/data/build.md + - converter: reference/data/converter.md + - dataset: reference/data/dataset.md + - loaders: reference/data/loaders.md + - utils: reference/data/utils.md + - engine: + - exporter: reference/engine/exporter.md + - model: reference/engine/model.md + - predictor: reference/engine/predictor.md + - results: reference/engine/results.md + - trainer: reference/engine/trainer.md + - validator: reference/engine/validator.md - hub: - __init__: reference/hub/__init__.md - auth: reference/hub/auth.md - session: reference/hub/session.md - utils: reference/hub/utils.md + - models: + - fastsam: + - model: reference/models/fastsam/model.md + - predict: reference/models/fastsam/predict.md + - prompt: reference/models/fastsam/prompt.md + - utils: reference/models/fastsam/utils.md + - val: reference/models/fastsam/val.md + - nas: + - model: reference/models/nas/model.md + - predict: reference/models/nas/predict.md + - val: reference/models/nas/val.md + - rtdetr: + - model: reference/models/rtdetr/model.md + - predict: reference/models/rtdetr/predict.md + - train: reference/models/rtdetr/train.md + - val: reference/models/rtdetr/val.md + - sam: + - amg: reference/models/sam/amg.md + - build: reference/models/sam/build.md + - model: reference/models/sam/model.md + - modules: + - decoders: reference/models/sam/modules/decoders.md + - encoders: reference/models/sam/modules/encoders.md + - sam: reference/models/sam/modules/sam.md + - tiny_encoder: reference/models/sam/modules/tiny_encoder.md + - transformer: reference/models/sam/modules/transformer.md + - predict: reference/models/sam/predict.md + - utils: + - loss: reference/models/utils/loss.md + - ops: reference/models/utils/ops.md + - yolo: + - classify: + - predict: reference/models/yolo/classify/predict.md + - train: reference/models/yolo/classify/train.md + - val: reference/models/yolo/classify/val.md + - detect: + - predict: reference/models/yolo/detect/predict.md + - train: reference/models/yolo/detect/train.md + - val: reference/models/yolo/detect/val.md + - pose: + - predict: reference/models/yolo/pose/predict.md + - train: reference/models/yolo/pose/train.md + - val: reference/models/yolo/pose/val.md + - segment: + - predict: reference/models/yolo/segment/predict.md + - train: reference/models/yolo/segment/train.md + - val: reference/models/yolo/segment/val.md - nn: - autobackend: reference/nn/autobackend.md - modules: @@ -264,113 +329,44 @@ nav: - transformer: reference/nn/modules/transformer.md - utils: reference/nn/modules/utils.md - tasks: reference/nn/tasks.md - - tracker: - - track: reference/tracker/track.md - - trackers: - - basetrack: reference/tracker/trackers/basetrack.md - - bot_sort: reference/tracker/trackers/bot_sort.md - - byte_tracker: reference/tracker/trackers/byte_tracker.md + - trackers: + - basetrack: reference/trackers/basetrack.md + - bot_sort: reference/trackers/bot_sort.md + - byte_tracker: reference/trackers/byte_tracker.md + - track: reference/trackers/track.md - utils: - - gmc: reference/tracker/utils/gmc.md - - kalman_filter: reference/tracker/utils/kalman_filter.md - - matching: reference/tracker/utils/matching.md - - vit: - - rtdetr: - - model: reference/vit/rtdetr/model.md - - predict: reference/vit/rtdetr/predict.md - - train: reference/vit/rtdetr/train.md - - val: reference/vit/rtdetr/val.md - - sam: - - amg: reference/vit/sam/amg.md - - build: reference/vit/sam/build.md - - model: reference/vit/sam/model.md - - modules: - - decoders: reference/vit/sam/modules/decoders.md - - encoders: reference/vit/sam/modules/encoders.md - - sam: reference/vit/sam/modules/sam.md - - tiny_encoder: reference/vit/sam/modules/tiny_encoder.md - - transformer: reference/vit/sam/modules/transformer.md - - predict: reference/vit/sam/predict.md - - utils: - - loss: reference/vit/utils/loss.md - - ops: reference/vit/utils/ops.md - - yolo: - - cfg: - - __init__: reference/yolo/cfg/__init__.md - - data: - - annotator: reference/yolo/data/annotator.md - - augment: reference/yolo/data/augment.md - - base: reference/yolo/data/base.md - - build: reference/yolo/data/build.md - - converter: reference/yolo/data/converter.md - - dataloaders: - - stream_loaders: reference/yolo/data/dataloaders/stream_loaders.md - - dataset: reference/yolo/data/dataset.md - - dataset_wrappers: reference/yolo/data/dataset_wrappers.md - - utils: reference/yolo/data/utils.md - - engine: - - exporter: reference/yolo/engine/exporter.md - - model: reference/yolo/engine/model.md - - predictor: reference/yolo/engine/predictor.md - - results: reference/yolo/engine/results.md - - trainer: reference/yolo/engine/trainer.md - - validator: reference/yolo/engine/validator.md - - fastsam: - - model: reference/yolo/fastsam/model.md - - predict: reference/yolo/fastsam/predict.md - - prompt: reference/yolo/fastsam/prompt.md - - utils: reference/yolo/fastsam/utils.md - - val: reference/yolo/fastsam/val.md - - nas: - - model: reference/yolo/nas/model.md - - predict: reference/yolo/nas/predict.md - - val: reference/yolo/nas/val.md - - utils: - - __init__: reference/yolo/utils/__init__.md - - autobatch: reference/yolo/utils/autobatch.md - - benchmarks: reference/yolo/utils/benchmarks.md - - callbacks: - - base: reference/yolo/utils/callbacks/base.md - - clearml: reference/yolo/utils/callbacks/clearml.md - - comet: reference/yolo/utils/callbacks/comet.md - - dvc: reference/yolo/utils/callbacks/dvc.md - - hub: reference/yolo/utils/callbacks/hub.md - - mlflow: reference/yolo/utils/callbacks/mlflow.md - - neptune: reference/yolo/utils/callbacks/neptune.md - - raytune: reference/yolo/utils/callbacks/raytune.md - - tensorboard: reference/yolo/utils/callbacks/tensorboard.md - - wb: reference/yolo/utils/callbacks/wb.md - - checks: reference/yolo/utils/checks.md - - dist: reference/yolo/utils/dist.md - - downloads: reference/yolo/utils/downloads.md - - errors: reference/yolo/utils/errors.md - - files: reference/yolo/utils/files.md - - instance: reference/yolo/utils/instance.md - - loss: reference/yolo/utils/loss.md - - metrics: reference/yolo/utils/metrics.md - - ops: reference/yolo/utils/ops.md - - patches: reference/yolo/utils/patches.md - - plotting: reference/yolo/utils/plotting.md - - tal: reference/yolo/utils/tal.md - - torch_utils: reference/yolo/utils/torch_utils.md - - tuner: reference/yolo/utils/tuner.md - - v8: - - classify: - - predict: reference/yolo/v8/classify/predict.md - - train: reference/yolo/v8/classify/train.md - - val: reference/yolo/v8/classify/val.md - - detect: - - predict: reference/yolo/v8/detect/predict.md - - train: reference/yolo/v8/detect/train.md - - val: reference/yolo/v8/detect/val.md - - pose: - - predict: reference/yolo/v8/pose/predict.md - - train: reference/yolo/v8/pose/train.md - - val: reference/yolo/v8/pose/val.md - - segment: - - predict: reference/yolo/v8/segment/predict.md - - train: reference/yolo/v8/segment/train.md - - val: reference/yolo/v8/segment/val.md + - gmc: reference/trackers/utils/gmc.md + - kalman_filter: reference/trackers/utils/kalman_filter.md + - matching: reference/trackers/utils/matching.md + - utils: + - __init__: reference/utils/__init__.md + - autobatch: reference/utils/autobatch.md + - benchmarks: reference/utils/benchmarks.md + - callbacks: + - base: reference/utils/callbacks/base.md + - clearml: reference/utils/callbacks/clearml.md + - comet: reference/utils/callbacks/comet.md + - dvc: reference/utils/callbacks/dvc.md + - hub: reference/utils/callbacks/hub.md + - mlflow: reference/utils/callbacks/mlflow.md + - neptune: reference/utils/callbacks/neptune.md + - raytune: reference/utils/callbacks/raytune.md + - tensorboard: reference/utils/callbacks/tensorboard.md + - wb: reference/utils/callbacks/wb.md + - checks: reference/utils/checks.md + - dist: reference/utils/dist.md + - downloads: reference/utils/downloads.md + - errors: reference/utils/errors.md + - files: reference/utils/files.md + - instance: reference/utils/instance.md + - loss: reference/utils/loss.md + - metrics: reference/utils/metrics.md + - ops: reference/utils/ops.md + - patches: reference/utils/patches.md + - plotting: reference/utils/plotting.md + - tal: reference/utils/tal.md + - torch_utils: reference/utils/torch_utils.md + - tuner: reference/utils/tuner.md - Help: - Help: help/index.md @@ -410,13 +406,13 @@ plugins: quick-start.md: quickstart.md app.md: hub/app/index.md sdk.md: index.md - reference/base_pred.md: reference/yolo/engine/predictor.md - reference/base_trainer.md: reference/yolo/engine/trainer.md - reference/exporter.md: reference/yolo/engine/exporter.md - reference/model.md: reference/yolo/engine/model.md + reference/base_pred.md: reference/engine/predictor.md + reference/base_trainer.md: reference/engine/trainer.md + reference/exporter.md: reference/engine/exporter.md + reference/model.md: reference/engine/model.md reference/nn.md: reference/nn/modules/head.md - reference/ops.md: reference/yolo/utils/ops.md - reference/results.md: reference/yolo/engine/results.md + reference/ops.md: reference/utils/ops.md + reference/results.md: reference/engine/results.md reference/base_val.md: index.md tasks/classification.md: tasks/classify.md tasks/detection.md: tasks/detect.md diff --git a/setup.py b/setup.py index 83bddf6..e808aa7 100644 --- a/setup.py +++ b/setup.py @@ -70,5 +70,4 @@ setup( 'Operating System :: MacOS', 'Operating System :: Microsoft :: Windows', ], keywords='machine-learning, deep-learning, vision, ML, DL, AI, YOLO, YOLOv3, YOLOv5, YOLOv8, HUB, Ultralytics', - entry_points={ - 'console_scripts': ['yolo = ultralytics.yolo.cfg:entrypoint', 'ultralytics = ultralytics.yolo.cfg:entrypoint']}) + entry_points={'console_scripts': ['yolo = ultralytics.cfg:entrypoint', 'ultralytics = ultralytics.cfg:entrypoint']}) diff --git a/tests/test_cli.py b/tests/test_cli.py index 24e9703..6cf68d1 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -5,7 +5,7 @@ from pathlib import Path import pytest -from ultralytics.yolo.utils import ONLINE, ROOT, SETTINGS +from ultralytics.utils import ONLINE, ROOT, SETTINGS WEIGHT_DIR = Path(SETTINGS['weights_dir']) TASK_ARGS = [ # (task, model, data) diff --git a/tests/test_engine.py b/tests/test_engine.py index deb546c..e98b90e 100644 --- a/tests/test_engine.py +++ b/tests/test_engine.py @@ -3,10 +3,10 @@ from pathlib import Path from ultralytics import YOLO -from ultralytics.yolo.cfg import get_cfg -from ultralytics.yolo.engine.exporter import Exporter -from ultralytics.yolo.utils import DEFAULT_CFG, ROOT, SETTINGS -from ultralytics.yolo.v8 import classify, detect, segment +from ultralytics.cfg import get_cfg +from ultralytics.engine.exporter import Exporter +from ultralytics.models.yolo import classify, detect, segment +from ultralytics.utils import DEFAULT_CFG, ROOT, SETTINGS CFG_DET = 'yolov8n.yaml' CFG_SEG = 'yolov8n-seg.yaml' diff --git a/tests/test_python.py b/tests/test_python.py index 10f24fd..6502cf5 100644 --- a/tests/test_python.py +++ b/tests/test_python.py @@ -9,8 +9,8 @@ from PIL import Image from torchvision.transforms import ToTensor from ultralytics import RTDETR, YOLO -from ultralytics.yolo.data.build import load_inference_source -from ultralytics.yolo.utils import LINUX, ONLINE, ROOT, SETTINGS +from ultralytics.data.build import load_inference_source +from ultralytics.utils import LINUX, ONLINE, ROOT, SETTINGS MODEL = Path(SETTINGS['weights_dir']) / 'yolov8n.pt' CFG = 'yolov8n.yaml' @@ -102,7 +102,7 @@ def test_val_scratch(): def test_amp(): if torch.cuda.is_available(): - from ultralytics.yolo.utils.checks import check_amp + from ultralytics.utils.checks import check_amp model = YOLO(MODEL).model.cuda() assert check_amp(model) diff --git a/ultralytics/__init__.py b/ultralytics/__init__.py index d4ffad6..3b1aabb 100644 --- a/ultralytics/__init__.py +++ b/ultralytics/__init__.py @@ -1,14 +1,13 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license -__version__ = '8.0.135' +__version__ = '8.0.136' +from ultralytics.engine.model import YOLO from ultralytics.hub import start -from ultralytics.vit.rtdetr import RTDETR -from ultralytics.vit.sam import SAM -from ultralytics.yolo.engine.model import YOLO -from ultralytics.yolo.fastsam import FastSAM -from ultralytics.yolo.nas import NAS -from ultralytics.yolo.utils.checks import check_yolo as checks -from ultralytics.yolo.utils.downloads import download +from ultralytics.models import RTDETR, SAM +from ultralytics.models.fastsam import FastSAM +from ultralytics.models.nas import NAS +from ultralytics.utils.checks import check_yolo as checks +from ultralytics.utils.downloads import download __all__ = '__version__', 'YOLO', 'NAS', 'SAM', 'FastSAM', 'RTDETR', 'checks', 'download', 'start' # allow simpler import diff --git a/ultralytics/cfg/__init__.py b/ultralytics/cfg/__init__.py new file mode 100644 index 0000000..75703de --- /dev/null +++ b/ultralytics/cfg/__init__.py @@ -0,0 +1,421 @@ +# Ultralytics YOLO 🚀, AGPL-3.0 license + +import contextlib +import re +import shutil +import sys +from difflib import get_close_matches +from pathlib import Path +from types import SimpleNamespace +from typing import Dict, List, Union + +from ultralytics.utils import (DEFAULT_CFG, DEFAULT_CFG_DICT, DEFAULT_CFG_PATH, LOGGER, ROOT, USER_CONFIG_DIR, + IterableSimpleNamespace, __version__, checks, colorstr, deprecation_warn, get_settings, + yaml_load, yaml_print) + +# Define valid tasks and modes +MODES = 'train', 'val', 'predict', 'export', 'track', 'benchmark' +TASKS = 'detect', 'segment', 'classify', 'pose' +TASK2DATA = {'detect': 'coco8.yaml', 'segment': 'coco8-seg.yaml', 'classify': 'imagenet100', 'pose': 'coco8-pose.yaml'} +TASK2MODEL = { + 'detect': 'yolov8n.pt', + 'segment': 'yolov8n-seg.pt', + 'classify': 'yolov8n-cls.pt', + 'pose': 'yolov8n-pose.pt'} +TASK2METRIC = { + 'detect': 'metrics/mAP50-95(B)', + 'segment': 'metrics/mAP50-95(M)', + 'classify': 'metrics/accuracy_top1', + 'pose': 'metrics/mAP50-95(P)'} + + +CLI_HELP_MSG = \ + f""" + Arguments received: {str(['yolo'] + sys.argv[1:])}. Ultralytics 'yolo' commands use the following syntax: + + yolo TASK MODE ARGS + + Where TASK (optional) is one of {TASKS} + MODE (required) is one of {MODES} + ARGS (optional) are any number of custom 'arg=value' pairs like 'imgsz=320' that override defaults. + See all ARGS at https://docs.ultralytics.com/usage/cfg or with 'yolo cfg' + + 1. Train a detection model for 10 epochs with an initial learning_rate of 0.01 + yolo train data=coco128.yaml model=yolov8n.pt epochs=10 lr0=0.01 + + 2. Predict a YouTube video using a pretrained segmentation model at image size 320: + yolo predict model=yolov8n-seg.pt source='https://youtu.be/Zgi9g1ksQHc' imgsz=320 + + 3. Val a pretrained detection model at batch-size 1 and image size 640: + yolo val model=yolov8n.pt data=coco128.yaml batch=1 imgsz=640 + + 4. Export a YOLOv8n classification model to ONNX format at image size 224 by 128 (no TASK required) + yolo export model=yolov8n-cls.pt format=onnx imgsz=224,128 + + 5. Run special commands: + yolo help + yolo checks + yolo version + yolo settings + yolo copy-cfg + yolo cfg + + Docs: https://docs.ultralytics.com + Community: https://community.ultralytics.com + GitHub: https://github.com/ultralytics/ultralytics + """ + +# Define keys for arg type checks +CFG_FLOAT_KEYS = 'warmup_epochs', 'box', 'cls', 'dfl', 'degrees', 'shear' +CFG_FRACTION_KEYS = ('dropout', 'iou', 'lr0', 'lrf', 'momentum', 'weight_decay', 'warmup_momentum', 'warmup_bias_lr', + 'label_smoothing', 'hsv_h', 'hsv_s', 'hsv_v', 'translate', 'scale', 'perspective', 'flipud', + 'fliplr', 'mosaic', 'mixup', 'copy_paste', 'conf', 'iou', 'fraction') # fraction floats 0.0 - 1.0 +CFG_INT_KEYS = ('epochs', 'patience', 'batch', 'workers', 'seed', 'close_mosaic', 'mask_ratio', 'max_det', 'vid_stride', + 'line_width', 'workspace', 'nbs', 'save_period') +CFG_BOOL_KEYS = ('save', 'exist_ok', 'verbose', 'deterministic', 'single_cls', 'rect', 'cos_lr', 'overlap_mask', 'val', + 'save_json', 'save_hybrid', 'half', 'dnn', 'plots', 'show', 'save_txt', 'save_conf', 'save_crop', + 'show_labels', 'show_conf', 'visualize', 'augment', 'agnostic_nms', 'retina_masks', 'boxes', 'keras', + 'optimize', 'int8', 'dynamic', 'simplify', 'nms', 'profile') + + +def cfg2dict(cfg): + """ + Convert a configuration object to a dictionary, whether it is a file path, a string, or a SimpleNamespace object. + + Args: + cfg (str | Path | SimpleNamespace): Configuration object to be converted to a dictionary. + + Returns: + cfg (dict): Configuration object in dictionary format. + """ + if isinstance(cfg, (str, Path)): + cfg = yaml_load(cfg) # load dict + elif isinstance(cfg, SimpleNamespace): + cfg = vars(cfg) # convert to dict + return cfg + + +def get_cfg(cfg: Union[str, Path, Dict, SimpleNamespace] = DEFAULT_CFG_DICT, overrides: Dict = None): + """ + Load and merge configuration data from a file or dictionary. + + Args: + cfg (str | Path | Dict | SimpleNamespace): Configuration data. + overrides (str | Dict | optional): Overrides in the form of a file name or a dictionary. Default is None. + + Returns: + (SimpleNamespace): Training arguments namespace. + """ + cfg = cfg2dict(cfg) + + # Merge overrides + if overrides: + overrides = cfg2dict(overrides) + check_cfg_mismatch(cfg, overrides) + cfg = {**cfg, **overrides} # merge cfg and overrides dicts (prefer overrides) + + # Special handling for numeric project/name + for k in 'project', 'name': + if k in cfg and isinstance(cfg[k], (int, float)): + cfg[k] = str(cfg[k]) + if cfg.get('name') == 'model': # assign model to 'name' arg + cfg['name'] = cfg.get('model', '').split('.')[0] + LOGGER.warning(f"WARNING ⚠️ 'name=model' automatically updated to 'name={cfg['name']}'.") + + # Type and Value checks + for k, v in cfg.items(): + if v is not None: # None values may be from optional args + if k in CFG_FLOAT_KEYS and not isinstance(v, (int, float)): + raise TypeError(f"'{k}={v}' is of invalid type {type(v).__name__}. " + f"Valid '{k}' types are int (i.e. '{k}=0') or float (i.e. '{k}=0.5')") + elif k in CFG_FRACTION_KEYS: + if not isinstance(v, (int, float)): + raise TypeError(f"'{k}={v}' is of invalid type {type(v).__name__}. " + f"Valid '{k}' types are int (i.e. '{k}=0') or float (i.e. '{k}=0.5')") + if not (0.0 <= v <= 1.0): + raise ValueError(f"'{k}={v}' is an invalid value. " + f"Valid '{k}' values are between 0.0 and 1.0.") + elif k in CFG_INT_KEYS and not isinstance(v, int): + raise TypeError(f"'{k}={v}' is of invalid type {type(v).__name__}. " + f"'{k}' must be an int (i.e. '{k}=8')") + elif k in CFG_BOOL_KEYS and not isinstance(v, bool): + raise TypeError(f"'{k}={v}' is of invalid type {type(v).__name__}. " + f"'{k}' must be a bool (i.e. '{k}=True' or '{k}=False')") + + # Return instance + return IterableSimpleNamespace(**cfg) + + +def _handle_deprecation(custom): + """ + Hardcoded function to handle deprecated config keys + """ + + for key in custom.copy().keys(): + if key == 'hide_labels': + deprecation_warn(key, 'show_labels') + custom['show_labels'] = custom.pop('hide_labels') == 'False' + if key == 'hide_conf': + deprecation_warn(key, 'show_conf') + custom['show_conf'] = custom.pop('hide_conf') == 'False' + if key == 'line_thickness': + deprecation_warn(key, 'line_width') + custom['line_width'] = custom.pop('line_thickness') + + return custom + + +def check_cfg_mismatch(base: Dict, custom: Dict, e=None): + """ + This function checks for any mismatched keys between a custom configuration list and a base configuration list. + If any mismatched keys are found, the function prints out similar keys from the base list and exits the program. + + Args: + custom (dict): a dictionary of custom configuration options + base (dict): a dictionary of base configuration options + """ + custom = _handle_deprecation(custom) + base, custom = (set(x.keys()) for x in (base, custom)) + mismatched = [x for x in custom if x not in base] + if mismatched: + string = '' + for x in mismatched: + matches = get_close_matches(x, base) # key list + matches = [f'{k}={DEFAULT_CFG_DICT[k]}' if DEFAULT_CFG_DICT.get(k) is not None else k for k in matches] + match_str = f'Similar arguments are i.e. {matches}.' if matches else '' + string += f"'{colorstr('red', 'bold', x)}' is not a valid YOLO argument. {match_str}\n" + raise SyntaxError(string + CLI_HELP_MSG) from e + + +def merge_equals_args(args: List[str]) -> List[str]: + """ + Merges arguments around isolated '=' args in a list of strings. + The function considers cases where the first argument ends with '=' or the second starts with '=', + as well as when the middle one is an equals sign. + + Args: + args (List[str]): A list of strings where each element is an argument. + + Returns: + List[str]: A list of strings where the arguments around isolated '=' are merged. + """ + new_args = [] + for i, arg in enumerate(args): + if arg == '=' and 0 < i < len(args) - 1: # merge ['arg', '=', 'val'] + new_args[-1] += f'={args[i + 1]}' + del args[i + 1] + elif arg.endswith('=') and i < len(args) - 1 and '=' not in args[i + 1]: # merge ['arg=', 'val'] + new_args.append(f'{arg}{args[i + 1]}') + del args[i + 1] + elif arg.startswith('=') and i > 0: # merge ['arg', '=val'] + new_args[-1] += arg + else: + new_args.append(arg) + return new_args + + +def handle_yolo_hub(args: List[str]) -> None: + """ + Handle Ultralytics HUB command-line interface (CLI) commands. + + This function processes Ultralytics HUB CLI commands such as login and logout. + It should be called when executing a script with arguments related to HUB authentication. + + Args: + args (List[str]): A list of command line arguments + + Example: + python my_script.py hub login your_api_key + """ + from ultralytics import hub + + if args[0] == 'login': + key = args[1] if len(args) > 1 else '' + # Log in to Ultralytics HUB using the provided API key + hub.login(key) + elif args[0] == 'logout': + # Log out from Ultralytics HUB + hub.logout() + + +def handle_yolo_settings(args: List[str]) -> None: + """ + Handle YOLO settings command-line interface (CLI) commands. + + This function processes YOLO settings CLI commands such as reset. + It should be called when executing a script with arguments related to YOLO settings management. + + Args: + args (List[str]): A list of command line arguments for YOLO settings management. + + Example: + python my_script.py yolo settings reset + """ + path = USER_CONFIG_DIR / 'settings.yaml' # get SETTINGS YAML file path + if any(args) and args[0] == 'reset': + path.unlink() # delete the settings file + get_settings() # create new settings + LOGGER.info('Settings reset successfully') # inform the user that settings have been reset + yaml_print(path) # print the current settings + + +def entrypoint(debug=''): + """ + This function is the ultralytics package entrypoint, it's responsible for parsing the command line arguments passed + to the package. + + This function allows for: + - passing mandatory YOLO args as a list of strings + - specifying the task to be performed, either 'detect', 'segment' or 'classify' + - specifying the mode, either 'train', 'val', 'test', or 'predict' + - running special modes like 'checks' + - passing overrides to the package's configuration + + It uses the package's default cfg and initializes it using the passed overrides. + Then it calls the CLI function with the composed cfg + """ + args = (debug.split(' ') if debug else sys.argv)[1:] + if not args: # no arguments passed + LOGGER.info(CLI_HELP_MSG) + return + + special = { + 'help': lambda: LOGGER.info(CLI_HELP_MSG), + 'checks': checks.check_yolo, + 'version': lambda: LOGGER.info(__version__), + 'settings': lambda: handle_yolo_settings(args[1:]), + 'cfg': lambda: yaml_print(DEFAULT_CFG_PATH), + 'hub': lambda: handle_yolo_hub(args[1:]), + 'login': lambda: handle_yolo_hub(args), + 'copy-cfg': copy_default_cfg} + full_args_dict = {**DEFAULT_CFG_DICT, **{k: None for k in TASKS}, **{k: None for k in MODES}, **special} + + # Define common mis-uses of special commands, i.e. -h, -help, --help + special.update({k[0]: v for k, v in special.items()}) # singular + special.update({k[:-1]: v for k, v in special.items() if len(k) > 1 and k.endswith('s')}) # singular + special = {**special, **{f'-{k}': v for k, v in special.items()}, **{f'--{k}': v for k, v in special.items()}} + + overrides = {} # basic overrides, i.e. imgsz=320 + for a in merge_equals_args(args): # merge spaces around '=' sign + if a.startswith('--'): + LOGGER.warning(f"WARNING ⚠️ '{a}' does not require leading dashes '--', updating to '{a[2:]}'.") + a = a[2:] + if a.endswith(','): + LOGGER.warning(f"WARNING ⚠️ '{a}' does not require trailing comma ',', updating to '{a[:-1]}'.") + a = a[:-1] + if '=' in a: + try: + re.sub(r' *= *', '=', a) # remove spaces around equals sign + k, v = a.split('=', 1) # split on first '=' sign + assert v, f"missing '{k}' value" + if k == 'cfg': # custom.yaml passed + LOGGER.info(f'Overriding {DEFAULT_CFG_PATH} with {v}') + overrides = {k: val for k, val in yaml_load(checks.check_yaml(v)).items() if k != 'cfg'} + else: + if v.lower() == 'none': + v = None + elif v.lower() == 'true': + v = True + elif v.lower() == 'false': + v = False + else: + with contextlib.suppress(Exception): + v = eval(v) + overrides[k] = v + except (NameError, SyntaxError, ValueError, AssertionError) as e: + check_cfg_mismatch(full_args_dict, {a: ''}, e) + + elif a in TASKS: + overrides['task'] = a + elif a in MODES: + overrides['mode'] = a + elif a.lower() in special: + special[a.lower()]() + return + elif a in DEFAULT_CFG_DICT and isinstance(DEFAULT_CFG_DICT[a], bool): + overrides[a] = True # auto-True for default bool args, i.e. 'yolo show' sets show=True + elif a in DEFAULT_CFG_DICT: + raise SyntaxError(f"'{colorstr('red', 'bold', a)}' is a valid YOLO argument but is missing an '=' sign " + f"to set its value, i.e. try '{a}={DEFAULT_CFG_DICT[a]}'\n{CLI_HELP_MSG}") + else: + check_cfg_mismatch(full_args_dict, {a: ''}) + + # Check keys + check_cfg_mismatch(full_args_dict, overrides) + + # Mode + mode = overrides.get('mode', None) + if mode is None: + mode = DEFAULT_CFG.mode or 'predict' + LOGGER.warning(f"WARNING ⚠️ 'mode' is missing. Valid modes are {MODES}. Using default 'mode={mode}'.") + elif mode not in MODES: + if mode not in ('checks', checks): + raise ValueError(f"Invalid 'mode={mode}'. Valid modes are {MODES}.\n{CLI_HELP_MSG}") + LOGGER.warning("WARNING ⚠️ 'yolo mode=checks' is deprecated. Use 'yolo checks' instead.") + checks.check_yolo() + return + + # Task + task = overrides.pop('task', None) + if task: + if task not in TASKS: + raise ValueError(f"Invalid 'task={task}'. Valid tasks are {TASKS}.\n{CLI_HELP_MSG}") + if 'model' not in overrides: + overrides['model'] = TASK2MODEL[task] + + # Model + model = overrides.pop('model', DEFAULT_CFG.model) + if model is None: + model = 'yolov8n.pt' + LOGGER.warning(f"WARNING ⚠️ 'model' is missing. Using default 'model={model}'.") + overrides['model'] = model + if 'rtdetr' in model.lower(): # guess architecture + from ultralytics import RTDETR + model = RTDETR(model) # no task argument + elif 'sam' in model.lower(): + from ultralytics import SAM + model = SAM(model) + else: + from ultralytics import YOLO + model = YOLO(model, task=task) + if isinstance(overrides.get('pretrained'), str): + model.load(overrides['pretrained']) + + # Task Update + if task != model.task: + if task: + LOGGER.warning(f"WARNING ⚠️ conflicting 'task={task}' passed with 'task={model.task}' model. " + f"Ignoring 'task={task}' and updating to 'task={model.task}' to match model.") + task = model.task + + # Mode + if mode in ('predict', 'track') and 'source' not in overrides: + overrides['source'] = DEFAULT_CFG.source or ROOT / 'assets' if (ROOT / 'assets').exists() \ + else 'https://ultralytics.com/images/bus.jpg' + LOGGER.warning(f"WARNING ⚠️ 'source' is missing. Using default 'source={overrides['source']}'.") + elif mode in ('train', 'val'): + if 'data' not in overrides: + overrides['data'] = TASK2DATA.get(task or DEFAULT_CFG.task, DEFAULT_CFG.data) + LOGGER.warning(f"WARNING ⚠️ 'data' is missing. Using default 'data={overrides['data']}'.") + elif mode == 'export': + if 'format' not in overrides: + overrides['format'] = DEFAULT_CFG.format or 'torchscript' + LOGGER.warning(f"WARNING ⚠️ 'format' is missing. Using default 'format={overrides['format']}'.") + + # Run command in python + # getattr(model, mode)(**vars(get_cfg(overrides=overrides))) # default args using default.yaml + getattr(model, mode)(**overrides) # default args from model + + +# Special modes -------------------------------------------------------------------------------------------------------- +def copy_default_cfg(): + """Copy and create a new default configuration file with '_copy' appended to its name.""" + new_file = Path.cwd() / DEFAULT_CFG_PATH.name.replace('.yaml', '_copy.yaml') + shutil.copy2(DEFAULT_CFG_PATH, new_file) + LOGGER.info(f'{DEFAULT_CFG_PATH} copied to {new_file}\n' + f"Example YOLO command with this new custom cfg:\n yolo cfg='{new_file}' imgsz=320 batch=8") + + +if __name__ == '__main__': + # Example Usage: entrypoint(debug='yolo predict model=yolov8n.pt') + entrypoint(debug='') diff --git a/ultralytics/datasets/Argoverse.yaml b/ultralytics/cfg/datasets/Argoverse.yaml similarity index 97% rename from ultralytics/datasets/Argoverse.yaml rename to ultralytics/cfg/datasets/Argoverse.yaml index e78758a..ddfdbb6 100644 --- a/ultralytics/datasets/Argoverse.yaml +++ b/ultralytics/cfg/datasets/Argoverse.yaml @@ -29,7 +29,7 @@ names: download: | import json from tqdm import tqdm - from ultralytics.yolo.utils.downloads import download + from ultralytics.utils.downloads import download from pathlib import Path def argoverse2yolo(set): diff --git a/ultralytics/datasets/GlobalWheat2020.yaml b/ultralytics/cfg/datasets/GlobalWheat2020.yaml similarity index 97% rename from ultralytics/datasets/GlobalWheat2020.yaml rename to ultralytics/cfg/datasets/GlobalWheat2020.yaml index 533a0b7..165004f 100644 --- a/ultralytics/datasets/GlobalWheat2020.yaml +++ b/ultralytics/cfg/datasets/GlobalWheat2020.yaml @@ -32,7 +32,7 @@ names: # Download script/URL (optional) --------------------------------------------------------------------------------------- download: | - from ultralytics.yolo.utils.downloads import download + from ultralytics.utils.downloads import download from pathlib import Path # Download diff --git a/ultralytics/datasets/ImageNet.yaml b/ultralytics/cfg/datasets/ImageNet.yaml similarity index 100% rename from ultralytics/datasets/ImageNet.yaml rename to ultralytics/cfg/datasets/ImageNet.yaml diff --git a/ultralytics/datasets/Objects365.yaml b/ultralytics/cfg/datasets/Objects365.yaml similarity index 98% rename from ultralytics/datasets/Objects365.yaml rename to ultralytics/cfg/datasets/Objects365.yaml index 8065432..415eff9 100644 --- a/ultralytics/datasets/Objects365.yaml +++ b/ultralytics/cfg/datasets/Objects365.yaml @@ -386,9 +386,9 @@ names: download: | from tqdm import tqdm - from ultralytics.yolo.utils.checks import check_requirements - from ultralytics.yolo.utils.downloads import download - from ultralytics.yolo.utils.ops import xyxy2xywhn + from ultralytics.utils.checks import check_requirements + from ultralytics.utils.downloads import download + from ultralytics.utils.ops import xyxy2xywhn import numpy as np from pathlib import Path diff --git a/ultralytics/datasets/SKU-110K.yaml b/ultralytics/cfg/datasets/SKU-110K.yaml similarity index 95% rename from ultralytics/datasets/SKU-110K.yaml rename to ultralytics/cfg/datasets/SKU-110K.yaml index ced2e08..e6deac2 100644 --- a/ultralytics/datasets/SKU-110K.yaml +++ b/ultralytics/cfg/datasets/SKU-110K.yaml @@ -27,8 +27,8 @@ download: | import pandas as pd from tqdm import tqdm - from ultralytics.yolo.utils.downloads import download - from ultralytics.yolo.utils.ops import xyxy2xywh + from ultralytics.utils.downloads import download + from ultralytics.utils.ops import xyxy2xywh # Download dir = Path(yaml['path']) # dataset root dir diff --git a/ultralytics/datasets/VOC.yaml b/ultralytics/cfg/datasets/VOC.yaml similarity index 98% rename from ultralytics/datasets/VOC.yaml rename to ultralytics/cfg/datasets/VOC.yaml index f1c91d2..ab34387 100644 --- a/ultralytics/datasets/VOC.yaml +++ b/ultralytics/cfg/datasets/VOC.yaml @@ -48,7 +48,7 @@ download: | import xml.etree.ElementTree as ET from tqdm import tqdm - from ultralytics.yolo.utils.downloads import download + from ultralytics.utils.downloads import download from pathlib import Path def convert_label(path, lb_path, year, image_id): diff --git a/ultralytics/datasets/VisDrone.yaml b/ultralytics/cfg/datasets/VisDrone.yaml similarity index 98% rename from ultralytics/datasets/VisDrone.yaml rename to ultralytics/cfg/datasets/VisDrone.yaml index a37782f..a1a4a46 100644 --- a/ultralytics/datasets/VisDrone.yaml +++ b/ultralytics/cfg/datasets/VisDrone.yaml @@ -32,7 +32,7 @@ download: | import os from pathlib import Path - from ultralytics.yolo.utils.downloads import download + from ultralytics.utils.downloads import download def visdrone2yolo(dir): from PIL import Image diff --git a/ultralytics/datasets/coco-pose.yaml b/ultralytics/cfg/datasets/coco-pose.yaml similarity index 96% rename from ultralytics/datasets/coco-pose.yaml rename to ultralytics/cfg/datasets/coco-pose.yaml index 82a2f15..670d55b 100644 --- a/ultralytics/datasets/coco-pose.yaml +++ b/ultralytics/cfg/datasets/coco-pose.yaml @@ -23,7 +23,7 @@ names: # Download script/URL (optional) download: | - from ultralytics.yolo.utils.downloads import download + from ultralytics.utils.downloads import download from pathlib import Path # Download labels diff --git a/ultralytics/datasets/coco.yaml b/ultralytics/cfg/datasets/coco.yaml similarity index 97% rename from ultralytics/datasets/coco.yaml rename to ultralytics/cfg/datasets/coco.yaml index 0e6edf7..8a70a5b 100644 --- a/ultralytics/datasets/coco.yaml +++ b/ultralytics/cfg/datasets/coco.yaml @@ -99,7 +99,7 @@ names: # Download script/URL (optional) download: | - from ultralytics.yolo.utils.downloads import download + from ultralytics.utils.downloads import download from pathlib import Path # Download labels diff --git a/ultralytics/datasets/coco128-seg.yaml b/ultralytics/cfg/datasets/coco128-seg.yaml similarity index 100% rename from ultralytics/datasets/coco128-seg.yaml rename to ultralytics/cfg/datasets/coco128-seg.yaml diff --git a/ultralytics/datasets/coco128.yaml b/ultralytics/cfg/datasets/coco128.yaml similarity index 100% rename from ultralytics/datasets/coco128.yaml rename to ultralytics/cfg/datasets/coco128.yaml diff --git a/ultralytics/datasets/coco8-pose.yaml b/ultralytics/cfg/datasets/coco8-pose.yaml similarity index 100% rename from ultralytics/datasets/coco8-pose.yaml rename to ultralytics/cfg/datasets/coco8-pose.yaml diff --git a/ultralytics/datasets/coco8-seg.yaml b/ultralytics/cfg/datasets/coco8-seg.yaml similarity index 100% rename from ultralytics/datasets/coco8-seg.yaml rename to ultralytics/cfg/datasets/coco8-seg.yaml diff --git a/ultralytics/datasets/coco8.yaml b/ultralytics/cfg/datasets/coco8.yaml similarity index 100% rename from ultralytics/datasets/coco8.yaml rename to ultralytics/cfg/datasets/coco8.yaml diff --git a/ultralytics/datasets/xView.yaml b/ultralytics/cfg/datasets/xView.yaml similarity index 97% rename from ultralytics/datasets/xView.yaml rename to ultralytics/cfg/datasets/xView.yaml index f58c4e5..bdc2d91 100644 --- a/ultralytics/datasets/xView.yaml +++ b/ultralytics/cfg/datasets/xView.yaml @@ -87,8 +87,8 @@ download: | from PIL import Image from tqdm import tqdm - from ultralytics.yolo.data.utils import autosplit - from ultralytics.yolo.utils.ops import xyxy2xywhn + from ultralytics.data.utils import autosplit + from ultralytics.utils.ops import xyxy2xywhn def convert_labels(fname=Path('xView/xView_train.geojson')): diff --git a/ultralytics/yolo/cfg/default.yaml b/ultralytics/cfg/default.yaml similarity index 100% rename from ultralytics/yolo/cfg/default.yaml rename to ultralytics/cfg/default.yaml diff --git a/ultralytics/models/README.md b/ultralytics/cfg/models/README.md similarity index 100% rename from ultralytics/models/README.md rename to ultralytics/cfg/models/README.md diff --git a/ultralytics/models/rt-detr/rtdetr-l.yaml b/ultralytics/cfg/models/rt-detr/rtdetr-l.yaml similarity index 100% rename from ultralytics/models/rt-detr/rtdetr-l.yaml rename to ultralytics/cfg/models/rt-detr/rtdetr-l.yaml diff --git a/ultralytics/models/rt-detr/rtdetr-x.yaml b/ultralytics/cfg/models/rt-detr/rtdetr-x.yaml similarity index 100% rename from ultralytics/models/rt-detr/rtdetr-x.yaml rename to ultralytics/cfg/models/rt-detr/rtdetr-x.yaml diff --git a/ultralytics/models/v3/yolov3-spp.yaml b/ultralytics/cfg/models/v3/yolov3-spp.yaml similarity index 100% rename from ultralytics/models/v3/yolov3-spp.yaml rename to ultralytics/cfg/models/v3/yolov3-spp.yaml diff --git a/ultralytics/models/v3/yolov3-tiny.yaml b/ultralytics/cfg/models/v3/yolov3-tiny.yaml similarity index 100% rename from ultralytics/models/v3/yolov3-tiny.yaml rename to ultralytics/cfg/models/v3/yolov3-tiny.yaml diff --git a/ultralytics/models/v3/yolov3.yaml b/ultralytics/cfg/models/v3/yolov3.yaml similarity index 100% rename from ultralytics/models/v3/yolov3.yaml rename to ultralytics/cfg/models/v3/yolov3.yaml diff --git a/ultralytics/models/v5/yolov5-p6.yaml b/ultralytics/cfg/models/v5/yolov5-p6.yaml similarity index 100% rename from ultralytics/models/v5/yolov5-p6.yaml rename to ultralytics/cfg/models/v5/yolov5-p6.yaml diff --git a/ultralytics/models/v5/yolov5.yaml b/ultralytics/cfg/models/v5/yolov5.yaml similarity index 100% rename from ultralytics/models/v5/yolov5.yaml rename to ultralytics/cfg/models/v5/yolov5.yaml diff --git a/ultralytics/models/v6/yolov6.yaml b/ultralytics/cfg/models/v6/yolov6.yaml similarity index 100% rename from ultralytics/models/v6/yolov6.yaml rename to ultralytics/cfg/models/v6/yolov6.yaml diff --git a/ultralytics/models/v8/yolov8-cls.yaml b/ultralytics/cfg/models/v8/yolov8-cls.yaml similarity index 100% rename from ultralytics/models/v8/yolov8-cls.yaml rename to ultralytics/cfg/models/v8/yolov8-cls.yaml diff --git a/ultralytics/models/v8/yolov8-p2.yaml b/ultralytics/cfg/models/v8/yolov8-p2.yaml similarity index 100% rename from ultralytics/models/v8/yolov8-p2.yaml rename to ultralytics/cfg/models/v8/yolov8-p2.yaml diff --git a/ultralytics/models/v8/yolov8-p6.yaml b/ultralytics/cfg/models/v8/yolov8-p6.yaml similarity index 100% rename from ultralytics/models/v8/yolov8-p6.yaml rename to ultralytics/cfg/models/v8/yolov8-p6.yaml diff --git a/ultralytics/models/v8/yolov8-pose-p6.yaml b/ultralytics/cfg/models/v8/yolov8-pose-p6.yaml similarity index 100% rename from ultralytics/models/v8/yolov8-pose-p6.yaml rename to ultralytics/cfg/models/v8/yolov8-pose-p6.yaml diff --git a/ultralytics/models/v8/yolov8-pose.yaml b/ultralytics/cfg/models/v8/yolov8-pose.yaml similarity index 100% rename from ultralytics/models/v8/yolov8-pose.yaml rename to ultralytics/cfg/models/v8/yolov8-pose.yaml diff --git a/ultralytics/models/v8/yolov8-rtdetr.yaml b/ultralytics/cfg/models/v8/yolov8-rtdetr.yaml similarity index 100% rename from ultralytics/models/v8/yolov8-rtdetr.yaml rename to ultralytics/cfg/models/v8/yolov8-rtdetr.yaml diff --git a/ultralytics/models/v8/yolov8-seg.yaml b/ultralytics/cfg/models/v8/yolov8-seg.yaml similarity index 100% rename from ultralytics/models/v8/yolov8-seg.yaml rename to ultralytics/cfg/models/v8/yolov8-seg.yaml diff --git a/ultralytics/models/v8/yolov8.yaml b/ultralytics/cfg/models/v8/yolov8.yaml similarity index 100% rename from ultralytics/models/v8/yolov8.yaml rename to ultralytics/cfg/models/v8/yolov8.yaml diff --git a/ultralytics/tracker/cfg/botsort.yaml b/ultralytics/cfg/trackers/botsort.yaml similarity index 100% rename from ultralytics/tracker/cfg/botsort.yaml rename to ultralytics/cfg/trackers/botsort.yaml diff --git a/ultralytics/tracker/cfg/bytetrack.yaml b/ultralytics/cfg/trackers/bytetrack.yaml similarity index 100% rename from ultralytics/tracker/cfg/bytetrack.yaml rename to ultralytics/cfg/trackers/bytetrack.yaml diff --git a/ultralytics/data/__init__.py b/ultralytics/data/__init__.py new file mode 100644 index 0000000..6fa7e84 --- /dev/null +++ b/ultralytics/data/__init__.py @@ -0,0 +1,8 @@ +# Ultralytics YOLO 🚀, AGPL-3.0 license + +from .base import BaseDataset +from .build import build_dataloader, build_yolo_dataset, load_inference_source +from .dataset import ClassificationDataset, SemanticDataset, YOLODataset + +__all__ = ('BaseDataset', 'ClassificationDataset', 'SemanticDataset', 'YOLODataset', 'build_yolo_dataset', + 'build_dataloader', 'load_inference_source') diff --git a/ultralytics/yolo/data/annotator.py b/ultralytics/data/annotator.py similarity index 100% rename from ultralytics/yolo/data/annotator.py rename to ultralytics/data/annotator.py diff --git a/ultralytics/yolo/data/augment.py b/ultralytics/data/augment.py similarity index 99% rename from ultralytics/yolo/data/augment.py rename to ultralytics/data/augment.py index d688159..12d09cf 100644 --- a/ultralytics/yolo/data/augment.py +++ b/ultralytics/data/augment.py @@ -9,11 +9,12 @@ import numpy as np import torch import torchvision.transforms as T -from ..utils import LOGGER, colorstr -from ..utils.checks import check_version -from ..utils.instance import Instances -from ..utils.metrics import bbox_ioa -from ..utils.ops import segment2box +from ultralytics.utils import LOGGER, colorstr +from ultralytics.utils.checks import check_version +from ultralytics.utils.instance import Instances +from ultralytics.utils.metrics import bbox_ioa +from ultralytics.utils.ops import segment2box + from .utils import polygons2masks, polygons2masks_overlap POSE_FLIPLR_INDEX = [0, 2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15] diff --git a/ultralytics/yolo/data/base.py b/ultralytics/data/base.py similarity index 99% rename from ultralytics/yolo/data/base.py rename to ultralytics/data/base.py index d2e9793..bfc3cc1 100644 --- a/ultralytics/yolo/data/base.py +++ b/ultralytics/data/base.py @@ -15,7 +15,8 @@ import psutil from torch.utils.data import Dataset from tqdm import tqdm -from ..utils import DEFAULT_CFG, LOCAL_RANK, LOGGER, NUM_THREADS, TQDM_BAR_FORMAT +from ultralytics.utils import DEFAULT_CFG, LOCAL_RANK, LOGGER, NUM_THREADS, TQDM_BAR_FORMAT + from .utils import HELP_URL, IMG_FORMATS diff --git a/ultralytics/yolo/data/build.py b/ultralytics/data/build.py similarity index 94% rename from ultralytics/yolo/data/build.py rename to ultralytics/data/build.py index 5499c76..8fd8602 100644 --- a/ultralytics/yolo/data/build.py +++ b/ultralytics/data/build.py @@ -9,12 +9,12 @@ import torch from PIL import Image from torch.utils.data import dataloader, distributed -from ultralytics.yolo.data.dataloaders.stream_loaders import (LOADERS, LoadImages, LoadPilAndNumpy, LoadScreenshots, - LoadStreams, LoadTensor, SourceTypes, autocast_list) -from ultralytics.yolo.data.utils import IMG_FORMATS, VID_FORMATS -from ultralytics.yolo.utils.checks import check_file +from ultralytics.data.loaders import (LOADERS, LoadImages, LoadPilAndNumpy, LoadScreenshots, LoadStreams, LoadTensor, + SourceTypes, autocast_list) +from ultralytics.data.utils import IMG_FORMATS, VID_FORMATS +from ultralytics.utils import RANK, colorstr +from ultralytics.utils.checks import check_file -from ..utils import RANK, colorstr from .dataset import YOLODataset from .utils import PIN_MEMORY diff --git a/ultralytics/yolo/data/converter.py b/ultralytics/data/converter.py similarity index 98% rename from ultralytics/yolo/data/converter.py rename to ultralytics/data/converter.py index c1278dd..c6f8547 100644 --- a/ultralytics/yolo/data/converter.py +++ b/ultralytics/data/converter.py @@ -6,8 +6,8 @@ import cv2 import numpy as np from tqdm import tqdm -from ultralytics.yolo.utils.checks import check_requirements -from ultralytics.yolo.utils.files import make_dirs +from ultralytics.utils.checks import check_requirements +from ultralytics.utils.files import make_dirs def coco91_to_coco80_class(): diff --git a/ultralytics/tracker/utils/__init__.py b/ultralytics/data/dataloaders/__init__.py similarity index 100% rename from ultralytics/tracker/utils/__init__.py rename to ultralytics/data/dataloaders/__init__.py diff --git a/ultralytics/yolo/data/dataset.py b/ultralytics/data/dataset.py similarity index 99% rename from ultralytics/yolo/data/dataset.py rename to ultralytics/data/dataset.py index 17e6d47..575243f 100644 --- a/ultralytics/yolo/data/dataset.py +++ b/ultralytics/data/dataset.py @@ -10,7 +10,8 @@ import torch import torchvision from tqdm import tqdm -from ..utils import LOCAL_RANK, NUM_THREADS, TQDM_BAR_FORMAT, is_dir_writeable +from ultralytics.utils import LOCAL_RANK, NUM_THREADS, TQDM_BAR_FORMAT, is_dir_writeable + from .augment import Compose, Format, Instances, LetterBox, classify_albumentations, classify_transforms, v8_transforms from .base import BaseDataset from .utils import HELP_URL, LOGGER, get_hash, img2label_paths, verify_image_label diff --git a/ultralytics/yolo/data/dataloaders/stream_loaders.py b/ultralytics/data/loaders.py similarity index 98% rename from ultralytics/yolo/data/dataloaders/stream_loaders.py rename to ultralytics/data/loaders.py index d124a43..f75f3f7 100644 --- a/ultralytics/yolo/data/dataloaders/stream_loaders.py +++ b/ultralytics/data/loaders.py @@ -15,9 +15,9 @@ import requests import torch from PIL import Image -from ultralytics.yolo.data.utils import IMG_FORMATS, VID_FORMATS -from ultralytics.yolo.utils import LOGGER, ROOT, is_colab, is_kaggle, ops -from ultralytics.yolo.utils.checks import check_requirements +from ultralytics.data.utils import IMG_FORMATS, VID_FORMATS +from ultralytics.utils import LOGGER, ROOT, is_colab, is_kaggle, ops +from ultralytics.utils.checks import check_requirements @dataclass @@ -318,11 +318,10 @@ class LoadTensor: s = f'WARNING ⚠️ torch.Tensor inputs should be BCHW i.e. shape(1, 3, 640, 640) ' \ f'divisible by stride {stride}. Input shape{tuple(im.shape)} is incompatible.' if len(im.shape) != 4: - if len(im.shape) == 3: - LOGGER.warning(s) - im = im.unsqueeze(0) - else: + if len(im.shape) != 3: raise ValueError(s) + LOGGER.warning(s) + im = im.unsqueeze(0) if im.shape[2] % stride or im.shape[3] % stride: raise ValueError(s) if im.max() > 1.0: diff --git a/ultralytics/yolo/data/scripts/download_weights.sh b/ultralytics/data/scripts/download_weights.sh similarity index 70% rename from ultralytics/yolo/data/scripts/download_weights.sh rename to ultralytics/data/scripts/download_weights.sh index 72502a3..87db31f 100755 --- a/ultralytics/yolo/data/scripts/download_weights.sh +++ b/ultralytics/data/scripts/download_weights.sh @@ -1,7 +1,7 @@ #!/bin/bash # Ultralytics YOLO 🚀, AGPL-3.0 license # Download latest models from https://github.com/ultralytics/assets/releases -# Example usage: bash ultralytics/yolo/data/scripts/download_weights.sh +# Example usage: bash ultralytics/data/scripts/download_weights.sh # parent # └── weights # ├── yolov8n.pt ← downloads here @@ -9,9 +9,9 @@ # └── ... python - < None: Fuses the model for faster inference. - predict(source=None, stream=False, **kwargs) -> List[ultralytics.yolo.engine.results.Results]: + predict(source=None, stream=False, **kwargs) -> List[ultralytics.engine.results.Results]: Performs prediction using the YOLO model. Returns: - list(ultralytics.yolo.engine.results.Results): The prediction results. + list(ultralytics.engine.results.Results): The prediction results. """ def __init__(self, model: Union[str, Path] = 'yolov8n.pt', task=None) -> None: @@ -230,7 +229,7 @@ class YOLO: Check the 'configuration' section in the documentation for all available options. Returns: - (List[ultralytics.yolo.engine.results.Results]): The prediction results. + (List[ultralytics.engine.results.Results]): The prediction results. """ if source is None: source = ROOT / 'assets' if is_git_dir() else 'https://ultralytics.com/images/bus.jpg' @@ -265,11 +264,11 @@ class YOLO: **kwargs (optional): Additional keyword arguments for the tracking process. Returns: - (List[ultralytics.yolo.engine.results.Results]): The tracking results. + (List[ultralytics.engine.results.Results]): The tracking results. """ if not hasattr(self.predictor, 'trackers'): - from ultralytics.tracker import register_tracker + from ultralytics.trackers import register_tracker register_tracker(self, persist) # ByteTrack-based method needs low confidence predictions as input conf = kwargs.get('conf') or 0.1 @@ -315,7 +314,7 @@ class YOLO: **kwargs : Any other args accepted by the validators. To see all args check 'configuration' section in docs """ self._check_is_pytorch_model() - from ultralytics.yolo.utils.benchmarks import benchmark + from ultralytics.utils.benchmarks import benchmark overrides = self.model.args.copy() overrides.update(kwargs) overrides['mode'] = 'benchmark' @@ -389,7 +388,7 @@ class YOLO: def tune(self, *args, **kwargs): """ - Runs hyperparameter tuning using Ray Tune. See ultralytics.yolo.utils.tuner.run_ray_tune for Args. + Runs hyperparameter tuning using Ray Tune. See ultralytics.utils.tuner.run_ray_tune for Args. Returns: (dict): A dictionary containing the results of the hyperparameter search. @@ -398,7 +397,7 @@ class YOLO: ModuleNotFoundError: If Ray Tune is not installed. """ self._check_is_pytorch_model() - from ultralytics.yolo.utils.tuner import run_ray_tune + from ultralytics.utils.tuner import run_ray_tune return run_ray_tune(self, *args, **kwargs) @property diff --git a/ultralytics/yolo/engine/predictor.py b/ultralytics/engine/predictor.py similarity index 97% rename from ultralytics/yolo/engine/predictor.py rename to ultralytics/engine/predictor.py index 011d0ab..142fe63 100644 --- a/ultralytics/yolo/engine/predictor.py +++ b/ultralytics/engine/predictor.py @@ -34,14 +34,14 @@ import cv2 import numpy as np import torch +from ultralytics.cfg import get_cfg +from ultralytics.data import load_inference_source +from ultralytics.data.augment import LetterBox, classify_transforms from ultralytics.nn.autobackend import AutoBackend -from ultralytics.yolo.cfg import get_cfg -from ultralytics.yolo.data import load_inference_source -from ultralytics.yolo.data.augment import LetterBox, classify_transforms -from ultralytics.yolo.utils import DEFAULT_CFG, LOGGER, MACOS, SETTINGS, WINDOWS, callbacks, colorstr, ops -from ultralytics.yolo.utils.checks import check_imgsz, check_imshow -from ultralytics.yolo.utils.files import increment_path -from ultralytics.yolo.utils.torch_utils import select_device, smart_inference_mode +from ultralytics.utils import DEFAULT_CFG, LOGGER, MACOS, SETTINGS, WINDOWS, callbacks, colorstr, ops +from ultralytics.utils.checks import check_imgsz, check_imshow +from ultralytics.utils.files import increment_path +from ultralytics.utils.torch_utils import select_device, smart_inference_mode STREAM_WARNING = """ WARNING ⚠️ stream/video/webcam/dir predict source will accumulate results in RAM unless `stream=True` is passed, diff --git a/ultralytics/yolo/engine/results.py b/ultralytics/engine/results.py similarity index 99% rename from ultralytics/yolo/engine/results.py rename to ultralytics/engine/results.py index e934730..7978b73 100644 --- a/ultralytics/yolo/engine/results.py +++ b/ultralytics/engine/results.py @@ -12,9 +12,9 @@ from pathlib import Path import numpy as np import torch -from ultralytics.yolo.data.augment import LetterBox -from ultralytics.yolo.utils import LOGGER, SimpleClass, deprecation_warn, ops -from ultralytics.yolo.utils.plotting import Annotator, colors, save_one_box +from ultralytics.data.augment import LetterBox +from ultralytics.utils import LOGGER, SimpleClass, deprecation_warn, ops +from ultralytics.utils.plotting import Annotator, colors, save_one_box class BaseTensor(SimpleClass): diff --git a/ultralytics/yolo/engine/trainer.py b/ultralytics/engine/trainer.py similarity index 97% rename from ultralytics/yolo/engine/trainer.py rename to ultralytics/engine/trainer.py index 26ceb6c..5c034cf 100644 --- a/ultralytics/yolo/engine/trainer.py +++ b/ultralytics/engine/trainer.py @@ -21,17 +21,17 @@ from torch.cuda import amp from torch.nn.parallel import DistributedDataParallel as DDP from tqdm import tqdm +from ultralytics.cfg import get_cfg +from ultralytics.data.utils import check_cls_dataset, check_det_dataset from ultralytics.nn.tasks import attempt_load_one_weight, attempt_load_weights -from ultralytics.yolo.cfg import get_cfg -from ultralytics.yolo.data.utils import check_cls_dataset, check_det_dataset -from ultralytics.yolo.utils import (DEFAULT_CFG, LOGGER, RANK, SETTINGS, TQDM_BAR_FORMAT, __version__, callbacks, - clean_url, colorstr, emojis, yaml_save) -from ultralytics.yolo.utils.autobatch import check_train_batch_size -from ultralytics.yolo.utils.checks import check_amp, check_file, check_imgsz, print_args -from ultralytics.yolo.utils.dist import ddp_cleanup, generate_ddp_command -from ultralytics.yolo.utils.files import get_latest_run, increment_path -from ultralytics.yolo.utils.torch_utils import (EarlyStopping, ModelEMA, de_parallel, init_seeds, one_cycle, - select_device, strip_optimizer) +from ultralytics.utils import (DEFAULT_CFG, LOGGER, RANK, SETTINGS, TQDM_BAR_FORMAT, __version__, callbacks, clean_url, + colorstr, emojis, yaml_save) +from ultralytics.utils.autobatch import check_train_batch_size +from ultralytics.utils.checks import check_amp, check_file, check_imgsz, print_args +from ultralytics.utils.dist import ddp_cleanup, generate_ddp_command +from ultralytics.utils.files import get_latest_run, increment_path +from ultralytics.utils.torch_utils import (EarlyStopping, ModelEMA, de_parallel, init_seeds, one_cycle, select_device, + strip_optimizer) class BaseTrainer: diff --git a/ultralytics/yolo/engine/validator.py b/ultralytics/engine/validator.py similarity index 95% rename from ultralytics/yolo/engine/validator.py rename to ultralytics/engine/validator.py index a3faebf..4d0f9f5 100644 --- a/ultralytics/yolo/engine/validator.py +++ b/ultralytics/engine/validator.py @@ -25,14 +25,14 @@ from pathlib import Path import torch from tqdm import tqdm +from ultralytics.cfg import get_cfg +from ultralytics.data.utils import check_cls_dataset, check_det_dataset from ultralytics.nn.autobackend import AutoBackend -from ultralytics.yolo.cfg import get_cfg -from ultralytics.yolo.data.utils import check_cls_dataset, check_det_dataset -from ultralytics.yolo.utils import DEFAULT_CFG, LOGGER, RANK, SETTINGS, TQDM_BAR_FORMAT, callbacks, colorstr, emojis -from ultralytics.yolo.utils.checks import check_imgsz -from ultralytics.yolo.utils.files import increment_path -from ultralytics.yolo.utils.ops import Profile -from ultralytics.yolo.utils.torch_utils import de_parallel, select_device, smart_inference_mode +from ultralytics.utils import DEFAULT_CFG, LOGGER, RANK, SETTINGS, TQDM_BAR_FORMAT, callbacks, colorstr, emojis +from ultralytics.utils.checks import check_imgsz +from ultralytics.utils.files import increment_path +from ultralytics.utils.ops import Profile +from ultralytics.utils.torch_utils import de_parallel, select_device, smart_inference_mode class BaseValidator: diff --git a/ultralytics/hub/__init__.py b/ultralytics/hub/__init__.py index 6059083..6ddb855 100644 --- a/ultralytics/hub/__init__.py +++ b/ultralytics/hub/__init__.py @@ -2,10 +2,10 @@ import requests +from ultralytics.data.utils import HUBDatasetStats from ultralytics.hub.auth import Auth from ultralytics.hub.utils import PREFIX -from ultralytics.yolo.data.utils import HUBDatasetStats -from ultralytics.yolo.utils import LOGGER, SETTINGS, USER_CONFIG_DIR, yaml_save +from ultralytics.utils import LOGGER, SETTINGS, USER_CONFIG_DIR, yaml_save def login(api_key=''): @@ -65,7 +65,7 @@ def reset_model(model_id=''): def export_fmts_hub(): """Returns a list of HUB-supported export formats.""" - from ultralytics.yolo.engine.exporter import export_formats + from ultralytics.engine.exporter import export_formats return list(export_formats()['Argument'][1:]) + ['ultralytics_tflite', 'ultralytics_coreml'] diff --git a/ultralytics/hub/auth.py b/ultralytics/hub/auth.py index 960b3dc..d8d728f 100644 --- a/ultralytics/hub/auth.py +++ b/ultralytics/hub/auth.py @@ -3,7 +3,7 @@ import requests from ultralytics.hub.utils import HUB_API_ROOT, PREFIX, request_with_credentials -from ultralytics.yolo.utils import LOGGER, SETTINGS, emojis, is_colab, set_settings +from ultralytics.utils import LOGGER, SETTINGS, emojis, is_colab, set_settings API_KEY_URL = 'https://hub.ultralytics.com/settings?tab=api+keys' diff --git a/ultralytics/hub/session.py b/ultralytics/hub/session.py index 1a96d20..b7856e3 100644 --- a/ultralytics/hub/session.py +++ b/ultralytics/hub/session.py @@ -7,8 +7,8 @@ from time import sleep import requests from ultralytics.hub.utils import HUB_API_ROOT, PREFIX, smart_request -from ultralytics.yolo.utils import LOGGER, __version__, checks, emojis, is_colab, threaded -from ultralytics.yolo.utils.errors import HUBModelError +from ultralytics.utils import LOGGER, __version__, checks, emojis, is_colab, threaded +from ultralytics.utils.errors import HUBModelError AGENT_NAME = f'python-{__version__}-colab' if is_colab() else f'python-{__version__}-local' diff --git a/ultralytics/hub/utils.py b/ultralytics/hub/utils.py index ecd64a9..adf0b3f 100644 --- a/ultralytics/hub/utils.py +++ b/ultralytics/hub/utils.py @@ -11,9 +11,8 @@ from pathlib import Path import requests from tqdm import tqdm -from ultralytics.yolo.utils import (ENVIRONMENT, LOGGER, ONLINE, RANK, SETTINGS, TESTS_RUNNING, TQDM_BAR_FORMAT, - TryExcept, __version__, colorstr, get_git_origin_url, is_colab, is_git_dir, - is_pip_package) +from ultralytics.utils import (ENVIRONMENT, LOGGER, ONLINE, RANK, SETTINGS, TESTS_RUNNING, TQDM_BAR_FORMAT, TryExcept, + __version__, colorstr, get_git_origin_url, is_colab, is_git_dir, is_pip_package) PREFIX = colorstr('Ultralytics HUB: ') HELP_MSG = 'If this issue persists please visit https://github.com/ultralytics/hub/issues for assistance.' diff --git a/ultralytics/vit/__init__.py b/ultralytics/models/__init__.py similarity index 69% rename from ultralytics/vit/__init__.py rename to ultralytics/models/__init__.py index 8e96f91..cca6222 100644 --- a/ultralytics/vit/__init__.py +++ b/ultralytics/models/__init__.py @@ -1,5 +1,3 @@ -# Ultralytics YOLO 🚀, AGPL-3.0 license - from .rtdetr import RTDETR from .sam import SAM diff --git a/ultralytics/yolo/fastsam/__init__.py b/ultralytics/models/fastsam/__init__.py similarity index 100% rename from ultralytics/yolo/fastsam/__init__.py rename to ultralytics/models/fastsam/__init__.py diff --git a/ultralytics/yolo/fastsam/model.py b/ultralytics/models/fastsam/model.py similarity index 90% rename from ultralytics/yolo/fastsam/model.py rename to ultralytics/models/fastsam/model.py index 36c7d42..96ebc30 100644 --- a/ultralytics/yolo/fastsam/model.py +++ b/ultralytics/models/fastsam/model.py @@ -9,13 +9,13 @@ Usage - Predict: results = model.predict('ultralytics/assets/bus.jpg') """ -from ultralytics.yolo.cfg import get_cfg -from ultralytics.yolo.engine.exporter import Exporter -from ultralytics.yolo.engine.model import YOLO -from ultralytics.yolo.utils import DEFAULT_CFG, LOGGER, ROOT, is_git_dir -from ultralytics.yolo.utils.checks import check_imgsz +from ultralytics.cfg import get_cfg +from ultralytics.engine.exporter import Exporter +from ultralytics.engine.model import YOLO +from ultralytics.utils import DEFAULT_CFG, LOGGER, ROOT, is_git_dir +from ultralytics.utils.checks import check_imgsz +from ultralytics.utils.torch_utils import model_info, smart_inference_mode -from ...yolo.utils.torch_utils import model_info, smart_inference_mode from .predict import FastSAMPredictor @@ -41,7 +41,7 @@ class FastSAM(YOLO): Check the 'configuration' section in the documentation for all available options. Returns: - (List[ultralytics.yolo.engine.results.Results]): The prediction results. + (List[ultralytics.engine.results.Results]): The prediction results. """ if source is None: source = ROOT / 'assets' if is_git_dir() else 'https://ultralytics.com/images/bus.jpg' diff --git a/ultralytics/yolo/fastsam/predict.py b/ultralytics/models/fastsam/predict.py similarity index 92% rename from ultralytics/yolo/fastsam/predict.py rename to ultralytics/models/fastsam/predict.py index 0a6ac27..7453632 100644 --- a/ultralytics/yolo/fastsam/predict.py +++ b/ultralytics/models/fastsam/predict.py @@ -2,10 +2,10 @@ import torch -from ultralytics.yolo.engine.results import Results -from ultralytics.yolo.fastsam.utils import bbox_iou -from ultralytics.yolo.utils import DEFAULT_CFG, ops -from ultralytics.yolo.v8.detect.predict import DetectionPredictor +from ultralytics.engine.results import Results +from ultralytics.models.fastsam.utils import bbox_iou +from ultralytics.models.yolo.detect.predict import DetectionPredictor +from ultralytics.utils import DEFAULT_CFG, ops class FastSAMPredictor(DetectionPredictor): diff --git a/ultralytics/yolo/fastsam/prompt.py b/ultralytics/models/fastsam/prompt.py similarity index 99% rename from ultralytics/yolo/fastsam/prompt.py rename to ultralytics/models/fastsam/prompt.py index d34968d..6cee91d 100644 --- a/ultralytics/yolo/fastsam/prompt.py +++ b/ultralytics/models/fastsam/prompt.py @@ -22,7 +22,7 @@ class FastSAMPrompt: try: import clip # for linear_assignment except ImportError: - from ultralytics.yolo.utils.checks import check_requirements + from ultralytics.utils.checks import check_requirements check_requirements('git+https://github.com/openai/CLIP.git') # required before installing lap from source import clip self.clip = clip diff --git a/ultralytics/yolo/fastsam/utils.py b/ultralytics/models/fastsam/utils.py similarity index 100% rename from ultralytics/yolo/fastsam/utils.py rename to ultralytics/models/fastsam/utils.py diff --git a/ultralytics/yolo/fastsam/val.py b/ultralytics/models/fastsam/val.py similarity index 97% rename from ultralytics/yolo/fastsam/val.py rename to ultralytics/models/fastsam/val.py index 250bd5e..9bbae57 100644 --- a/ultralytics/yolo/fastsam/val.py +++ b/ultralytics/models/fastsam/val.py @@ -7,11 +7,11 @@ import numpy as np import torch import torch.nn.functional as F -from ultralytics.yolo.utils import LOGGER, NUM_THREADS, ops -from ultralytics.yolo.utils.checks import check_requirements -from ultralytics.yolo.utils.metrics import SegmentMetrics, box_iou, mask_iou -from ultralytics.yolo.utils.plotting import output_to_target, plot_images -from ultralytics.yolo.v8.detect import DetectionValidator +from ultralytics.models.yolo.detect import DetectionValidator +from ultralytics.utils import LOGGER, NUM_THREADS, ops +from ultralytics.utils.checks import check_requirements +from ultralytics.utils.metrics import SegmentMetrics, box_iou, mask_iou +from ultralytics.utils.plotting import output_to_target, plot_images class FastSAMValidator(DetectionValidator): diff --git a/ultralytics/yolo/nas/__init__.py b/ultralytics/models/nas/__init__.py similarity index 100% rename from ultralytics/yolo/nas/__init__.py rename to ultralytics/models/nas/__init__.py diff --git a/ultralytics/yolo/nas/model.py b/ultralytics/models/nas/model.py similarity index 92% rename from ultralytics/yolo/nas/model.py rename to ultralytics/models/nas/model.py index bfe7dcd..1fece72 100644 --- a/ultralytics/yolo/nas/model.py +++ b/ultralytics/models/nas/model.py @@ -13,12 +13,12 @@ from pathlib import Path import torch -from ultralytics.yolo.cfg import get_cfg -from ultralytics.yolo.engine.exporter import Exporter -from ultralytics.yolo.utils import DEFAULT_CFG, DEFAULT_CFG_DICT, LOGGER, ROOT, is_git_dir -from ultralytics.yolo.utils.checks import check_imgsz +from ultralytics.cfg import get_cfg +from ultralytics.engine.exporter import Exporter +from ultralytics.utils import DEFAULT_CFG, DEFAULT_CFG_DICT, LOGGER, ROOT, is_git_dir +from ultralytics.utils.checks import check_imgsz +from ultralytics.utils.torch_utils import model_info, smart_inference_mode -from ...yolo.utils.torch_utils import model_info, smart_inference_mode from .predict import NASPredictor from .val import NASValidator @@ -65,7 +65,7 @@ class NAS: Check the 'configuration' section in the documentation for all available options. Returns: - (List[ultralytics.yolo.engine.results.Results]): The prediction results. + (List[ultralytics.engine.results.Results]): The prediction results. """ if source is None: source = ROOT / 'assets' if is_git_dir() else 'https://ultralytics.com/images/bus.jpg' diff --git a/ultralytics/yolo/nas/predict.py b/ultralytics/models/nas/predict.py similarity index 86% rename from ultralytics/yolo/nas/predict.py rename to ultralytics/models/nas/predict.py index e135bc1..f5ae430 100644 --- a/ultralytics/yolo/nas/predict.py +++ b/ultralytics/models/nas/predict.py @@ -2,10 +2,10 @@ import torch -from ultralytics.yolo.engine.predictor import BasePredictor -from ultralytics.yolo.engine.results import Results -from ultralytics.yolo.utils import ops -from ultralytics.yolo.utils.ops import xyxy2xywh +from ultralytics.engine.predictor import BasePredictor +from ultralytics.engine.results import Results +from ultralytics.utils import ops +from ultralytics.utils.ops import xyxy2xywh class NASPredictor(BasePredictor): diff --git a/ultralytics/yolo/nas/val.py b/ultralytics/models/nas/val.py similarity index 84% rename from ultralytics/yolo/nas/val.py rename to ultralytics/models/nas/val.py index 474cf6b..05986c0 100644 --- a/ultralytics/yolo/nas/val.py +++ b/ultralytics/models/nas/val.py @@ -2,9 +2,9 @@ import torch -from ultralytics.yolo.utils import ops -from ultralytics.yolo.utils.ops import xyxy2xywh -from ultralytics.yolo.v8.detect import DetectionValidator +from ultralytics.models.yolo.detect import DetectionValidator +from ultralytics.utils import ops +from ultralytics.utils.ops import xyxy2xywh __all__ = ['NASValidator'] diff --git a/ultralytics/vit/rtdetr/__init__.py b/ultralytics/models/rtdetr/__init__.py similarity index 100% rename from ultralytics/vit/rtdetr/__init__.py rename to ultralytics/models/rtdetr/__init__.py diff --git a/ultralytics/vit/rtdetr/model.py b/ultralytics/models/rtdetr/model.py similarity index 94% rename from ultralytics/vit/rtdetr/model.py rename to ultralytics/models/rtdetr/model.py index 259c7c9..19c903e 100644 --- a/ultralytics/vit/rtdetr/model.py +++ b/ultralytics/models/rtdetr/model.py @@ -7,12 +7,12 @@ from pathlib import Path import torch.nn as nn +from ultralytics.cfg import get_cfg +from ultralytics.engine.exporter import Exporter from ultralytics.nn.tasks import RTDETRDetectionModel, attempt_load_one_weight, yaml_model_load -from ultralytics.yolo.cfg import get_cfg -from ultralytics.yolo.engine.exporter import Exporter -from ultralytics.yolo.utils import DEFAULT_CFG, DEFAULT_CFG_DICT, LOGGER, RANK, ROOT, is_git_dir -from ultralytics.yolo.utils.checks import check_imgsz -from ultralytics.yolo.utils.torch_utils import model_info, smart_inference_mode +from ultralytics.utils import DEFAULT_CFG, DEFAULT_CFG_DICT, LOGGER, RANK, ROOT, is_git_dir +from ultralytics.utils.checks import check_imgsz +from ultralytics.utils.torch_utils import model_info, smart_inference_mode from .predict import RTDETRPredictor from .train import RTDETRTrainer @@ -72,7 +72,7 @@ class RTDETR: Check the 'configuration' section in the documentation for all available options. Returns: - (List[ultralytics.yolo.engine.results.Results]): The prediction results. + (List[ultralytics.engine.results.Results]): The prediction results. """ if source is None: source = ROOT / 'assets' if is_git_dir() else 'https://ultralytics.com/images/bus.jpg' diff --git a/ultralytics/vit/rtdetr/predict.py b/ultralytics/models/rtdetr/predict.py similarity index 89% rename from ultralytics/vit/rtdetr/predict.py rename to ultralytics/models/rtdetr/predict.py index 77c02c2..356098d 100644 --- a/ultralytics/vit/rtdetr/predict.py +++ b/ultralytics/models/rtdetr/predict.py @@ -2,10 +2,10 @@ import torch -from ultralytics.yolo.data.augment import LetterBox -from ultralytics.yolo.engine.predictor import BasePredictor -from ultralytics.yolo.engine.results import Results -from ultralytics.yolo.utils import ops +from ultralytics.data.augment import LetterBox +from ultralytics.engine.predictor import BasePredictor +from ultralytics.engine.results import Results +from ultralytics.utils import ops class RTDETRPredictor(BasePredictor): diff --git a/ultralytics/vit/rtdetr/train.py b/ultralytics/models/rtdetr/train.py similarity index 95% rename from ultralytics/vit/rtdetr/train.py rename to ultralytics/models/rtdetr/train.py index 54eeaf4..dc3bc7f 100644 --- a/ultralytics/vit/rtdetr/train.py +++ b/ultralytics/models/rtdetr/train.py @@ -4,9 +4,9 @@ from copy import copy import torch +from ultralytics.models.yolo.detect import DetectionTrainer from ultralytics.nn.tasks import RTDETRDetectionModel -from ultralytics.yolo.utils import DEFAULT_CFG, RANK, colorstr -from ultralytics.yolo.v8.detect import DetectionTrainer +from ultralytics.utils import DEFAULT_CFG, RANK, colorstr from .val import RTDETRDataset, RTDETRValidator diff --git a/ultralytics/vit/rtdetr/val.py b/ultralytics/models/rtdetr/val.py similarity index 96% rename from ultralytics/vit/rtdetr/val.py rename to ultralytics/models/rtdetr/val.py index cfee292..ff6855a 100644 --- a/ultralytics/vit/rtdetr/val.py +++ b/ultralytics/models/rtdetr/val.py @@ -6,10 +6,10 @@ import cv2 import numpy as np import torch -from ultralytics.yolo.data import YOLODataset -from ultralytics.yolo.data.augment import Compose, Format, v8_transforms -from ultralytics.yolo.utils import colorstr, ops -from ultralytics.yolo.v8.detect import DetectionValidator +from ultralytics.data import YOLODataset +from ultralytics.data.augment import Compose, Format, v8_transforms +from ultralytics.models.yolo.detect import DetectionValidator +from ultralytics.utils import colorstr, ops __all__ = 'RTDETRValidator', # tuple or list diff --git a/ultralytics/vit/sam/__init__.py b/ultralytics/models/sam/__init__.py similarity index 100% rename from ultralytics/vit/sam/__init__.py rename to ultralytics/models/sam/__init__.py diff --git a/ultralytics/vit/sam/amg.py b/ultralytics/models/sam/amg.py similarity index 100% rename from ultralytics/vit/sam/amg.py rename to ultralytics/models/sam/amg.py diff --git a/ultralytics/vit/sam/build.py b/ultralytics/models/sam/build.py similarity index 98% rename from ultralytics/vit/sam/build.py rename to ultralytics/models/sam/build.py index 3572c2e..21da265 100644 --- a/ultralytics/vit/sam/build.py +++ b/ultralytics/models/sam/build.py @@ -10,7 +10,8 @@ from functools import partial import torch -from ...yolo.utils.downloads import attempt_download_asset +from ultralytics.utils.downloads import attempt_download_asset + from .modules.decoders import MaskDecoder from .modules.encoders import ImageEncoderViT, PromptEncoder from .modules.sam import Sam diff --git a/ultralytics/vit/sam/model.py b/ultralytics/models/sam/model.py similarity index 96% rename from ultralytics/vit/sam/model.py rename to ultralytics/models/sam/model.py index 925328e..4d70251 100644 --- a/ultralytics/vit/sam/model.py +++ b/ultralytics/models/sam/model.py @@ -3,8 +3,8 @@ SAM model interface """ -from ultralytics.yolo.cfg import get_cfg -from ultralytics.yolo.utils.torch_utils import model_info +from ultralytics.cfg import get_cfg +from ultralytics.utils.torch_utils import model_info from .build import build_sam from .predict import Predictor diff --git a/ultralytics/vit/sam/modules/__init__.py b/ultralytics/models/sam/modules/__init__.py similarity index 100% rename from ultralytics/vit/sam/modules/__init__.py rename to ultralytics/models/sam/modules/__init__.py diff --git a/ultralytics/vit/sam/modules/decoders.py b/ultralytics/models/sam/modules/decoders.py similarity index 100% rename from ultralytics/vit/sam/modules/decoders.py rename to ultralytics/models/sam/modules/decoders.py diff --git a/ultralytics/vit/sam/modules/encoders.py b/ultralytics/models/sam/modules/encoders.py similarity index 100% rename from ultralytics/vit/sam/modules/encoders.py rename to ultralytics/models/sam/modules/encoders.py diff --git a/ultralytics/vit/sam/modules/sam.py b/ultralytics/models/sam/modules/sam.py similarity index 100% rename from ultralytics/vit/sam/modules/sam.py rename to ultralytics/models/sam/modules/sam.py diff --git a/ultralytics/vit/sam/modules/tiny_encoder.py b/ultralytics/models/sam/modules/tiny_encoder.py similarity index 99% rename from ultralytics/vit/sam/modules/tiny_encoder.py rename to ultralytics/models/sam/modules/tiny_encoder.py index e3f5101..d00d1e8 100644 --- a/ultralytics/vit/sam/modules/tiny_encoder.py +++ b/ultralytics/models/sam/modules/tiny_encoder.py @@ -17,7 +17,7 @@ import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint -from ultralytics.yolo.utils.instance import to_2tuple +from ultralytics.utils.instance import to_2tuple class Conv2d_BN(torch.nn.Sequential): @@ -50,7 +50,7 @@ class Conv2d_BN(torch.nn.Sequential): # NOTE: This module and timm package is needed only for training. -# from ultralytics.yolo.utils.checks import check_requirements +# from ultralytics.utils.checks import check_requirements # check_requirements('timm') # from timm.models.layers import DropPath as TimmDropPath # from timm.models.layers import trunc_normal_ diff --git a/ultralytics/vit/sam/modules/transformer.py b/ultralytics/models/sam/modules/transformer.py similarity index 100% rename from ultralytics/vit/sam/modules/transformer.py rename to ultralytics/models/sam/modules/transformer.py diff --git a/ultralytics/vit/sam/predict.py b/ultralytics/models/sam/predict.py similarity index 98% rename from ultralytics/vit/sam/predict.py rename to ultralytics/models/sam/predict.py index c6db86e..8f98d58 100644 --- a/ultralytics/vit/sam/predict.py +++ b/ultralytics/models/sam/predict.py @@ -5,11 +5,11 @@ import torch import torch.nn.functional as F import torchvision -from ultralytics.yolo.data.augment import LetterBox -from ultralytics.yolo.engine.predictor import BasePredictor -from ultralytics.yolo.engine.results import Results -from ultralytics.yolo.utils import DEFAULT_CFG, ops -from ultralytics.yolo.utils.torch_utils import select_device +from ultralytics.data.augment import LetterBox +from ultralytics.engine.predictor import BasePredictor +from ultralytics.engine.results import Results +from ultralytics.utils import DEFAULT_CFG, ops +from ultralytics.utils.torch_utils import select_device from .amg import (batch_iterator, batched_mask_to_box, build_all_layer_point_grids, calculate_stability_score, generate_crop_boxes, is_box_near_crop_edge, remove_small_regions, uncrop_boxes_xyxy, uncrop_masks) diff --git a/ultralytics/vit/utils/__init__.py b/ultralytics/models/utils/__init__.py similarity index 100% rename from ultralytics/vit/utils/__init__.py rename to ultralytics/models/utils/__init__.py diff --git a/ultralytics/vit/utils/loss.py b/ultralytics/models/utils/loss.py similarity index 98% rename from ultralytics/vit/utils/loss.py rename to ultralytics/models/utils/loss.py index cb2de20..db6fd63 100644 --- a/ultralytics/vit/utils/loss.py +++ b/ultralytics/models/utils/loss.py @@ -4,9 +4,10 @@ import torch import torch.nn as nn import torch.nn.functional as F -from ultralytics.vit.utils.ops import HungarianMatcher -from ultralytics.yolo.utils.loss import FocalLoss, VarifocalLoss -from ultralytics.yolo.utils.metrics import bbox_iou +from ultralytics.utils.loss import FocalLoss, VarifocalLoss +from ultralytics.utils.metrics import bbox_iou + +from .ops import HungarianMatcher class DETRLoss(nn.Module): diff --git a/ultralytics/vit/utils/ops.py b/ultralytics/models/utils/ops.py similarity index 99% rename from ultralytics/vit/utils/ops.py rename to ultralytics/models/utils/ops.py index 4b37931..e7f829b 100644 --- a/ultralytics/vit/utils/ops.py +++ b/ultralytics/models/utils/ops.py @@ -5,8 +5,8 @@ import torch.nn as nn import torch.nn.functional as F from scipy.optimize import linear_sum_assignment -from ultralytics.yolo.utils.metrics import bbox_iou -from ultralytics.yolo.utils.ops import xywh2xyxy, xyxy2xywh +from ultralytics.utils.metrics import bbox_iou +from ultralytics.utils.ops import xywh2xyxy, xyxy2xywh class HungarianMatcher(nn.Module): diff --git a/ultralytics/models/yolo/__init__.py b/ultralytics/models/yolo/__init__.py new file mode 100644 index 0000000..a88c60b --- /dev/null +++ b/ultralytics/models/yolo/__init__.py @@ -0,0 +1,5 @@ +# Ultralytics YOLO 🚀, AGPL-3.0 license + +from ultralytics.models.yolo import classify, detect, pose, segment + +__all__ = 'classify', 'segment', 'detect', 'pose' diff --git a/ultralytics/models/yolo/classify/__init__.py b/ultralytics/models/yolo/classify/__init__.py new file mode 100644 index 0000000..84e7114 --- /dev/null +++ b/ultralytics/models/yolo/classify/__init__.py @@ -0,0 +1,7 @@ +# Ultralytics YOLO 🚀, AGPL-3.0 license + +from ultralytics.models.yolo.classify.predict import ClassificationPredictor, predict +from ultralytics.models.yolo.classify.train import ClassificationTrainer, train +from ultralytics.models.yolo.classify.val import ClassificationValidator, val + +__all__ = 'ClassificationPredictor', 'predict', 'ClassificationTrainer', 'train', 'ClassificationValidator', 'val' diff --git a/ultralytics/yolo/v8/classify/predict.py b/ultralytics/models/yolo/classify/predict.py similarity index 91% rename from ultralytics/yolo/v8/classify/predict.py rename to ultralytics/models/yolo/classify/predict.py index fb486e2..a21b3fc 100644 --- a/ultralytics/yolo/v8/classify/predict.py +++ b/ultralytics/models/yolo/classify/predict.py @@ -2,9 +2,9 @@ import torch -from ultralytics.yolo.engine.predictor import BasePredictor -from ultralytics.yolo.engine.results import Results -from ultralytics.yolo.utils import DEFAULT_CFG, ROOT +from ultralytics.engine.predictor import BasePredictor +from ultralytics.engine.results import Results +from ultralytics.utils import DEFAULT_CFG, ROOT class ClassificationPredictor(BasePredictor): diff --git a/ultralytics/yolo/v8/classify/train.py b/ultralytics/models/yolo/classify/train.py similarity index 92% rename from ultralytics/yolo/v8/classify/train.py rename to ultralytics/models/yolo/classify/train.py index 72feb55..21101b5 100644 --- a/ultralytics/yolo/v8/classify/train.py +++ b/ultralytics/models/yolo/classify/train.py @@ -3,13 +3,13 @@ import torch import torchvision +from ultralytics.data import ClassificationDataset, build_dataloader +from ultralytics.engine.trainer import BaseTrainer +from ultralytics.models import yolo from ultralytics.nn.tasks import ClassificationModel, attempt_load_one_weight -from ultralytics.yolo import v8 -from ultralytics.yolo.data import ClassificationDataset, build_dataloader -from ultralytics.yolo.engine.trainer import BaseTrainer -from ultralytics.yolo.utils import DEFAULT_CFG, LOGGER, RANK, colorstr -from ultralytics.yolo.utils.plotting import plot_images, plot_results -from ultralytics.yolo.utils.torch_utils import is_parallel, strip_optimizer, torch_distributed_zero_first +from ultralytics.utils import DEFAULT_CFG, LOGGER, RANK, colorstr +from ultralytics.utils.plotting import plot_images, plot_results +from ultralytics.utils.torch_utils import is_parallel, strip_optimizer, torch_distributed_zero_first class ClassificationTrainer(BaseTrainer): @@ -98,7 +98,7 @@ class ClassificationTrainer(BaseTrainer): def get_validator(self): """Returns an instance of ClassificationValidator for validation.""" self.loss_names = ['loss'] - return v8.classify.ClassificationValidator(self.test_loader, self.save_dir) + return yolo.classify.ClassificationValidator(self.test_loader, self.save_dir) def label_loss_items(self, loss_items=None, prefix='train'): """ diff --git a/ultralytics/yolo/v8/classify/val.py b/ultralytics/models/yolo/classify/val.py similarity index 93% rename from ultralytics/yolo/v8/classify/val.py rename to ultralytics/models/yolo/classify/val.py index f56dea0..76c4700 100644 --- a/ultralytics/yolo/v8/classify/val.py +++ b/ultralytics/models/yolo/classify/val.py @@ -2,11 +2,11 @@ import torch -from ultralytics.yolo.data import ClassificationDataset, build_dataloader -from ultralytics.yolo.engine.validator import BaseValidator -from ultralytics.yolo.utils import DEFAULT_CFG, LOGGER -from ultralytics.yolo.utils.metrics import ClassifyMetrics, ConfusionMatrix -from ultralytics.yolo.utils.plotting import plot_images +from ultralytics.data import ClassificationDataset, build_dataloader +from ultralytics.engine.validator import BaseValidator +from ultralytics.utils import DEFAULT_CFG, LOGGER +from ultralytics.utils.metrics import ClassifyMetrics, ConfusionMatrix +from ultralytics.utils.plotting import plot_images class ClassificationValidator(BaseValidator): diff --git a/ultralytics/yolo/v8/detect/__init__.py b/ultralytics/models/yolo/detect/__init__.py similarity index 100% rename from ultralytics/yolo/v8/detect/__init__.py rename to ultralytics/models/yolo/detect/__init__.py diff --git a/ultralytics/yolo/v8/detect/predict.py b/ultralytics/models/yolo/detect/predict.py similarity index 90% rename from ultralytics/yolo/v8/detect/predict.py rename to ultralytics/models/yolo/detect/predict.py index 31e8a9f..b7bf16b 100644 --- a/ultralytics/yolo/v8/detect/predict.py +++ b/ultralytics/models/yolo/detect/predict.py @@ -2,9 +2,9 @@ import torch -from ultralytics.yolo.engine.predictor import BasePredictor -from ultralytics.yolo.engine.results import Results -from ultralytics.yolo.utils import DEFAULT_CFG, ROOT, ops +from ultralytics.engine.predictor import BasePredictor +from ultralytics.engine.results import Results +from ultralytics.utils import DEFAULT_CFG, ROOT, ops class DetectionPredictor(BasePredictor): diff --git a/ultralytics/yolo/v8/detect/train.py b/ultralytics/models/yolo/detect/train.py similarity index 91% rename from ultralytics/yolo/v8/detect/train.py rename to ultralytics/models/yolo/detect/train.py index abb94fc..e697a05 100644 --- a/ultralytics/yolo/v8/detect/train.py +++ b/ultralytics/models/yolo/detect/train.py @@ -3,13 +3,13 @@ from copy import copy import numpy as np +from ultralytics.data import build_dataloader, build_yolo_dataset +from ultralytics.engine.trainer import BaseTrainer +from ultralytics.models import yolo from ultralytics.nn.tasks import DetectionModel -from ultralytics.yolo import v8 -from ultralytics.yolo.data import build_dataloader, build_yolo_dataset -from ultralytics.yolo.engine.trainer import BaseTrainer -from ultralytics.yolo.utils import DEFAULT_CFG, LOGGER, RANK -from ultralytics.yolo.utils.plotting import plot_images, plot_labels, plot_results -from ultralytics.yolo.utils.torch_utils import de_parallel, torch_distributed_zero_first +from ultralytics.utils import DEFAULT_CFG, LOGGER, RANK +from ultralytics.utils.plotting import plot_images, plot_labels, plot_results +from ultralytics.utils.torch_utils import de_parallel, torch_distributed_zero_first # BaseTrainer python usage @@ -64,7 +64,7 @@ class DetectionTrainer(BaseTrainer): def get_validator(self): """Returns a DetectionValidator for YOLO model validation.""" self.loss_names = 'box_loss', 'cls_loss', 'dfl_loss' - return v8.detect.DetectionValidator(self.test_loader, save_dir=self.save_dir, args=copy(self.args)) + return yolo.detect.DetectionValidator(self.test_loader, save_dir=self.save_dir, args=copy(self.args)) def label_loss_items(self, loss_items=None, prefix='train'): """ diff --git a/ultralytics/yolo/v8/detect/val.py b/ultralytics/models/yolo/detect/val.py similarity index 96% rename from ultralytics/yolo/v8/detect/val.py rename to ultralytics/models/yolo/detect/val.py index c28dfb5..f4109f5 100644 --- a/ultralytics/yolo/v8/detect/val.py +++ b/ultralytics/models/yolo/detect/val.py @@ -6,13 +6,13 @@ from pathlib import Path import numpy as np import torch -from ultralytics.yolo.data import build_dataloader, build_yolo_dataset -from ultralytics.yolo.engine.validator import BaseValidator -from ultralytics.yolo.utils import DEFAULT_CFG, LOGGER, ops -from ultralytics.yolo.utils.checks import check_requirements -from ultralytics.yolo.utils.metrics import ConfusionMatrix, DetMetrics, box_iou -from ultralytics.yolo.utils.plotting import output_to_target, plot_images -from ultralytics.yolo.utils.torch_utils import de_parallel +from ultralytics.data import build_dataloader, build_yolo_dataset +from ultralytics.engine.validator import BaseValidator +from ultralytics.utils import DEFAULT_CFG, LOGGER, ops +from ultralytics.utils.checks import check_requirements +from ultralytics.utils.metrics import ConfusionMatrix, DetMetrics, box_iou +from ultralytics.utils.plotting import output_to_target, plot_images +from ultralytics.utils.torch_utils import de_parallel class DetectionValidator(BaseValidator): diff --git a/ultralytics/yolo/v8/pose/__init__.py b/ultralytics/models/yolo/pose/__init__.py similarity index 100% rename from ultralytics/yolo/v8/pose/__init__.py rename to ultralytics/models/yolo/pose/__init__.py diff --git a/ultralytics/yolo/v8/pose/predict.py b/ultralytics/models/yolo/pose/predict.py similarity index 92% rename from ultralytics/yolo/v8/pose/predict.py rename to ultralytics/models/yolo/pose/predict.py index ad3246e..fe7f383 100644 --- a/ultralytics/yolo/v8/pose/predict.py +++ b/ultralytics/models/yolo/pose/predict.py @@ -1,8 +1,8 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license -from ultralytics.yolo.engine.results import Results -from ultralytics.yolo.utils import DEFAULT_CFG, ROOT, ops -from ultralytics.yolo.v8.detect.predict import DetectionPredictor +from ultralytics.engine.results import Results +from ultralytics.models.yolo.detect.predict import DetectionPredictor +from ultralytics.utils import DEFAULT_CFG, ROOT, ops class PosePredictor(DetectionPredictor): diff --git a/ultralytics/yolo/v8/pose/train.py b/ultralytics/models/yolo/pose/train.py similarity index 89% rename from ultralytics/yolo/v8/pose/train.py rename to ultralytics/models/yolo/pose/train.py index af3043c..df4a4af 100644 --- a/ultralytics/yolo/v8/pose/train.py +++ b/ultralytics/models/yolo/pose/train.py @@ -2,14 +2,14 @@ from copy import copy +from ultralytics.models import yolo from ultralytics.nn.tasks import PoseModel -from ultralytics.yolo import v8 -from ultralytics.yolo.utils import DEFAULT_CFG -from ultralytics.yolo.utils.plotting import plot_images, plot_results +from ultralytics.utils import DEFAULT_CFG +from ultralytics.utils.plotting import plot_images, plot_results # BaseTrainer python usage -class PoseTrainer(v8.detect.DetectionTrainer): +class PoseTrainer(yolo.detect.DetectionTrainer): def __init__(self, cfg=DEFAULT_CFG, overrides=None, _callbacks=None): """Initialize a PoseTrainer object with specified configurations and overrides.""" @@ -34,7 +34,7 @@ class PoseTrainer(v8.detect.DetectionTrainer): def get_validator(self): """Returns an instance of the PoseValidator class for validation.""" self.loss_names = 'box_loss', 'pose_loss', 'kobj_loss', 'cls_loss', 'dfl_loss' - return v8.pose.PoseValidator(self.test_loader, save_dir=self.save_dir, args=copy(self.args)) + return yolo.pose.PoseValidator(self.test_loader, save_dir=self.save_dir, args=copy(self.args)) def plot_training_samples(self, batch, ni): """Plot a batch of training samples with annotated class labels, bounding boxes, and keypoints.""" diff --git a/ultralytics/yolo/v8/pose/val.py b/ultralytics/models/yolo/pose/val.py similarity index 96% rename from ultralytics/yolo/v8/pose/val.py rename to ultralytics/models/yolo/pose/val.py index f3fc1ac..1fd5f32 100644 --- a/ultralytics/yolo/v8/pose/val.py +++ b/ultralytics/models/yolo/pose/val.py @@ -5,11 +5,11 @@ from pathlib import Path import numpy as np import torch -from ultralytics.yolo.utils import DEFAULT_CFG, LOGGER, ops -from ultralytics.yolo.utils.checks import check_requirements -from ultralytics.yolo.utils.metrics import OKS_SIGMA, PoseMetrics, box_iou, kpt_iou -from ultralytics.yolo.utils.plotting import output_to_target, plot_images -from ultralytics.yolo.v8.detect import DetectionValidator +from ultralytics.models.yolo.detect import DetectionValidator +from ultralytics.utils import DEFAULT_CFG, LOGGER, ops +from ultralytics.utils.checks import check_requirements +from ultralytics.utils.metrics import OKS_SIGMA, PoseMetrics, box_iou, kpt_iou +from ultralytics.utils.plotting import output_to_target, plot_images class PoseValidator(DetectionValidator): diff --git a/ultralytics/yolo/v8/segment/__init__.py b/ultralytics/models/yolo/segment/__init__.py similarity index 100% rename from ultralytics/yolo/v8/segment/__init__.py rename to ultralytics/models/yolo/segment/__init__.py diff --git a/ultralytics/yolo/v8/segment/predict.py b/ultralytics/models/yolo/segment/predict.py similarity index 93% rename from ultralytics/yolo/v8/segment/predict.py rename to ultralytics/models/yolo/segment/predict.py index 0b6ebc4..cef9d7a 100644 --- a/ultralytics/yolo/v8/segment/predict.py +++ b/ultralytics/models/yolo/segment/predict.py @@ -2,9 +2,9 @@ import torch -from ultralytics.yolo.engine.results import Results -from ultralytics.yolo.utils import DEFAULT_CFG, ROOT, ops -from ultralytics.yolo.v8.detect.predict import DetectionPredictor +from ultralytics.engine.results import Results +from ultralytics.models.yolo.detect.predict import DetectionPredictor +from ultralytics.utils import DEFAULT_CFG, ROOT, ops class SegmentationPredictor(DetectionPredictor): diff --git a/ultralytics/yolo/v8/segment/train.py b/ultralytics/models/yolo/segment/train.py similarity index 87% rename from ultralytics/yolo/v8/segment/train.py rename to ultralytics/models/yolo/segment/train.py index ab66cf0..e239c26 100644 --- a/ultralytics/yolo/v8/segment/train.py +++ b/ultralytics/models/yolo/segment/train.py @@ -1,14 +1,14 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license from copy import copy +from ultralytics.models import yolo from ultralytics.nn.tasks import SegmentationModel -from ultralytics.yolo import v8 -from ultralytics.yolo.utils import DEFAULT_CFG, RANK -from ultralytics.yolo.utils.plotting import plot_images, plot_results +from ultralytics.utils import DEFAULT_CFG, RANK +from ultralytics.utils.plotting import plot_images, plot_results # BaseTrainer python usage -class SegmentationTrainer(v8.detect.DetectionTrainer): +class SegmentationTrainer(yolo.detect.DetectionTrainer): def __init__(self, cfg=DEFAULT_CFG, overrides=None, _callbacks=None): """Initialize a SegmentationTrainer object with given arguments.""" @@ -28,7 +28,7 @@ class SegmentationTrainer(v8.detect.DetectionTrainer): def get_validator(self): """Return an instance of SegmentationValidator for validation of YOLO model.""" self.loss_names = 'box_loss', 'seg_loss', 'cls_loss', 'dfl_loss' - return v8.segment.SegmentationValidator(self.test_loader, save_dir=self.save_dir, args=copy(self.args)) + return yolo.segment.SegmentationValidator(self.test_loader, save_dir=self.save_dir, args=copy(self.args)) def plot_training_samples(self, batch, ni): """Creates a plot of training sample images with labels and box coordinates.""" diff --git a/ultralytics/yolo/v8/segment/val.py b/ultralytics/models/yolo/segment/val.py similarity index 97% rename from ultralytics/yolo/v8/segment/val.py rename to ultralytics/models/yolo/segment/val.py index 73c2fe8..5735d3f 100644 --- a/ultralytics/yolo/v8/segment/val.py +++ b/ultralytics/models/yolo/segment/val.py @@ -7,11 +7,11 @@ import numpy as np import torch import torch.nn.functional as F -from ultralytics.yolo.utils import DEFAULT_CFG, LOGGER, NUM_THREADS, ops -from ultralytics.yolo.utils.checks import check_requirements -from ultralytics.yolo.utils.metrics import SegmentMetrics, box_iou, mask_iou -from ultralytics.yolo.utils.plotting import output_to_target, plot_images -from ultralytics.yolo.v8.detect import DetectionValidator +from ultralytics.models.yolo.detect import DetectionValidator +from ultralytics.utils import DEFAULT_CFG, LOGGER, NUM_THREADS, ops +from ultralytics.utils.checks import check_requirements +from ultralytics.utils.metrics import SegmentMetrics, box_iou, mask_iou +from ultralytics.utils.plotting import output_to_target, plot_images class SegmentationValidator(DetectionValidator): diff --git a/ultralytics/nn/autobackend.py b/ultralytics/nn/autobackend.py index 78776bd..6a8e387 100644 --- a/ultralytics/nn/autobackend.py +++ b/ultralytics/nn/autobackend.py @@ -16,10 +16,10 @@ import torch import torch.nn as nn from PIL import Image -from ultralytics.yolo.utils import ARM64, LINUX, LOGGER, ROOT, yaml_load -from ultralytics.yolo.utils.checks import check_requirements, check_suffix, check_version, check_yaml -from ultralytics.yolo.utils.downloads import attempt_download_asset, is_url -from ultralytics.yolo.utils.ops import xywh2xyxy +from ultralytics.utils import ARM64, LINUX, LOGGER, ROOT, yaml_load +from ultralytics.utils.checks import check_requirements, check_suffix, check_version, check_yaml +from ultralytics.utils.downloads import attempt_download_asset, is_url +from ultralytics.utils.ops import xywh2xyxy def check_class_names(names): @@ -34,7 +34,7 @@ def check_class_names(names): raise KeyError(f'{n}-class dataset requires class indices 0-{n - 1}, but you have invalid class indices ' f'{min(names.keys())}-{max(names.keys())} defined in your dataset YAML.') if isinstance(names[0], str) and names[0].startswith('n0'): # imagenet class codes, i.e. 'n01440764' - map = yaml_load(ROOT / 'datasets/ImageNet.yaml')['map'] # human-readable names + map = yaml_load(ROOT / 'cfg/datasets/ImageNet.yaml')['map'] # human-readable names names = {k: map[v] for k, v in names.items()} return names @@ -210,7 +210,7 @@ class AutoBackend(nn.Module): LOGGER.info(f'Loading {w} for TensorFlow GraphDef inference...') import tensorflow as tf - from ultralytics.yolo.engine.exporter import gd_outputs + from ultralytics.engine.exporter import gd_outputs def wrap_frozen_graph(gd, inputs, outputs): """Wrap frozen graphs for deployment.""" @@ -284,7 +284,7 @@ class AutoBackend(nn.Module): """ raise NotImplementedError('Triton Inference Server is not currently supported.') else: - from ultralytics.yolo.engine.exporter import export_formats + from ultralytics.engine.exporter import export_formats raise TypeError(f"model='{w}' is not a supported model format. " 'See https://docs.ultralytics.com/modes/predict for help.' f'\n\n{export_formats()}') @@ -476,7 +476,7 @@ class AutoBackend(nn.Module): """ # Return model type from model path, i.e. path='path/to/model.onnx' -> type=onnx # types = [pt, jit, onnx, xml, engine, coreml, saved_model, pb, tflite, edgetpu, tfjs, paddle] - from ultralytics.yolo.engine.exporter import export_formats + from ultralytics.engine.exporter import export_formats sf = list(export_formats().Suffix) # export suffixes if not is_url(p, check=False) and not isinstance(p, str): check_suffix(p, sf) # checks diff --git a/ultralytics/nn/modules/head.py b/ultralytics/nn/modules/head.py index 3b70d70..e31ae8b 100644 --- a/ultralytics/nn/modules/head.py +++ b/ultralytics/nn/modules/head.py @@ -9,7 +9,7 @@ import torch import torch.nn as nn from torch.nn.init import constant_, xavier_uniform_ -from ultralytics.yolo.utils.tal import dist2bbox, make_anchors +from ultralytics.utils.tal import dist2bbox, make_anchors from .block import DFL, Proto from .conv import Conv @@ -219,7 +219,7 @@ class RTDETRDecoder(nn.Module): self._reset_parameters() def forward(self, x, batch=None): - from ultralytics.vit.utils.ops import get_cdn_group + from ultralytics.models.utils.ops import get_cdn_group # input projection and embedding feats, shapes = self._get_encoder_input(x) diff --git a/ultralytics/nn/tasks.py b/ultralytics/nn/tasks.py index 08f5b18..036c9f9 100644 --- a/ultralytics/nn/tasks.py +++ b/ultralytics/nn/tasks.py @@ -11,12 +11,12 @@ from ultralytics.nn.modules import (AIFI, C1, C2, C3, C3TR, SPP, SPPF, Bottlenec Classify, Concat, Conv, Conv2, ConvTranspose, Detect, DWConv, DWConvTranspose2d, Focus, GhostBottleneck, GhostConv, HGBlock, HGStem, Pose, RepC3, RepConv, RTDETRDecoder, Segment) -from ultralytics.yolo.utils import DEFAULT_CFG_DICT, DEFAULT_CFG_KEYS, LOGGER, colorstr, emojis, yaml_load -from ultralytics.yolo.utils.checks import check_requirements, check_suffix, check_yaml -from ultralytics.yolo.utils.loss import v8ClassificationLoss, v8DetectionLoss, v8PoseLoss, v8SegmentationLoss -from ultralytics.yolo.utils.plotting import feature_visualization -from ultralytics.yolo.utils.torch_utils import (fuse_conv_and_bn, fuse_deconv_and_bn, initialize_weights, - intersect_dicts, make_divisible, model_info, scale_img, time_sync) +from ultralytics.utils import DEFAULT_CFG_DICT, DEFAULT_CFG_KEYS, LOGGER, colorstr, emojis, yaml_load +from ultralytics.utils.checks import check_requirements, check_suffix, check_yaml +from ultralytics.utils.loss import v8ClassificationLoss, v8DetectionLoss, v8PoseLoss, v8SegmentationLoss +from ultralytics.utils.plotting import feature_visualization +from ultralytics.utils.torch_utils import (fuse_conv_and_bn, fuse_deconv_and_bn, initialize_weights, intersect_dicts, + make_divisible, model_info, scale_img, time_sync) try: import thop @@ -412,7 +412,7 @@ class RTDETRDetectionModel(DetectionModel): def init_criterion(self): """Compute the classification loss between predictions and true labels.""" - from ultralytics.vit.utils.loss import RTDETRDetectionLoss + from ultralytics.models.utils.loss import RTDETRDetectionLoss return RTDETRDetectionLoss(nc=self.nc, use_vfl=True) @@ -498,6 +498,45 @@ class Ensemble(nn.ModuleList): # Functions ------------------------------------------------------------------------------------------------------------ +@contextlib.contextmanager +def temporary_modules(modules=None): + """ + Context manager for temporarily adding or modifying modules in Python's module cache (`sys.modules`). + + This function can be used to change the module paths during runtime. It's useful when refactoring code, + where you've moved a module from one location to another, but you still want to support the old import + paths for backwards compatibility. + + Args: + modules (dict, optional): A dictionary mapping old module paths to new module paths. + + Example: + with temporary_modules({'old.module.path': 'new.module.path'}): + import old.module.path # this will now import new.module.path + + Note: + The changes are only in effect inside the context manager and are undone once the context manager exits. + Be aware that directly manipulating `sys.modules` can lead to unpredictable results, especially in larger + applications or libraries. Use this function with caution. + """ + if not modules: + modules = {} + + import importlib + import sys + try: + # Set modules in sys.modules under their old name + for old, new in modules.items(): + sys.modules[old] = importlib.import_module(new) + + yield + finally: + # Remove the temporary module paths + for old in modules: + if old in sys.modules: + del sys.modules[old] + + def torch_safe_load(weight): """ This function attempts to load a PyTorch model with the torch.load() function. If a ModuleNotFoundError is raised, @@ -510,12 +549,17 @@ def torch_safe_load(weight): Returns: (dict): The loaded PyTorch model. """ - from ultralytics.yolo.utils.downloads import attempt_download_asset + from ultralytics.utils.downloads import attempt_download_asset check_suffix(file=weight, suffix='.pt') file = attempt_download_asset(weight) # search online if missing locally try: - return torch.load(file, map_location='cpu'), file # load + with temporary_modules({ + 'ultralytics.yolo.utils': 'ultralytics.utils', + 'ultralytics.yolo.v8': 'ultralytics.models.yolo', + 'ultralytics.yolo.data': 'ultralytics.data'}): # for legacy 8.0 Classify and Pose models + return torch.load(file, map_location='cpu'), file # load + except ModuleNotFoundError as e: # e.name is missing module name if e.name == 'models': raise TypeError( diff --git a/ultralytics/tracker/trackers/__init__.py b/ultralytics/tracker/trackers/__init__.py deleted file mode 100644 index a0fd890..0000000 --- a/ultralytics/tracker/trackers/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# Ultralytics YOLO 🚀, AGPL-3.0 license - -from .bot_sort import BOTSORT -from .byte_tracker import BYTETracker - -__all__ = 'BOTSORT', 'BYTETracker' # allow simpler import diff --git a/ultralytics/tracker/README.md b/ultralytics/trackers/README.md similarity index 95% rename from ultralytics/tracker/README.md rename to ultralytics/trackers/README.md index 26ec0c3..843bd22 100644 --- a/ultralytics/tracker/README.md +++ b/ultralytics/trackers/README.md @@ -69,7 +69,7 @@ while True: ## Change tracker parameters -You can change the tracker parameters by eding the `tracker.yaml` file which is located in the ultralytics/tracker/cfg folder. +You can change the tracker parameters by eding the `tracker.yaml` file which is located in the ultralytics/cfg/trackers folder. ## Command Line Interface (CLI) @@ -81,6 +81,6 @@ yolo segment track source=... tracker=... yolo pose track source=... tracker=... ``` -By default, trackers will use the configuration in `ultralytics/tracker/cfg`. +By default, trackers will use the configuration in `ultralytics/cfg/trackers`. We also support using a modified tracker config file. Please refer to the tracker config files -in `ultralytics/tracker/cfg`.
+in `ultralytics/cfg/trackers`.
diff --git a/ultralytics/tracker/__init__.py b/ultralytics/trackers/__init__.py similarity index 70% rename from ultralytics/tracker/__init__.py rename to ultralytics/trackers/__init__.py index 13d3903..46e178e 100644 --- a/ultralytics/tracker/__init__.py +++ b/ultralytics/trackers/__init__.py @@ -1,6 +1,7 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license +from .bot_sort import BOTSORT +from .byte_tracker import BYTETracker from .track import register_tracker -from .trackers import BOTSORT, BYTETracker __all__ = 'register_tracker', 'BOTSORT', 'BYTETracker' # allow simpler import diff --git a/ultralytics/tracker/trackers/basetrack.py b/ultralytics/trackers/basetrack.py similarity index 100% rename from ultralytics/tracker/trackers/basetrack.py rename to ultralytics/trackers/basetrack.py diff --git a/ultralytics/tracker/trackers/bot_sort.py b/ultralytics/trackers/bot_sort.py similarity index 98% rename from ultralytics/tracker/trackers/bot_sort.py rename to ultralytics/trackers/bot_sort.py index 10e8868..168b942 100644 --- a/ultralytics/tracker/trackers/bot_sort.py +++ b/ultralytics/trackers/bot_sort.py @@ -4,11 +4,11 @@ from collections import deque import numpy as np -from ..utils import matching -from ..utils.gmc import GMC -from ..utils.kalman_filter import KalmanFilterXYWH from .basetrack import TrackState from .byte_tracker import BYTETracker, STrack +from .utils import matching +from .utils.gmc import GMC +from .utils.kalman_filter import KalmanFilterXYWH class BOTrack(STrack): diff --git a/ultralytics/tracker/trackers/byte_tracker.py b/ultralytics/trackers/byte_tracker.py similarity index 99% rename from ultralytics/tracker/trackers/byte_tracker.py rename to ultralytics/trackers/byte_tracker.py index 6034cdc..04958cd 100644 --- a/ultralytics/tracker/trackers/byte_tracker.py +++ b/ultralytics/trackers/byte_tracker.py @@ -2,9 +2,9 @@ import numpy as np -from ..utils import matching -from ..utils.kalman_filter import KalmanFilterXYAH from .basetrack import BaseTrack, TrackState +from .utils import matching +from .utils.kalman_filter import KalmanFilterXYAH class STrack(BaseTrack): diff --git a/ultralytics/tracker/track.py b/ultralytics/trackers/track.py similarity index 92% rename from ultralytics/tracker/track.py rename to ultralytics/trackers/track.py index d08abfc..cfb4b08 100644 --- a/ultralytics/tracker/track.py +++ b/ultralytics/trackers/track.py @@ -4,10 +4,11 @@ from functools import partial import torch -from ultralytics.yolo.utils import IterableSimpleNamespace, yaml_load -from ultralytics.yolo.utils.checks import check_yaml +from ultralytics.utils import IterableSimpleNamespace, yaml_load +from ultralytics.utils.checks import check_yaml -from .trackers import BOTSORT, BYTETracker +from .bot_sort import BOTSORT +from .byte_tracker import BYTETracker TRACKER_MAP = {'bytetrack': BYTETracker, 'botsort': BOTSORT} diff --git a/ultralytics/trackers/utils/__init__.py b/ultralytics/trackers/utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ultralytics/tracker/utils/gmc.py b/ultralytics/trackers/utils/gmc.py similarity index 99% rename from ultralytics/tracker/utils/gmc.py rename to ultralytics/trackers/utils/gmc.py index a5c910d..0529be4 100644 --- a/ultralytics/tracker/utils/gmc.py +++ b/ultralytics/trackers/utils/gmc.py @@ -5,7 +5,7 @@ import copy import cv2 import numpy as np -from ultralytics.yolo.utils import LOGGER +from ultralytics.utils import LOGGER class GMC: diff --git a/ultralytics/tracker/utils/kalman_filter.py b/ultralytics/trackers/utils/kalman_filter.py similarity index 100% rename from ultralytics/tracker/utils/kalman_filter.py rename to ultralytics/trackers/utils/kalman_filter.py diff --git a/ultralytics/tracker/utils/matching.py b/ultralytics/trackers/utils/matching.py similarity index 99% rename from ultralytics/tracker/utils/matching.py rename to ultralytics/trackers/utils/matching.py index 0b22b3d..02a322d 100644 --- a/ultralytics/tracker/utils/matching.py +++ b/ultralytics/trackers/utils/matching.py @@ -11,7 +11,7 @@ try: assert lap.__version__ # verify package is not directory except (ImportError, AssertionError, AttributeError): - from ultralytics.yolo.utils.checks import check_requirements + from ultralytics.utils.checks import check_requirements check_requirements('lapx>=0.5.2') # update to lap package from https://github.com/rathaROG/lapx import lap diff --git a/ultralytics/utils/__init__.py b/ultralytics/utils/__init__.py new file mode 100644 index 0000000..44559a6 --- /dev/null +++ b/ultralytics/utils/__init__.py @@ -0,0 +1,809 @@ +# Ultralytics YOLO 🚀, AGPL-3.0 license + +import contextlib +import inspect +import logging.config +import os +import platform +import re +import subprocess +import sys +import threading +import urllib +import uuid +from pathlib import Path +from types import SimpleNamespace +from typing import Union + +import cv2 +import matplotlib.pyplot as plt +import numpy as np +import torch +import yaml + +from ultralytics import __version__ + +# PyTorch Multi-GPU DDP Constants +RANK = int(os.getenv('RANK', -1)) +LOCAL_RANK = int(os.getenv('LOCAL_RANK', -1)) # https://pytorch.org/docs/stable/elastic/run.html +WORLD_SIZE = int(os.getenv('WORLD_SIZE', 1)) + +# Other Constants +FILE = Path(__file__).resolve() +ROOT = FILE.parents[1] # YOLO +DEFAULT_CFG_PATH = ROOT / 'cfg/default.yaml' +NUM_THREADS = min(8, max(1, os.cpu_count() - 1)) # number of YOLOv5 multiprocessing threads +AUTOINSTALL = str(os.getenv('YOLO_AUTOINSTALL', True)).lower() == 'true' # global auto-install mode +VERBOSE = str(os.getenv('YOLO_VERBOSE', True)).lower() == 'true' # global verbose mode +TQDM_BAR_FORMAT = '{l_bar}{bar:10}{r_bar}' # tqdm bar format +LOGGING_NAME = 'ultralytics' +MACOS, LINUX, WINDOWS = (platform.system() == x for x in ['Darwin', 'Linux', 'Windows']) # environment booleans +ARM64 = platform.machine() in ('arm64', 'aarch64') # ARM64 booleans +HELP_MSG = \ + """ + Usage examples for running YOLOv8: + + 1. Install the ultralytics package: + + pip install ultralytics + + 2. Use the Python SDK: + + from ultralytics import YOLO + + # Load a model + model = YOLO('yolov8n.yaml') # build a new model from scratch + model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training) + + # Use the model + results = model.train(data="coco128.yaml", epochs=3) # train the model + results = model.val() # evaluate model performance on the validation set + results = model('https://ultralytics.com/images/bus.jpg') # predict on an image + success = model.export(format='onnx') # export the model to ONNX format + + 3. Use the command line interface (CLI): + + YOLOv8 'yolo' CLI commands use the following syntax: + + yolo TASK MODE ARGS + + Where TASK (optional) is one of [detect, segment, classify] + MODE (required) is one of [train, val, predict, export] + ARGS (optional) are any number of custom 'arg=value' pairs like 'imgsz=320' that override defaults. + See all ARGS at https://docs.ultralytics.com/usage/cfg or with 'yolo cfg' + + - Train a detection model for 10 epochs with an initial learning_rate of 0.01 + yolo detect train data=coco128.yaml model=yolov8n.pt epochs=10 lr0=0.01 + + - Predict a YouTube video using a pretrained segmentation model at image size 320: + yolo segment predict model=yolov8n-seg.pt source='https://youtu.be/Zgi9g1ksQHc' imgsz=320 + + - Val a pretrained detection model at batch-size 1 and image size 640: + yolo detect val model=yolov8n.pt data=coco128.yaml batch=1 imgsz=640 + + - Export a YOLOv8n classification model to ONNX format at image size 224 by 128 (no TASK required) + yolo export model=yolov8n-cls.pt format=onnx imgsz=224,128 + + - Run special commands: + yolo help + yolo checks + yolo version + yolo settings + yolo copy-cfg + yolo cfg + + Docs: https://docs.ultralytics.com + Community: https://community.ultralytics.com + GitHub: https://github.com/ultralytics/ultralytics + """ + +# Settings +torch.set_printoptions(linewidth=320, precision=4, profile='default') +np.set_printoptions(linewidth=320, formatter={'float_kind': '{:11.5g}'.format}) # format short g, %precision=5 +cv2.setNumThreads(0) # prevent OpenCV from multithreading (incompatible with PyTorch DataLoader) +os.environ['NUMEXPR_MAX_THREADS'] = str(NUM_THREADS) # NumExpr max threads +os.environ['CUBLAS_WORKSPACE_CONFIG'] = ':4096:8' # for deterministic training +os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # suppress verbose TF compiler warnings in Colab + + +class SimpleClass: + """ + Ultralytics SimpleClass is a base class providing helpful string representation, error reporting, and attribute + access methods for easier debugging and usage. + """ + + def __str__(self): + """Return a human-readable string representation of the object.""" + attr = [] + for a in dir(self): + v = getattr(self, a) + if not callable(v) and not a.startswith('_'): + if isinstance(v, SimpleClass): + # Display only the module and class name for subclasses + s = f'{a}: {v.__module__}.{v.__class__.__name__} object' + else: + s = f'{a}: {repr(v)}' + attr.append(s) + return f'{self.__module__}.{self.__class__.__name__} object with attributes:\n\n' + '\n'.join(attr) + + def __repr__(self): + """Return a machine-readable string representation of the object.""" + return self.__str__() + + def __getattr__(self, attr): + """Custom attribute access error message with helpful information.""" + name = self.__class__.__name__ + raise AttributeError(f"'{name}' object has no attribute '{attr}'. See valid attributes below.\n{self.__doc__}") + + +class IterableSimpleNamespace(SimpleNamespace): + """ + Ultralytics IterableSimpleNamespace is an extension class of SimpleNamespace that adds iterable functionality and + enables usage with dict() and for loops. + """ + + def __iter__(self): + """Return an iterator of key-value pairs from the namespace's attributes.""" + return iter(vars(self).items()) + + def __str__(self): + """Return a human-readable string representation of the object.""" + return '\n'.join(f'{k}={v}' for k, v in vars(self).items()) + + def __getattr__(self, attr): + """Custom attribute access error message with helpful information.""" + name = self.__class__.__name__ + raise AttributeError(f""" + '{name}' object has no attribute '{attr}'. This may be caused by a modified or out of date ultralytics + 'default.yaml' file.\nPlease update your code with 'pip install -U ultralytics' and if necessary replace + {DEFAULT_CFG_PATH} with the latest version from + https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/default.yaml + """) + + def get(self, key, default=None): + """Return the value of the specified key if it exists; otherwise, return the default value.""" + return getattr(self, key, default) + + +def plt_settings(rcparams=None, backend='Agg'): + """ + Decorator to temporarily set rc parameters and the backend for a plotting function. + + Usage: + decorator: @plt_settings({"font.size": 12}) + context manager: with plt_settings({"font.size": 12}): + + Args: + rcparams (dict): Dictionary of rc parameters to set. + backend (str, optional): Name of the backend to use. Defaults to 'Agg'. + + Returns: + (Callable): Decorated function with temporarily set rc parameters and backend. This decorator can be + applied to any function that needs to have specific matplotlib rc parameters and backend for its execution. + """ + + if rcparams is None: + rcparams = {'font.size': 11} + + def decorator(func): + """Decorator to apply temporary rc parameters and backend to a function.""" + + def wrapper(*args, **kwargs): + """Sets rc parameters and backend, calls the original function, and restores the settings.""" + original_backend = plt.get_backend() + plt.switch_backend(backend) + + with plt.rc_context(rcparams): + result = func(*args, **kwargs) + + plt.switch_backend(original_backend) + return result + + return wrapper + + return decorator + + +def set_logging(name=LOGGING_NAME, verbose=True): + """Sets up logging for the given name.""" + rank = int(os.getenv('RANK', -1)) # rank in world for Multi-GPU trainings + level = logging.INFO if verbose and rank in {-1, 0} else logging.ERROR + logging.config.dictConfig({ + 'version': 1, + 'disable_existing_loggers': False, + 'formatters': { + name: { + 'format': '%(message)s'}}, + 'handlers': { + name: { + 'class': 'logging.StreamHandler', + 'formatter': name, + 'level': level}}, + 'loggers': { + name: { + 'level': level, + 'handlers': [name], + 'propagate': False}}}) + + +def emojis(string=''): + """Return platform-dependent emoji-safe version of string.""" + return string.encode().decode('ascii', 'ignore') if WINDOWS else string + + +class EmojiFilter(logging.Filter): + """ + A custom logging filter class for removing emojis in log messages. + + This filter is particularly useful for ensuring compatibility with Windows terminals + that may not support the display of emojis in log messages. + """ + + def filter(self, record): + """Filter logs by emoji unicode characters on windows.""" + record.msg = emojis(record.msg) + return super().filter(record) + + +# Set logger +set_logging(LOGGING_NAME, verbose=VERBOSE) # run before defining LOGGER +LOGGER = logging.getLogger(LOGGING_NAME) # define globally (used in train.py, val.py, detect.py, etc.) +if WINDOWS: # emoji-safe logging + LOGGER.addFilter(EmojiFilter()) + + +class ThreadingLocked: + """ + A decorator class for ensuring thread-safe execution of a function or method. + This class can be used as a decorator to make sure that if the decorated function + is called from multiple threads, only one thread at a time will be able to execute the function. + + Attributes: + lock (threading.Lock): A lock object used to manage access to the decorated function. + + Usage: + @ThreadingLocked() + def my_function(): + # Your code here + pass + """ + + def __init__(self): + self.lock = threading.Lock() + + def __call__(self, f): + from functools import wraps + + @wraps(f) + def decorated(*args, **kwargs): + with self.lock: + return f(*args, **kwargs) + + return decorated + + +def yaml_save(file='data.yaml', data=None): + """ + Save YAML data to a file. + + Args: + file (str, optional): File name. Default is 'data.yaml'. + data (dict): Data to save in YAML format. + + Returns: + (None): Data is saved to the specified file. + """ + if data is None: + data = {} + file = Path(file) + if not file.parent.exists(): + # Create parent directories if they don't exist + file.parent.mkdir(parents=True, exist_ok=True) + + # Convert Path objects to strings + for k, v in data.items(): + if isinstance(v, Path): + data[k] = str(v) + + # Dump data to file in YAML format + with open(file, 'w') as f: + yaml.safe_dump(data, f, sort_keys=False, allow_unicode=True) + + +def yaml_load(file='data.yaml', append_filename=False): + """ + Load YAML data from a file. + + Args: + file (str, optional): File name. Default is 'data.yaml'. + append_filename (bool): Add the YAML filename to the YAML dictionary. Default is False. + + Returns: + (dict): YAML data and file name. + """ + with open(file, errors='ignore', encoding='utf-8') as f: + s = f.read() # string + + # Remove special characters + if not s.isprintable(): + s = re.sub(r'[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD\U00010000-\U0010ffff]+', '', s) + + # Add YAML filename to dict and return + return {**yaml.safe_load(s), 'yaml_file': str(file)} if append_filename else yaml.safe_load(s) + + +def yaml_print(yaml_file: Union[str, Path, dict]) -> None: + """ + Pretty prints a yaml file or a yaml-formatted dictionary. + + Args: + yaml_file: The file path of the yaml file or a yaml-formatted dictionary. + + Returns: + None + """ + yaml_dict = yaml_load(yaml_file) if isinstance(yaml_file, (str, Path)) else yaml_file + dump = yaml.dump(yaml_dict, sort_keys=False, allow_unicode=True) + LOGGER.info(f"Printing '{colorstr('bold', 'black', yaml_file)}'\n\n{dump}") + + +# Default configuration +DEFAULT_CFG_DICT = yaml_load(DEFAULT_CFG_PATH) +for k, v in DEFAULT_CFG_DICT.items(): + if isinstance(v, str) and v.lower() == 'none': + DEFAULT_CFG_DICT[k] = None +DEFAULT_CFG_KEYS = DEFAULT_CFG_DICT.keys() +DEFAULT_CFG = IterableSimpleNamespace(**DEFAULT_CFG_DICT) + + +def is_colab(): + """ + Check if the current script is running inside a Google Colab notebook. + + Returns: + (bool): True if running inside a Colab notebook, False otherwise. + """ + return 'COLAB_RELEASE_TAG' in os.environ or 'COLAB_BACKEND_VERSION' in os.environ + + +def is_kaggle(): + """ + Check if the current script is running inside a Kaggle kernel. + + Returns: + (bool): True if running inside a Kaggle kernel, False otherwise. + """ + return os.environ.get('PWD') == '/kaggle/working' and os.environ.get('KAGGLE_URL_BASE') == 'https://www.kaggle.com' + + +def is_jupyter(): + """ + Check if the current script is running inside a Jupyter Notebook. + Verified on Colab, Jupyterlab, Kaggle, Paperspace. + + Returns: + (bool): True if running inside a Jupyter Notebook, False otherwise. + """ + with contextlib.suppress(Exception): + from IPython import get_ipython + return get_ipython() is not None + return False + + +def is_docker() -> bool: + """ + Determine if the script is running inside a Docker container. + + Returns: + (bool): True if the script is running inside a Docker container, False otherwise. + """ + file = Path('/proc/self/cgroup') + if file.exists(): + with open(file) as f: + return 'docker' in f.read() + else: + return False + + +def is_online() -> bool: + """ + Check internet connectivity by attempting to connect to a known online host. + + Returns: + (bool): True if connection is successful, False otherwise. + """ + import socket + + for host in '1.1.1.1', '8.8.8.8', '223.5.5.5': # Cloudflare, Google, AliDNS: + try: + test_connection = socket.create_connection(address=(host, 53), timeout=2) + except (socket.timeout, socket.gaierror, OSError): + continue + else: + # If the connection was successful, close it to avoid a ResourceWarning + test_connection.close() + return True + return False + + +ONLINE = is_online() + + +def is_pip_package(filepath: str = __name__) -> bool: + """ + Determines if the file at the given filepath is part of a pip package. + + Args: + filepath (str): The filepath to check. + + Returns: + (bool): True if the file is part of a pip package, False otherwise. + """ + import importlib.util + + # Get the spec for the module + spec = importlib.util.find_spec(filepath) + + # Return whether the spec is not None and the origin is not None (indicating it is a package) + return spec is not None and spec.origin is not None + + +def is_dir_writeable(dir_path: Union[str, Path]) -> bool: + """ + Check if a directory is writeable. + + Args: + dir_path (str | Path): The path to the directory. + + Returns: + (bool): True if the directory is writeable, False otherwise. + """ + return os.access(str(dir_path), os.W_OK) + + +def is_pytest_running(): + """ + Determines whether pytest is currently running or not. + + Returns: + (bool): True if pytest is running, False otherwise. + """ + return ('PYTEST_CURRENT_TEST' in os.environ) or ('pytest' in sys.modules) or ('pytest' in Path(sys.argv[0]).stem) + + +def is_github_actions_ci() -> bool: + """ + Determine if the current environment is a GitHub Actions CI Python runner. + + Returns: + (bool): True if the current environment is a GitHub Actions CI Python runner, False otherwise. + """ + return 'GITHUB_ACTIONS' in os.environ and 'RUNNER_OS' in os.environ and 'RUNNER_TOOL_CACHE' in os.environ + + +def is_git_dir(): + """ + Determines whether the current file is part of a git repository. + If the current file is not part of a git repository, returns None. + + Returns: + (bool): True if current file is part of a git repository. + """ + return get_git_dir() is not None + + +def get_git_dir(): + """ + Determines whether the current file is part of a git repository and if so, returns the repository root directory. + If the current file is not part of a git repository, returns None. + + Returns: + (Path | None): Git root directory if found or None if not found. + """ + for d in Path(__file__).parents: + if (d / '.git').is_dir(): + return d + return None # no .git dir found + + +def get_git_origin_url(): + """ + Retrieves the origin URL of a git repository. + + Returns: + (str | None): The origin URL of the git repository. + """ + if is_git_dir(): + with contextlib.suppress(subprocess.CalledProcessError): + origin = subprocess.check_output(['git', 'config', '--get', 'remote.origin.url']) + return origin.decode().strip() + return None # if not git dir or on error + + +def get_git_branch(): + """ + Returns the current git branch name. If not in a git repository, returns None. + + Returns: + (str | None): The current git branch name. + """ + if is_git_dir(): + with contextlib.suppress(subprocess.CalledProcessError): + origin = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']) + return origin.decode().strip() + return None # if not git dir or on error + + +def get_default_args(func): + """Returns a dictionary of default arguments for a function. + + Args: + func (callable): The function to inspect. + + Returns: + (dict): A dictionary where each key is a parameter name, and each value is the default value of that parameter. + """ + signature = inspect.signature(func) + return {k: v.default for k, v in signature.parameters.items() if v.default is not inspect.Parameter.empty} + + +def get_user_config_dir(sub_dir='Ultralytics'): + """ + Get the user config directory. + + Args: + sub_dir (str): The name of the subdirectory to create. + + Returns: + (Path): The path to the user config directory. + """ + # Return the appropriate config directory for each operating system + if WINDOWS: + path = Path.home() / 'AppData' / 'Roaming' / sub_dir + elif MACOS: # macOS + path = Path.home() / 'Library' / 'Application Support' / sub_dir + elif LINUX: + path = Path.home() / '.config' / sub_dir + else: + raise ValueError(f'Unsupported operating system: {platform.system()}') + + # GCP and AWS lambda fix, only /tmp is writeable + if not is_dir_writeable(str(path.parent)): + path = Path('/tmp') / sub_dir + LOGGER.warning(f"WARNING ⚠️ user config directory is not writeable, defaulting to '{path}'.") + + # Create the subdirectory if it does not exist + path.mkdir(parents=True, exist_ok=True) + + return path + + +USER_CONFIG_DIR = Path(os.getenv('YOLO_CONFIG_DIR', get_user_config_dir())) # Ultralytics settings dir +SETTINGS_YAML = USER_CONFIG_DIR / 'settings.yaml' + + +def colorstr(*input): + """Colors a string https://en.wikipedia.org/wiki/ANSI_escape_code, i.e. colorstr('blue', 'hello world').""" + *args, string = input if len(input) > 1 else ('blue', 'bold', input[0]) # color arguments, string + colors = { + 'black': '\033[30m', # basic colors + 'red': '\033[31m', + 'green': '\033[32m', + 'yellow': '\033[33m', + 'blue': '\033[34m', + 'magenta': '\033[35m', + 'cyan': '\033[36m', + 'white': '\033[37m', + 'bright_black': '\033[90m', # bright colors + 'bright_red': '\033[91m', + 'bright_green': '\033[92m', + 'bright_yellow': '\033[93m', + 'bright_blue': '\033[94m', + 'bright_magenta': '\033[95m', + 'bright_cyan': '\033[96m', + 'bright_white': '\033[97m', + 'end': '\033[0m', # misc + 'bold': '\033[1m', + 'underline': '\033[4m'} + return ''.join(colors[x] for x in args) + f'{string}' + colors['end'] + + +class TryExcept(contextlib.ContextDecorator): + """YOLOv8 TryExcept class. Usage: @TryExcept() decorator or 'with TryExcept():' context manager.""" + + def __init__(self, msg='', verbose=True): + """Initialize TryExcept class with optional message and verbosity settings.""" + self.msg = msg + self.verbose = verbose + + def __enter__(self): + """Executes when entering TryExcept context, initializes instance.""" + pass + + def __exit__(self, exc_type, value, traceback): + """Defines behavior when exiting a 'with' block, prints error message if necessary.""" + if self.verbose and value: + print(emojis(f"{self.msg}{': ' if self.msg else ''}{value}")) + return True + + +def threaded(func): + """Multi-threads a target function and returns thread. Usage: @threaded decorator.""" + + def wrapper(*args, **kwargs): + """Multi-threads a given function and returns the thread.""" + thread = threading.Thread(target=func, args=args, kwargs=kwargs, daemon=True) + thread.start() + return thread + + return wrapper + + +def set_sentry(): + """ + Initialize the Sentry SDK for error tracking and reporting. Only used if sentry_sdk package is installed and + sync=True in settings. Run 'yolo settings' to see and update settings YAML file. + + Conditions required to send errors (ALL conditions must be met or no errors will be reported): + - sentry_sdk package is installed + - sync=True in YOLO settings + - pytest is not running + - running in a pip package installation + - running in a non-git directory + - running with rank -1 or 0 + - online environment + - CLI used to run package (checked with 'yolo' as the name of the main CLI command) + + The function also configures Sentry SDK to ignore KeyboardInterrupt and FileNotFoundError + exceptions and to exclude events with 'out of memory' in their exception message. + + Additionally, the function sets custom tags and user information for Sentry events. + """ + + def before_send(event, hint): + """ + Modify the event before sending it to Sentry based on specific exception types and messages. + + Args: + event (dict): The event dictionary containing information about the error. + hint (dict): A dictionary containing additional information about the error. + + Returns: + dict: The modified event or None if the event should not be sent to Sentry. + """ + if 'exc_info' in hint: + exc_type, exc_value, tb = hint['exc_info'] + if exc_type in (KeyboardInterrupt, FileNotFoundError) \ + or 'out of memory' in str(exc_value): + return None # do not send event + + event['tags'] = { + 'sys_argv': sys.argv[0], + 'sys_argv_name': Path(sys.argv[0]).name, + 'install': 'git' if is_git_dir() else 'pip' if is_pip_package() else 'other', + 'os': ENVIRONMENT} + return event + + if SETTINGS['sync'] and \ + RANK in (-1, 0) and \ + Path(sys.argv[0]).name == 'yolo' and \ + not TESTS_RUNNING and \ + ONLINE and \ + is_pip_package() and \ + not is_git_dir(): + + # If sentry_sdk package is not installed then return and do not use Sentry + try: + import sentry_sdk # noqa + except ImportError: + return + + sentry_sdk.init( + dsn='https://5ff1556b71594bfea135ff0203a0d290@o4504521589325824.ingest.sentry.io/4504521592406016', + debug=False, + traces_sample_rate=1.0, + release=__version__, + environment='production', # 'dev' or 'production' + before_send=before_send, + ignore_errors=[KeyboardInterrupt, FileNotFoundError]) + sentry_sdk.set_user({'id': SETTINGS['uuid']}) # SHA-256 anonymized UUID hash + + # Disable all sentry logging + for logger in 'sentry_sdk', 'sentry_sdk.errors': + logging.getLogger(logger).setLevel(logging.CRITICAL) + + +def get_settings(file=SETTINGS_YAML, version='0.0.3'): + """ + Loads a global Ultralytics settings YAML file or creates one with default values if it does not exist. + + Args: + file (Path): Path to the Ultralytics settings YAML file. Defaults to 'settings.yaml' in the USER_CONFIG_DIR. + version (str): Settings version. If min settings version not met, new default settings will be saved. + + Returns: + (dict): Dictionary of settings key-value pairs. + """ + import hashlib + + from ultralytics.utils.checks import check_version + from ultralytics.utils.torch_utils import torch_distributed_zero_first + + git_dir = get_git_dir() + root = git_dir or Path() + datasets_root = (root.parent if git_dir and is_dir_writeable(root.parent) else root).resolve() + defaults = { + 'datasets_dir': str(datasets_root / 'datasets'), # default datasets directory. + 'weights_dir': str(root / 'weights'), # default weights directory. + 'runs_dir': str(root / 'runs'), # default runs directory. + 'uuid': hashlib.sha256(str(uuid.getnode()).encode()).hexdigest(), # SHA-256 anonymized UUID hash + 'sync': True, # sync analytics to help with YOLO development + 'api_key': '', # Ultralytics HUB API key (https://hub.ultralytics.com/) + 'settings_version': version} # Ultralytics settings version + + with torch_distributed_zero_first(RANK): + if not file.exists(): + yaml_save(file, defaults) + settings = yaml_load(file) + + # Check that settings keys and types match defaults + correct = \ + settings \ + and settings.keys() == defaults.keys() \ + and all(type(a) == type(b) for a, b in zip(settings.values(), defaults.values())) \ + and check_version(settings['settings_version'], version) + if not correct: + LOGGER.warning('WARNING ⚠️ Ultralytics settings reset to defaults. This is normal and may be due to a ' + 'recent ultralytics package update, but may have overwritten previous settings. ' + f"\nView and update settings with 'yolo settings' or at '{file}'") + settings = defaults # merge **defaults with **settings (prefer **settings) + yaml_save(file, settings) # save updated defaults + + return settings + + +def set_settings(kwargs, file=SETTINGS_YAML): + """ + Function that runs on a first-time ultralytics package installation to set up global settings and create necessary + directories. + """ + SETTINGS.update(kwargs) + yaml_save(file, SETTINGS) + + +def deprecation_warn(arg, new_arg, version=None): + """Issue a deprecation warning when a deprecated argument is used, suggesting an updated argument.""" + if not version: + version = float(__version__[:3]) + 0.2 # deprecate after 2nd major release + LOGGER.warning(f"WARNING ⚠️ '{arg}' is deprecated and will be removed in 'ultralytics {version}' in the future. " + f"Please use '{new_arg}' instead.") + + +def clean_url(url): + """Strip auth from URL, i.e. https://url.com/file.txt?auth -> https://url.com/file.txt.""" + url = str(Path(url)).replace(':/', '://') # Pathlib turns :// -> :/ + return urllib.parse.unquote(url).split('?')[0] # '%2F' to '/', split https://url.com/file.txt?auth + + +def url2file(url): + """Convert URL to filename, i.e. https://url.com/file.txt?auth -> file.txt.""" + return Path(clean_url(url)).name + + +# Run below code on utils init ------------------------------------------------------------------------------------ + +# Check first-install steps +PREFIX = colorstr('Ultralytics: ') +SETTINGS = get_settings() +DATASETS_DIR = Path(SETTINGS['datasets_dir']) # global datasets directory +ENVIRONMENT = 'Colab' if is_colab() else 'Kaggle' if is_kaggle() else 'Jupyter' if is_jupyter() else \ + 'Docker' if is_docker() else platform.system() +TESTS_RUNNING = is_pytest_running() or is_github_actions_ci() +set_sentry() + +# Apply monkey patches if the script is being run from within the parent directory of the script's location +from .patches import imread, imshow, imwrite + +# torch.save = torch_save +if Path(inspect.stack()[0].filename).parent.parent.as_posix() in inspect.stack()[-1].filename: + cv2.imread, cv2.imwrite, cv2.imshow = imread, imwrite, imshow diff --git a/ultralytics/yolo/utils/autobatch.py b/ultralytics/utils/autobatch.py similarity index 96% rename from ultralytics/yolo/utils/autobatch.py rename to ultralytics/utils/autobatch.py index 0645f81..252f3db 100644 --- a/ultralytics/yolo/utils/autobatch.py +++ b/ultralytics/utils/autobatch.py @@ -8,8 +8,8 @@ from copy import deepcopy import numpy as np import torch -from ultralytics.yolo.utils import DEFAULT_CFG, LOGGER, colorstr -from ultralytics.yolo.utils.torch_utils import profile +from ultralytics.utils import DEFAULT_CFG, LOGGER, colorstr +from ultralytics.utils.torch_utils import profile def check_train_batch_size(model, imgsz=640, amp=True): diff --git a/ultralytics/yolo/utils/benchmarks.py b/ultralytics/utils/benchmarks.py similarity index 96% rename from ultralytics/yolo/utils/benchmarks.py rename to ultralytics/utils/benchmarks.py index e84a1a6..c35fde4 100644 --- a/ultralytics/yolo/utils/benchmarks.py +++ b/ultralytics/utils/benchmarks.py @@ -3,7 +3,7 @@ Benchmark a YOLO model formats for speed and accuracy Usage: - from ultralytics.yolo.utils.benchmarks import ProfileModels, benchmark + from ultralytics.utils.benchmarks import ProfileModels, benchmark ProfileModels(['yolov8n.yaml', 'yolov8s.yaml']).profile() run_benchmarks(model='yolov8n.pt', imgsz=160) @@ -34,13 +34,13 @@ import torch.cuda from tqdm import tqdm from ultralytics import YOLO -from ultralytics.yolo.cfg import TASK2DATA, TASK2METRIC -from ultralytics.yolo.engine.exporter import export_formats -from ultralytics.yolo.utils import LINUX, LOGGER, MACOS, ROOT, SETTINGS -from ultralytics.yolo.utils.checks import check_requirements, check_yolo -from ultralytics.yolo.utils.downloads import download -from ultralytics.yolo.utils.files import file_size -from ultralytics.yolo.utils.torch_utils import select_device +from ultralytics.cfg import TASK2DATA, TASK2METRIC +from ultralytics.engine.exporter import export_formats +from ultralytics.utils import LINUX, LOGGER, MACOS, ROOT, SETTINGS +from ultralytics.utils.checks import check_requirements, check_yolo +from ultralytics.utils.downloads import download +from ultralytics.utils.files import file_size +from ultralytics.utils.torch_utils import select_device def benchmark(model=Path(SETTINGS['weights_dir']) / 'yolov8n.pt', diff --git a/ultralytics/yolo/utils/callbacks/__init__.py b/ultralytics/utils/callbacks/__init__.py similarity index 100% rename from ultralytics/yolo/utils/callbacks/__init__.py rename to ultralytics/utils/callbacks/__init__.py diff --git a/ultralytics/yolo/utils/callbacks/base.py b/ultralytics/utils/callbacks/base.py similarity index 100% rename from ultralytics/yolo/utils/callbacks/base.py rename to ultralytics/utils/callbacks/base.py diff --git a/ultralytics/yolo/utils/callbacks/clearml.py b/ultralytics/utils/callbacks/clearml.py similarity index 97% rename from ultralytics/yolo/utils/callbacks/clearml.py rename to ultralytics/utils/callbacks/clearml.py index 2cfdd73..a5a01d5 100644 --- a/ultralytics/yolo/utils/callbacks/clearml.py +++ b/ultralytics/utils/callbacks/clearml.py @@ -5,8 +5,8 @@ import re import matplotlib.image as mpimg import matplotlib.pyplot as plt -from ultralytics.yolo.utils import LOGGER, TESTS_RUNNING -from ultralytics.yolo.utils.torch_utils import model_info_for_loggers +from ultralytics.utils import LOGGER, TESTS_RUNNING +from ultralytics.utils.torch_utils import model_info_for_loggers try: import clearml diff --git a/ultralytics/yolo/utils/callbacks/comet.py b/ultralytics/utils/callbacks/comet.py similarity index 98% rename from ultralytics/yolo/utils/callbacks/comet.py rename to ultralytics/utils/callbacks/comet.py index 94aeb8f..0366442 100644 --- a/ultralytics/yolo/utils/callbacks/comet.py +++ b/ultralytics/utils/callbacks/comet.py @@ -3,8 +3,8 @@ import os from pathlib import Path -from ultralytics.yolo.utils import LOGGER, RANK, TESTS_RUNNING, ops -from ultralytics.yolo.utils.torch_utils import model_info_for_loggers +from ultralytics.utils import LOGGER, RANK, TESTS_RUNNING, ops +from ultralytics.utils.torch_utils import model_info_for_loggers try: import comet_ml diff --git a/ultralytics/yolo/utils/callbacks/dvc.py b/ultralytics/utils/callbacks/dvc.py similarity index 97% rename from ultralytics/yolo/utils/callbacks/dvc.py rename to ultralytics/utils/callbacks/dvc.py index 138100c..ce3076e 100644 --- a/ultralytics/yolo/utils/callbacks/dvc.py +++ b/ultralytics/utils/callbacks/dvc.py @@ -3,8 +3,8 @@ import os import pkg_resources as pkg -from ultralytics.yolo.utils import LOGGER, TESTS_RUNNING -from ultralytics.yolo.utils.torch_utils import model_info_for_loggers +from ultralytics.utils import LOGGER, TESTS_RUNNING +from ultralytics.utils.torch_utils import model_info_for_loggers try: from importlib.metadata import version diff --git a/ultralytics/yolo/utils/callbacks/hub.py b/ultralytics/utils/callbacks/hub.py similarity index 96% rename from ultralytics/yolo/utils/callbacks/hub.py rename to ultralytics/utils/callbacks/hub.py index e3b3427..edb8078 100644 --- a/ultralytics/yolo/utils/callbacks/hub.py +++ b/ultralytics/utils/callbacks/hub.py @@ -4,8 +4,8 @@ import json from time import time from ultralytics.hub.utils import PREFIX, events -from ultralytics.yolo.utils import LOGGER -from ultralytics.yolo.utils.torch_utils import model_info_for_loggers +from ultralytics.utils import LOGGER +from ultralytics.utils.torch_utils import model_info_for_loggers def on_pretrain_routine_end(trainer): diff --git a/ultralytics/yolo/utils/callbacks/mlflow.py b/ultralytics/utils/callbacks/mlflow.py similarity index 97% rename from ultralytics/yolo/utils/callbacks/mlflow.py rename to ultralytics/utils/callbacks/mlflow.py index 6c4b798..76bc0c1 100644 --- a/ultralytics/yolo/utils/callbacks/mlflow.py +++ b/ultralytics/utils/callbacks/mlflow.py @@ -4,7 +4,7 @@ import os import re from pathlib import Path -from ultralytics.yolo.utils import LOGGER, TESTS_RUNNING, colorstr +from ultralytics.utils import LOGGER, TESTS_RUNNING, colorstr try: import mlflow diff --git a/ultralytics/yolo/utils/callbacks/neptune.py b/ultralytics/utils/callbacks/neptune.py similarity index 96% rename from ultralytics/yolo/utils/callbacks/neptune.py rename to ultralytics/utils/callbacks/neptune.py index be64341..da5ccf4 100644 --- a/ultralytics/yolo/utils/callbacks/neptune.py +++ b/ultralytics/utils/callbacks/neptune.py @@ -3,8 +3,8 @@ import matplotlib.image as mpimg import matplotlib.pyplot as plt -from ultralytics.yolo.utils import LOGGER, TESTS_RUNNING -from ultralytics.yolo.utils.torch_utils import model_info_for_loggers +from ultralytics.utils import LOGGER, TESTS_RUNNING +from ultralytics.utils.torch_utils import model_info_for_loggers try: import neptune diff --git a/ultralytics/yolo/utils/callbacks/raytune.py b/ultralytics/utils/callbacks/raytune.py similarity index 100% rename from ultralytics/yolo/utils/callbacks/raytune.py rename to ultralytics/utils/callbacks/raytune.py diff --git a/ultralytics/yolo/utils/callbacks/tensorboard.py b/ultralytics/utils/callbacks/tensorboard.py similarity index 95% rename from ultralytics/yolo/utils/callbacks/tensorboard.py rename to ultralytics/utils/callbacks/tensorboard.py index a436b9c..7ddf1bb 100644 --- a/ultralytics/yolo/utils/callbacks/tensorboard.py +++ b/ultralytics/utils/callbacks/tensorboard.py @@ -1,6 +1,6 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license -from ultralytics.yolo.utils import LOGGER, TESTS_RUNNING, colorstr +from ultralytics.utils import LOGGER, TESTS_RUNNING, colorstr try: from torch.utils.tensorboard import SummaryWriter diff --git a/ultralytics/yolo/utils/callbacks/wb.py b/ultralytics/utils/callbacks/wb.py similarity index 94% rename from ultralytics/yolo/utils/callbacks/wb.py rename to ultralytics/utils/callbacks/wb.py index 4b4c29b..605a228 100644 --- a/ultralytics/yolo/utils/callbacks/wb.py +++ b/ultralytics/utils/callbacks/wb.py @@ -1,6 +1,6 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license -from ultralytics.yolo.utils import TESTS_RUNNING -from ultralytics.yolo.utils.torch_utils import model_info_for_loggers +from ultralytics.utils import TESTS_RUNNING +from ultralytics.utils.torch_utils import model_info_for_loggers try: import wandb as wb diff --git a/ultralytics/yolo/utils/checks.py b/ultralytics/utils/checks.py similarity index 97% rename from ultralytics/yolo/utils/checks.py rename to ultralytics/utils/checks.py index 80e2cc3..6d8bd8e 100644 --- a/ultralytics/yolo/utils/checks.py +++ b/ultralytics/utils/checks.py @@ -20,9 +20,9 @@ import requests import torch from matplotlib import font_manager -from ultralytics.yolo.utils import (AUTOINSTALL, LOGGER, ONLINE, ROOT, USER_CONFIG_DIR, ThreadingLocked, TryExcept, - clean_url, colorstr, downloads, emojis, is_colab, is_docker, is_jupyter, is_kaggle, - is_online, is_pip_package, url2file) +from ultralytics.utils import (AUTOINSTALL, LOGGER, ONLINE, ROOT, USER_CONFIG_DIR, ThreadingLocked, TryExcept, + clean_url, colorstr, downloads, emojis, is_colab, is_docker, is_jupyter, is_kaggle, + is_online, is_pip_package, url2file) def is_ascii(s) -> bool: @@ -325,9 +325,7 @@ def check_file(file, suffix='', download=True, hard=True): downloads.safe_download(url=url, file=file, unzip=False) return file else: # search - files = [] - for d in 'models', 'datasets', 'tracker/cfg', 'yolo/cfg': # search directories - files.extend(glob.glob(str(ROOT / d / '**' / file), recursive=True)) # find file + files = glob.glob(str(ROOT / 'cfg' / '**' / file), recursive=True) # find file if not files and hard: raise FileNotFoundError(f"'{file}' does not exist") elif len(files) > 1 and hard: @@ -357,7 +355,7 @@ def check_imshow(warn=False): def check_yolo(verbose=True, device=''): """Return a human-readable YOLO software and hardware summary.""" - from ultralytics.yolo.utils.torch_utils import select_device + from ultralytics.utils.torch_utils import select_device if is_jupyter(): if check_requirements('wandb', install=False): diff --git a/ultralytics/yolo/utils/dist.py b/ultralytics/utils/dist.py similarity index 97% rename from ultralytics/yolo/utils/dist.py rename to ultralytics/utils/dist.py index 6de029f..1190098 100644 --- a/ultralytics/yolo/utils/dist.py +++ b/ultralytics/utils/dist.py @@ -29,7 +29,7 @@ def generate_ddp_file(trainer): content = f'''overrides = {vars(trainer.args)} \nif __name__ == "__main__": from {module} import {name} - from ultralytics.yolo.utils import DEFAULT_CFG_DICT + from ultralytics.utils import DEFAULT_CFG_DICT cfg = DEFAULT_CFG_DICT.copy() cfg.update(save_dir='') # handle the extra key 'save_dir' diff --git a/ultralytics/yolo/utils/downloads.py b/ultralytics/utils/downloads.py similarity index 98% rename from ultralytics/yolo/utils/downloads.py rename to ultralytics/utils/downloads.py index c131921..0958f35 100644 --- a/ultralytics/yolo/utils/downloads.py +++ b/ultralytics/utils/downloads.py @@ -13,7 +13,7 @@ import requests import torch from tqdm import tqdm -from ultralytics.yolo.utils import LOGGER, checks, clean_url, emojis, is_online, url2file +from ultralytics.utils import LOGGER, checks, clean_url, emojis, is_online, url2file GITHUB_ASSET_NAMES = [f'yolov8{k}{suffix}.pt' for k in 'nsmlx' for suffix in ('', '6', '-cls', '-seg', '-pose')] + \ [f'yolov5{k}u.pt' for k in 'nsmlx'] + \ @@ -164,7 +164,7 @@ def safe_download(url, if method == 'torch': torch.hub.download_url_to_file(url, f, progress=progress) else: - from ultralytics.yolo.utils import TQDM_BAR_FORMAT + from ultralytics.utils import TQDM_BAR_FORMAT with request.urlopen(url) as response, tqdm(total=int(response.getheader('Content-Length', 0)), desc=desc, disable=not progress, @@ -212,7 +212,7 @@ def get_github_assets(repo='ultralytics/assets', version='latest'): def attempt_download_asset(file, repo='ultralytics/assets', release='v0.0.0'): """Attempt file download from GitHub release assets if not found locally. release = 'latest', 'v6.2', etc.""" - from ultralytics.yolo.utils import SETTINGS # scoped for circular import + from ultralytics.utils import SETTINGS # scoped for circular import # YOLOv3/5u updates file = str(file) diff --git a/ultralytics/yolo/utils/errors.py b/ultralytics/utils/errors.py similarity index 86% rename from ultralytics/yolo/utils/errors.py rename to ultralytics/utils/errors.py index 7163d4d..5a76431 100644 --- a/ultralytics/yolo/utils/errors.py +++ b/ultralytics/utils/errors.py @@ -1,6 +1,6 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license -from ultralytics.yolo.utils import emojis +from ultralytics.utils import emojis class HUBModelError(Exception): diff --git a/ultralytics/yolo/utils/files.py b/ultralytics/utils/files.py similarity index 100% rename from ultralytics/yolo/utils/files.py rename to ultralytics/utils/files.py diff --git a/ultralytics/yolo/utils/instance.py b/ultralytics/utils/instance.py similarity index 100% rename from ultralytics/yolo/utils/instance.py rename to ultralytics/utils/instance.py diff --git a/ultralytics/yolo/utils/loss.py b/ultralytics/utils/loss.py similarity index 98% rename from ultralytics/yolo/utils/loss.py rename to ultralytics/utils/loss.py index 71ed0a5..1da0586 100644 --- a/ultralytics/yolo/utils/loss.py +++ b/ultralytics/utils/loss.py @@ -4,9 +4,9 @@ import torch import torch.nn as nn import torch.nn.functional as F -from ultralytics.yolo.utils.metrics import OKS_SIGMA -from ultralytics.yolo.utils.ops import crop_mask, xywh2xyxy, xyxy2xywh -from ultralytics.yolo.utils.tal import TaskAlignedAssigner, dist2bbox, make_anchors +from ultralytics.utils.metrics import OKS_SIGMA +from ultralytics.utils.ops import crop_mask, xywh2xyxy, xyxy2xywh +from ultralytics.utils.tal import TaskAlignedAssigner, dist2bbox, make_anchors from .metrics import bbox_iou from .tal import bbox2dist diff --git a/ultralytics/yolo/utils/metrics.py b/ultralytics/utils/metrics.py similarity index 99% rename from ultralytics/yolo/utils/metrics.py rename to ultralytics/utils/metrics.py index cd90321..cdf9331 100644 --- a/ultralytics/yolo/utils/metrics.py +++ b/ultralytics/utils/metrics.py @@ -10,7 +10,7 @@ import matplotlib.pyplot as plt import numpy as np import torch -from ultralytics.yolo.utils import LOGGER, SimpleClass, TryExcept, plt_settings +from ultralytics.utils import LOGGER, SimpleClass, TryExcept, plt_settings OKS_SIGMA = np.array([.26, .25, .25, .35, .35, .79, .79, .72, .72, .62, .62, 1.07, 1.07, .87, .87, .89, .89]) / 10.0 diff --git a/ultralytics/yolo/utils/ops.py b/ultralytics/utils/ops.py similarity index 99% rename from ultralytics/yolo/utils/ops.py rename to ultralytics/utils/ops.py index bb9ca49..38f4eb0 100644 --- a/ultralytics/yolo/utils/ops.py +++ b/ultralytics/utils/ops.py @@ -11,7 +11,7 @@ import torch import torch.nn.functional as F import torchvision -from ultralytics.yolo.utils import LOGGER +from ultralytics.utils import LOGGER from .metrics import box_iou diff --git a/ultralytics/yolo/utils/patches.py b/ultralytics/utils/patches.py similarity index 100% rename from ultralytics/yolo/utils/patches.py rename to ultralytics/utils/patches.py diff --git a/ultralytics/yolo/utils/plotting.py b/ultralytics/utils/plotting.py similarity index 99% rename from ultralytics/yolo/utils/plotting.py rename to ultralytics/utils/plotting.py index 0236a79..9681636 100644 --- a/ultralytics/yolo/utils/plotting.py +++ b/ultralytics/utils/plotting.py @@ -13,7 +13,7 @@ from PIL import Image, ImageDraw, ImageFont from PIL import __version__ as pil_version from scipy.ndimage import gaussian_filter1d -from ultralytics.yolo.utils import LOGGER, TryExcept, plt_settings, threaded +from ultralytics.utils import LOGGER, TryExcept, plt_settings, threaded from .checks import check_font, check_version, is_ascii from .files import increment_path diff --git a/ultralytics/yolo/utils/tal.py b/ultralytics/utils/tal.py similarity index 100% rename from ultralytics/yolo/utils/tal.py rename to ultralytics/utils/tal.py diff --git a/ultralytics/yolo/utils/torch_utils.py b/ultralytics/utils/torch_utils.py similarity index 97% rename from ultralytics/yolo/utils/torch_utils.py rename to ultralytics/utils/torch_utils.py index 0ab1f4e..77235ae 100644 --- a/ultralytics/yolo/utils/torch_utils.py +++ b/ultralytics/utils/torch_utils.py @@ -17,8 +17,8 @@ import torch.nn as nn import torch.nn.functional as F import torchvision -from ultralytics.yolo.utils import DEFAULT_CFG_DICT, DEFAULT_CFG_KEYS, LOGGER, RANK, __version__ -from ultralytics.yolo.utils.checks import check_requirements, check_version +from ultralytics.utils import DEFAULT_CFG_DICT, DEFAULT_CFG_KEYS, LOGGER, RANK, __version__ +from ultralytics.utils.checks import check_requirements, check_version try: import thop @@ -213,7 +213,7 @@ def model_info_for_loggers(trainer): 'model/speed_PyTorch(ms)': 18.755} """ if trainer.args.profile: # profile ONNX and TensorRT times - from ultralytics.yolo.utils.benchmarks import ProfileModels + from ultralytics.utils.benchmarks import ProfileModels results = ProfileModels([trainer.last], device=trainer.device).profile()[0] results.pop('model/name') else: # only return PyTorch times from most recent validation @@ -387,7 +387,7 @@ def strip_optimizer(f: Union[str, Path] = 'best.pt', s: str = '') -> None: Usage: from pathlib import Path - from ultralytics.yolo.utils.torch_utils import strip_optimizer + from ultralytics.utils.torch_utils import strip_optimizer for f in Path('/Users/glennjocher/Downloads/weights').rglob('*.pt'): strip_optimizer(f) """ @@ -398,6 +398,12 @@ def strip_optimizer(f: Union[str, Path] = 'best.pt', s: str = '') -> None: import pickle x = torch.load(f, map_location=torch.device('cpu')) + if 'model' not in x: + LOGGER.info(f'Skipping {f}, not a valid Ultralytics model.') + return + + if hasattr(x['model'], 'args'): + x['model'].args = dict(x['model'].args) # convert from IterableSimpleNamespace to dict args = {**DEFAULT_CFG_DICT, **x['train_args']} if 'train_args' in x else None # combine args if x.get('ema'): x['model'] = x['ema'] # replace model with ema diff --git a/ultralytics/yolo/utils/tuner.py b/ultralytics/utils/tuner.py similarity index 97% rename from ultralytics/yolo/utils/tuner.py rename to ultralytics/utils/tuner.py index 54f10b0..c40983c 100644 --- a/ultralytics/yolo/utils/tuner.py +++ b/ultralytics/utils/tuner.py @@ -1,6 +1,6 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license -from ultralytics.yolo.cfg import TASK2DATA, TASK2METRIC -from ultralytics.yolo.utils import DEFAULT_CFG_DICT, LOGGER, NUM_THREADS +from ultralytics.cfg import TASK2DATA, TASK2METRIC +from ultralytics.utils import DEFAULT_CFG_DICT, LOGGER, NUM_THREADS def run_ray_tune(model, diff --git a/ultralytics/yolo/cfg/__init__.py b/ultralytics/yolo/cfg/__init__.py index 41d86aa..5ea5519 100644 --- a/ultralytics/yolo/cfg/__init__.py +++ b/ultralytics/yolo/cfg/__init__.py @@ -1,421 +1,10 @@ -# Ultralytics YOLO 🚀, AGPL-3.0 license - -import contextlib -import re -import shutil +import importlib import sys -from difflib import get_close_matches -from pathlib import Path -from types import SimpleNamespace -from typing import Dict, List, Union - -from ultralytics.yolo.utils import (DEFAULT_CFG, DEFAULT_CFG_DICT, DEFAULT_CFG_PATH, LOGGER, ROOT, USER_CONFIG_DIR, - IterableSimpleNamespace, __version__, checks, colorstr, deprecation_warn, - get_settings, yaml_load, yaml_print) - -# Define valid tasks and modes -MODES = 'train', 'val', 'predict', 'export', 'track', 'benchmark' -TASKS = 'detect', 'segment', 'classify', 'pose' -TASK2DATA = {'detect': 'coco8.yaml', 'segment': 'coco8-seg.yaml', 'classify': 'imagenet100', 'pose': 'coco8-pose.yaml'} -TASK2MODEL = { - 'detect': 'yolov8n.pt', - 'segment': 'yolov8n-seg.pt', - 'classify': 'yolov8n-cls.pt', - 'pose': 'yolov8n-pose.pt'} -TASK2METRIC = { - 'detect': 'metrics/mAP50-95(B)', - 'segment': 'metrics/mAP50-95(M)', - 'classify': 'metrics/accuracy_top1', - 'pose': 'metrics/mAP50-95(P)'} - - -CLI_HELP_MSG = \ - f""" - Arguments received: {str(['yolo'] + sys.argv[1:])}. Ultralytics 'yolo' commands use the following syntax: - - yolo TASK MODE ARGS - - Where TASK (optional) is one of {TASKS} - MODE (required) is one of {MODES} - ARGS (optional) are any number of custom 'arg=value' pairs like 'imgsz=320' that override defaults. - See all ARGS at https://docs.ultralytics.com/usage/cfg or with 'yolo cfg' - - 1. Train a detection model for 10 epochs with an initial learning_rate of 0.01 - yolo train data=coco128.yaml model=yolov8n.pt epochs=10 lr0=0.01 - - 2. Predict a YouTube video using a pretrained segmentation model at image size 320: - yolo predict model=yolov8n-seg.pt source='https://youtu.be/Zgi9g1ksQHc' imgsz=320 - - 3. Val a pretrained detection model at batch-size 1 and image size 640: - yolo val model=yolov8n.pt data=coco128.yaml batch=1 imgsz=640 - - 4. Export a YOLOv8n classification model to ONNX format at image size 224 by 128 (no TASK required) - yolo export model=yolov8n-cls.pt format=onnx imgsz=224,128 - - 5. Run special commands: - yolo help - yolo checks - yolo version - yolo settings - yolo copy-cfg - yolo cfg - - Docs: https://docs.ultralytics.com - Community: https://community.ultralytics.com - GitHub: https://github.com/ultralytics/ultralytics - """ - -# Define keys for arg type checks -CFG_FLOAT_KEYS = 'warmup_epochs', 'box', 'cls', 'dfl', 'degrees', 'shear' -CFG_FRACTION_KEYS = ('dropout', 'iou', 'lr0', 'lrf', 'momentum', 'weight_decay', 'warmup_momentum', 'warmup_bias_lr', - 'label_smoothing', 'hsv_h', 'hsv_s', 'hsv_v', 'translate', 'scale', 'perspective', 'flipud', - 'fliplr', 'mosaic', 'mixup', 'copy_paste', 'conf', 'iou', 'fraction') # fraction floats 0.0 - 1.0 -CFG_INT_KEYS = ('epochs', 'patience', 'batch', 'workers', 'seed', 'close_mosaic', 'mask_ratio', 'max_det', 'vid_stride', - 'line_width', 'workspace', 'nbs', 'save_period') -CFG_BOOL_KEYS = ('save', 'exist_ok', 'verbose', 'deterministic', 'single_cls', 'rect', 'cos_lr', 'overlap_mask', 'val', - 'save_json', 'save_hybrid', 'half', 'dnn', 'plots', 'show', 'save_txt', 'save_conf', 'save_crop', - 'show_labels', 'show_conf', 'visualize', 'augment', 'agnostic_nms', 'retina_masks', 'boxes', 'keras', - 'optimize', 'int8', 'dynamic', 'simplify', 'nms', 'profile') - - -def cfg2dict(cfg): - """ - Convert a configuration object to a dictionary, whether it is a file path, a string, or a SimpleNamespace object. - - Args: - cfg (str | Path | SimpleNamespace): Configuration object to be converted to a dictionary. - - Returns: - cfg (dict): Configuration object in dictionary format. - """ - if isinstance(cfg, (str, Path)): - cfg = yaml_load(cfg) # load dict - elif isinstance(cfg, SimpleNamespace): - cfg = vars(cfg) # convert to dict - return cfg - - -def get_cfg(cfg: Union[str, Path, Dict, SimpleNamespace] = DEFAULT_CFG_DICT, overrides: Dict = None): - """ - Load and merge configuration data from a file or dictionary. - - Args: - cfg (str | Path | Dict | SimpleNamespace): Configuration data. - overrides (str | Dict | optional): Overrides in the form of a file name or a dictionary. Default is None. - - Returns: - (SimpleNamespace): Training arguments namespace. - """ - cfg = cfg2dict(cfg) - - # Merge overrides - if overrides: - overrides = cfg2dict(overrides) - check_cfg_mismatch(cfg, overrides) - cfg = {**cfg, **overrides} # merge cfg and overrides dicts (prefer overrides) - - # Special handling for numeric project/name - for k in 'project', 'name': - if k in cfg and isinstance(cfg[k], (int, float)): - cfg[k] = str(cfg[k]) - if cfg.get('name') == 'model': # assign model to 'name' arg - cfg['name'] = cfg.get('model', '').split('.')[0] - LOGGER.warning(f"WARNING ⚠️ 'name=model' automatically updated to 'name={cfg['name']}'.") - - # Type and Value checks - for k, v in cfg.items(): - if v is not None: # None values may be from optional args - if k in CFG_FLOAT_KEYS and not isinstance(v, (int, float)): - raise TypeError(f"'{k}={v}' is of invalid type {type(v).__name__}. " - f"Valid '{k}' types are int (i.e. '{k}=0') or float (i.e. '{k}=0.5')") - elif k in CFG_FRACTION_KEYS: - if not isinstance(v, (int, float)): - raise TypeError(f"'{k}={v}' is of invalid type {type(v).__name__}. " - f"Valid '{k}' types are int (i.e. '{k}=0') or float (i.e. '{k}=0.5')") - if not (0.0 <= v <= 1.0): - raise ValueError(f"'{k}={v}' is an invalid value. " - f"Valid '{k}' values are between 0.0 and 1.0.") - elif k in CFG_INT_KEYS and not isinstance(v, int): - raise TypeError(f"'{k}={v}' is of invalid type {type(v).__name__}. " - f"'{k}' must be an int (i.e. '{k}=8')") - elif k in CFG_BOOL_KEYS and not isinstance(v, bool): - raise TypeError(f"'{k}={v}' is of invalid type {type(v).__name__}. " - f"'{k}' must be a bool (i.e. '{k}=True' or '{k}=False')") - - # Return instance - return IterableSimpleNamespace(**cfg) - - -def _handle_deprecation(custom): - """ - Hardcoded function to handle deprecated config keys - """ - - for key in custom.copy().keys(): - if key == 'hide_labels': - deprecation_warn(key, 'show_labels') - custom['show_labels'] = custom.pop('hide_labels') == 'False' - if key == 'hide_conf': - deprecation_warn(key, 'show_conf') - custom['show_conf'] = custom.pop('hide_conf') == 'False' - if key == 'line_thickness': - deprecation_warn(key, 'line_width') - custom['line_width'] = custom.pop('line_thickness') - - return custom - - -def check_cfg_mismatch(base: Dict, custom: Dict, e=None): - """ - This function checks for any mismatched keys between a custom configuration list and a base configuration list. - If any mismatched keys are found, the function prints out similar keys from the base list and exits the program. - - Args: - custom (dict): a dictionary of custom configuration options - base (dict): a dictionary of base configuration options - """ - custom = _handle_deprecation(custom) - base, custom = (set(x.keys()) for x in (base, custom)) - mismatched = [x for x in custom if x not in base] - if mismatched: - string = '' - for x in mismatched: - matches = get_close_matches(x, base) # key list - matches = [f'{k}={DEFAULT_CFG_DICT[k]}' if DEFAULT_CFG_DICT.get(k) is not None else k for k in matches] - match_str = f'Similar arguments are i.e. {matches}.' if matches else '' - string += f"'{colorstr('red', 'bold', x)}' is not a valid YOLO argument. {match_str}\n" - raise SyntaxError(string + CLI_HELP_MSG) from e - - -def merge_equals_args(args: List[str]) -> List[str]: - """ - Merges arguments around isolated '=' args in a list of strings. - The function considers cases where the first argument ends with '=' or the second starts with '=', - as well as when the middle one is an equals sign. - - Args: - args (List[str]): A list of strings where each element is an argument. - - Returns: - List[str]: A list of strings where the arguments around isolated '=' are merged. - """ - new_args = [] - for i, arg in enumerate(args): - if arg == '=' and 0 < i < len(args) - 1: # merge ['arg', '=', 'val'] - new_args[-1] += f'={args[i + 1]}' - del args[i + 1] - elif arg.endswith('=') and i < len(args) - 1 and '=' not in args[i + 1]: # merge ['arg=', 'val'] - new_args.append(f'{arg}{args[i + 1]}') - del args[i + 1] - elif arg.startswith('=') and i > 0: # merge ['arg', '=val'] - new_args[-1] += arg - else: - new_args.append(arg) - return new_args - - -def handle_yolo_hub(args: List[str]) -> None: - """ - Handle Ultralytics HUB command-line interface (CLI) commands. - - This function processes Ultralytics HUB CLI commands such as login and logout. - It should be called when executing a script with arguments related to HUB authentication. - - Args: - args (List[str]): A list of command line arguments - - Example: - python my_script.py hub login your_api_key - """ - from ultralytics import hub - - if args[0] == 'login': - key = args[1] if len(args) > 1 else '' - # Log in to Ultralytics HUB using the provided API key - hub.login(key) - elif args[0] == 'logout': - # Log out from Ultralytics HUB - hub.logout() - - -def handle_yolo_settings(args: List[str]) -> None: - """ - Handle YOLO settings command-line interface (CLI) commands. - - This function processes YOLO settings CLI commands such as reset. - It should be called when executing a script with arguments related to YOLO settings management. - - Args: - args (List[str]): A list of command line arguments for YOLO settings management. - - Example: - python my_script.py yolo settings reset - """ - path = USER_CONFIG_DIR / 'settings.yaml' # get SETTINGS YAML file path - if any(args) and args[0] == 'reset': - path.unlink() # delete the settings file - get_settings() # create new settings - LOGGER.info('Settings reset successfully') # inform the user that settings have been reset - yaml_print(path) # print the current settings - - -def entrypoint(debug=''): - """ - This function is the ultralytics package entrypoint, it's responsible for parsing the command line arguments passed - to the package. - - This function allows for: - - passing mandatory YOLO args as a list of strings - - specifying the task to be performed, either 'detect', 'segment' or 'classify' - - specifying the mode, either 'train', 'val', 'test', or 'predict' - - running special modes like 'checks' - - passing overrides to the package's configuration - - It uses the package's default cfg and initializes it using the passed overrides. - Then it calls the CLI function with the composed cfg - """ - args = (debug.split(' ') if debug else sys.argv)[1:] - if not args: # no arguments passed - LOGGER.info(CLI_HELP_MSG) - return - - special = { - 'help': lambda: LOGGER.info(CLI_HELP_MSG), - 'checks': checks.check_yolo, - 'version': lambda: LOGGER.info(__version__), - 'settings': lambda: handle_yolo_settings(args[1:]), - 'cfg': lambda: yaml_print(DEFAULT_CFG_PATH), - 'hub': lambda: handle_yolo_hub(args[1:]), - 'login': lambda: handle_yolo_hub(args), - 'copy-cfg': copy_default_cfg} - full_args_dict = {**DEFAULT_CFG_DICT, **{k: None for k in TASKS}, **{k: None for k in MODES}, **special} - - # Define common mis-uses of special commands, i.e. -h, -help, --help - special.update({k[0]: v for k, v in special.items()}) # singular - special.update({k[:-1]: v for k, v in special.items() if len(k) > 1 and k.endswith('s')}) # singular - special = {**special, **{f'-{k}': v for k, v in special.items()}, **{f'--{k}': v for k, v in special.items()}} - - overrides = {} # basic overrides, i.e. imgsz=320 - for a in merge_equals_args(args): # merge spaces around '=' sign - if a.startswith('--'): - LOGGER.warning(f"WARNING ⚠️ '{a}' does not require leading dashes '--', updating to '{a[2:]}'.") - a = a[2:] - if a.endswith(','): - LOGGER.warning(f"WARNING ⚠️ '{a}' does not require trailing comma ',', updating to '{a[:-1]}'.") - a = a[:-1] - if '=' in a: - try: - re.sub(r' *= *', '=', a) # remove spaces around equals sign - k, v = a.split('=', 1) # split on first '=' sign - assert v, f"missing '{k}' value" - if k == 'cfg': # custom.yaml passed - LOGGER.info(f'Overriding {DEFAULT_CFG_PATH} with {v}') - overrides = {k: val for k, val in yaml_load(checks.check_yaml(v)).items() if k != 'cfg'} - else: - if v.lower() == 'none': - v = None - elif v.lower() == 'true': - v = True - elif v.lower() == 'false': - v = False - else: - with contextlib.suppress(Exception): - v = eval(v) - overrides[k] = v - except (NameError, SyntaxError, ValueError, AssertionError) as e: - check_cfg_mismatch(full_args_dict, {a: ''}, e) - - elif a in TASKS: - overrides['task'] = a - elif a in MODES: - overrides['mode'] = a - elif a.lower() in special: - special[a.lower()]() - return - elif a in DEFAULT_CFG_DICT and isinstance(DEFAULT_CFG_DICT[a], bool): - overrides[a] = True # auto-True for default bool args, i.e. 'yolo show' sets show=True - elif a in DEFAULT_CFG_DICT: - raise SyntaxError(f"'{colorstr('red', 'bold', a)}' is a valid YOLO argument but is missing an '=' sign " - f"to set its value, i.e. try '{a}={DEFAULT_CFG_DICT[a]}'\n{CLI_HELP_MSG}") - else: - check_cfg_mismatch(full_args_dict, {a: ''}) - - # Check keys - check_cfg_mismatch(full_args_dict, overrides) - - # Mode - mode = overrides.get('mode', None) - if mode is None: - mode = DEFAULT_CFG.mode or 'predict' - LOGGER.warning(f"WARNING ⚠️ 'mode' is missing. Valid modes are {MODES}. Using default 'mode={mode}'.") - elif mode not in MODES: - if mode not in ('checks', checks): - raise ValueError(f"Invalid 'mode={mode}'. Valid modes are {MODES}.\n{CLI_HELP_MSG}") - LOGGER.warning("WARNING ⚠️ 'yolo mode=checks' is deprecated. Use 'yolo checks' instead.") - checks.check_yolo() - return - - # Task - task = overrides.pop('task', None) - if task: - if task not in TASKS: - raise ValueError(f"Invalid 'task={task}'. Valid tasks are {TASKS}.\n{CLI_HELP_MSG}") - if 'model' not in overrides: - overrides['model'] = TASK2MODEL[task] - - # Model - model = overrides.pop('model', DEFAULT_CFG.model) - if model is None: - model = 'yolov8n.pt' - LOGGER.warning(f"WARNING ⚠️ 'model' is missing. Using default 'model={model}'.") - overrides['model'] = model - if 'rtdetr' in model.lower(): # guess architecture - from ultralytics import RTDETR - model = RTDETR(model) # no task argument - elif 'sam' in model.lower(): - from ultralytics import SAM - model = SAM(model) - else: - from ultralytics import YOLO - model = YOLO(model, task=task) - if isinstance(overrides.get('pretrained'), str): - model.load(overrides['pretrained']) - - # Task Update - if task != model.task: - if task: - LOGGER.warning(f"WARNING ⚠️ conflicting 'task={task}' passed with 'task={model.task}' model. " - f"Ignoring 'task={task}' and updating to 'task={model.task}' to match model.") - task = model.task - - # Mode - if mode in ('predict', 'track') and 'source' not in overrides: - overrides['source'] = DEFAULT_CFG.source or ROOT / 'assets' if (ROOT / 'assets').exists() \ - else 'https://ultralytics.com/images/bus.jpg' - LOGGER.warning(f"WARNING ⚠️ 'source' is missing. Using default 'source={overrides['source']}'.") - elif mode in ('train', 'val'): - if 'data' not in overrides: - overrides['data'] = TASK2DATA.get(task or DEFAULT_CFG.task, DEFAULT_CFG.data) - LOGGER.warning(f"WARNING ⚠️ 'data' is missing. Using default 'data={overrides['data']}'.") - elif mode == 'export': - if 'format' not in overrides: - overrides['format'] = DEFAULT_CFG.format or 'torchscript' - LOGGER.warning(f"WARNING ⚠️ 'format' is missing. Using default 'format={overrides['format']}'.") - - # Run command in python - # getattr(model, mode)(**vars(get_cfg(overrides=overrides))) # default args using default.yaml - getattr(model, mode)(**overrides) # default args from model - -# Special modes -------------------------------------------------------------------------------------------------------- -def copy_default_cfg(): - """Copy and create a new default configuration file with '_copy' appended to its name.""" - new_file = Path.cwd() / DEFAULT_CFG_PATH.name.replace('.yaml', '_copy.yaml') - shutil.copy2(DEFAULT_CFG_PATH, new_file) - LOGGER.info(f'{DEFAULT_CFG_PATH} copied to {new_file}\n' - f"Example YOLO command with this new custom cfg:\n yolo cfg='{new_file}' imgsz=320 batch=8") +from ultralytics.utils import LOGGER +# Set modules in sys.modules under their old name +sys.modules['ultralytics.yolo.cfg'] = importlib.import_module('ultralytics.cfg') -if __name__ == '__main__': - # Example Usage: entrypoint(debug='yolo predict model=yolov8n.pt') - entrypoint(debug='') +LOGGER.warning("WARNING ⚠️ 'ultralytics.yolo.cfg' is deprecated since '8.0.136' and will be removed in '8.1.0'. " + "Please use 'ultralytics.cfg' instead.") diff --git a/ultralytics/yolo/data/__init__.py b/ultralytics/yolo/data/__init__.py index f1d9dee..f68391e 100644 --- a/ultralytics/yolo/data/__init__.py +++ b/ultralytics/yolo/data/__init__.py @@ -1,9 +1,17 @@ -# Ultralytics YOLO 🚀, AGPL-3.0 license +import importlib +import sys -from .base import BaseDataset -from .build import build_dataloader, build_yolo_dataset, load_inference_source -from .dataset import ClassificationDataset, SemanticDataset, YOLODataset -from .dataset_wrappers import MixAndRectDataset +from ultralytics.utils import LOGGER -__all__ = ('BaseDataset', 'ClassificationDataset', 'MixAndRectDataset', 'SemanticDataset', 'YOLODataset', - 'build_yolo_dataset', 'build_dataloader', 'load_inference_source') +# Set modules in sys.modules under their old name +sys.modules['ultralytics.yolo.data'] = importlib.import_module('ultralytics.data') +# This is for updating old cls models, or the way in following warning won't work. +sys.modules['ultralytics.yolo.data.augment'] = importlib.import_module('ultralytics.data.augment') + +DATA_WARNING = """WARNING ⚠️ 'ultralytics.yolo.data' is deprecated since '8.0.136' and will be removed in '8.1.0'. Please use 'ultralytics.data' instead. +Note this warning may be related to loading older models. You can update your model to current structure with: + import torch + ckpt = torch.load("model.pt") # applies to both official and custom models + torch.save(ckpt, "updated-model.pt") +""" +LOGGER.warning(DATA_WARNING) diff --git a/ultralytics/yolo/data/dataset_wrappers.py b/ultralytics/yolo/data/dataset_wrappers.py deleted file mode 100644 index 72a6fb5..0000000 --- a/ultralytics/yolo/data/dataset_wrappers.py +++ /dev/null @@ -1,53 +0,0 @@ -# Ultralytics YOLO 🚀, AGPL-3.0 license - -import collections -from copy import deepcopy - -from .augment import LetterBox - - -class MixAndRectDataset: - """ - A dataset class that applies mosaic and mixup transformations as well as rectangular training. - - Attributes: - dataset: The base dataset. - imgsz: The size of the images in the dataset. - """ - - def __init__(self, dataset): - """ - Args: - dataset (BaseDataset): The base dataset to apply transformations to. - """ - self.dataset = dataset - self.imgsz = dataset.imgsz - - def __len__(self): - """Returns the number of items in the dataset.""" - return len(self.dataset) - - def __getitem__(self, index): - """ - Applies mosaic, mixup and rectangular training transformations to an item in the dataset. - - Args: - index (int): Index of the item in the dataset. - - Returns: - (dict): A dictionary containing the transformed item data. - """ - labels = deepcopy(self.dataset[index]) - for transform in self.dataset.transforms.tolist(): - # Mosaic and mixup - if hasattr(transform, 'get_indexes'): - indexes = transform.get_indexes(self.dataset) - if not isinstance(indexes, collections.abc.Sequence): - indexes = [indexes] - labels['mix_labels'] = [deepcopy(self.dataset[index]) for index in indexes] - if self.dataset.rect and isinstance(transform, LetterBox): - transform.new_shape = self.dataset.batch_shapes[self.dataset.batch[index]] - labels = transform(labels) - if 'mix_labels' in labels: - labels.pop('mix_labels') - return labels diff --git a/ultralytics/yolo/engine/__init__.py b/ultralytics/yolo/engine/__init__.py index e69de29..794efcd 100644 --- a/ultralytics/yolo/engine/__init__.py +++ b/ultralytics/yolo/engine/__init__.py @@ -0,0 +1,10 @@ +import importlib +import sys + +from ultralytics.utils import LOGGER + +# Set modules in sys.modules under their old name +sys.modules['ultralytics.yolo.engine'] = importlib.import_module('ultralytics.engine') + +LOGGER.warning("WARNING ⚠️ 'ultralytics.yolo.engine' is deprecated since '8.0.136' and will be removed in '8.1.0'. " + "Please use 'ultralytics.engine' instead.") diff --git a/ultralytics/yolo/utils/__init__.py b/ultralytics/yolo/utils/__init__.py index 5160322..71557b0 100644 --- a/ultralytics/yolo/utils/__init__.py +++ b/ultralytics/yolo/utils/__init__.py @@ -1,809 +1,15 @@ -# Ultralytics YOLO 🚀, AGPL-3.0 license - -import contextlib -import inspect -import logging.config -import os -import platform -import re -import subprocess +import importlib import sys -import threading -import urllib -import uuid -from pathlib import Path -from types import SimpleNamespace -from typing import Union - -import cv2 -import matplotlib.pyplot as plt -import numpy as np -import torch -import yaml - -from ultralytics import __version__ - -# PyTorch Multi-GPU DDP Constants -RANK = int(os.getenv('RANK', -1)) -LOCAL_RANK = int(os.getenv('LOCAL_RANK', -1)) # https://pytorch.org/docs/stable/elastic/run.html -WORLD_SIZE = int(os.getenv('WORLD_SIZE', 1)) - -# Other Constants -FILE = Path(__file__).resolve() -ROOT = FILE.parents[2] # YOLO -DEFAULT_CFG_PATH = ROOT / 'yolo/cfg/default.yaml' -NUM_THREADS = min(8, max(1, os.cpu_count() - 1)) # number of YOLOv5 multiprocessing threads -AUTOINSTALL = str(os.getenv('YOLO_AUTOINSTALL', True)).lower() == 'true' # global auto-install mode -VERBOSE = str(os.getenv('YOLO_VERBOSE', True)).lower() == 'true' # global verbose mode -TQDM_BAR_FORMAT = '{l_bar}{bar:10}{r_bar}' # tqdm bar format -LOGGING_NAME = 'ultralytics' -MACOS, LINUX, WINDOWS = (platform.system() == x for x in ['Darwin', 'Linux', 'Windows']) # environment booleans -ARM64 = platform.machine() in ('arm64', 'aarch64') # ARM64 booleans -HELP_MSG = \ - """ - Usage examples for running YOLOv8: - - 1. Install the ultralytics package: - - pip install ultralytics - - 2. Use the Python SDK: - - from ultralytics import YOLO - - # Load a model - model = YOLO('yolov8n.yaml') # build a new model from scratch - model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training) - - # Use the model - results = model.train(data="coco128.yaml", epochs=3) # train the model - results = model.val() # evaluate model performance on the validation set - results = model('https://ultralytics.com/images/bus.jpg') # predict on an image - success = model.export(format='onnx') # export the model to ONNX format - - 3. Use the command line interface (CLI): - - YOLOv8 'yolo' CLI commands use the following syntax: - - yolo TASK MODE ARGS - - Where TASK (optional) is one of [detect, segment, classify] - MODE (required) is one of [train, val, predict, export] - ARGS (optional) are any number of custom 'arg=value' pairs like 'imgsz=320' that override defaults. - See all ARGS at https://docs.ultralytics.com/usage/cfg or with 'yolo cfg' - - - Train a detection model for 10 epochs with an initial learning_rate of 0.01 - yolo detect train data=coco128.yaml model=yolov8n.pt epochs=10 lr0=0.01 - - - Predict a YouTube video using a pretrained segmentation model at image size 320: - yolo segment predict model=yolov8n-seg.pt source='https://youtu.be/Zgi9g1ksQHc' imgsz=320 - - - Val a pretrained detection model at batch-size 1 and image size 640: - yolo detect val model=yolov8n.pt data=coco128.yaml batch=1 imgsz=640 - - - Export a YOLOv8n classification model to ONNX format at image size 224 by 128 (no TASK required) - yolo export model=yolov8n-cls.pt format=onnx imgsz=224,128 - - - Run special commands: - yolo help - yolo checks - yolo version - yolo settings - yolo copy-cfg - yolo cfg - - Docs: https://docs.ultralytics.com - Community: https://community.ultralytics.com - GitHub: https://github.com/ultralytics/ultralytics - """ - -# Settings -torch.set_printoptions(linewidth=320, precision=4, profile='default') -np.set_printoptions(linewidth=320, formatter={'float_kind': '{:11.5g}'.format}) # format short g, %precision=5 -cv2.setNumThreads(0) # prevent OpenCV from multithreading (incompatible with PyTorch DataLoader) -os.environ['NUMEXPR_MAX_THREADS'] = str(NUM_THREADS) # NumExpr max threads -os.environ['CUBLAS_WORKSPACE_CONFIG'] = ':4096:8' # for deterministic training -os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # suppress verbose TF compiler warnings in Colab - - -class SimpleClass: - """ - Ultralytics SimpleClass is a base class providing helpful string representation, error reporting, and attribute - access methods for easier debugging and usage. - """ - - def __str__(self): - """Return a human-readable string representation of the object.""" - attr = [] - for a in dir(self): - v = getattr(self, a) - if not callable(v) and not a.startswith('_'): - if isinstance(v, SimpleClass): - # Display only the module and class name for subclasses - s = f'{a}: {v.__module__}.{v.__class__.__name__} object' - else: - s = f'{a}: {repr(v)}' - attr.append(s) - return f'{self.__module__}.{self.__class__.__name__} object with attributes:\n\n' + '\n'.join(attr) - - def __repr__(self): - """Return a machine-readable string representation of the object.""" - return self.__str__() - - def __getattr__(self, attr): - """Custom attribute access error message with helpful information.""" - name = self.__class__.__name__ - raise AttributeError(f"'{name}' object has no attribute '{attr}'. See valid attributes below.\n{self.__doc__}") - - -class IterableSimpleNamespace(SimpleNamespace): - """ - Ultralytics IterableSimpleNamespace is an extension class of SimpleNamespace that adds iterable functionality and - enables usage with dict() and for loops. - """ - - def __iter__(self): - """Return an iterator of key-value pairs from the namespace's attributes.""" - return iter(vars(self).items()) - - def __str__(self): - """Return a human-readable string representation of the object.""" - return '\n'.join(f'{k}={v}' for k, v in vars(self).items()) - - def __getattr__(self, attr): - """Custom attribute access error message with helpful information.""" - name = self.__class__.__name__ - raise AttributeError(f""" - '{name}' object has no attribute '{attr}'. This may be caused by a modified or out of date ultralytics - 'default.yaml' file.\nPlease update your code with 'pip install -U ultralytics' and if necessary replace - {DEFAULT_CFG_PATH} with the latest version from - https://github.com/ultralytics/ultralytics/blob/main/ultralytics/yolo/cfg/default.yaml - """) - - def get(self, key, default=None): - """Return the value of the specified key if it exists; otherwise, return the default value.""" - return getattr(self, key, default) - - -def plt_settings(rcparams=None, backend='Agg'): - """ - Decorator to temporarily set rc parameters and the backend for a plotting function. - - Usage: - decorator: @plt_settings({"font.size": 12}) - context manager: with plt_settings({"font.size": 12}): - - Args: - rcparams (dict): Dictionary of rc parameters to set. - backend (str, optional): Name of the backend to use. Defaults to 'Agg'. - - Returns: - (Callable): Decorated function with temporarily set rc parameters and backend. This decorator can be - applied to any function that needs to have specific matplotlib rc parameters and backend for its execution. - """ - - if rcparams is None: - rcparams = {'font.size': 11} - - def decorator(func): - """Decorator to apply temporary rc parameters and backend to a function.""" - - def wrapper(*args, **kwargs): - """Sets rc parameters and backend, calls the original function, and restores the settings.""" - original_backend = plt.get_backend() - plt.switch_backend(backend) - - with plt.rc_context(rcparams): - result = func(*args, **kwargs) - - plt.switch_backend(original_backend) - return result - - return wrapper - - return decorator - - -def set_logging(name=LOGGING_NAME, verbose=True): - """Sets up logging for the given name.""" - rank = int(os.getenv('RANK', -1)) # rank in world for Multi-GPU trainings - level = logging.INFO if verbose and rank in {-1, 0} else logging.ERROR - logging.config.dictConfig({ - 'version': 1, - 'disable_existing_loggers': False, - 'formatters': { - name: { - 'format': '%(message)s'}}, - 'handlers': { - name: { - 'class': 'logging.StreamHandler', - 'formatter': name, - 'level': level}}, - 'loggers': { - name: { - 'level': level, - 'handlers': [name], - 'propagate': False}}}) - - -def emojis(string=''): - """Return platform-dependent emoji-safe version of string.""" - return string.encode().decode('ascii', 'ignore') if WINDOWS else string - - -class EmojiFilter(logging.Filter): - """ - A custom logging filter class for removing emojis in log messages. - - This filter is particularly useful for ensuring compatibility with Windows terminals - that may not support the display of emojis in log messages. - """ - - def filter(self, record): - """Filter logs by emoji unicode characters on windows.""" - record.msg = emojis(record.msg) - return super().filter(record) - - -# Set logger -set_logging(LOGGING_NAME, verbose=VERBOSE) # run before defining LOGGER -LOGGER = logging.getLogger(LOGGING_NAME) # define globally (used in train.py, val.py, detect.py, etc.) -if WINDOWS: # emoji-safe logging - LOGGER.addFilter(EmojiFilter()) - - -class ThreadingLocked: - """ - A decorator class for ensuring thread-safe execution of a function or method. - This class can be used as a decorator to make sure that if the decorated function - is called from multiple threads, only one thread at a time will be able to execute the function. - - Attributes: - lock (threading.Lock): A lock object used to manage access to the decorated function. - - Usage: - @ThreadingLocked() - def my_function(): - # Your code here - pass - """ - - def __init__(self): - self.lock = threading.Lock() - - def __call__(self, f): - from functools import wraps - - @wraps(f) - def decorated(*args, **kwargs): - with self.lock: - return f(*args, **kwargs) - - return decorated - - -def yaml_save(file='data.yaml', data=None): - """ - Save YAML data to a file. - - Args: - file (str, optional): File name. Default is 'data.yaml'. - data (dict): Data to save in YAML format. - - Returns: - (None): Data is saved to the specified file. - """ - if data is None: - data = {} - file = Path(file) - if not file.parent.exists(): - # Create parent directories if they don't exist - file.parent.mkdir(parents=True, exist_ok=True) - - # Convert Path objects to strings - for k, v in data.items(): - if isinstance(v, Path): - data[k] = str(v) - - # Dump data to file in YAML format - with open(file, 'w') as f: - yaml.safe_dump(data, f, sort_keys=False, allow_unicode=True) - - -def yaml_load(file='data.yaml', append_filename=False): - """ - Load YAML data from a file. - - Args: - file (str, optional): File name. Default is 'data.yaml'. - append_filename (bool): Add the YAML filename to the YAML dictionary. Default is False. - - Returns: - (dict): YAML data and file name. - """ - with open(file, errors='ignore', encoding='utf-8') as f: - s = f.read() # string - - # Remove special characters - if not s.isprintable(): - s = re.sub(r'[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD\U00010000-\U0010ffff]+', '', s) - - # Add YAML filename to dict and return - return {**yaml.safe_load(s), 'yaml_file': str(file)} if append_filename else yaml.safe_load(s) - - -def yaml_print(yaml_file: Union[str, Path, dict]) -> None: - """ - Pretty prints a yaml file or a yaml-formatted dictionary. - - Args: - yaml_file: The file path of the yaml file or a yaml-formatted dictionary. - - Returns: - None - """ - yaml_dict = yaml_load(yaml_file) if isinstance(yaml_file, (str, Path)) else yaml_file - dump = yaml.dump(yaml_dict, sort_keys=False, allow_unicode=True) - LOGGER.info(f"Printing '{colorstr('bold', 'black', yaml_file)}'\n\n{dump}") - - -# Default configuration -DEFAULT_CFG_DICT = yaml_load(DEFAULT_CFG_PATH) -for k, v in DEFAULT_CFG_DICT.items(): - if isinstance(v, str) and v.lower() == 'none': - DEFAULT_CFG_DICT[k] = None -DEFAULT_CFG_KEYS = DEFAULT_CFG_DICT.keys() -DEFAULT_CFG = IterableSimpleNamespace(**DEFAULT_CFG_DICT) - - -def is_colab(): - """ - Check if the current script is running inside a Google Colab notebook. - - Returns: - (bool): True if running inside a Colab notebook, False otherwise. - """ - return 'COLAB_RELEASE_TAG' in os.environ or 'COLAB_BACKEND_VERSION' in os.environ - - -def is_kaggle(): - """ - Check if the current script is running inside a Kaggle kernel. - - Returns: - (bool): True if running inside a Kaggle kernel, False otherwise. - """ - return os.environ.get('PWD') == '/kaggle/working' and os.environ.get('KAGGLE_URL_BASE') == 'https://www.kaggle.com' - - -def is_jupyter(): - """ - Check if the current script is running inside a Jupyter Notebook. - Verified on Colab, Jupyterlab, Kaggle, Paperspace. - - Returns: - (bool): True if running inside a Jupyter Notebook, False otherwise. - """ - with contextlib.suppress(Exception): - from IPython import get_ipython - return get_ipython() is not None - return False - - -def is_docker() -> bool: - """ - Determine if the script is running inside a Docker container. - - Returns: - (bool): True if the script is running inside a Docker container, False otherwise. - """ - file = Path('/proc/self/cgroup') - if file.exists(): - with open(file) as f: - return 'docker' in f.read() - else: - return False - - -def is_online() -> bool: - """ - Check internet connectivity by attempting to connect to a known online host. - - Returns: - (bool): True if connection is successful, False otherwise. - """ - import socket - - for host in '1.1.1.1', '8.8.8.8', '223.5.5.5': # Cloudflare, Google, AliDNS: - try: - test_connection = socket.create_connection(address=(host, 53), timeout=2) - except (socket.timeout, socket.gaierror, OSError): - continue - else: - # If the connection was successful, close it to avoid a ResourceWarning - test_connection.close() - return True - return False - - -ONLINE = is_online() - - -def is_pip_package(filepath: str = __name__) -> bool: - """ - Determines if the file at the given filepath is part of a pip package. - - Args: - filepath (str): The filepath to check. - - Returns: - (bool): True if the file is part of a pip package, False otherwise. - """ - import importlib.util - - # Get the spec for the module - spec = importlib.util.find_spec(filepath) - - # Return whether the spec is not None and the origin is not None (indicating it is a package) - return spec is not None and spec.origin is not None - - -def is_dir_writeable(dir_path: Union[str, Path]) -> bool: - """ - Check if a directory is writeable. - - Args: - dir_path (str | Path): The path to the directory. - - Returns: - (bool): True if the directory is writeable, False otherwise. - """ - return os.access(str(dir_path), os.W_OK) - - -def is_pytest_running(): - """ - Determines whether pytest is currently running or not. - - Returns: - (bool): True if pytest is running, False otherwise. - """ - return ('PYTEST_CURRENT_TEST' in os.environ) or ('pytest' in sys.modules) or ('pytest' in Path(sys.argv[0]).stem) - - -def is_github_actions_ci() -> bool: - """ - Determine if the current environment is a GitHub Actions CI Python runner. - - Returns: - (bool): True if the current environment is a GitHub Actions CI Python runner, False otherwise. - """ - return 'GITHUB_ACTIONS' in os.environ and 'RUNNER_OS' in os.environ and 'RUNNER_TOOL_CACHE' in os.environ - - -def is_git_dir(): - """ - Determines whether the current file is part of a git repository. - If the current file is not part of a git repository, returns None. - - Returns: - (bool): True if current file is part of a git repository. - """ - return get_git_dir() is not None - - -def get_git_dir(): - """ - Determines whether the current file is part of a git repository and if so, returns the repository root directory. - If the current file is not part of a git repository, returns None. - - Returns: - (Path | None): Git root directory if found or None if not found. - """ - for d in Path(__file__).parents: - if (d / '.git').is_dir(): - return d - return None # no .git dir found - - -def get_git_origin_url(): - """ - Retrieves the origin URL of a git repository. - - Returns: - (str | None): The origin URL of the git repository. - """ - if is_git_dir(): - with contextlib.suppress(subprocess.CalledProcessError): - origin = subprocess.check_output(['git', 'config', '--get', 'remote.origin.url']) - return origin.decode().strip() - return None # if not git dir or on error - - -def get_git_branch(): - """ - Returns the current git branch name. If not in a git repository, returns None. - - Returns: - (str | None): The current git branch name. - """ - if is_git_dir(): - with contextlib.suppress(subprocess.CalledProcessError): - origin = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']) - return origin.decode().strip() - return None # if not git dir or on error - - -def get_default_args(func): - """Returns a dictionary of default arguments for a function. - - Args: - func (callable): The function to inspect. - - Returns: - (dict): A dictionary where each key is a parameter name, and each value is the default value of that parameter. - """ - signature = inspect.signature(func) - return {k: v.default for k, v in signature.parameters.items() if v.default is not inspect.Parameter.empty} - - -def get_user_config_dir(sub_dir='Ultralytics'): - """ - Get the user config directory. - - Args: - sub_dir (str): The name of the subdirectory to create. - - Returns: - (Path): The path to the user config directory. - """ - # Return the appropriate config directory for each operating system - if WINDOWS: - path = Path.home() / 'AppData' / 'Roaming' / sub_dir - elif MACOS: # macOS - path = Path.home() / 'Library' / 'Application Support' / sub_dir - elif LINUX: - path = Path.home() / '.config' / sub_dir - else: - raise ValueError(f'Unsupported operating system: {platform.system()}') - - # GCP and AWS lambda fix, only /tmp is writeable - if not is_dir_writeable(str(path.parent)): - path = Path('/tmp') / sub_dir - LOGGER.warning(f"WARNING ⚠️ user config directory is not writeable, defaulting to '{path}'.") - - # Create the subdirectory if it does not exist - path.mkdir(parents=True, exist_ok=True) - - return path - - -USER_CONFIG_DIR = Path(os.getenv('YOLO_CONFIG_DIR', get_user_config_dir())) # Ultralytics settings dir -SETTINGS_YAML = USER_CONFIG_DIR / 'settings.yaml' - - -def colorstr(*input): - """Colors a string https://en.wikipedia.org/wiki/ANSI_escape_code, i.e. colorstr('blue', 'hello world').""" - *args, string = input if len(input) > 1 else ('blue', 'bold', input[0]) # color arguments, string - colors = { - 'black': '\033[30m', # basic colors - 'red': '\033[31m', - 'green': '\033[32m', - 'yellow': '\033[33m', - 'blue': '\033[34m', - 'magenta': '\033[35m', - 'cyan': '\033[36m', - 'white': '\033[37m', - 'bright_black': '\033[90m', # bright colors - 'bright_red': '\033[91m', - 'bright_green': '\033[92m', - 'bright_yellow': '\033[93m', - 'bright_blue': '\033[94m', - 'bright_magenta': '\033[95m', - 'bright_cyan': '\033[96m', - 'bright_white': '\033[97m', - 'end': '\033[0m', # misc - 'bold': '\033[1m', - 'underline': '\033[4m'} - return ''.join(colors[x] for x in args) + f'{string}' + colors['end'] - - -class TryExcept(contextlib.ContextDecorator): - """YOLOv8 TryExcept class. Usage: @TryExcept() decorator or 'with TryExcept():' context manager.""" - - def __init__(self, msg='', verbose=True): - """Initialize TryExcept class with optional message and verbosity settings.""" - self.msg = msg - self.verbose = verbose - - def __enter__(self): - """Executes when entering TryExcept context, initializes instance.""" - pass - - def __exit__(self, exc_type, value, traceback): - """Defines behavior when exiting a 'with' block, prints error message if necessary.""" - if self.verbose and value: - print(emojis(f"{self.msg}{': ' if self.msg else ''}{value}")) - return True - - -def threaded(func): - """Multi-threads a target function and returns thread. Usage: @threaded decorator.""" - - def wrapper(*args, **kwargs): - """Multi-threads a given function and returns the thread.""" - thread = threading.Thread(target=func, args=args, kwargs=kwargs, daemon=True) - thread.start() - return thread - - return wrapper - - -def set_sentry(): - """ - Initialize the Sentry SDK for error tracking and reporting. Only used if sentry_sdk package is installed and - sync=True in settings. Run 'yolo settings' to see and update settings YAML file. - - Conditions required to send errors (ALL conditions must be met or no errors will be reported): - - sentry_sdk package is installed - - sync=True in YOLO settings - - pytest is not running - - running in a pip package installation - - running in a non-git directory - - running with rank -1 or 0 - - online environment - - CLI used to run package (checked with 'yolo' as the name of the main CLI command) - - The function also configures Sentry SDK to ignore KeyboardInterrupt and FileNotFoundError - exceptions and to exclude events with 'out of memory' in their exception message. - - Additionally, the function sets custom tags and user information for Sentry events. - """ - - def before_send(event, hint): - """ - Modify the event before sending it to Sentry based on specific exception types and messages. - - Args: - event (dict): The event dictionary containing information about the error. - hint (dict): A dictionary containing additional information about the error. - - Returns: - dict: The modified event or None if the event should not be sent to Sentry. - """ - if 'exc_info' in hint: - exc_type, exc_value, tb = hint['exc_info'] - if exc_type in (KeyboardInterrupt, FileNotFoundError) \ - or 'out of memory' in str(exc_value): - return None # do not send event - - event['tags'] = { - 'sys_argv': sys.argv[0], - 'sys_argv_name': Path(sys.argv[0]).name, - 'install': 'git' if is_git_dir() else 'pip' if is_pip_package() else 'other', - 'os': ENVIRONMENT} - return event - - if SETTINGS['sync'] and \ - RANK in (-1, 0) and \ - Path(sys.argv[0]).name == 'yolo' and \ - not TESTS_RUNNING and \ - ONLINE and \ - is_pip_package() and \ - not is_git_dir(): - - # If sentry_sdk package is not installed then return and do not use Sentry - try: - import sentry_sdk # noqa - except ImportError: - return - - sentry_sdk.init( - dsn='https://5ff1556b71594bfea135ff0203a0d290@o4504521589325824.ingest.sentry.io/4504521592406016', - debug=False, - traces_sample_rate=1.0, - release=__version__, - environment='production', # 'dev' or 'production' - before_send=before_send, - ignore_errors=[KeyboardInterrupt, FileNotFoundError]) - sentry_sdk.set_user({'id': SETTINGS['uuid']}) # SHA-256 anonymized UUID hash - - # Disable all sentry logging - for logger in 'sentry_sdk', 'sentry_sdk.errors': - logging.getLogger(logger).setLevel(logging.CRITICAL) - - -def get_settings(file=SETTINGS_YAML, version='0.0.3'): - """ - Loads a global Ultralytics settings YAML file or creates one with default values if it does not exist. - - Args: - file (Path): Path to the Ultralytics settings YAML file. Defaults to 'settings.yaml' in the USER_CONFIG_DIR. - version (str): Settings version. If min settings version not met, new default settings will be saved. - - Returns: - (dict): Dictionary of settings key-value pairs. - """ - import hashlib - - from ultralytics.yolo.utils.checks import check_version - from ultralytics.yolo.utils.torch_utils import torch_distributed_zero_first - - git_dir = get_git_dir() - root = git_dir or Path() - datasets_root = (root.parent if git_dir and is_dir_writeable(root.parent) else root).resolve() - defaults = { - 'datasets_dir': str(datasets_root / 'datasets'), # default datasets directory. - 'weights_dir': str(root / 'weights'), # default weights directory. - 'runs_dir': str(root / 'runs'), # default runs directory. - 'uuid': hashlib.sha256(str(uuid.getnode()).encode()).hexdigest(), # SHA-256 anonymized UUID hash - 'sync': True, # sync analytics to help with YOLO development - 'api_key': '', # Ultralytics HUB API key (https://hub.ultralytics.com/) - 'settings_version': version} # Ultralytics settings version - - with torch_distributed_zero_first(RANK): - if not file.exists(): - yaml_save(file, defaults) - settings = yaml_load(file) - - # Check that settings keys and types match defaults - correct = \ - settings \ - and settings.keys() == defaults.keys() \ - and all(type(a) == type(b) for a, b in zip(settings.values(), defaults.values())) \ - and check_version(settings['settings_version'], version) - if not correct: - LOGGER.warning('WARNING ⚠️ Ultralytics settings reset to defaults. This is normal and may be due to a ' - 'recent ultralytics package update, but may have overwritten previous settings. ' - f"\nView and update settings with 'yolo settings' or at '{file}'") - settings = defaults # merge **defaults with **settings (prefer **settings) - yaml_save(file, settings) # save updated defaults - - return settings - - -def set_settings(kwargs, file=SETTINGS_YAML): - """ - Function that runs on a first-time ultralytics package installation to set up global settings and create necessary - directories. - """ - SETTINGS.update(kwargs) - yaml_save(file, SETTINGS) - - -def deprecation_warn(arg, new_arg, version=None): - """Issue a deprecation warning when a deprecated argument is used, suggesting an updated argument.""" - if not version: - version = float(__version__[:3]) + 0.2 # deprecate after 2nd major release - LOGGER.warning(f"WARNING ⚠️ '{arg}' is deprecated and will be removed in 'ultralytics {version}' in the future. " - f"Please use '{new_arg}' instead.") - - -def clean_url(url): - """Strip auth from URL, i.e. https://url.com/file.txt?auth -> https://url.com/file.txt.""" - url = str(Path(url)).replace(':/', '://') # Pathlib turns :// -> :/ - return urllib.parse.unquote(url).split('?')[0] # '%2F' to '/', split https://url.com/file.txt?auth - - -def url2file(url): - """Convert URL to filename, i.e. https://url.com/file.txt?auth -> file.txt.""" - return Path(clean_url(url)).name - - -# Run below code on yolo/utils init ------------------------------------------------------------------------------------ -# Check first-install steps -PREFIX = colorstr('Ultralytics: ') -SETTINGS = get_settings() -DATASETS_DIR = Path(SETTINGS['datasets_dir']) # global datasets directory -ENVIRONMENT = 'Colab' if is_colab() else 'Kaggle' if is_kaggle() else 'Jupyter' if is_jupyter() else \ - 'Docker' if is_docker() else platform.system() -TESTS_RUNNING = is_pytest_running() or is_github_actions_ci() -set_sentry() +from ultralytics.utils import LOGGER -# Apply monkey patches if the script is being run from within the parent directory of the script's location -from .patches import imread, imshow, imwrite +# Set modules in sys.modules under their old name +sys.modules['ultralytics.yolo.utils'] = importlib.import_module('ultralytics.utils') -# torch.save = torch_save -if Path(inspect.stack()[0].filename).parent.parent.as_posix() in inspect.stack()[-1].filename: - cv2.imread, cv2.imwrite, cv2.imshow = imread, imwrite, imshow +UTILS_WARNING = """WARNING ⚠️ 'ultralytics.yolo.utils' is deprecated since '8.0.136' and will be removed in '8.1.0'. Please use 'ultralytics.utils' instead. +Note this warning may be related to loading older models. You can update your model to current structure with: + import torch + ckpt = torch.load("model.pt") # applies to both official and custom models + torch.save(ckpt, "updated-model.pt") +""" +LOGGER.warning(UTILS_WARNING) diff --git a/ultralytics/yolo/v8/__init__.py b/ultralytics/yolo/v8/__init__.py index adc0351..51adf81 100644 --- a/ultralytics/yolo/v8/__init__.py +++ b/ultralytics/yolo/v8/__init__.py @@ -1,5 +1,10 @@ -# Ultralytics YOLO 🚀, AGPL-3.0 license +import importlib +import sys -from ultralytics.yolo.v8 import classify, detect, pose, segment +from ultralytics.utils import LOGGER -__all__ = 'classify', 'segment', 'detect', 'pose' +# Set modules in sys.modules under their old name +sys.modules['ultralytics.yolo.v8'] = importlib.import_module('ultralytics.models.yolo') + +LOGGER.warning("WARNING ⚠️ 'ultralytics.yolo.v8' is deprecated since '8.0.136' and will be removed in '8.1.0'. " + "Please use 'ultralytics.models.yolo' instead.") diff --git a/ultralytics/yolo/v8/classify/__init__.py b/ultralytics/yolo/v8/classify/__init__.py deleted file mode 100644 index 2f049ed..0000000 --- a/ultralytics/yolo/v8/classify/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -# Ultralytics YOLO 🚀, AGPL-3.0 license - -from ultralytics.yolo.v8.classify.predict import ClassificationPredictor, predict -from ultralytics.yolo.v8.classify.train import ClassificationTrainer, train -from ultralytics.yolo.v8.classify.val import ClassificationValidator, val - -__all__ = 'ClassificationPredictor', 'predict', 'ClassificationTrainer', 'train', 'ClassificationValidator', 'val'