Пример #1
0
def test_from_array():
    array = np.array([1, 2, 3, 4, 5, 6, 7, 8], dtype=np.float32)

    b = Box.from_array(array)

    assert 1 == b.x
    assert isinstance(b.x, float)
    assert 2 == b.y
    assert isinstance(b.y, float)
    assert 3 == b.w
    assert isinstance(b.w, float)
    assert 4 == b.h
    assert isinstance(b.h, float)
    assert 5 == b.objectness
    assert isinstance(b.objectness, float)
    assert [float(x) for x in range(6, 9)] == b.classes
    for c in b.classes:
        assert isinstance(c, float)
Пример #2
0
def test_corners():
    assert Box(100, 50, 60, 20).corners() == (70, 40, 130, 60)
    assert Box(100, 50, 60, 15).corners() == (70, 42, 130, 57)
Пример #3
0
def test_iou_wrong_parameter():
    b = Box(10, 10, 10, 10)

    with pytest.raises(AssertionError):
        b.iou(10)
Пример #4
0
def test_iou(b2_args, iou):
    b1 = Box(100, 50, 60, 20)
    b2 = Box(*b2_args)

    assert iou == b1.iou(b2)
    assert iou == b2.iou(b1)
Пример #5
0
def test_intersection_wrong_parameter():
    b = Box(10, 10, 10, 10)

    with pytest.raises(AssertionError):
        b.intersection(10)
Пример #6
0
def test_intersection(b2_args, isect):
    b1 = Box(100, 50, 60, 20)
    b2 = Box(*b2_args)

    assert isect == b1.intersection(b2)
    assert isect == b2.intersection(b1)
Пример #7
0
def test_to_list():
    array = np.array([1, 2, 3, 4, 5, 6, 7, 8], dtype=np.float32)

    b = Box.from_array(array)
    assert [1., 2., 3., 4., 5., 6., 7., 8.] == b.to_list()