Skip to content

Commit

Permalink
fix urls in CI and readthedocs (#2364)
Browse files Browse the repository at this point in the history
* debug

* fix ut

* fix ut for end2end model

* fix

* update readthedocs

* fix

* fix skip

* enlarge space
  • Loading branch information
RunningLeon committed Aug 30, 2023
1 parent b7024dd commit d9140ab
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 48 deletions.
4 changes: 2 additions & 2 deletions .github/scripts/test_onnx2ncnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
'mmpretrain/configs/resnet/resnet18_8xb32_in1k.py',
'https://download.openmmlab.com/mmclassification/v0/resnet/resnet18_8xb32_in1k_20210831-fbbb1da6.pth', # noqa: E501
'resnet18.onnx',
'https://media.githubusercontent.com/media/tpoisonooo/mmdeploy-onnx2ncnn-testdata/main/resnet18.onnx', # noqa: E501
'https://github.com/open-mmlab/mmdeploy/releases/download/v0.1.0/resnet18.onnx', # noqa: E501
),
(
'mmpretrain/configs/mobilenet_v2/mobilenet-v2_8xb32_in1k.py',
'https://download.openmmlab.com/mmclassification/v0/mobilenet_v2/mobilenet_v2_batch256_imagenet_20200708-3b2dc3af.pth', # noqa: E501
'mobilenet-v2.onnx',
'https://media.githubusercontent.com/media/tpoisonooo/mmdeploy-onnx2ncnn-testdata/main/mobilenet-v2.onnx', # noqa: E501
'https://github.com/open-mmlab/mmdeploy/releases/download/v0.1.0/mobilenet-v2.onnx', # noqa: E501
)
]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/backend-ncnn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ jobs:
export input_img=tests/data/tiger.jpeg
python3 -m mim download mmpretrain --config resnet18_8xb32_in1k --dest $work_dir
python3 tools/torch2onnx.py $deploy_cfg $model_cfg $checkpoint $input_img --work-dir $work_dir
wget https://media.githubusercontent.com/media/tpoisonooo/mmdeploy-onnx2ncnn-testdata/main/dataset.tar
wget https://github.com/open-mmlab/mmdeploy/releases/download/v0.1.0/dataset.tar
tar xvf dataset.tar
python3 tools/onnx2ncnn_quant_table.py \
--onnx $work_dir/end2end.onnx \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/backend-snpe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
sudo apt install libopencv-dev
- name: Install snpe
run: |
wget https://media.githubusercontent.com/media/tpoisonooo/mmdeploy_snpe_testdata/main/snpe-1.59.tar.gz
wget https://github.com/open-mmlab/mmdeploy/releases/download/v0.1.0/snpe-1.59.tar.gz
tar xf snpe-1.59.tar.gz
pushd snpe-1.59.0.3230
pwd
Expand Down
74 changes: 43 additions & 31 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
python -m pip install -r requirements/backends.txt
python -m mim install "mmcv>=2.0.0"
python -m mim install -r requirements/codebases.txt
python -m pip install clip numba transformers numpy==1.23
python -m pip install clip numba transformers numpy==1.23 albumentations
python -m pip list
- name: Install mmyolo
run: |
Expand Down Expand Up @@ -145,23 +145,16 @@ jobs:
COLOR: ${{ steps.badge_status.conclusion == 'success' && 'green' || 'red' }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build_cuda102:
build_cuda117:
runs-on: ubuntu-20.04
container:
image: pytorch/pytorch:1.9.0-cuda10.2-cudnn7-devel
image: pytorch/pytorch:2.0.0-cuda11.7-cudnn8-devel
env:
FORCE_CUDA: 1
strategy:
matrix:
torch: [1.9.0+cu102]
include:
- torch: 1.9.0+cu102
torchvision: 0.10.0+cu102
steps:
- uses: actions/checkout@v2
- name: Install system dependencies
run: |
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A4B469963BF863CC
apt-get update && apt-get install -y ffmpeg libsm6 libxext6 git ninja-build libglib2.0-0 libxrender-dev
apt-get clean
rm -rf /var/lib/apt/lists/*
Expand All @@ -170,33 +163,50 @@ jobs:
python -V
python -m pip show torch torchvision
python -m pip install --no-cache-dir --upgrade pip
python -m pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html
- name: Check disk space
continue-on-error: true
run: |
df -h
rm -rf /__t/go
rm -rf /__t/node
rm -rf /__t/Ruby
rm -rf /__t/CodeQL
cat /proc/cpuinfo | grep -ic proc
free
df -h
- name: Install dependencies
run: |
python -V
export CFLAGS=`python -c 'import sysconfig;print("-I"+sysconfig.get_paths()["include"])'`
python -m pip install --no-cache-dir openmim
python -m pip install --no-cache-dir -r requirements.txt
python -m pip install --no-cache-dir -r requirements/backends.txt
python -m mim install "mmcv>=2.0.0rc1"
CFLAGS=$CFLAGS python -m mim install -r requirements/codebases.txt
python -m pip install --no-cache-dir -U pycuda numpy clip numba transformers
python -m mim install "mmcv>=2.0.0"
python -m pip install --no-cache-dir -r requirements/codebases.txt
python -m pip install --no-cache-dir -U pycuda numpy==1.23 clip numba transformers albumentations
python -m pip list
- name: Build and install
run: |
rm -rf .eggs && python -m pip install -e .
python tools/check_env.py
- name: Run unittests and generate coverage report
id: badge_status
run: |
coverage run --branch --source mmdeploy -m pytest -rsE tests
coverage xml
coverage report -m
- name: Upload coverage to Codecov
id: badge_status
uses: codecov/codecov-action@v2
with:
file: ./coverage.xml,./coverage.info
flags: unittests
env_vars: OS,PYTHON,CPLUS
name: codecov-umbrella
fail_ci_if_error: false
- name: create badge
if: always()
uses: RubbaBoy/[email protected]
with:
NAME: build_cuda102
NAME: build_cuda117
LABEL: 'build'
STATUS: ${{ steps.badge_status.conclusion == 'success' && 'passing' || 'failing' }}
COLOR: ${{ steps.badge_status.conclusion == 'success' && 'green' || 'red' }}
Expand All @@ -210,7 +220,6 @@ jobs:
- uses: actions/checkout@v2
- name: Install system dependencies
run: |
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A4B469963BF863CC
apt-get update && apt-get install -y ffmpeg libsm6 libxext6 git ninja-build libglib2.0-0 libxrender-dev
apt-get clean
rm -rf /var/lib/apt/lists/*
Expand All @@ -219,16 +228,26 @@ jobs:
python -V
python -m pip show torch torchvision
python -m pip install --no-cache-dir --upgrade pip
- name: Check disk space
continue-on-error: true
run: |
df -h
rm -rf /__t/go
rm -rf /__t/node
rm -rf /__t/Ruby
rm -rf /__t/CodeQL
cat /proc/cpuinfo | grep -ic proc
free
df -h
- name: Install dependencies
run: |
python -V
export CFLAGS=`python -c 'import sysconfig;print("-I"+sysconfig.get_paths()["include"])'`
python -m pip install --no-cache-dir openmim
python -m pip install --no-cache-dir -r requirements.txt
python -m pip install --no-cache-dir -r requirements/backends.txt
python -m mim install "mmcv>=2.0.0rc1"
python -m mim install -r requirements/codebases.txt
python -m pip install --no-cache-dir -U pycuda numpy clip numba transformers
python -m mim install --no-cache-dir "mmcv>=2.0.0"
python -m pip install --no-cache-dir -r requirements/codebases.txt
python -m pip install --no-cache-dir -U pycuda numpy clip numba transformers albumentations
python -m pip list
- name: Build and install
run: |
Expand All @@ -239,15 +258,6 @@ jobs:
coverage run --branch --source mmdeploy -m pytest -rsE tests
coverage xml
coverage report -m
- name: Upload coverage to Codecov
id: badge_status
uses: codecov/codecov-action@v2
with:
file: ./coverage.xml,./coverage.info
flags: unittests
env_vars: OS,PYTHON,CPLUS
name: codecov-umbrella
fail_ci_if_error: false
- name: create badge
if: always()
uses: RubbaBoy/[email protected]
Expand All @@ -259,6 +269,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build_cuda113_linux:
needs: [build_cpu_model_convert, build_cpu_sdk, build_cuda117]
runs-on: [self-hosted, linux-3090]
container:
image: openmmlab/mmdeploy:ubuntu20.04-cuda11.3
Expand Down Expand Up @@ -309,6 +320,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build_cuda113_windows:
needs: [build_cpu_model_convert, build_cpu_sdk, build_cuda117]
runs-on: [self-hosted, win10-3080]
env:
BASE_ENV: cuda11.3-cudnn8.2-py3.8-torch1.10
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/regression-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ on:
required: false
description: 'Do not change it unless you know what you are doing!'
type: string
default: 'https://8d17-103-108-182-56.ngrok-free.app'
default: 'https://e2e1-14-136-99-158.ngrok-free.app'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
close-issue-message: 'This issue is closed because it has been stale for 5 days. Please open a new issue if you have similar issues or you have any new updates now.'
close-pr-message: 'This PR is closed because it has been stale for 10 days. Please reopen this PR if you have any updates and want to keep contributing the code.'
# only issues/PRS with following labels are checked
any-of-labels: 'invalid, awaiting response, duplicate'
any-of-labels: 'invalid, awaiting response, duplicate, Stale, upstream issue'
days-before-issue-stale: 7
days-before-pr-stale: 45
days-before-issue-close: 5
Expand Down
6 changes: 5 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ version: 2

formats: all

build:
os: "ubuntu-22.04"
tools:
python: "3.8"

python:
version: 3.7
install:
- requirements: requirements/docs.txt
- requirements: requirements/readthedocs.txt
2 changes: 1 addition & 1 deletion mmdeploy/apis/onnx/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def wrapper(*arg, **kwargs):
if isinstance(args, torch.Tensor):
args = args.cpu()
elif isinstance(args, (tuple, list)):
args = [_.cpu() for _ in args]
args = tuple([_.cpu() for _ in args])
else:
raise RuntimeError(f'Not supported args: {args}')
torch.onnx.export(
Expand Down
17 changes: 9 additions & 8 deletions mmdeploy/codebase/mmdet/deploy/object_detection_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,19 +199,20 @@ def postprocessing_results(self,
labels = labels.to(device)
bboxes = dets[:, :4]
scores = dets[:, 4]
scale_factor = bboxes.new_ones(1, 4)
scale_factor = bboxes.new_ones(4)
# get scale_factor
if 'scale_factor' in img_metas[i]:
scale_factor = img_metas[i]['scale_factor']
if isinstance(scale_factor, (list, tuple, np.ndarray)):
if isinstance(scale_factor, np.ndarray):
scale_factor = scale_factor.squeeze(0).tolist()

if isinstance(scale_factor, (list, tuple)):
if len(scale_factor) == 2:
scale_factor = np.array(scale_factor)
scale_factor = np.concatenate(
[scale_factor, scale_factor])
scale_factor = np.array(scale_factor)[None, :] # [1,4]
scale_factor = torch.from_numpy(scale_factor).to(dets)
scale_factor = scale_factor + scale_factor
assert len(scale_factor) == 4
scale_factor = torch.tensor(scale_factor).to(dets)
if rescale:
bboxes /= scale_factor
bboxes /= scale_factor.view(1, 4)

# Most of models in mmdetection 3.x use `pad_param`, but some
# models like CenterNet uses `border`.
Expand Down
5 changes: 4 additions & 1 deletion tests/test_apis/test_onnx_passes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest
import torch
import torch.nn as nn
from packaging import version

from mmdeploy.apis.onnx.optimizer import \
model_to_graph__custom_optimizer # noqa
Expand Down Expand Up @@ -195,7 +196,9 @@ def forward(self, x):

def test_fuse_select_assign():
pytest.importorskip('mmdeploy.backend.torchscript.ts_optimizer.onnx')

# TODO fix later
if version.parse(torch.__version__) >= version.parse('2.0.0'):
pytest.skip('ignore torch>=2.0.0')
try:
from mmdeploy.backend.torchscript import ts_optimizer
opt_pass = ts_optimizer.onnx._jit_pass_fuse_select_assign
Expand Down

0 comments on commit d9140ab

Please sign in to comment.