[CI] Add Circle CI for mmcls 1.x. (#970)
* [CI] Add Circle CI for mmcls 1.x * Fix circle-ci config * Use `torch.cat` instead of `torch.hstack` to compat with PyTorch 1.6 * Compat the behavior of LongTensor in PyTorch 1.6 * Avoid random behavior in the unit test of Lighting * Fix cuda ci * Remove github workflow temporarily.pull/977/head^2
parent
e4252d6848
commit
20f9ace5c5
|
@ -2,238 +2,33 @@
|
|||
# See: https://circleci.com/docs/2.0/configuration-reference
|
||||
version: 2.1
|
||||
|
||||
# Define a job to be invoked later in a workflow.
|
||||
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
|
||||
jobs:
|
||||
lint:
|
||||
docker:
|
||||
- image: cimg/python:3.7.4
|
||||
# Add steps to the job
|
||||
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Install dependencies
|
||||
command: |
|
||||
sudo apt-add-repository ppa:brightbox/ruby-ng -y
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y ruby2.7
|
||||
- run:
|
||||
name: Install pre-commit hook
|
||||
command: |
|
||||
pip install pre-commit
|
||||
pre-commit install
|
||||
- run:
|
||||
name: Linting
|
||||
command: pre-commit run --all-files
|
||||
- run:
|
||||
name: Check docstring coverage
|
||||
command: |
|
||||
pip install interrogate
|
||||
interrogate -v --ignore-init-method --ignore-module --ignore-nested-functions --ignore-regex "__repr__" --fail-under 40 mmcls
|
||||
build:
|
||||
parameters:
|
||||
# The python version must match available image tags in
|
||||
# https://circleci.com/developer/images/image/cimg/python
|
||||
python:
|
||||
type: string
|
||||
default: "3.6.15"
|
||||
torch:
|
||||
type: string
|
||||
torchvision:
|
||||
type: string
|
||||
env:
|
||||
type: string
|
||||
default: ""
|
||||
docker:
|
||||
- image: cimg/python:<< parameters.python >>
|
||||
resource_class: large
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Install Libraries
|
||||
command: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libjpeg8-dev zlib1g-dev
|
||||
- run:
|
||||
name: Configure Python & pip
|
||||
command: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install wheel
|
||||
- run:
|
||||
name: Install PyTorch
|
||||
command: |
|
||||
python -V
|
||||
python -m pip install torch==<< parameters.torch >>+cpu torchvision==<< parameters.torchvision >>+cpu -f https://download.pytorch.org/whl/torch_stable.html
|
||||
- run:
|
||||
name: Install mmcls dependencies
|
||||
command: |
|
||||
python -m pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cpu/torch<< parameters.torch >>/index.html
|
||||
python -m pip install -r requirements.txt
|
||||
- run:
|
||||
name: Build and install
|
||||
command: |
|
||||
python -m pip install -e .
|
||||
- run:
|
||||
name: Run unittests
|
||||
command: |
|
||||
<< parameters.env >> python -m pytest tests/ --ignore tests/test_models/test_backbones/test_timm_backbone.py
|
||||
# This allows you to use CircleCI's dynamic configuration feature
|
||||
setup: true
|
||||
|
||||
build_with_cuda:
|
||||
machine:
|
||||
image: ubuntu-1604-cuda-10.1:201909-23
|
||||
resource_class: gpu.nvidia.small
|
||||
steps:
|
||||
- checkout
|
||||
# - run:
|
||||
# name: Install Libraries
|
||||
# command: |
|
||||
# sudo apt-get update
|
||||
# sudo apt-get install -y libjpeg8-dev zlib1g-dev
|
||||
- run:
|
||||
name: Configure Python & pip
|
||||
command: |
|
||||
pyenv global 3.7.0
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install wheel
|
||||
- run:
|
||||
name: Install PyTorch
|
||||
command: |
|
||||
python -V
|
||||
python -m pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
|
||||
- run:
|
||||
name: Install mmcls dependencies
|
||||
command: |
|
||||
python -m pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.6.0/index.html
|
||||
python -m pip install -r requirements.txt
|
||||
- run:
|
||||
name: Build and install
|
||||
command: |
|
||||
python setup.py check -m -s
|
||||
TORCH_CUDA_ARCH_LIST=7.0 python -m pip install -e .
|
||||
- run:
|
||||
name: Run unittests
|
||||
command: |
|
||||
python -m pytest tests/ --ignore tests/test_models/test_backbones/test_timm_backbone.py
|
||||
# the path-filtering orb is required to continue a pipeline based on
|
||||
# the path of an updated fileset
|
||||
orbs:
|
||||
path-filtering: circleci/path-filtering@0.1.2
|
||||
|
||||
build_with_timm:
|
||||
parameters:
|
||||
# The python version must match available image tags in
|
||||
# https://circleci.com/developer/images/image/cimg/python
|
||||
python:
|
||||
type: string
|
||||
default: "3.7.12"
|
||||
torch:
|
||||
type: string
|
||||
default: "1.10.0"
|
||||
torchvision:
|
||||
type: string
|
||||
default: "0.11.1"
|
||||
docker:
|
||||
- image: cimg/python:<< parameters.python >>
|
||||
resource_class: large
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Install Libraries
|
||||
command: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libjpeg8-dev zlib1g-dev
|
||||
- run:
|
||||
name: Configure Python & pip
|
||||
command: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install wheel
|
||||
- run:
|
||||
name: Install PyTorch
|
||||
command: |
|
||||
python -V
|
||||
python -m pip install torch==<< parameters.torch >>+cpu torchvision==<< parameters.torchvision >>+cpu -f https://download.pytorch.org/whl/torch_stable.html
|
||||
- run:
|
||||
name: Install mmcls dependencies
|
||||
command: |
|
||||
python -m pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cpu/torch<< parameters.torch >>/index.html
|
||||
python -m pip install -r requirements.txt
|
||||
- run:
|
||||
name: Install TIMM
|
||||
command: |
|
||||
pip install timm
|
||||
- run:
|
||||
name: Build and install
|
||||
command: |
|
||||
python -m pip install -e .
|
||||
- run:
|
||||
name: Run unittests
|
||||
command: |
|
||||
python -m coverage run --branch --source mmcls -m pytest tests/
|
||||
python -m coverage xml
|
||||
python -m coverage report -m
|
||||
|
||||
# Invoke jobs via workflows
|
||||
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
|
||||
workflows:
|
||||
unit_tests:
|
||||
jobs:
|
||||
- lint
|
||||
- build_with_timm:
|
||||
name: build_with_timm
|
||||
requires:
|
||||
- lint
|
||||
- build:
|
||||
name: build_py36_torch1.5
|
||||
torch: 1.5.0
|
||||
torchvision: 0.6.0
|
||||
# To fix memory leak in torch1.5+cpu, refers to pytorch#32037
|
||||
env: LRU_CACHE_CAPACITY=1
|
||||
requires:
|
||||
- lint
|
||||
- build:
|
||||
name: build_py36_torch1.6
|
||||
torch: 1.6.0
|
||||
torchvision: 0.7.0
|
||||
requires:
|
||||
- lint
|
||||
- build:
|
||||
name: build_py36_torch1.7
|
||||
torch: 1.7.0
|
||||
torchvision: 0.8.1
|
||||
requires:
|
||||
- lint
|
||||
- build:
|
||||
name: build_py36_torch1.8
|
||||
torch: 1.8.0
|
||||
torchvision: 0.9.0
|
||||
requires:
|
||||
- lint
|
||||
- build:
|
||||
name: build_py39_torch1.8
|
||||
torch: 1.8.0
|
||||
torchvision: 0.9.0
|
||||
python: "3.9.0"
|
||||
requires:
|
||||
- lint
|
||||
- build:
|
||||
name: build_py39_torch1.9
|
||||
torch: 1.9.0
|
||||
torchvision: 0.10.0
|
||||
python: "3.9.0"
|
||||
requires:
|
||||
- lint
|
||||
- build:
|
||||
name: build_py39_torch1.10
|
||||
torch: 1.10.0
|
||||
torchvision: 0.11.1
|
||||
python: "3.9.0"
|
||||
requires:
|
||||
- lint
|
||||
- build_with_cuda:
|
||||
name: build_py36_torch1.6_cu101
|
||||
requires:
|
||||
- build_with_timm
|
||||
- build_py36_torch1.5
|
||||
- build_py36_torch1.6
|
||||
- build_py36_torch1.7
|
||||
- build_py36_torch1.8
|
||||
- build_py39_torch1.8
|
||||
- build_py39_torch1.9
|
||||
- build_py39_torch1.10
|
||||
# the always-run workflow is always triggered, regardless of the pipeline parameters.
|
||||
always-run:
|
||||
jobs:
|
||||
# the path-filtering/filter job determines which pipeline
|
||||
# parameters to update.
|
||||
- path-filtering/filter:
|
||||
name: check-updated-files
|
||||
# 3-column, whitespace-delimited mapping. One mapping per
|
||||
# line:
|
||||
# <regex path-to-test> <parameter-to-set> <value-of-pipeline-parameter>
|
||||
mapping: |
|
||||
mmcls/.* lint_only false
|
||||
requirements/.* lint_only false
|
||||
tests/.* lint_only false
|
||||
.circleci/.* lint_only false
|
||||
base-revision: dev-1.x
|
||||
# this is the path of the configuration we should trigger once
|
||||
# path filtering and pipeline parameter value updates are
|
||||
# complete. In this case, we are using the parent dynamic
|
||||
# configuration itself.
|
||||
config-path: .circleci/test.yml
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
ARG PYTORCH="1.8.1"
|
||||
ARG CUDA="10.2"
|
||||
ARG CUDNN="7"
|
||||
|
||||
FROM pytorch/pytorch:${PYTORCH}-cuda${CUDA}-cudnn${CUDNN}-devel
|
||||
|
||||
# To fix GPG key error when running apt-get update
|
||||
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub
|
||||
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub
|
||||
|
||||
RUN apt-get update && apt-get install -y ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 libgl1-mesa-glx
|
|
@ -0,0 +1,196 @@
|
|||
# Use the latest 2.1 version of CircleCI pipeline process engine.
|
||||
# See: https://circleci.com/docs/2.0/configuration-reference
|
||||
version: 2.1
|
||||
|
||||
# the default pipeline parameters, which will be updated according to
|
||||
# the results of the path-filtering orb
|
||||
parameters:
|
||||
lint_only:
|
||||
type: boolean
|
||||
default: true
|
||||
|
||||
# Define a job to be invoked later in a workflow.
|
||||
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
|
||||
jobs:
|
||||
lint:
|
||||
docker:
|
||||
- image: cimg/python:3.7.4
|
||||
# Add steps to the job
|
||||
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Install pre-commit hook
|
||||
command: |
|
||||
pip install pre-commit
|
||||
pre-commit install
|
||||
- run:
|
||||
name: Linting
|
||||
command: pre-commit run --all-files
|
||||
- run:
|
||||
name: Check docstring coverage
|
||||
command: |
|
||||
pip install interrogate
|
||||
interrogate -v --ignore-init-method --ignore-module --ignore-nested-functions --ignore-regex "__repr__" --fail-under 60 mmcls
|
||||
build_cpu:
|
||||
parameters:
|
||||
# The python version must match available image tags in
|
||||
# https://circleci.com/developer/images/image/cimg/python
|
||||
python:
|
||||
type: string
|
||||
torch:
|
||||
type: string
|
||||
torchvision:
|
||||
type: string
|
||||
mmcv:
|
||||
type: string
|
||||
docker:
|
||||
- image: cimg/python:<< parameters.python >>
|
||||
resource_class: large
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Install Libraries
|
||||
command: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libjpeg8-dev zlib1g-dev
|
||||
- run:
|
||||
name: Configure Python & pip
|
||||
command: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install wheel
|
||||
- run:
|
||||
name: Install PyTorch
|
||||
command: |
|
||||
python -V
|
||||
python -m pip install torch==<< parameters.torch >>+cpu torchvision==<< parameters.torchvision >>+cpu -f https://download.pytorch.org/whl/torch_stable.html
|
||||
- run:
|
||||
name: Install mmcls dependencies
|
||||
command: |
|
||||
python -m pip install git+ssh://git@github.com/open-mmlab/mmengine.git@main
|
||||
python -m pip install << parameters.mmcv >>
|
||||
python -m pip install timm
|
||||
python -m pip install -r requirements.txt
|
||||
python -c 'import mmcv; print(mmcv.__version__)'
|
||||
- run:
|
||||
name: Build and install
|
||||
command: |
|
||||
python -m pip install -e .
|
||||
- run:
|
||||
name: Run unittests
|
||||
command: |
|
||||
python -m coverage run --branch --source mmcls -m pytest tests/
|
||||
python -m coverage xml
|
||||
python -m coverage report -m
|
||||
|
||||
build_cuda:
|
||||
machine:
|
||||
image: ubuntu-2004-cuda-11.4:202110-01
|
||||
resource_class: gpu.nvidia.small
|
||||
parameters:
|
||||
torch:
|
||||
type: string
|
||||
cuda:
|
||||
type: enum
|
||||
enum: ["10.1", "10.2", "11.1"]
|
||||
cudnn:
|
||||
type: integer
|
||||
default: 7
|
||||
mmcv:
|
||||
type: string
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
# Cloning repos in VM since Docker doesn't have access to the private key
|
||||
name: Clone Repos
|
||||
command: |
|
||||
git clone -b main --depth 1 ssh://git@github.com/open-mmlab/mmengine.git /home/circleci/mmengine
|
||||
- run:
|
||||
name: Build Docker image
|
||||
command: |
|
||||
docker build .circleci/docker -t mmcls:gpu --build-arg PYTORCH=<< parameters.torch >> --build-arg CUDA=<< parameters.cuda >> --build-arg CUDNN=<< parameters.cudnn >>
|
||||
docker run --gpus all -t -d -v /home/circleci/project:/mmcls -v /home/circleci/mmengine:/mmengine -w /mmcls --name mmcls mmcls:gpu
|
||||
- run:
|
||||
name: Install mmcls dependencies
|
||||
command: |
|
||||
docker exec mmcls pip install -e /mmengine
|
||||
docker exec mmcls pip install << parameters.mmcv >>
|
||||
docker exec mmcls pip install -r requirements.txt
|
||||
docker exec mmcls python -c 'import mmcv; print(mmcv.__version__)'
|
||||
- run:
|
||||
name: Build and install
|
||||
command: |
|
||||
docker exec mmcls pip install -e .
|
||||
- run:
|
||||
name: Run unittests
|
||||
command: |
|
||||
docker exec mmcls python -m pytest tests/ --ignore tests/test_models/test_backbones/test_timm_backbone.py
|
||||
|
||||
# Invoke jobs via workflows
|
||||
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
|
||||
workflows:
|
||||
pr_stage_lint:
|
||||
when: << pipeline.parameters.lint_only >>
|
||||
jobs:
|
||||
- lint:
|
||||
name: lint
|
||||
filters:
|
||||
branches:
|
||||
ignore:
|
||||
- dev-1.x
|
||||
pr_stage_test:
|
||||
when:
|
||||
not:
|
||||
<< pipeline.parameters.lint_only >>
|
||||
jobs:
|
||||
- lint:
|
||||
name: lint
|
||||
filters:
|
||||
branches:
|
||||
ignore:
|
||||
- dev-1.x
|
||||
- build_cpu:
|
||||
name: minimum_version_cpu
|
||||
torch: 1.6.0
|
||||
torchvision: 0.7.0
|
||||
python: 3.6.9 # The lowest python 3.6.x version available on CircleCI images
|
||||
mmcv: https://download.openmmlab.com/mmcv/dev-2.x/cpu/torch1.6.0/mmcv_full-2.0.0rc0-cp36-cp36m-manylinux1_x86_64.whl
|
||||
requires:
|
||||
- lint
|
||||
- build_cpu:
|
||||
name: maximum_version_cpu
|
||||
torch: 1.9.0 # TODO: Update the version after mmcv provides more pre-compiled packages.
|
||||
torchvision: 0.10.0
|
||||
python: 3.9.0
|
||||
mmcv: https://download.openmmlab.com/mmcv/dev-2.x/cpu/torch1.9.0/mmcv_full-2.0.0rc0-cp39-cp39-manylinux1_x86_64.whl
|
||||
requires:
|
||||
- minimum_version_cpu
|
||||
- hold:
|
||||
type: approval
|
||||
requires:
|
||||
- maximum_version_cpu
|
||||
- build_cuda:
|
||||
name: mainstream_version_gpu
|
||||
torch: 1.8.1
|
||||
# Use double quotation mark to explicitly specify its type
|
||||
# as string instead of number
|
||||
cuda: "10.2"
|
||||
mmcv: https://download.openmmlab.com/mmcv/dev-2.x/cu102/torch1.8.0/mmcv_full-2.0.0rc0-cp37-cp37m-manylinux1_x86_64.whl
|
||||
requires:
|
||||
- hold
|
||||
merge_stage_test:
|
||||
when:
|
||||
not:
|
||||
<< pipeline.parameters.lint_only >>
|
||||
jobs:
|
||||
- build_cuda:
|
||||
name: minimum_version_gpu
|
||||
torch: 1.6.0
|
||||
# Use double quotation mark to explicitly specify its type
|
||||
# as string instead of number
|
||||
mmcv: https://download.openmmlab.com/mmcv/dev-2.x/cu101/torch1.6.0/mmcv_full-2.0.0rc0-cp37-cp37m-manylinux1_x86_64.whl
|
||||
cuda: "10.1"
|
||||
filters:
|
||||
branches:
|
||||
only:
|
||||
- dev-1.x
|
|
@ -1,198 +0,0 @@
|
|||
# This workflow will install Python dependencies, run tests with a variety of Python versions
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
|
||||
|
||||
name: build
|
||||
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'README_zh-CN.md'
|
||||
- 'model-index.yml'
|
||||
- 'configs/**'
|
||||
- 'docs/**'
|
||||
- 'demo/**'
|
||||
- '.dev_scripts/**'
|
||||
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'README_zh-CN.md'
|
||||
- 'model-index.yml'
|
||||
- 'configs/**'
|
||||
- 'docs/**'
|
||||
- 'demo/**'
|
||||
- '.dev_scripts/**'
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build_without_timm:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
UBUNTU_VERSION: ubuntu1804
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: [3.6]
|
||||
torch: [1.5.0, 1.8.0, 1.9.0]
|
||||
include:
|
||||
- torch: 1.5.0
|
||||
torchvision: 0.6.0
|
||||
torch_major: 1.5.0
|
||||
- torch: 1.8.0
|
||||
torchvision: 0.9.0
|
||||
torch_major: 1.8.0
|
||||
- torch: 1.9.0
|
||||
torchvision: 0.10.0
|
||||
torch_major: 1.9.0
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install PyTorch
|
||||
run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu -f https://download.pytorch.org/whl/torch_stable.html
|
||||
- name: Install MMCV
|
||||
run: |
|
||||
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cpu/torch${{matrix.torch_major}}/index.html
|
||||
python -c 'import mmcv; print(mmcv.__version__)'
|
||||
- name: Install mmcls dependencies
|
||||
run: |
|
||||
pip install -r requirements.txt
|
||||
- name: Build and install
|
||||
run: |
|
||||
rm -rf .eggs
|
||||
pip install -e . -U
|
||||
- name: Run unittests
|
||||
run: |
|
||||
pytest tests/ --ignore tests/test_models/test_backbones/test_timm_backbone.py
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
UBUNTU_VERSION: ubuntu1804
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: [3.7]
|
||||
torch: [1.5.0, 1.6.0, 1.7.0, 1.8.0, 1.9.0]
|
||||
include:
|
||||
- torch: 1.5.0
|
||||
torchvision: 0.6.0
|
||||
torch_major: 1.5.0
|
||||
- torch: 1.6.0
|
||||
torchvision: 0.7.0
|
||||
torch_major: 1.6.0
|
||||
- torch: 1.7.0
|
||||
torchvision: 0.8.1
|
||||
torch_major: 1.7.0
|
||||
- torch: 1.8.0
|
||||
torchvision: 0.9.0
|
||||
torch_major: 1.8.0
|
||||
- torch: 1.8.0
|
||||
torchvision: 0.9.0
|
||||
torch_major: 1.8.0
|
||||
python-version: 3.8
|
||||
- torch: 1.8.0
|
||||
torchvision: 0.9.0
|
||||
torch_major: 1.8.0
|
||||
python-version: 3.9
|
||||
- torch: 1.9.0
|
||||
torchvision: 0.10.0
|
||||
torch_major: 1.9.0
|
||||
- torch: 1.10.0
|
||||
torchvision: 0.11.1
|
||||
torch_major: 1.10.0
|
||||
- torch: 1.10.0
|
||||
torchvision: 0.11.1
|
||||
torch_major: 1.10.0
|
||||
python-version: 3.8
|
||||
- torch: 1.10.0
|
||||
torchvision: 0.11.1
|
||||
torch_major: 1.10.0
|
||||
python-version: 3.9
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install PyTorch
|
||||
run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu -f https://download.pytorch.org/whl/torch_stable.html
|
||||
- name: Install MMCV
|
||||
run: |
|
||||
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cpu/torch${{matrix.torch_major}}/index.html
|
||||
python -c 'import mmcv; print(mmcv.__version__)'
|
||||
- name: Install mmcls dependencies
|
||||
run: |
|
||||
pip install -r requirements.txt
|
||||
- name: Install timm
|
||||
run: |
|
||||
pip install timm
|
||||
- name: Build and install
|
||||
run: |
|
||||
rm -rf .eggs
|
||||
pip install -e . -U
|
||||
- name: Run unittests and generate coverage report
|
||||
run: |
|
||||
coverage run --branch --source mmcls -m pytest tests/
|
||||
coverage xml
|
||||
coverage report -m --omit="mmcls/utils/*","mmcls/apis/*"
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v2
|
||||
with:
|
||||
file: ./coverage.xml
|
||||
flags: unittests
|
||||
env_vars: OS,PYTHON
|
||||
name: codecov-umbrella
|
||||
fail_ci_if_error: false
|
||||
|
||||
build-windows:
|
||||
runs-on: windows-2022
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: [3.8]
|
||||
torch: [1.8.1]
|
||||
include:
|
||||
- torch: 1.8.1
|
||||
torchvision: 0.9.1
|
||||
torch_major: 1.8.0
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install PyTorch
|
||||
run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu -f https://download.pytorch.org/whl/torch_stable.html
|
||||
- name: Install MMCV & OpenCV
|
||||
run: |
|
||||
pip install opencv-python
|
||||
pip install mmcv-full==1.4.2 -f https://download.openmmlab.com/mmcv/dist/cpu/torch${{matrix.torch_major}}/index.html
|
||||
python -c 'import mmcv; print(mmcv.__version__)'
|
||||
- name: Install mmcls dependencies
|
||||
run: |
|
||||
pip install -r requirements.txt
|
||||
- name: Install timm
|
||||
run: |
|
||||
pip install timm
|
||||
- name: Build and install
|
||||
run: |
|
||||
pip install -e . -U
|
||||
- name: Run unittests and generate coverage report
|
||||
run: |
|
||||
coverage run --branch --source mmcls -m pytest tests/
|
||||
coverage xml
|
||||
coverage report -m --omit="mmcls/utils/*","mmcls/apis/*"
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v2
|
||||
with:
|
||||
file: ./coverage.xml
|
||||
flags: unittests
|
||||
env_vars: OS,PYTHON
|
||||
name: codecov-umbrella
|
||||
fail_ci_if_error: false
|
|
@ -1,22 +0,0 @@
|
|||
name: deploy
|
||||
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
build-n-publish:
|
||||
runs-on: ubuntu-latest
|
||||
if: startsWith(github.event.ref, 'refs/tags')
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Python 3.7
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.7
|
||||
- name: Build MMClassification
|
||||
run: |
|
||||
pip install wheel
|
||||
python setup.py sdist bdist_wheel
|
||||
- name: Publish distribution to PyPI
|
||||
run: |
|
||||
pip install twine
|
||||
twine upload dist/* -u __token__ -p ${{ secrets.pypi_password }}
|
|
@ -1,25 +0,0 @@
|
|||
# This workflow will run lint
|
||||
|
||||
name: lint
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Python 3.7
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.7
|
||||
- name: Install pre-commit hook
|
||||
run: |
|
||||
pip install pre-commit
|
||||
pre-commit install
|
||||
- name: Linting
|
||||
run: pre-commit run --all-files
|
|
@ -411,7 +411,7 @@ def _average_precision(pred: torch.Tensor,
|
|||
pred_pos_nums[pred_pos_nums < eps] = eps
|
||||
|
||||
tps[torch.logical_not(pos_inds)] = 0
|
||||
precision = tps / pred_pos_nums
|
||||
precision = tps / pred_pos_nums.float()
|
||||
ap = torch.sum(precision, 0) / max(total_pos, eps)
|
||||
return ap
|
||||
|
||||
|
|
|
@ -38,8 +38,8 @@ def _precision_recall_f1_support(pred_positive, gt_positive, average):
|
|||
pred_sum = pred_positive.sum(0)
|
||||
gt_sum = gt_positive.sum(0)
|
||||
|
||||
precision = tp_sum / torch.clamp(pred_sum, min=1.) * 100
|
||||
recall = tp_sum / torch.clamp(gt_sum, min=1.) * 100
|
||||
precision = tp_sum / torch.clamp(pred_sum, min=1).float() * 100
|
||||
recall = tp_sum / torch.clamp(gt_sum, min=1).float() * 100
|
||||
f1_score = 2 * precision * recall / torch.clamp(
|
||||
precision + recall, min=torch.finfo(torch.float32).eps)
|
||||
if average in ['macro', 'micro']:
|
||||
|
|
|
@ -85,7 +85,7 @@ class ClsHead(BaseHead):
|
|||
# Batch augmentation may convert labels to one-hot format scores.
|
||||
target = torch.stack([i.gt_label.score for i in data_samples])
|
||||
else:
|
||||
target = torch.hstack([i.gt_label.label for i in data_samples])
|
||||
target = torch.cat([i.gt_label.label for i in data_samples])
|
||||
|
||||
# compute loss
|
||||
losses = dict()
|
||||
|
|
|
@ -99,7 +99,7 @@ class ConformerHead(ClsHead):
|
|||
# Batch augmentation may convert labels to one-hot format scores.
|
||||
target = torch.stack([i.gt_label.score for i in data_samples])
|
||||
else:
|
||||
target = torch.hstack([i.gt_label.label for i in data_samples])
|
||||
target = torch.cat([i.gt_label.label for i in data_samples])
|
||||
|
||||
# compute loss
|
||||
losses = dict()
|
||||
|
|
|
@ -641,9 +641,10 @@ class TestLighting(TestCase):
|
|||
# test call
|
||||
cfg = copy.deepcopy(self.DEFAULT_ARGS)
|
||||
lightening_module = TRANSFORMS.build(cfg)
|
||||
results = lightening_module(results)
|
||||
self.assertEqual(results['img'].dtype, ori_img.dtype)
|
||||
assert not np.equal(results['img'], ori_img).all()
|
||||
with patch('numpy.random', np.random.RandomState(0)):
|
||||
results = lightening_module(results)
|
||||
self.assertEqual(results['img'].dtype, ori_img.dtype)
|
||||
assert not np.equal(results['img'], ori_img).all()
|
||||
|
||||
# test call with alphastd == 0
|
||||
results = dict(img=copy.deepcopy(ori_img))
|
||||
|
|
Loading…
Reference in New Issue