|
|
@ -1,11 +1,11 @@
|
|
|
|
import torch
|
|
|
|
import torch
|
|
|
|
|
|
|
|
|
|
|
|
from ultralytics.yolo import YOLO
|
|
|
|
from ultralytics import YOLO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_model_forward():
|
|
|
|
def test_model_forward():
|
|
|
|
model = YOLO()
|
|
|
|
model = YOLO()
|
|
|
|
model.new("yolov8n-seg.yaml")
|
|
|
|
model.new("yolov8n.yaml")
|
|
|
|
img = torch.rand(512 * 512 * 3).view(1, 3, 512, 512)
|
|
|
|
img = torch.rand(512 * 512 * 3).view(1, 3, 512, 512)
|
|
|
|
model.forward(img)
|
|
|
|
model.forward(img)
|
|
|
|
model(img)
|
|
|
|
model(img)
|
|
|
@ -15,7 +15,7 @@ def test_model_info():
|
|
|
|
model = YOLO()
|
|
|
|
model = YOLO()
|
|
|
|
model.new("yolov8n.yaml")
|
|
|
|
model.new("yolov8n.yaml")
|
|
|
|
model.info()
|
|
|
|
model.info()
|
|
|
|
model.load("balloon-detect.pt")
|
|
|
|
model.load("best.pt")
|
|
|
|
model.info(verbose=True)
|
|
|
|
model.info(verbose=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -23,35 +23,35 @@ def test_model_fuse():
|
|
|
|
model = YOLO()
|
|
|
|
model = YOLO()
|
|
|
|
model.new("yolov8n.yaml")
|
|
|
|
model.new("yolov8n.yaml")
|
|
|
|
model.fuse()
|
|
|
|
model.fuse()
|
|
|
|
model.load("balloon-detect.pt")
|
|
|
|
model.load("best.pt")
|
|
|
|
model.fuse()
|
|
|
|
model.fuse()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_visualize_preds():
|
|
|
|
def test_visualize_preds():
|
|
|
|
model = YOLO()
|
|
|
|
model = YOLO()
|
|
|
|
model.load("balloon-segment.pt")
|
|
|
|
model.load("best.pt")
|
|
|
|
model.predict(source="ultralytics/assets")
|
|
|
|
model.predict(source="ultralytics/assets")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_val():
|
|
|
|
def test_val():
|
|
|
|
model = YOLO()
|
|
|
|
model = YOLO()
|
|
|
|
model.load("balloon-segment.pt")
|
|
|
|
model.load("best.pt")
|
|
|
|
model.val(data="coco128-seg.yaml", imgsz=32)
|
|
|
|
model.val(data="coco128.yaml", imgsz=32)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_model_resume():
|
|
|
|
def test_model_resume():
|
|
|
|
model = YOLO()
|
|
|
|
model = YOLO()
|
|
|
|
model.new("yolov8n-seg.yaml")
|
|
|
|
model.new("yolov8n.yaml")
|
|
|
|
model.train(epochs=1, imgsz=32, data="coco128-seg.yaml")
|
|
|
|
model.train(epochs=1, imgsz=32, data="coco128.yaml")
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
model.resume(task="segment")
|
|
|
|
model.resume(task="detect")
|
|
|
|
except AssertionError:
|
|
|
|
except AssertionError:
|
|
|
|
print("Successfully caught resume assert!")
|
|
|
|
print("Successfully caught resume assert!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_model_train_pretrained():
|
|
|
|
def test_model_train_pretrained():
|
|
|
|
model = YOLO()
|
|
|
|
model = YOLO()
|
|
|
|
model.load("balloon-detect.pt")
|
|
|
|
model.load("best.pt")
|
|
|
|
model.train(data="coco128.yaml", epochs=1, imgsz=32)
|
|
|
|
model.train(data="coco128.yaml", epochs=1, imgsz=32)
|
|
|
|
model.new("yolov8n.yaml")
|
|
|
|
model.new("yolov8n.yaml")
|
|
|
|
model.train(data="coco128.yaml", epochs=1, imgsz=32)
|
|
|
|
model.train(data="coco128.yaml", epochs=1, imgsz=32)
|
|
|
|