ultralytics 8.0.157
fix unzip_file()
bug (#4407)
Co-authored-by: Nadim Bou Alwan <64587372+nadinator@users.noreply.github.com>
This commit is contained in:
@ -7,7 +7,7 @@ import pytest
|
||||
|
||||
from ultralytics.utils import ROOT, SETTINGS
|
||||
|
||||
WEIGHT_DIR = Path(SETTINGS['weights_dir'])
|
||||
WEIGHTS_DIR = Path(SETTINGS['weights_dir'])
|
||||
TASK_ARGS = [
|
||||
('detect', 'yolov8n', 'coco8.yaml'),
|
||||
('segment', 'yolov8n-seg', 'coco8-seg.yaml'),
|
||||
@ -40,17 +40,17 @@ def test_train(task, model, data):
|
||||
|
||||
@pytest.mark.parametrize('task,model,data', TASK_ARGS)
|
||||
def test_val(task, model, data):
|
||||
run(f'yolo val {task} model={WEIGHT_DIR / model}.pt data={data} imgsz=32')
|
||||
run(f'yolo val {task} model={WEIGHTS_DIR / model}.pt data={data} imgsz=32')
|
||||
|
||||
|
||||
@pytest.mark.parametrize('task,model,data', TASK_ARGS)
|
||||
def test_predict(task, model, data):
|
||||
run(f"yolo predict model={WEIGHT_DIR / model}.pt source={ROOT / 'assets'} imgsz=32 save save_crop save_txt")
|
||||
run(f"yolo predict model={WEIGHTS_DIR / model}.pt source={ROOT / 'assets'} imgsz=32 save save_crop save_txt")
|
||||
|
||||
|
||||
@pytest.mark.parametrize('model,format', EXPORT_ARGS)
|
||||
def test_export(model, format):
|
||||
run(f'yolo export model={WEIGHT_DIR / model}.pt format={format} imgsz=32')
|
||||
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'):
|
||||
@ -59,7 +59,7 @@ def test_rtdetr(task='detect', model='yolov8n-rtdetr.yaml', data='coco8.yaml'):
|
||||
run(f"yolo predict {task} model={model} source={ROOT / 'assets/bus.jpg'} imgsz=640 save save_crop save_txt")
|
||||
|
||||
|
||||
def test_fastsam(task='segment', model=WEIGHT_DIR / 'FastSAM-s.pt', data='coco8-seg.yaml'):
|
||||
def test_fastsam(task='segment', model=WEIGHTS_DIR / 'FastSAM-s.pt', data='coco8-seg.yaml'):
|
||||
source = ROOT / 'assets/bus.jpg'
|
||||
|
||||
run(f'yolo segment val {task} model={model} data={data} imgsz=32')
|
||||
@ -95,7 +95,7 @@ def test_mobilesam():
|
||||
from ultralytics import SAM
|
||||
|
||||
# Load the model
|
||||
model = SAM(WEIGHT_DIR / 'mobile_sam.pt')
|
||||
model = SAM(WEIGHTS_DIR / 'mobile_sam.pt')
|
||||
|
||||
# Source
|
||||
source = ROOT / 'assets/zidane.jpg'
|
||||
|
@ -26,7 +26,7 @@ TMP = (ROOT / '../tests/tmp').resolve() # temp directory for test files
|
||||
|
||||
def test_model_forward():
|
||||
model = YOLO(CFG)
|
||||
model(SOURCE, imgsz=32)
|
||||
model(SOURCE, imgsz=32, augment=True)
|
||||
|
||||
|
||||
def test_model_info():
|
||||
@ -120,8 +120,8 @@ def test_train_scratch():
|
||||
|
||||
|
||||
def test_train_pretrained():
|
||||
model = YOLO(MODEL)
|
||||
model.train(data='coco8.yaml', epochs=1, imgsz=32, cache='ram') # test RAM caching
|
||||
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) # test RAM caching
|
||||
model(SOURCE)
|
||||
|
||||
|
||||
@ -232,7 +232,8 @@ def test_results():
|
||||
@pytest.mark.skipif(not ONLINE, reason='environment is offline')
|
||||
def test_data_utils():
|
||||
# Test functions in ultralytics/data/utils.py
|
||||
from ultralytics.data.utils import HUBDatasetStats, autosplit, zip_directory
|
||||
from ultralytics.data.utils import HUBDatasetStats, autosplit
|
||||
from ultralytics.utils.downloads import zip_directory
|
||||
|
||||
# from ultralytics.utils.files import WorkingDirectory
|
||||
# with WorkingDirectory(ROOT.parent / 'tests'):
|
||||
@ -240,7 +241,7 @@ def test_data_utils():
|
||||
download('https://github.com/ultralytics/hub/raw/master/example_datasets/coco8.zip', unzip=False)
|
||||
shutil.move('coco8.zip', TMP)
|
||||
stats = HUBDatasetStats(TMP / 'coco8.zip', task='detect')
|
||||
stats.get_json(save=False)
|
||||
stats.get_json(save=True)
|
||||
stats.process_images()
|
||||
|
||||
autosplit(TMP / 'coco8')
|
||||
@ -267,3 +268,11 @@ def test_events():
|
||||
cfg = copy(DEFAULT_CFG) # does not require deepcopy
|
||||
cfg.mode = 'test'
|
||||
events(cfg)
|
||||
|
||||
|
||||
def test_utils_checks():
|
||||
from ultralytics.utils.checks import check_yolov5u_filename, git_describe
|
||||
|
||||
check_yolov5u_filename('yolov5.pt')
|
||||
# check_imshow(warn=True)
|
||||
git_describe(ROOT)
|
||||
|
Reference in New Issue
Block a user