diff --git a/.travis.yml b/.travis.yml index 35a68d79cc4110c7799d6c635d6b32df02d2835b..30595047a49ab69cb0bca017e881c7c7586c75c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,39 @@ dist: xenial language: python -install: - - pip install isort flake8 yapf - python: - "3.5" - "3.6" - "3.7" +env: CUDA=9.2.148-1 CUDA_SHORT=9.2 UBUNTU_VERSION=ubuntu1604 + +# Ref to CUDA installation in Travis: https://github.com/jeremad/cuda-travis +before_install: + - INSTALLER=cuda-repo-${UBUNTU_VERSION}_${CUDA}_amd64.deb + - wget http://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/x86_64/${INSTALLER} + - sudo dpkg -i ${INSTALLER} + - wget https://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/x86_64/7fa2af80.pub + - sudo apt-key add 7fa2af80.pub + - sudo apt update -qq + - sudo apt install -y cuda-${CUDA_SHORT/./-} cuda-cufft-dev-${CUDA_SHORT/./-} + - sudo apt clean + - CUDA_HOME=/usr/local/cuda-${CUDA_SHORT} + - LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${CUDA_HOME}/include:${LD_LIBRARY_PATH} + - PATH=${CUDA_HOME}/bin:${PATH} + +install: + - pip install Cython + - pip install -r requirements.txt + - pip install -r tests/requirements.txt + script: - - flake8 - - isort -rc --check-only --diff mmdet/ tools/ - - yapf -r -d --style .style.yapf mmdet/ tools/ \ No newline at end of file + - flake8 . + - isort -rc --check-only --diff mmdet/ tools/ tests/ + - yapf -r -d --style .style.yapf mmdet/ tools/ tests/ + - python setup.py check -m -s + - python setup.py build_ext --inplace + - coverage run --source mmdet -m py.test tests -v --doctest-modules + +after_success: + - coverage report \ No newline at end of file diff --git a/mmdet/utils/flops_counter.py b/mmdet/utils/flops_counter.py index 3005a14fc02e2b97232c94c786489d1a9c936799..5d9cdfce82b0e63c55eb08419a01c924127e9e2e 100644 --- a/mmdet/utils/flops_counter.py +++ b/mmdet/utils/flops_counter.py @@ -101,6 +101,18 @@ def flops_to_string(flops, units='GMac', precision=2): def params_to_string(params_num): + """converting number to string + + :param float params_num: number + :returns str: number + + >>> params_to_string(1e9) + '1000.0 M' + >>> params_to_string(2e5) + '200.0 k' + >>> params_to_string(3e-9) + '3e-09' + """ if params_num // 10**6 > 0: return str(round(params_num / 10**6, 2)) + ' M' elif params_num // 10**3: diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..f39f962db99168354384682459fa22a3ea860280 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,9 @@ +mmcv>=0.2.10 +numpy +matplotlib +six +terminaltables +pycocotools +torch>=1.1 +torchvision +imagecorruptions \ No newline at end of file diff --git a/setup.py b/setup.py index cf3a6e1d7c6d25509e6c54abe124a6a4a06865f2..976cc4bde23e2dd54433379e280a1fd2df543dd1 100644 --- a/setup.py +++ b/setup.py @@ -126,6 +126,8 @@ if __name__ == '__main__': version=get_version(), description='Open MMLab Detection Toolbox and Benchmark', long_description=readme(), + author='OpenMMLab', + author_email='chenkaidev@gmail.com', keywords='computer vision, object detection', url='https://github.com/open-mmlab/mmdetection', packages=find_packages(exclude=('configs', 'tools', 'demo')), diff --git a/tests/requirements.txt b/tests/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..4eced7995e77c429dfdc489483e17da24afcdefc --- /dev/null +++ b/tests/requirements.txt @@ -0,0 +1,5 @@ +isort +flake8 +yapf +pytest-cov +codecov \ No newline at end of file diff --git a/tests/test_utils.py b/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..cdefd2df21816b23258e20ebc7828d356a6dfcee --- /dev/null +++ b/tests/test_utils.py @@ -0,0 +1,9 @@ +import numpy.testing as npt + +from mmdet.utils.flops_counter import params_to_string + + +def test_params_to_string(): + npt.assert_equal(params_to_string(1e9), '1000.0 M') + npt.assert_equal(params_to_string(2e5), '200.0 k') + npt.assert_equal(params_to_string(3e-9), '3e-09')