New YOLOv8 Results() class for prediction outputs (#314)
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: Laughing-q <1185102784@qq.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Laughing <61612323+Laughing-q@users.noreply.github.com> Co-authored-by: Viet Nhat Thai <60825385+vietnhatthai@users.noreply.github.com> Co-authored-by: Paula Derrenger <107626595+pderrenger@users.noreply.github.com>
This commit is contained in:
parent
0cb87f7dd3
commit
c6985da9de
32 changed files with 813 additions and 259 deletions
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
from pathlib import Path
|
||||
|
||||
import cv2
|
||||
import torch
|
||||
from PIL import Image
|
||||
|
||||
from ultralytics import YOLO
|
||||
from ultralytics.yolo.utils import ROOT, SETTINGS
|
||||
|
||||
|
|
@ -35,6 +39,21 @@ def test_predict_dir():
|
|||
model.predict(source=ROOT / "assets")
|
||||
|
||||
|
||||
def test_predict_img():
|
||||
model = YOLO(MODEL)
|
||||
img = Image.open(str(SOURCE))
|
||||
output = model(source=img, save=True, verbose=True) # PIL
|
||||
assert len(output) == 1, "predict test failed"
|
||||
img = cv2.imread(str(SOURCE))
|
||||
output = model(source=img, save=True, save_txt=True) # ndarray
|
||||
assert len(output) == 1, "predict test failed"
|
||||
output = model(source=[img, img], save=True, save_txt=True) # batch
|
||||
assert len(output) == 2, "predict test failed"
|
||||
tens = torch.zeros(320, 640, 3)
|
||||
output = model(tens.numpy())
|
||||
assert len(output) == 1, "predict test failed"
|
||||
|
||||
|
||||
def test_val():
|
||||
model = YOLO(MODEL)
|
||||
model.val(data="coco8.yaml", imgsz=32)
|
||||
|
|
@ -106,3 +125,7 @@ def test_workflow():
|
|||
model.val()
|
||||
model.predict(SOURCE)
|
||||
model.export(format="onnx", opset=12) # export a model to ONNX format
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_predict_img()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue