Simplify usage, remove YOLO.new() and YOLO.load()
This commit is contained in:
@ -4,7 +4,7 @@ from ultralytics.yolo.utils import ROOT
|
||||
if __name__ == "__main__":
|
||||
for m in list((ROOT / 'yolo/v8/models').rglob('*.yaml')):
|
||||
try:
|
||||
YOLO.new(m.name, verbose=True)
|
||||
YOLO(m.name, verbose=True)
|
||||
except Exception as e:
|
||||
print(f'ERROR for {m}: {e}')
|
||||
|
||||
|
@ -4,7 +4,7 @@ from ultralytics import YOLO
|
||||
|
||||
|
||||
def test_model_init():
|
||||
model = YOLO.new("yolov8n.yaml")
|
||||
model = YOLO("yolov8n.yaml")
|
||||
model.info()
|
||||
try:
|
||||
YOLO()
|
||||
@ -14,38 +14,38 @@ def test_model_init():
|
||||
|
||||
|
||||
def test_model_forward():
|
||||
model = YOLO.new("yolov8n.yaml")
|
||||
model = YOLO("yolov8n.yaml")
|
||||
img = torch.rand(512 * 512 * 3).view(1, 3, 512, 512)
|
||||
model.forward(img)
|
||||
model(img)
|
||||
|
||||
|
||||
def test_model_info():
|
||||
model = YOLO.new("yolov8n.yaml")
|
||||
model = YOLO("yolov8n.yaml")
|
||||
model.info()
|
||||
model = model.load("best.pt")
|
||||
model.info(verbose=True)
|
||||
|
||||
|
||||
def test_model_fuse():
|
||||
model = YOLO.new("yolov8n.yaml")
|
||||
model = YOLO("yolov8n.yaml")
|
||||
model.fuse()
|
||||
model.load("best.pt")
|
||||
model.fuse()
|
||||
|
||||
|
||||
def test_visualize_preds():
|
||||
model = YOLO.load("best.pt")
|
||||
model = YOLO("best.pt")
|
||||
model.predict(source="ultralytics/assets")
|
||||
|
||||
|
||||
def test_val():
|
||||
model = YOLO.load("best.pt")
|
||||
model = YOLO("best.pt")
|
||||
model.val(data="coco128.yaml", imgsz=32)
|
||||
|
||||
|
||||
def test_model_resume():
|
||||
model = YOLO.new("yolov8n.yaml")
|
||||
model = YOLO("yolov8n.yaml")
|
||||
model.train(epochs=1, imgsz=32, data="coco128.yaml")
|
||||
try:
|
||||
model.resume(task="detect")
|
||||
@ -54,7 +54,7 @@ def test_model_resume():
|
||||
|
||||
|
||||
def test_model_train_pretrained():
|
||||
model = YOLO.load("best.pt")
|
||||
model = YOLO("best.pt")
|
||||
model.train(data="coco128.yaml", epochs=1, imgsz=32)
|
||||
model = model.new("yolov8n.yaml")
|
||||
model.train(data="coco128.yaml", epochs=1, imgsz=32)
|
||||
@ -83,7 +83,7 @@ def test_exports():
|
||||
|
||||
print(export_formats())
|
||||
|
||||
model = YOLO.new("yolov8n.yaml")
|
||||
model = YOLO("yolov8n.yaml")
|
||||
model.export(format='torchscript')
|
||||
model.export(format='onnx')
|
||||
model.export(format='openvino')
|
||||
|
Reference in New Issue
Block a user