forked from majiaqi/OpenCDA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_ml_manager.py
35 lines (27 loc) · 1.05 KB
/
test_ml_manager.py
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
33
34
35
# -*- coding: utf-8 -*-
"""
Unit test for ML Manager.
"""
# Author: Runsheng Xu <[email protected]>
# License: MIT
import os
import sys
import unittest
import cv2
import numpy as np
# temporary solution for relative imports in case opencda is not installed
# if opencda is installed, no need to use the following line
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '.')))
from opencda.customize.ml_libs.ml_manager import MLManager
class TestMlManager(unittest.TestCase):
def setUp(self):
current_path = os.path.dirname(os.path.realpath(__file__))
self.data = cv2.imread(os.path.join(current_path, 'data/test.jpg'))
self.ml_manager = MLManager()
def test_parameters(self):
assert self.ml_manager.object_detector
def test_draw_2d_bbx(self):
results = self.ml_manager.object_detector(self.data)
assert len(results) == 1
assert self.ml_manager.draw_2d_box(results, self.data, 0).shape == self.data.shape