mirror of
https://github.com/Bing-su/adetailer.git
synced 2026-04-30 19:21:33 +00:00
test: pytests
This commit is contained in:
48
tests/test_ultralytics.py
Normal file
48
tests/test_ultralytics.py
Normal file
@@ -0,0 +1,48 @@
|
||||
import pytest
|
||||
from huggingface_hub import hf_hub_download
|
||||
from PIL import Image
|
||||
|
||||
from adetailer.ultralytics import ultralytics_predict
|
||||
|
||||
repo_id = "Bingsu/adetailer"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"model_name",
|
||||
[
|
||||
"face_yolov8n.pt",
|
||||
"face_yolov8n_v2.pt",
|
||||
"face_yolov8s.pt",
|
||||
"hand_yolov8n.pt",
|
||||
"hand_yolov8s.pt",
|
||||
"person_yolov8n-seg.pt",
|
||||
"person_yolov8s-seg.pt",
|
||||
"person_yolov8m-seg.pt",
|
||||
"deepfashion2_yolov8s-seg.pt",
|
||||
],
|
||||
)
|
||||
def test_ultralytics_hf_models(sample_image: Image.Image, model_name: str):
|
||||
model_path = hf_hub_download(repo_id, model_name)
|
||||
result = ultralytics_predict(model_path, sample_image)
|
||||
assert result.preview is not None
|
||||
|
||||
|
||||
def test_yolo_world_default(sample_image: Image.Image):
|
||||
result = ultralytics_predict("yolov8l-world.pt", sample_image)
|
||||
assert result.preview is not None
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"klass",
|
||||
[
|
||||
"person",
|
||||
"bird",
|
||||
"yellow bird",
|
||||
"person,glasses,headphone",
|
||||
"person,bird",
|
||||
"glasses,yellow bird",
|
||||
],
|
||||
)
|
||||
def test_yolo_world(sample_image2: Image.Image, klass: str):
|
||||
result = ultralytics_predict("yolov8l-world.pt", sample_image2, classes=klass)
|
||||
assert result.preview is not None
|
||||
Reference in New Issue
Block a user