Skip to content

Commit

Permalink
fix(test_predictor): dont test MultiprocessPredictor
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulHax committed Jan 30, 2025
1 parent 7c4a0d6 commit 54c0fed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ dependencies = [
"nrtk[headless]==0.19.1",
"trame-annotations>=0.4.0",
"kwcoco",
"psutil",
]

[project.optional-dependencies]
Expand Down
12 changes: 4 additions & 8 deletions tests/test_predictor.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import pytest
from nrtk_explorer.library.predictor import Predictor
from nrtk_explorer.library.multiprocess_predictor import MultiprocessPredictor
from nrtk_explorer.library.scoring import compute_score
from nrtk_explorer.library.dataset import get_dataset
from utils import get_images, DATASET
import asyncio


def test_predictor_small():
Expand All @@ -16,25 +14,23 @@ def test_predictor_small():

@pytest.fixture
def predictor():
predictor = MultiprocessPredictor(model_name="facebook/detr-resnet-50")
yield predictor
predictor.shutdown()
return Predictor(model_name="facebook/detr-resnet-50")


def test_detect(predictor):
"""Test the detect method with sample images."""
images = get_images()
results = asyncio.run(predictor.infer(images))
results = predictor.eval(images)
assert len(results) == len(images), "Number of results should match number of images"
for img_id, preds in results.items():
assert isinstance(preds, list), f"Predictions for {img_id} should be a list"


def test_set_model(predictor):
"""Test setting a new model and performing detection."""
predictor.set_model(model_name="hustvl/yolos-tiny")
predictor.pipeline = "hustvl/yolos-tiny"
images = get_images()
results = asyncio.run(predictor.infer(images))
results = predictor.eval(images)
assert len(results) == len(
images
), "Number of results should match number of images after setting new model"
Expand Down

0 comments on commit 54c0fed

Please sign in to comment.