ultralytics 8.0.105
classification hyp fix and new onplot
callbacks (#2684)
Co-authored-by: ayush chaurasia <ayush.chaurarsia@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Ivan Shcheklein <shcheklein@gmail.com>
This commit is contained in:
19
tests/conftest.py
Normal file
19
tests/conftest.py
Normal file
@ -0,0 +1,19 @@
|
||||
import pytest
|
||||
|
||||
|
||||
def pytest_addoption(parser):
|
||||
parser.addoption('--runslow', action='store_true', default=False, help='run slow tests')
|
||||
|
||||
|
||||
def pytest_configure(config):
|
||||
config.addinivalue_line('markers', 'slow: mark test as slow to run')
|
||||
|
||||
|
||||
def pytest_collection_modifyitems(config, items):
|
||||
if config.getoption('--runslow'):
|
||||
# --runslow given in cli: do not skip slow tests
|
||||
return
|
||||
skip_slow = pytest.mark.skip(reason='need --runslow option to run')
|
||||
for item in items:
|
||||
if 'slow' in item.keywords:
|
||||
item.add_marker(skip_slow)
|
@ -3,10 +3,17 @@
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
from ultralytics.yolo.utils import LINUX, ONLINE, ROOT, SETTINGS
|
||||
import pytest
|
||||
|
||||
MODEL = Path(SETTINGS['weights_dir']) / 'yolov8n'
|
||||
CFG = 'yolov8n'
|
||||
from ultralytics.yolo.utils import ONLINE, ROOT, SETTINGS
|
||||
|
||||
WEIGHT_DIR = Path(SETTINGS['weights_dir'])
|
||||
TASK_ARGS = [ # (task, model, data)
|
||||
('detect', 'yolov8n', 'coco8.yaml'), ('segment', 'yolov8n-seg', 'coco8-seg.yaml'),
|
||||
('classify', 'yolov8n-cls', 'imagenet10'), ('pose', 'yolov8n-pose', 'coco8-pose.yaml')]
|
||||
EXPORT_ARGS = [ # (model, format)
|
||||
('yolov8n', 'torchscript'), ('yolov8n-seg', 'torchscript'), ('yolov8n-cls', 'torchscript'),
|
||||
('yolov8n-pose', 'torchscript')]
|
||||
|
||||
|
||||
def run(cmd):
|
||||
@ -20,78 +27,33 @@ def test_special_modes():
|
||||
run('yolo help')
|
||||
|
||||
|
||||
# Train checks ---------------------------------------------------------------------------------------------------------
|
||||
def test_train_det():
|
||||
run(f'yolo train detect model={CFG}.yaml data=coco8.yaml imgsz=32 epochs=1 v5loader')
|
||||
@pytest.mark.parametrize('task,model,data', TASK_ARGS)
|
||||
def test_train(task, model, data):
|
||||
run(f'yolo train {task} model={model}.yaml data={data} imgsz=32 epochs=1')
|
||||
|
||||
|
||||
def test_train_seg():
|
||||
run(f'yolo train segment model={CFG}-seg.yaml data=coco8-seg.yaml imgsz=32 epochs=1')
|
||||
@pytest.mark.parametrize('task,model,data', TASK_ARGS)
|
||||
def test_val(task, model, data):
|
||||
run(f'yolo val {task} model={model}.pt data={data} imgsz=32')
|
||||
|
||||
|
||||
def test_train_cls():
|
||||
run(f'yolo train classify model={CFG}-cls.yaml data=imagenet10 imgsz=32 epochs=1')
|
||||
|
||||
|
||||
def test_train_pose():
|
||||
run(f'yolo train pose model={CFG}-pose.yaml data=coco8-pose.yaml imgsz=32 epochs=1')
|
||||
|
||||
|
||||
# Val checks -----------------------------------------------------------------------------------------------------------
|
||||
def test_val_detect():
|
||||
run(f'yolo val detect model={MODEL}.pt data=coco8.yaml imgsz=32')
|
||||
|
||||
|
||||
def test_val_segment():
|
||||
run(f'yolo val segment model={MODEL}-seg.pt data=coco8-seg.yaml imgsz=32')
|
||||
|
||||
|
||||
def test_val_classify():
|
||||
run(f'yolo val classify model={MODEL}-cls.pt data=imagenet10 imgsz=32')
|
||||
|
||||
|
||||
def test_val_pose():
|
||||
run(f'yolo val pose model={MODEL}-pose.pt data=coco8-pose.yaml imgsz=32')
|
||||
|
||||
|
||||
# Predict checks -------------------------------------------------------------------------------------------------------
|
||||
def test_predict_detect():
|
||||
run(f"yolo predict model={MODEL}.pt source={ROOT / 'assets'} imgsz=32 save save_crop save_txt")
|
||||
@pytest.mark.parametrize('task,model,data', TASK_ARGS)
|
||||
def test_predict(task, model, data):
|
||||
run(f"yolo predict model={model}.pt source={ROOT / 'assets'} imgsz=32 save save_crop save_txt")
|
||||
if ONLINE:
|
||||
run(f'yolo predict model={MODEL}.pt source=https://ultralytics.com/images/bus.jpg imgsz=32')
|
||||
run(f'yolo predict model={MODEL}.pt source=https://ultralytics.com/assets/decelera_landscape_min.mov imgsz=32')
|
||||
run(f'yolo predict model={MODEL}.pt source=https://ultralytics.com/assets/decelera_portrait_min.mov imgsz=32')
|
||||
run(f'yolo predict model={model}.pt source=https://ultralytics.com/images/bus.jpg imgsz=32')
|
||||
run(f'yolo predict model={model}.pt source=https://ultralytics.com/assets/decelera_landscape_min.mov imgsz=32')
|
||||
run(f'yolo predict model={model}.pt source=https://ultralytics.com/assets/decelera_portrait_min.mov imgsz=32')
|
||||
|
||||
|
||||
def test_predict_segment():
|
||||
run(f"yolo predict model={MODEL}-seg.pt source={ROOT / 'assets'} imgsz=32 save save_txt")
|
||||
@pytest.mark.parametrize('model,format', EXPORT_ARGS)
|
||||
def test_export(model, format):
|
||||
run(f'yolo export model={model}.pt format={format}')
|
||||
|
||||
|
||||
def test_predict_classify():
|
||||
run(f"yolo predict model={MODEL}-cls.pt source={ROOT / 'assets'} imgsz=32 save save_txt")
|
||||
|
||||
|
||||
def test_predict_pose():
|
||||
run(f"yolo predict model={MODEL}-pose.pt source={ROOT / 'assets'} imgsz=32 save save_txt")
|
||||
|
||||
|
||||
# Export checks --------------------------------------------------------------------------------------------------------
|
||||
def test_export_detect_torchscript():
|
||||
run(f'yolo export model={MODEL}.pt format=torchscript')
|
||||
|
||||
|
||||
def test_export_segment_torchscript():
|
||||
run(f'yolo export model={MODEL}-seg.pt format=torchscript')
|
||||
|
||||
|
||||
def test_export_classify_torchscript():
|
||||
run(f'yolo export model={MODEL}-cls.pt format=torchscript')
|
||||
|
||||
|
||||
def test_export_classify_pose():
|
||||
run(f'yolo export model={MODEL}-pose.pt format=torchscript')
|
||||
|
||||
|
||||
def test_export_detect_edgetpu(enabled=False):
|
||||
if enabled and LINUX:
|
||||
run(f'yolo export model={MODEL}.pt format=edgetpu')
|
||||
# Slow Tests
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.parametrize('task,model,data', TASK_ARGS)
|
||||
def test_train_gpu(task, model, data):
|
||||
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
|
||||
|
Reference in New Issue
Block a user