Add docformatter to pre-commit (#5279)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Burhan <62214284+Burhan-Q@users.noreply.github.com>
This commit is contained in:
parent
c7aa83da31
commit
7517667a33
90 changed files with 1396 additions and 497 deletions
|
|
@ -9,7 +9,8 @@ TMP = Path(__file__).resolve().parent / 'tmp' # temp directory for test files
|
|||
|
||||
|
||||
def pytest_addoption(parser):
|
||||
"""Add custom command-line options to pytest.
|
||||
"""
|
||||
Add custom command-line options to pytest.
|
||||
|
||||
Args:
|
||||
parser (pytest.config.Parser): The pytest parser object.
|
||||
|
|
@ -18,7 +19,8 @@ def pytest_addoption(parser):
|
|||
|
||||
|
||||
def pytest_configure(config):
|
||||
"""Register custom markers to avoid pytest warnings.
|
||||
"""
|
||||
Register custom markers to avoid pytest warnings.
|
||||
|
||||
Args:
|
||||
config (pytest.config.Config): The pytest config object.
|
||||
|
|
@ -27,7 +29,8 @@ def pytest_configure(config):
|
|||
|
||||
|
||||
def pytest_runtest_setup(item):
|
||||
"""Setup hook to skip tests marked as slow if the --slow option is not provided.
|
||||
"""
|
||||
Setup hook to skip tests marked as slow if the --slow option is not provided.
|
||||
|
||||
Args:
|
||||
item (pytest.Item): The test item object.
|
||||
|
|
|
|||
|
|
@ -22,11 +22,12 @@ EXPORT_ARGS = [
|
|||
|
||||
|
||||
def run(cmd):
|
||||
# Run a subprocess command with check=True
|
||||
"""Execute a shell command using subprocess."""
|
||||
subprocess.run(cmd.split(), check=True)
|
||||
|
||||
|
||||
def test_special_modes():
|
||||
"""Test various special command modes of YOLO."""
|
||||
run('yolo help')
|
||||
run('yolo checks')
|
||||
run('yolo version')
|
||||
|
|
@ -36,31 +37,37 @@ def test_special_modes():
|
|||
|
||||
@pytest.mark.parametrize('task,model,data', TASK_ARGS)
|
||||
def test_train(task, model, data):
|
||||
"""Test YOLO training for a given task, model, and data."""
|
||||
run(f'yolo train {task} model={model}.yaml data={data} imgsz=32 epochs=1 cache=disk')
|
||||
|
||||
|
||||
@pytest.mark.parametrize('task,model,data', TASK_ARGS)
|
||||
def test_val(task, model, data):
|
||||
"""Test YOLO validation for a given task, model, and data."""
|
||||
run(f'yolo val {task} model={WEIGHTS_DIR / model}.pt data={data} imgsz=32 save_txt save_json')
|
||||
|
||||
|
||||
@pytest.mark.parametrize('task,model,data', TASK_ARGS)
|
||||
def test_predict(task, model, data):
|
||||
"""Test YOLO prediction on sample assets for a given task and model."""
|
||||
run(f'yolo predict model={WEIGHTS_DIR / model}.pt source={ASSETS} imgsz=32 save save_crop save_txt')
|
||||
|
||||
|
||||
@pytest.mark.parametrize('model,format', EXPORT_ARGS)
|
||||
def test_export(model, format):
|
||||
"""Test exporting a YOLO model to different formats."""
|
||||
run(f'yolo export model={WEIGHTS_DIR / model}.pt format={format} imgsz=32')
|
||||
|
||||
|
||||
def test_rtdetr(task='detect', model='yolov8n-rtdetr.yaml', data='coco8.yaml'):
|
||||
"""Test the RTDETR functionality with the Ultralytics framework."""
|
||||
# Warning: MUST use imgsz=640
|
||||
run(f'yolo train {task} model={model} data={data} --imgsz= 640 epochs =1, cache = disk') # add coma, spaces to args
|
||||
run(f"yolo predict {task} model={model} source={ASSETS / 'bus.jpg'} imgsz=640 save save_crop save_txt")
|
||||
|
||||
|
||||
def test_fastsam(task='segment', model=WEIGHTS_DIR / 'FastSAM-s.pt', data='coco8-seg.yaml'):
|
||||
"""Test FastSAM segmentation functionality within Ultralytics."""
|
||||
source = ASSETS / 'bus.jpg'
|
||||
|
||||
run(f'yolo segment val {task} model={model} data={data} imgsz=32')
|
||||
|
|
@ -97,6 +104,7 @@ def test_fastsam(task='segment', model=WEIGHTS_DIR / 'FastSAM-s.pt', data='coco8
|
|||
|
||||
|
||||
def test_mobilesam():
|
||||
"""Test MobileSAM segmentation functionality using Ultralytics."""
|
||||
from ultralytics import SAM
|
||||
|
||||
# Load the model
|
||||
|
|
@ -121,5 +129,6 @@ def test_mobilesam():
|
|||
@pytest.mark.skipif(not CUDA_IS_AVAILABLE, reason='CUDA is not available')
|
||||
@pytest.mark.skipif(CUDA_DEVICE_COUNT < 2, reason='DDP is not available')
|
||||
def test_train_gpu(task, model, data):
|
||||
"""Test YOLO training on GPU(s) for various tasks and models."""
|
||||
run(f'yolo train {task} model={model}.yaml data={data} imgsz=32 epochs=1 device=0') # single GPU
|
||||
run(f'yolo train {task} model={model}.pt data={data} imgsz=32 epochs=1 device=0,1') # multi GPU
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
||||
|
||||
import contextlib
|
||||
|
||||
import pytest
|
||||
|
|
@ -17,18 +18,21 @@ BUS = ASSETS / 'bus.jpg'
|
|||
|
||||
|
||||
def test_checks():
|
||||
"""Validate CUDA settings against torch CUDA functions."""
|
||||
assert torch.cuda.is_available() == CUDA_IS_AVAILABLE
|
||||
assert torch.cuda.device_count() == CUDA_DEVICE_COUNT
|
||||
|
||||
|
||||
@pytest.mark.skipif(not CUDA_IS_AVAILABLE, reason='CUDA is not available')
|
||||
def test_train():
|
||||
"""Test model training on a minimal dataset."""
|
||||
device = 0 if CUDA_DEVICE_COUNT == 1 else [0, 1]
|
||||
YOLO(MODEL).train(data=DATA, imgsz=64, epochs=1, device=device) # requires imgsz>=64
|
||||
|
||||
|
||||
@pytest.mark.skipif(not CUDA_IS_AVAILABLE, reason='CUDA is not available')
|
||||
def test_predict_multiple_devices():
|
||||
"""Validate model prediction on multiple devices."""
|
||||
model = YOLO('yolov8n.pt')
|
||||
model = model.cpu()
|
||||
assert str(model.device) == 'cpu'
|
||||
|
|
@ -53,6 +57,7 @@ def test_predict_multiple_devices():
|
|||
|
||||
@pytest.mark.skipif(not CUDA_IS_AVAILABLE, reason='CUDA is not available')
|
||||
def test_autobatch():
|
||||
"""Check batch size for YOLO model using autobatch."""
|
||||
from ultralytics.utils.autobatch import check_train_batch_size
|
||||
|
||||
check_train_batch_size(YOLO(MODEL).model.cuda(), imgsz=128, amp=True)
|
||||
|
|
@ -60,6 +65,7 @@ def test_autobatch():
|
|||
|
||||
@pytest.mark.skipif(not CUDA_IS_AVAILABLE, reason='CUDA is not available')
|
||||
def test_utils_benchmarks():
|
||||
"""Profile YOLO models for performance benchmarks."""
|
||||
from ultralytics.utils.benchmarks import ProfileModels
|
||||
|
||||
# Pre-export a dynamic engine model to use dynamic inference
|
||||
|
|
@ -69,6 +75,7 @@ def test_utils_benchmarks():
|
|||
|
||||
@pytest.mark.skipif(not CUDA_IS_AVAILABLE, reason='CUDA is not available')
|
||||
def test_predict_sam():
|
||||
"""Test SAM model prediction with various prompts."""
|
||||
from ultralytics import SAM
|
||||
from ultralytics.models.sam import Predictor as SAMPredictor
|
||||
|
||||
|
|
@ -102,6 +109,7 @@ def test_predict_sam():
|
|||
|
||||
@pytest.mark.skipif(not CUDA_IS_AVAILABLE, reason='CUDA is not available')
|
||||
def test_model_ray_tune():
|
||||
"""Tune YOLO model with Ray optimization library."""
|
||||
with contextlib.suppress(RuntimeError): # RuntimeError may be caused by out-of-memory
|
||||
YOLO('yolov8n-cls.yaml').tune(use_ray=True,
|
||||
data='imagenet10',
|
||||
|
|
@ -115,12 +123,14 @@ def test_model_ray_tune():
|
|||
|
||||
@pytest.mark.skipif(not CUDA_IS_AVAILABLE, reason='CUDA is not available')
|
||||
def test_model_tune():
|
||||
"""Tune YOLO model for performance."""
|
||||
YOLO('yolov8n-pose.pt').tune(data='coco8-pose.yaml', plots=False, imgsz=32, epochs=1, iterations=2, device='cpu')
|
||||
YOLO('yolov8n-cls.pt').tune(data='imagenet10', plots=False, imgsz=32, epochs=1, iterations=2, device='cpu')
|
||||
|
||||
|
||||
@pytest.mark.skipif(not CUDA_IS_AVAILABLE, reason='CUDA is not available')
|
||||
def test_pycocotools():
|
||||
"""Validate model predictions using pycocotools."""
|
||||
from ultralytics.models.yolo.detect import DetectionValidator
|
||||
from ultralytics.models.yolo.pose import PoseValidator
|
||||
from ultralytics.models.yolo.segment import SegmentationValidator
|
||||
|
|
|
|||
|
|
@ -14,10 +14,12 @@ MODEL = WEIGHTS_DIR / 'yolov8n'
|
|||
|
||||
|
||||
def test_func(*args): # noqa
|
||||
"""Test function callback."""
|
||||
print('callback test passed')
|
||||
|
||||
|
||||
def test_export():
|
||||
"""Test model exporting functionality."""
|
||||
exporter = Exporter()
|
||||
exporter.add_callback('on_export_start', test_func)
|
||||
assert test_func in exporter.callbacks['on_export_start'], 'callback test failed'
|
||||
|
|
@ -26,6 +28,7 @@ def test_export():
|
|||
|
||||
|
||||
def test_detect():
|
||||
"""Test object detection functionality."""
|
||||
overrides = {'data': 'coco8.yaml', 'model': CFG_DET, 'imgsz': 32, 'epochs': 1, 'save': False}
|
||||
CFG.data = 'coco8.yaml'
|
||||
CFG.imgsz = 32
|
||||
|
|
@ -61,6 +64,7 @@ def test_detect():
|
|||
|
||||
|
||||
def test_segment():
|
||||
"""Test image segmentation functionality."""
|
||||
overrides = {'data': 'coco8-seg.yaml', 'model': CFG_SEG, 'imgsz': 32, 'epochs': 1, 'save': False}
|
||||
CFG.data = 'coco8-seg.yaml'
|
||||
CFG.imgsz = 32
|
||||
|
|
@ -98,6 +102,7 @@ def test_segment():
|
|||
|
||||
|
||||
def test_classify():
|
||||
"""Test image classification functionality."""
|
||||
overrides = {'data': 'imagenet10', 'model': CFG_CLS, 'imgsz': 32, 'epochs': 1, 'save': False}
|
||||
CFG.data = 'imagenet10'
|
||||
CFG.imgsz = 32
|
||||
|
|
|
|||
|
|
@ -27,11 +27,13 @@ IS_TMP_WRITEABLE = is_dir_writeable(TMP)
|
|||
|
||||
|
||||
def test_model_forward():
|
||||
"""Test the forward pass of the YOLO model."""
|
||||
model = YOLO(CFG)
|
||||
model(source=None, imgsz=32, augment=True) # also test no source and augment
|
||||
|
||||
|
||||
def test_model_methods():
|
||||
"""Test various methods and properties of the YOLO model."""
|
||||
model = YOLO(MODEL)
|
||||
|
||||
# Model methods
|
||||
|
|
@ -51,7 +53,7 @@ def test_model_methods():
|
|||
|
||||
|
||||
def test_model_profile():
|
||||
# Test profile=True model argument
|
||||
"""Test profiling of the YOLO model with 'profile=True' argument."""
|
||||
from ultralytics.nn.tasks import DetectionModel
|
||||
|
||||
model = DetectionModel() # build model
|
||||
|
|
@ -61,7 +63,7 @@ def test_model_profile():
|
|||
|
||||
@pytest.mark.skipif(not IS_TMP_WRITEABLE, reason='directory is not writeable')
|
||||
def test_predict_txt():
|
||||
# Write a list of sources (file, dir, glob, recursive glob) to a txt file
|
||||
"""Test YOLO predictions with sources (file, dir, glob, recursive glob) specified in a text file."""
|
||||
txt_file = TMP / 'sources.txt'
|
||||
with open(txt_file, 'w') as f:
|
||||
for x in [ASSETS / 'bus.jpg', ASSETS, ASSETS / '*', ASSETS / '**/*.jpg']:
|
||||
|
|
@ -70,6 +72,7 @@ def test_predict_txt():
|
|||
|
||||
|
||||
def test_predict_img():
|
||||
"""Test YOLO prediction on various types of image sources."""
|
||||
model = YOLO(MODEL)
|
||||
seg_model = YOLO(WEIGHTS_DIR / 'yolov8n-seg.pt')
|
||||
cls_model = YOLO(WEIGHTS_DIR / 'yolov8n-cls.pt')
|
||||
|
|
@ -105,7 +108,7 @@ def test_predict_img():
|
|||
|
||||
|
||||
def test_predict_grey_and_4ch():
|
||||
# Convert SOURCE to greyscale and 4-ch
|
||||
"""Test YOLO prediction on SOURCE converted to greyscale and 4-channel images."""
|
||||
im = Image.open(SOURCE)
|
||||
directory = TMP / 'im4'
|
||||
directory.mkdir(parents=True, exist_ok=True)
|
||||
|
|
@ -132,8 +135,11 @@ def test_predict_grey_and_4ch():
|
|||
@pytest.mark.skipif(not ONLINE, reason='environment is offline')
|
||||
@pytest.mark.skipif(not IS_TMP_WRITEABLE, reason='directory is not writeable')
|
||||
def test_track_stream():
|
||||
# Test YouTube streaming inference (short 10 frame video) with non-default ByteTrack tracker
|
||||
# imgsz=160 required for tracking for higher confidence and better matches
|
||||
"""
|
||||
Test YouTube streaming tracking (short 10 frame video) with non-default ByteTrack tracker.
|
||||
|
||||
Note imgsz=160 required for tracking for higher confidence and better matches
|
||||
"""
|
||||
import yaml
|
||||
|
||||
model = YOLO(MODEL)
|
||||
|
|
@ -153,37 +159,44 @@ def test_track_stream():
|
|||
|
||||
|
||||
def test_val():
|
||||
"""Test the validation mode of the YOLO model."""
|
||||
YOLO(MODEL).val(data='coco8.yaml', imgsz=32, save_hybrid=True)
|
||||
|
||||
|
||||
def test_train_scratch():
|
||||
"""Test training the YOLO model from scratch."""
|
||||
model = YOLO(CFG)
|
||||
model.train(data='coco8.yaml', epochs=2, imgsz=32, cache='disk', batch=-1, close_mosaic=1, name='model')
|
||||
model(SOURCE)
|
||||
|
||||
|
||||
def test_train_pretrained():
|
||||
"""Test training the YOLO model from a pre-trained state."""
|
||||
model = YOLO(WEIGHTS_DIR / 'yolov8n-seg.pt')
|
||||
model.train(data='coco8-seg.yaml', epochs=1, imgsz=32, cache='ram', copy_paste=0.5, mixup=0.5, name=0)
|
||||
model(SOURCE)
|
||||
|
||||
|
||||
def test_export_torchscript():
|
||||
"""Test exporting the YOLO model to TorchScript format."""
|
||||
f = YOLO(MODEL).export(format='torchscript', optimize=False)
|
||||
YOLO(f)(SOURCE) # exported model inference
|
||||
|
||||
|
||||
def test_export_onnx():
|
||||
"""Test exporting the YOLO model to ONNX format."""
|
||||
f = YOLO(MODEL).export(format='onnx', dynamic=True)
|
||||
YOLO(f)(SOURCE) # exported model inference
|
||||
|
||||
|
||||
def test_export_openvino():
|
||||
"""Test exporting the YOLO model to OpenVINO format."""
|
||||
f = YOLO(MODEL).export(format='openvino')
|
||||
YOLO(f)(SOURCE) # exported model inference
|
||||
|
||||
|
||||
def test_export_coreml():
|
||||
"""Test exporting the YOLO model to CoreML format."""
|
||||
if not WINDOWS: # RuntimeError: BlobWriter not loaded with coremltools 7.0 on windows
|
||||
if MACOS:
|
||||
f = YOLO(MODEL).export(format='coreml')
|
||||
|
|
@ -193,7 +206,11 @@ def test_export_coreml():
|
|||
|
||||
|
||||
def test_export_tflite(enabled=False):
|
||||
# TF suffers from install conflicts on Windows and macOS
|
||||
"""
|
||||
Test exporting the YOLO model to TFLite format.
|
||||
|
||||
Note TF suffers from install conflicts on Windows and macOS.
|
||||
"""
|
||||
if enabled and LINUX:
|
||||
model = YOLO(MODEL)
|
||||
f = model.export(format='tflite')
|
||||
|
|
@ -201,7 +218,11 @@ def test_export_tflite(enabled=False):
|
|||
|
||||
|
||||
def test_export_pb(enabled=False):
|
||||
# TF suffers from install conflicts on Windows and macOS
|
||||
"""
|
||||
Test exporting the YOLO model to *.pb format.
|
||||
|
||||
Note TF suffers from install conflicts on Windows and macOS.
|
||||
"""
|
||||
if enabled and LINUX:
|
||||
model = YOLO(MODEL)
|
||||
f = model.export(format='pb')
|
||||
|
|
@ -209,18 +230,24 @@ def test_export_pb(enabled=False):
|
|||
|
||||
|
||||
def test_export_paddle(enabled=False):
|
||||
# Paddle protobuf requirements conflicting with onnx protobuf requirements
|
||||
"""
|
||||
Test exporting the YOLO model to Paddle format.
|
||||
|
||||
Note Paddle protobuf requirements conflicting with onnx protobuf requirements.
|
||||
"""
|
||||
if enabled:
|
||||
YOLO(MODEL).export(format='paddle')
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_export_ncnn():
|
||||
"""Test exporting the YOLO model to NCNN format."""
|
||||
f = YOLO(MODEL).export(format='ncnn')
|
||||
YOLO(f)(SOURCE) # exported model inference
|
||||
|
||||
|
||||
def test_all_model_yamls():
|
||||
"""Test YOLO model creation for all available YAML configurations."""
|
||||
for m in (ROOT / 'cfg' / 'models').rglob('*.yaml'):
|
||||
if 'rtdetr' in m.name:
|
||||
if TORCH_1_9: # torch<=1.8 issue - TypeError: __init__() got an unexpected keyword argument 'batch_first'
|
||||
|
|
@ -230,6 +257,7 @@ def test_all_model_yamls():
|
|||
|
||||
|
||||
def test_workflow():
|
||||
"""Test the complete workflow including training, validation, prediction, and exporting."""
|
||||
model = YOLO(MODEL)
|
||||
model.train(data='coco8.yaml', epochs=1, imgsz=32, optimizer='SGD')
|
||||
model.val(imgsz=32)
|
||||
|
|
@ -238,12 +266,14 @@ def test_workflow():
|
|||
|
||||
|
||||
def test_predict_callback_and_setup():
|
||||
# Test callback addition for prediction
|
||||
def on_predict_batch_end(predictor): # results -> List[batch_size]
|
||||
"""Test callback functionality during YOLO prediction."""
|
||||
|
||||
def on_predict_batch_end(predictor):
|
||||
"""Callback function that handles operations at the end of a prediction batch."""
|
||||
path, im0s, _, _ = predictor.batch
|
||||
im0s = im0s if isinstance(im0s, list) else [im0s]
|
||||
bs = [predictor.dataset.bs for _ in range(len(path))]
|
||||
predictor.results = zip(predictor.results, im0s, bs)
|
||||
predictor.results = zip(predictor.results, im0s, bs) # results is List[batch_size]
|
||||
|
||||
model = YOLO(MODEL)
|
||||
model.add_callback('on_predict_batch_end', on_predict_batch_end)
|
||||
|
|
@ -259,6 +289,7 @@ def test_predict_callback_and_setup():
|
|||
|
||||
|
||||
def test_results():
|
||||
"""Test various result formats for the YOLO model."""
|
||||
for m in 'yolov8n-pose.pt', 'yolov8n-seg.pt', 'yolov8n.pt', 'yolov8n-cls.pt':
|
||||
results = YOLO(WEIGHTS_DIR / m)([SOURCE, SOURCE], imgsz=160)
|
||||
for r in results:
|
||||
|
|
@ -274,7 +305,7 @@ def test_results():
|
|||
|
||||
@pytest.mark.skipif(not ONLINE, reason='environment is offline')
|
||||
def test_data_utils():
|
||||
# Test functions in ultralytics/data/utils.py
|
||||
"""Test utility functions in ultralytics/data/utils.py."""
|
||||
from ultralytics.data.utils import HUBDatasetStats, autosplit
|
||||
from ultralytics.utils.downloads import zip_directory
|
||||
|
||||
|
|
@ -294,7 +325,7 @@ def test_data_utils():
|
|||
|
||||
@pytest.mark.skipif(not ONLINE, reason='environment is offline')
|
||||
def test_data_converter():
|
||||
# Test dataset converters
|
||||
"""Test dataset converters."""
|
||||
from ultralytics.data.converter import coco80_to_coco91_class, convert_coco
|
||||
|
||||
file = 'instances_val2017.json'
|
||||
|
|
@ -304,6 +335,7 @@ def test_data_converter():
|
|||
|
||||
|
||||
def test_data_annotator():
|
||||
"""Test automatic data annotation."""
|
||||
from ultralytics.data.annotator import auto_annotate
|
||||
|
||||
auto_annotate(ASSETS,
|
||||
|
|
@ -313,7 +345,7 @@ def test_data_annotator():
|
|||
|
||||
|
||||
def test_events():
|
||||
# Test event sending
|
||||
"""Test event sending functionality."""
|
||||
from ultralytics.hub.utils import Events
|
||||
|
||||
events = Events()
|
||||
|
|
@ -324,6 +356,7 @@ def test_events():
|
|||
|
||||
|
||||
def test_cfg_init():
|
||||
"""Test configuration initialization utilities."""
|
||||
from ultralytics.cfg import check_dict_alignment, copy_default_cfg, smart_value
|
||||
|
||||
with contextlib.suppress(SyntaxError):
|
||||
|
|
@ -334,6 +367,7 @@ def test_cfg_init():
|
|||
|
||||
|
||||
def test_utils_init():
|
||||
"""Test initialization utilities."""
|
||||
from ultralytics.utils import get_git_branch, get_git_origin_url, get_ubuntu_version, is_github_actions_ci
|
||||
|
||||
get_ubuntu_version()
|
||||
|
|
@ -343,6 +377,7 @@ def test_utils_init():
|
|||
|
||||
|
||||
def test_utils_checks():
|
||||
"""Test various utility checks."""
|
||||
checks.check_yolov5u_filename('yolov5n.pt')
|
||||
checks.git_describe(ROOT)
|
||||
checks.check_requirements() # check requirements.txt
|
||||
|
|
@ -354,12 +389,14 @@ def test_utils_checks():
|
|||
|
||||
|
||||
def test_utils_benchmarks():
|
||||
"""Test model benchmarking."""
|
||||
from ultralytics.utils.benchmarks import ProfileModels
|
||||
|
||||
ProfileModels(['yolov8n.yaml'], imgsz=32, min_time=1, num_timed_runs=3, num_warmup_runs=1).profile()
|
||||
|
||||
|
||||
def test_utils_torchutils():
|
||||
"""Test Torch utility functions."""
|
||||
from ultralytics.nn.modules.conv import Conv
|
||||
from ultralytics.utils.torch_utils import get_flops_with_torch_profiler, profile, time_sync
|
||||
|
||||
|
|
@ -373,12 +410,14 @@ def test_utils_torchutils():
|
|||
|
||||
@pytest.mark.skipif(not ONLINE, reason='environment is offline')
|
||||
def test_utils_downloads():
|
||||
"""Test file download utilities."""
|
||||
from ultralytics.utils.downloads import get_google_drive_file_info
|
||||
|
||||
get_google_drive_file_info('https://drive.google.com/file/d/1cqT-cJgANNrhIHCrEufUYhQ4RqiWG_lJ/view?usp=drive_link')
|
||||
|
||||
|
||||
def test_utils_ops():
|
||||
"""Test various operations utilities."""
|
||||
from ultralytics.utils.ops import (ltwh2xywh, ltwh2xyxy, make_divisible, xywh2ltwh, xywh2xyxy, xywhn2xyxy,
|
||||
xywhr2xyxyxyxy, xyxy2ltwh, xyxy2xywh, xyxy2xywhn, xyxyxyxy2xywhr)
|
||||
|
||||
|
|
@ -396,6 +435,7 @@ def test_utils_ops():
|
|||
|
||||
|
||||
def test_utils_files():
|
||||
"""Test file handling utilities."""
|
||||
from ultralytics.utils.files import file_age, file_date, get_latest_run, spaces_in_path
|
||||
|
||||
file_age(SOURCE)
|
||||
|
|
@ -409,6 +449,7 @@ def test_utils_files():
|
|||
|
||||
|
||||
def test_nn_modules_conv():
|
||||
"""Test Convolutional Neural Network modules."""
|
||||
from ultralytics.nn.modules.conv import CBAM, Conv2, ConvTranspose, DWConvTranspose2d, Focus
|
||||
|
||||
c1, c2 = 8, 16 # input and output channels
|
||||
|
|
@ -427,6 +468,7 @@ def test_nn_modules_conv():
|
|||
|
||||
|
||||
def test_nn_modules_block():
|
||||
"""Test Neural Network block modules."""
|
||||
from ultralytics.nn.modules.block import C1, C3TR, BottleneckCSP, C3Ghost, C3x
|
||||
|
||||
c1, c2 = 8, 16 # input and output channels
|
||||
|
|
@ -442,6 +484,7 @@ def test_nn_modules_block():
|
|||
|
||||
@pytest.mark.skipif(not ONLINE, reason='environment is offline')
|
||||
def test_hub():
|
||||
"""Test Ultralytics HUB functionalities."""
|
||||
from ultralytics.hub import export_fmts_hub, logout
|
||||
from ultralytics.hub.utils import smart_request
|
||||
|
||||
|
|
@ -453,6 +496,7 @@ def test_hub():
|
|||
@pytest.mark.slow
|
||||
@pytest.mark.skipif(not ONLINE, reason='environment is offline')
|
||||
def test_triton():
|
||||
"""Test NVIDIA Triton Server functionalities."""
|
||||
checks.check_requirements('tritonclient[all]')
|
||||
import subprocess
|
||||
import time
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue