diff --git a/.circleci/scripts/get_mmcv_var.sh b/.circleci/scripts/get_mmcv_var.sh deleted file mode 100755 index 552ff871..00000000 --- a/.circleci/scripts/get_mmcv_var.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -TORCH=$1 -CUDA=$2 - -# 10.2 -> cu102 -MMCV_CUDA="cu`echo ${CUDA} | tr -d '.'`" - -# MMCV only provides pre-compiled packages for torch 1.x.0 -# which works for any subversions of torch 1.x. -# We force the torch version to be 1.x.0 to ease package searching -# and avoid unnecessary rebuild during MMCV's installation. -TORCH_VER_ARR=(${TORCH//./ }) -TORCH_VER_ARR[2]=0 -printf -v MMCV_TORCH "%s." "${TORCH_VER_ARR[@]}" -MMCV_TORCH=${MMCV_TORCH%?} # Remove the last dot - -echo "export MMCV_CUDA=${MMCV_CUDA}" >> $BASH_ENV -echo "export MMCV_TORCH=${MMCV_TORCH}" >> $BASH_ENV diff --git a/.circleci/test.yml b/.circleci/test.yml index e9dd2453..8b7c2a7f 100644 --- a/.circleci/test.yml +++ b/.circleci/test.yml @@ -36,8 +36,6 @@ jobs: type: string torchvision: type: string - mmcv: - type: string docker: - image: cimg/python:<< parameters.python >> resource_class: large @@ -51,30 +49,31 @@ jobs: - run: name: Configure Python & pip command: | - python -m pip install --upgrade pip - python -m pip install wheel + pip install --upgrade pip + 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 + pip install torch==<< parameters.torch >>+cpu torchvision==<< parameters.torchvision >>+cpu -f https://download.pytorch.org/whl/torch_stable.html - run: name: Install mmocr 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 git+ssh://git@github.com/open-mmlab/mmdetection.git@dev-3.x - python -m pip install -r requirements.txt + pip install git+https://github.com/open-mmlab/mmengine.git@main + pip install -U openmim + mim install 'mmcv >= 2.0.0rc1' + pip install git+https://github.com/open-mmlab/mmdetection.git@dev-3.x + pip install -r requirements/tests.txt - run: name: Build and install command: | - python -m pip install -e . + pip install -e . - run: name: Run unittests command: | - python -m coverage run --branch --source mmocr -m pytest tests/ - python -m coverage xml - python -m coverage report -m + coverage run --branch --source mmocr -m pytest tests/ + coverage xml + coverage report -m build_cuda: parameters: torch: @@ -85,8 +84,6 @@ jobs: cudnn: type: integer default: 7 - mmcv: - type: string machine: image: ubuntu-2004-cuda-11.4:202110-01 # docker_layer_caching: true @@ -97,8 +94,8 @@ jobs: # 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 - git clone -b dev-3.x --depth 1 ssh://git@github.com/open-mmlab/mmdetection.git /home/circleci/mmdetection + git clone -b main --depth 1 https://github.com/open-mmlab/mmengine.git /home/circleci/mmengine + git clone -b dev-3.x --depth 1 https://github.com/open-mmlab/mmdetection.git /home/circleci/mmdetection - run: name: Build Docker image command: | @@ -108,9 +105,10 @@ jobs: name: Install mmocr dependencies command: | docker exec mmocr pip install -e /mmengine - docker exec mmocr pip install << parameters.mmcv >> + docker exec mmocr pip install -U openmim + docker exec mmocr mim install 'mmcv >= 2.0.0rc1' docker exec mmocr pip install -e /mmdetection - docker exec mmocr pip install -r requirements.txt + docker exec mmocr pip install -r requirements/tests.txt - run: name: Build and install command: | @@ -118,7 +116,8 @@ jobs: - run: name: Run unittests command: | - docker exec mmocr python -m pytest tests/ + docker exec mmocr pytest tests/ + workflows: pr_stage_lint: when: << pipeline.parameters.lint_only >> @@ -129,7 +128,7 @@ workflows: branches: ignore: - dev-1.x - - test-1.x + - 1.x pr_stage_test: when: not: @@ -142,42 +141,18 @@ workflows: ignore: - dev-1.x - test-1.x - 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 - - test-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 - filters: - branches: - only: - - dev-1.x - - test-1.x + requires: + - lint - build_cpu: name: maximum_version_cpu - torch: 1.9.0 - torchvision: 0.10.0 + torch: 1.12.1 + torchvision: 0.13.1 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: @@ -190,6 +165,20 @@ workflows: # 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 + cuda: "10.1" + filters: + branches: + only: + - dev-1.x diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9d836594..e9cdba66 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -6,22 +6,22 @@ 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 -# - name: Check docstring coverage -# run: | -# pip install interrogate -# interrogate -v --ignore-init-method --ignore-module --ignore-nested-functions --ignore-regex "__repr__" --fail-under 50 mmocr +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 + - name: Check docstring coverage + run: | + pip install interrogate + interrogate -v --ignore-init-method --ignore-module --ignore-nested-functions --ignore-regex "__repr__" --fail-under 90 mmocr diff --git a/.github/workflows/merge_stage_test.yml b/.github/workflows/merge_stage_test.yml index e3522e3e..cf0051e6 100644 --- a/.github/workflows/merge_stage_test.yml +++ b/.github/workflows/merge_stage_test.yml @@ -16,169 +16,174 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -# jobs: -# build_cpu_py: -# runs-on: ubuntu-18.04 -# strategy: -# matrix: -# python-version: [3.6, 3.8, 3.9] -# torch: [1.8.1] -# include: -# - torch: 1.8.1 -# torchvision: 0.9.1 -# steps: -# - uses: actions/checkout@v2 -# - name: Set up Python ${{ matrix.python-version }} -# uses: actions/setup-python@v2 -# with: -# python-version: ${{ matrix.python-version }} -# - name: Get MMCV_TORCH as the environment variable -# run: . .github/workflows/scripts/get_mmcv_var.sh ${{matrix.torch}} -# shell: bash -# - name: Upgrade pip -# run: pip install pip --upgrade -# - 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${MMCV_TORCH}/index.html -# - name: Install MMDet -# run: pip install mmdet -# - name: Install other dependencies -# run: pip install -r requirements.txt -# - name: Build and install -# run: rm -rf .eggs && pip install -e . -# - name: Run unittests and generate coverage report -# run: | -# coverage run --branch --source mmocr -m pytest tests/ -# coverage xml -# coverage report -m +jobs: + build_cpu_py: + runs-on: ubuntu-18.04 + strategy: + matrix: + python-version: [3.6, 3.8, 3.9] + torch: [1.8.1] + include: + - torch: 1.8.1 + torchvision: 0.9.1 + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Upgrade pip + run: pip install pip --upgrade + - 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 MMEngine + run: pip install git+https://github.com/open-mmlab/mmengine.git@main + - name: Install MMCV + run: | + pip install -U openmim + mim install 'mmcv >= 2.0.0rc1' + - name: Install MMDet + run: pip install git+https://github.com/open-mmlab/mmdetection.git@dev-3.x + - name: Install other dependencies + run: pip install -r requirements/tests.txt + - name: Build and install + run: rm -rf .eggs && pip install -e . + - name: Run unittests and generate coverage report + run: | + coverage run --branch --source mmocr -m pytest tests/ + coverage xml + coverage report -m -# build_cpu_pt: -# runs-on: ubuntu-18.04 -# strategy: -# matrix: -# python-version: [3.7] -# torch: [1.5.1, 1.6.0, 1.7.1, 1.8.1, 1.9.1, 1.10.1, 1.11.0] -# include: -# - torch: 1.5.1 -# torchvision: 0.6.1 -# - torch: 1.6.0 -# torchvision: 0.7.0 -# - torch: 1.7.1 -# torchvision: 0.8.2 -# - torch: 1.8.1 -# torchvision: 0.9.1 -# - torch: 1.9.1 -# torchvision: 0.10.1 -# - torch: 1.10.1 -# torchvision: 0.11.2 -# - torch: 1.11.0 -# torchvision: 0.12.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: Upgrade pip -# run: pip install pip --upgrade -# - name: Get MMCV_TORCH as the environment variable -# run: . .github/workflows/scripts/get_mmcv_var.sh ${{matrix.torch}} -# shell: bash -# - 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${MMCV_TORCH}/index.html -# - name: Install MMDet -# run: pip install mmdet -# - name: Install other dependencies -# run: pip install -r requirements.txt -# - name: Build and install -# run: rm -rf .eggs && pip install -e . -# - name: Run unittests and generate coverage report -# run: | -# coverage run --branch --source mmocr -m pytest tests/ -# coverage xml -# coverage report -m -# # Only upload coverage report for python3.7 && pytorch1.8.1 cpu -# - name: Upload coverage to Codecov -# if: ${{matrix.torch == '1.8.1' && matrix.python-version == '3.7'}} -# uses: codecov/codecov-action@v1.0.14 -# with: -# file: ./coverage.xml -# flags: unittests -# env_vars: OS,PYTHON -# name: codecov-umbrella -# fail_ci_if_error: false + build_cpu_pt: + runs-on: ubuntu-18.04 + strategy: + matrix: + python-version: [3.7] + torch: [1.6.0, 1.7.1, 1.8.1, 1.9.1, 1.10.1, 1.11.0, 1.12.1] + include: + - torch: 1.5.1 + torchvision: 0.6.1 + - torch: 1.6.0 + torchvision: 0.7.0 + - torch: 1.7.1 + torchvision: 0.8.2 + - torch: 1.8.1 + torchvision: 0.9.1 + - torch: 1.9.1 + torchvision: 0.10.1 + - torch: 1.10.1 + torchvision: 0.11.2 + - torch: 1.11.0 + torchvision: 0.12.0 + - torch: 1.12.1 + torchvision: 0.13.1 + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Upgrade pip + run: pip install pip --upgrade + - 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 MMEngine + run: pip install git+https://github.com/open-mmlab/mmengine.git@main + - name: Install MMCV + run: | + pip install -U openmim + mim install 'mmcv >= 2.0.0rc1' + - name: Install MMDet + run: pip install git+https://github.com/open-mmlab/mmdetection.git@dev-3.x + - name: Install other dependencies + run: pip install -r requirements/tests.txt + - name: Build and install + run: rm -rf .eggs && pip install -e . + - name: Run unittests and generate coverage report + run: | + coverage run --branch --source mmocr -m pytest tests/ + coverage xml + coverage report -m + # Only upload coverage report for python3.7 && pytorch1.8.1 cpu + - name: Upload coverage to Codecov + if: ${{matrix.torch == '1.8.1' && matrix.python-version == '3.7'}} + uses: codecov/codecov-action@v1.0.14 + with: + file: ./coverage.xml + flags: unittests + env_vars: OS,PYTHON + name: codecov-umbrella + fail_ci_if_error: false -# build_cu102: -# runs-on: ubuntu-18.04 -# container: -# image: pytorch/pytorch:1.8.1-cuda10.2-cudnn7-devel -# strategy: -# matrix: -# python-version: [3.7] -# include: -# - torch: 1.8.1 -# cuda: 10.2 -# steps: -# - uses: actions/checkout@v2 -# - name: Set up Python ${{ matrix.python-version }} -# uses: actions/setup-python@v2 -# with: -# python-version: ${{ matrix.python-version }} -# - name: Upgrade pip -# run: python -m pip install pip --upgrade -# - name: Fetch GPG keys -# run: | -# apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub -# apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub -# - name: Get MMCV_TORCH and MMCV_CUDA as environment variables -# run: . .github/workflows/scripts/get_mmcv_var.sh ${{matrix.torch}} ${{matrix.cuda}} -# shell: bash -# - name: Install Python-dev -# run: apt-get update && apt-get install -y python${{matrix.python-version}}-dev -# if: ${{matrix.python-version != 3.9}} -# - name: Install system dependencies -# run: | -# apt-get update && apt-get install -y ffmpeg libsm6 libxext6 git ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 -# - name: Install mmocr dependencies -# run: | -# python -m pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/${MMCV_CUDA}/torch${MMCV_TORCH}}/index.html -# python -m pip install mmdet -# python -m pip install -r requirements.txt -# - name: Build and install -# run: | -# python setup.py check -m -s -# TORCH_CUDA_ARCH_LIST=7.0 python -m pip install -e . + build_cu102: + runs-on: ubuntu-18.04 + container: + image: pytorch/pytorch:1.8.1-cuda10.2-cudnn7-devel + strategy: + matrix: + python-version: [3.7] + include: + - torch: 1.8.1 + cuda: 10.2 + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Upgrade pip + run: pip install pip --upgrade + - name: Fetch GPG keys + run: | + apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub + apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub + - name: Install Python-dev + run: apt-get update && apt-get install -y python${{matrix.python-version}}-dev + if: ${{matrix.python-version != 3.9}} + - name: Install system dependencies + run: | + apt-get update && apt-get install -y ffmpeg libsm6 libxext6 git ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 + - name: Install mmocr dependencies + run: | + pip install git+https://github.com/open-mmlab/mmengine.git@main + pip install -U openmim + mim install 'mmcv >= 2.0.0rc1' + pip install git+https://github.com/open-mmlab/mmdetection.git@dev-3.x + pip install -r requirements/tests.txt + - name: Build and install + run: | + python setup.py check -m -s + TORCH_CUDA_ARCH_LIST=7.0 pip install -e . -# build_windows: -# runs-on: ${{ matrix.os }} -# strategy: -# matrix: -# os: [windows-2022] -# python: [3.7] -# platform: [cpu, cu102] -# steps: -# - uses: actions/checkout@v2 -# - name: Set up Python ${{ matrix.python-version }} -# uses: actions/setup-python@v2 -# with: -# python-version: ${{ matrix.python-version }} -# - name: Upgrade pip -# run: python -m pip install pip --upgrade -# - name: Install lmdb -# run: python -m pip install lmdb -# - name: Install PyTorch -# run: python -m pip install torch==1.8.1+${{matrix.platform}} torchvision==0.9.1+${{matrix.platform}} -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html -# - name: Install mmocr dependencies -# run: | -# python -m pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cpu/torch1.8/index.html --only-binary mmcv-full -# python -m pip install mmdet -# python -m pip install -r requirements.txt -# - name: Build and install -# run: | -# python -m pip install -e . -# - name: Run unittests and generate coverage report -# run: | -# pytest tests/ + build_windows: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-2022] + python: [3.7] + platform: [cpu] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Upgrade pip + run: pip install pip --upgrade + - name: Install lmdb + run: pip install lmdb + - name: Install PyTorch + run: pip install torch==1.8.1+${{matrix.platform}} torchvision==0.9.1+${{matrix.platform}} -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html + - name: Install mmocr dependencies + run: | + pip install git+https://github.com/open-mmlab/mmengine.git@main + pip install -U openmim + mim install 'mmcv >= 2.0.0rc1' + pip install git+https://github.com/open-mmlab/mmdetection.git@dev-3.x + pip install -r requirements/tests.txt + - name: Build and install + run: | + pip install -e . + - name: Run unittests and generate coverage report + run: | + pytest tests/ diff --git a/.github/workflows/pr_stage_test.yml b/.github/workflows/pr_stage_test.yml index b7568419..dbc68308 100644 --- a/.github/workflows/pr_stage_test.yml +++ b/.github/workflows/pr_stage_test.yml @@ -14,117 +14,119 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -# jobs: -# build_cpu: -# runs-on: ubuntu-18.04 -# strategy: -# matrix: -# python-version: [3.7] -# include: -# - torch: 1.8.1 -# torchvision: 0.9.1 -# steps: -# - uses: actions/checkout@v2 -# - name: Set up Python ${{ matrix.python-version }} -# uses: actions/setup-python@v2 -# with: -# python-version: ${{ matrix.python-version }} -# - name: Upgrade pip -# run: pip install pip --upgrade -# - name: Get MMCV_TORCH as the environment variable -# run: . .github/workflows/scripts/get_mmcv_var.sh ${{matrix.torch}} -# shell: bash -# - 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${MMCV_TORCH}/index.html -# - name: Install MMDet -# run: pip install mmdet -# - name: Install other dependencies -# run: pip install -r requirements.txt -# - name: Build and install -# run: rm -rf .eggs && pip install -e . -# - name: Run unittests and generate coverage report -# run: | -# coverage run --branch --source mmocr -m pytest tests/ -# coverage xml -# coverage report -m -# # Upload coverage report for python3.7 && pytorch1.8.1 cpu -# - name: Upload coverage to Codecov -# uses: codecov/codecov-action@v1.0.14 -# with: -# file: ./coverage.xml -# flags: unittests -# env_vars: OS,PYTHON -# name: codecov-umbrella -# fail_ci_if_error: false +jobs: + build_cpu: + runs-on: ubuntu-18.04 + strategy: + matrix: + python-version: [3.7] + include: + - torch: 1.8.1 + torchvision: 0.9.1 + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Upgrade pip + run: pip install pip --upgrade + - 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 MMEngine + run: pip install git+https://github.com/open-mmlab/mmengine.git@main + - name: Install MMCV + run: | + pip install -U openmim + mim install 'mmcv >= 2.0.0rc1' + - name: Install MMDet + run: pip install git+https://github.com/open-mmlab/mmdetection.git@dev-3.x + - name: Install other dependencies + run: pip install -r requirements/tests.txt + - name: Build and install + run: rm -rf .eggs && pip install -e . + - name: Run unittests and generate coverage report + run: | + coverage run --branch --source mmocr -m pytest tests/ + coverage xml + coverage report -m + # Upload coverage report for python3.7 && pytorch1.8.1 cpu + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1.0.14 + with: + file: ./coverage.xml + flags: unittests + env_vars: OS,PYTHON + name: codecov-umbrella + fail_ci_if_error: false -# build_cu102: -# runs-on: ubuntu-18.04 -# container: -# image: pytorch/pytorch:1.8.1-cuda10.2-cudnn7-devel -# strategy: -# matrix: -# python-version: [3.7] -# steps: -# - uses: actions/checkout@v2 -# - name: Set up Python ${{ matrix.python-version }} -# uses: actions/setup-python@v2 -# with: -# python-version: ${{ matrix.python-version }} -# - name: Upgrade pip -# run: python -m pip install pip --upgrade -# - name: Fetch GPG keys -# run: | -# apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub -# apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub -# - name: Get MMCV_TORCH and MMCV_CUDA as environment variables -# run: . .github/workflows/scripts/get_mmcv_var.sh ${{matrix.torch}} ${{matrix.cuda}} -# shell: bash -# - name: Install Python-dev -# run: apt-get update && apt-get install -y python${{matrix.python-version}}-dev -# if: ${{matrix.python-version != 3.9}} -# - name: Install system dependencies -# run: | -# apt-get update -# apt-get install -y ffmpeg libsm6 libxext6 git ninja-build libglib2.0-0 libxrender-dev -# - name: Install mmocr dependencies -# run: | -# python -m pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/${MMCV_CUDA}/torch${MMCV_TORCH}/index.html -# python -m pip install mmdet -# python -m pip install -r requirements.txt -# - name: Build and install -# run: | -# python setup.py check -m -s -# TORCH_CUDA_ARCH_LIST=7.0 python -m pip install -e . + build_cu102: + runs-on: ubuntu-18.04 + container: + image: pytorch/pytorch:1.8.1-cuda10.2-cudnn7-devel + strategy: + matrix: + python-version: [3.7] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Upgrade pip + run: pip install pip --upgrade + - name: Fetch GPG keys + run: | + apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub + apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub + - name: Install Python-dev + run: apt-get update && apt-get install -y python${{matrix.python-version}}-dev + if: ${{matrix.python-version != 3.9}} + - name: Install system dependencies + run: | + apt-get update + apt-get install -y ffmpeg libsm6 libxext6 git ninja-build libglib2.0-0 libxrender-dev + - name: Install mmocr dependencies + run: | + pip install git+https://github.com/open-mmlab/mmengine.git@main + pip install -U openmim + mim install 'mmcv >= 2.0.0rc1' + pip install git+https://github.com/open-mmlab/mmdetection.git@dev-3.x + pip install -r requirements/tests.txt + - name: Build and install + run: | + python setup.py check -m -s + TORCH_CUDA_ARCH_LIST=7.0 pip install -e . -# build_windows: -# runs-on: ${{ matrix.os }} -# strategy: -# matrix: -# os: [windows-2022] -# python: [3.7] -# platform: [cpu, cu102] -# steps: -# - uses: actions/checkout@v2 -# - name: Set up Python ${{ matrix.python-version }} -# uses: actions/setup-python@v2 -# with: -# python-version: ${{ matrix.python-version }} -# - name: Upgrade pip -# run: python -m pip install pip --upgrade -# - name: Install lmdb -# run: python -m pip install lmdb -# - name: Install PyTorch -# run: python -m pip install torch==1.8.1+${{matrix.platform}} torchvision==0.9.1+${{matrix.platform}} -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html -# - name: Install mmocr dependencies -# run: | -# python -m pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cpu/torch1.8/index.html --only-binary mmcv-full -# python -m pip install mmdet -# python -m pip install -r requirements.txt -# - name: Build and install -# run: | -# python -m pip install -e . -# - name: Run unittests and generate coverage report -# run: | -# pytest tests/ + build_windows: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-2022] + python: [3.7] + platform: [cpu] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Upgrade pip + run: pip install pip --upgrade + - name: Install lmdb + run: pip install lmdb + - name: Install PyTorch + run: pip install torch==1.8.1+${{matrix.platform}} torchvision==0.9.1+${{matrix.platform}} -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html + - name: Install mmocr dependencies + run: | + pip install git+https://github.com/open-mmlab/mmengine.git@main + pip install -U openmim + mim install 'mmcv >= 2.0.0rc1' + pip install git+https://github.com/open-mmlab/mmdetection.git@dev-3.x + pip install -r requirements/tests.txt + - name: Build and install + run: | + pip install -e . + - name: Run unittests and generate coverage report + run: | + pytest tests/ diff --git a/.github/workflows/scripts/get_mmcv_var.sh b/.github/workflows/scripts/get_mmcv_var.sh deleted file mode 100755 index 67604fec..00000000 --- a/.github/workflows/scripts/get_mmcv_var.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -TORCH=$1 -CUDA=$2 - -# 10.2 -> cu102 -MMCV_CUDA="cu`echo ${CUDA} | tr -d '.'`" - -# MMCV only provides pre-compiled packages for torch 1.x.0 -# which works for any subversions of torch 1.x. -# We force the torch version to be 1.x.0 to ease package searching -# and avoid unnecessary rebuild during MMCV's installation. -TORCH_VER_ARR=(${TORCH//./ }) -TORCH_VER_ARR[2]=0 -printf -v MMCV_TORCH "%s." "${TORCH_VER_ARR[@]}" -MMCV_TORCH=${MMCV_TORCH%?} # Remove the last dot - -echo "MMCV_CUDA=${MMCV_CUDA}" >> $GITHUB_ENV -echo "MMCV_TORCH=${MMCV_TORCH}" >> $GITHUB_ENV diff --git a/mmocr/datasets/recog_lmdb_dataset.py b/mmocr/datasets/recog_lmdb_dataset.py index e76409f9..2c5c0dd9 100644 --- a/mmocr/datasets/recog_lmdb_dataset.py +++ b/mmocr/datasets/recog_lmdb_dataset.py @@ -191,3 +191,9 @@ class RecogLMDBDataset(BaseDataset): readahead=False, meminit=False, ) + + def close(self): + """Close lmdb environment.""" + if hasattr(self, 'env'): + self.env.close() + del self.env diff --git a/tests/test_datasets/test_recog_lmdb_dataset.py b/tests/test_datasets/test_recog_lmdb_dataset.py index c52d048b..27201cca 100644 --- a/tests/test_datasets/test_recog_lmdb_dataset.py +++ b/tests/test_datasets/test_recog_lmdb_dataset.py @@ -37,7 +37,8 @@ class TestRecogLMDBDataset(TestCase): # test load_data_list anno = dataset.load_data_list()[0] - self.assertEqual(anno['img_path'], 'imgs/1223731.jpg') + self.assertIn(anno['img_path'], + ['imgs/1223731.jpg', 'imgs\\1223731.jpg']) self.assertEqual(anno['instances'][0]['text'], 'GRAND') def test_label_and_image_dataset(self): @@ -53,7 +54,8 @@ class TestRecogLMDBDataset(TestCase): # test load_data_list anno = dataset.load_data_list()[0] - self.assertEqual(anno['img_path'], f'imgs/image-{1:09d}') + self.assertIn(anno['img_path'], + [f'imgs/image-{1:09d}', f'imgs\\image-{1:09d}']) self.assertEqual(anno['instances'][0]['text'], 'GRAND') def test_deprecated_format(self): @@ -75,3 +77,4 @@ class TestRecogLMDBDataset(TestCase): dataset.full_init() self.assertWarnsRegex(UserWarning, warm_msg) + dataset.close() diff --git a/tests/test_datasets/test_recog_text_dataset.py b/tests/test_datasets/test_recog_text_dataset.py index 02dc7c90..f9550d17 100644 --- a/tests/test_datasets/test_recog_text_dataset.py +++ b/tests/test_datasets/test_recog_text_dataset.py @@ -23,9 +23,12 @@ class TestRecogTextDataset(TestCase): # test load_data_list anno = dataset.load_data_list() - self.assertEqual(anno[0]['img_path'], 'imgs/1223731.jpg') + self.assertIn(anno[0]['img_path'], + ['imgs/1223731.jpg', 'imgs\\1223731.jpg']) self.assertEqual(anno[0]['instances'][0]['text'], 'GRAND') - self.assertEqual(anno[1]['img_path'], 'imgs/1223733.jpg') + self.assertIn(anno[1]['img_path'], + ['imgs/1223733.jpg', 'imgs\\1223733.jpg']) + self.assertEqual(anno[1]['instances'][0]['text'], 'HOTEL') def test_jsonl_dataset(self): @@ -40,7 +43,9 @@ class TestRecogTextDataset(TestCase): # test load_data_list anno = dataset.load_data_list() - self.assertEqual(anno[0]['img_path'], 'imgs/1223731.jpg') + self.assertIn(anno[0]['img_path'], + ['imgs/1223731.jpg', 'imgs\\1223731.jpg']) self.assertEqual(anno[0]['instances'][0]['text'], 'GRAND') - self.assertEqual(anno[1]['img_path'], 'imgs/1223733.jpg') + self.assertIn(anno[1]['img_path'], + ['imgs/1223733.jpg', 'imgs\\1223733.jpg']) self.assertEqual(anno[1]['instances'][0]['text'], 'HOTEL')