Skip to content

Commit

Permalink
👮 updating tests to simulate yolo8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
rbturnbull committed Feb 25, 2024
1 parent e61e5f2 commit 6d3e570
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tests/test_yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@

class MockBoxes():
def __init__(self, boxes):
self.boxes = torch.tensor(boxes)
self.xyxy = torch.tensor([boxes[0:4]])
self.cls = torch.tensor(boxes[-1])


class MockImageResult():
def __init__(self, boxes):
self.boxes = MockBoxes(boxes)
self.boxes = [MockBoxes(box) for box in boxes]


class MockYoloOutput():
Expand Down Expand Up @@ -47,22 +48,22 @@ def __init__(self, *args):
def setup_model(self, model):
pass


class MockYoloModel():
predictor = None
model = None
names = [str(x) for x in range(4)]

def predict(self, source, show=False, save=True, batch=4, imgsz=1280):
for index, image in enumerate(source):
shutil.copy(image, self.predictor.save_dir/f"image{index}.jpg" )
shutil.copy(image, self.predictor.save_dir/image.name )

return MockYoloOutput(source)

def to(self, device):
self.device = device



@patch('hespi.yolo.DetectionPredictor', return_value=MockYoloPredictor())
def test_yolo_output(mock_detection_predictor):
base_dir = Path(__file__).parent/"testdata"
Expand Down

0 comments on commit 6d3e570

Please sign in to comment.