Skip to content

Commit

Permalink
test on ml manager done
Browse files Browse the repository at this point in the history
  • Loading branch information
DerrickXuNu committed Jun 24, 2021
1 parent ace7312 commit c56eee0
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ python:

install:
- pip install --upgrade pip
- pip install -r requirements.txt
- pip install -r requirements_ci.txt
- pip install pytest
- pip install pytest-cov
- pip install coveralls
Expand All @@ -23,5 +23,5 @@ notifications:
email:
recipients:
- [email protected]
on_success: change # default: change
on_success: never # default: change
on_failure: always # default: always
5 changes: 4 additions & 1 deletion requirements_ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ pygame
scikit-learn==0.24.2
scipy==1.6.3
seaborn
torch
--find-links https://download.pytorch.org/whl/torch_stable.html
torch==1.9.0+cpu
torchvision==0.10.0+cpu
tqdm>=4.41.0
Binary file added test/data/test.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions test/test_ml_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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

0 comments on commit c56eee0

Please sign in to comment.