File size: 1,150 Bytes
80b99e5
 
7a1e317
 
80b99e5
7a1e317
 
 
 
 
 
 
80b99e5
7a1e317
 
 
 
 
190be42
7a1e317
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import pytest
import numpy as np
from app import YOLOv8Model, preprocess_frame
import cv2

def test_yolo_model_initialization():
    """Test YOLO model can be initialized"""
    try:
        model = YOLOv8Model()
        assert model.model is not None, "YOLO model should be initialized"
    except Exception as e:
        pytest.skip(f"Model initialization failed: {e}")

def test_preprocess_frame():
    """Test frame preprocessing"""
    # Create a test frame
    frame = np.random.randint(0, 255, (480, 640, 3), dtype=np.uint8)
    processed = preprocess_frame(frame)
    
    assert processed.shape == (640, 640, 3), "Processed frame should be 640x640x3"
    assert processed.dtype == np.uint8, "Processed frame should be uint8"

def test_yolo_prediction():
    """Test YOLO prediction on dummy image"""
    try:
        model = YOLOv8Model()
        # Create a dummy image
        image = np.random.randint(0, 255, (640, 640, 3), dtype=np.uint8)
        results = model.predict(image)
        assert results is not None, "YOLO prediction should return results"
    except Exception as e:
        pytest.skip(f"YOLO prediction test failed: {e}")