From 3292c246a8f0dac11c54617ee51ae5b2d0317662 Mon Sep 17 00:00:00 2001 From: MeowZheng Date: Sat, 31 Dec 2022 12:52:44 +0800 Subject: [PATCH 01/14] [Fix]Fix the deprecation of np.float --- tests/test_metrics.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_metrics.py b/tests/test_metrics.py index 51ad1f349c..eea104ed7b 100644 --- a/tests/test_metrics.py +++ b/tests/test_metrics.py @@ -31,7 +31,7 @@ def get_confusion_matrix(pred_label, label, num_classes, ignore_index): def legacy_mean_iou(results, gt_seg_maps, num_classes, ignore_index): num_imgs = len(results) assert len(gt_seg_maps) == num_imgs - total_mat = np.zeros((num_classes, num_classes), dtype=np.float) + total_mat = np.zeros((num_classes, num_classes), dtype=np.float32) for i in range(num_imgs): mat = get_confusion_matrix( results[i], gt_seg_maps[i], num_classes, ignore_index=ignore_index) @@ -48,7 +48,7 @@ def legacy_mean_iou(results, gt_seg_maps, num_classes, ignore_index): def legacy_mean_dice(results, gt_seg_maps, num_classes, ignore_index): num_imgs = len(results) assert len(gt_seg_maps) == num_imgs - total_mat = np.zeros((num_classes, num_classes), dtype=np.float) + total_mat = np.zeros((num_classes, num_classes), dtype=np.float32) for i in range(num_imgs): mat = get_confusion_matrix( results[i], gt_seg_maps[i], num_classes, ignore_index=ignore_index) From b6888980345e774d4caae1d1bec3d583274c7713 Mon Sep 17 00:00:00 2001 From: MeowZheng Date: Sat, 31 Dec 2022 13:53:27 +0800 Subject: [PATCH 02/14] use np.allclose --- tests/test_metrics.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/test_metrics.py b/tests/test_metrics.py index eea104ed7b..323c773aaf 100644 --- a/tests/test_metrics.py +++ b/tests/test_metrics.py @@ -100,7 +100,7 @@ def test_metrics(): 'IoU'] all_acc_l, acc_l, iou_l = legacy_mean_iou(results, label, num_classes, ignore_index) - assert all_acc == all_acc_l + assert np.allclose(all_acc, all_acc_l) assert np.allclose(acc, acc_l) assert np.allclose(iou, iou_l) # Test the correctness of the implementation of mDice calculation. @@ -110,7 +110,7 @@ def test_metrics(): 'Dice'] all_acc_l, acc_l, dice_l = legacy_mean_dice(results, label, num_classes, ignore_index) - assert all_acc == all_acc_l + assert np.allclose(all_acc, all_acc_l) assert np.allclose(acc, acc_l) assert np.allclose(dice, dice_l) # Test the correctness of the implementation of mDice calculation. @@ -120,7 +120,7 @@ def test_metrics(): 'Recall'], ret_metrics['Precision'], ret_metrics['Fscore'] all_acc_l, recall_l, precision_l, fscore_l = legacy_mean_fscore( results, label, num_classes, ignore_index) - assert all_acc == all_acc_l + assert np.allclose(all_acc, all_acc_l) assert np.allclose(recall, recall_l) assert np.allclose(precision, precision_l) assert np.allclose(fscore, fscore_l) @@ -135,7 +135,7 @@ def test_metrics(): 'aAcc'], ret_metrics['Acc'], ret_metrics['IoU'], ret_metrics[ 'Dice'], ret_metrics['Precision'], ret_metrics[ 'Recall'], ret_metrics['Fscore'] - assert all_acc == all_acc_l + assert np.allclose(all_acc, all_acc_l) assert np.allclose(acc, acc_l) assert np.allclose(iou, iou_l) assert np.allclose(dice, dice_l) @@ -228,7 +228,7 @@ def test_mean_iou(): 'IoU'] all_acc_l, acc_l, iou_l = legacy_mean_iou(results, label, num_classes, ignore_index) - assert all_acc == all_acc_l + assert np.allclose(all_acc, all_acc_l) assert np.allclose(acc, acc_l) assert np.allclose(iou, iou_l) @@ -254,7 +254,7 @@ def test_mean_dice(): 'Dice'] all_acc_l, acc_l, dice_l = legacy_mean_dice(results, label, num_classes, ignore_index) - assert all_acc == all_acc_l + assert np.allclose(all_acc, all_acc_l) assert np.allclose(acc, acc_l) assert np.allclose(iou, dice_l) @@ -280,7 +280,7 @@ def test_mean_fscore(): 'Recall'], ret_metrics['Precision'], ret_metrics['Fscore'] all_acc_l, recall_l, precision_l, fscore_l = legacy_mean_fscore( results, label, num_classes, ignore_index) - assert all_acc == all_acc_l + assert np.allclose(all_acc, all_acc_l) assert np.allclose(recall, recall_l) assert np.allclose(precision, precision_l) assert np.allclose(fscore, fscore_l) @@ -291,7 +291,7 @@ def test_mean_fscore(): 'Recall'], ret_metrics['Precision'], ret_metrics['Fscore'] all_acc_l, recall_l, precision_l, fscore_l = legacy_mean_fscore( results, label, num_classes, ignore_index, beta=2) - assert all_acc == all_acc_l + assert np.allclose(all_acc, all_acc_l) assert np.allclose(recall, recall_l) assert np.allclose(precision, precision_l) assert np.allclose(fscore, fscore_l) @@ -346,6 +346,6 @@ def save_arr(input_arrays: list, title: str, is_image: bool, dir: str): 'Acc'], ret_metrics['IoU'] all_acc_l, acc_l, iou_l = legacy_mean_iou(results, labels, num_classes, ignore_index) - assert all_acc == all_acc_l + assert np.allclose(all_acc, all_acc_l) assert np.allclose(acc, acc_l) assert np.allclose(iou, iou_l) From a17c4dd80b9901da64ca65a1a1f48f642cdca01f Mon Sep 17 00:00:00 2001 From: MeowZheng Date: Sat, 31 Dec 2022 14:09:25 +0800 Subject: [PATCH 03/14] use np.float --- tests/test_metrics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_metrics.py b/tests/test_metrics.py index 323c773aaf..adb09ae4ee 100644 --- a/tests/test_metrics.py +++ b/tests/test_metrics.py @@ -69,7 +69,7 @@ def legacy_mean_fscore(results, beta=1): num_imgs = len(results) assert len(gt_seg_maps) == num_imgs - total_mat = np.zeros((num_classes, num_classes), dtype=np.float) + total_mat = np.zeros((num_classes, num_classes), dtype=np.float32) for i in range(num_imgs): mat = get_confusion_matrix( results[i], gt_seg_maps[i], num_classes, ignore_index=ignore_index) From 81fa487a52b710662c6633b55b0e47de8e6212b0 Mon Sep 17 00:00:00 2001 From: MeowZheng Date: Sat, 31 Dec 2022 15:15:45 +0800 Subject: [PATCH 04/14] mim install mmcv --- .github/workflows/build.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4e067cfa39..10ceb62f17 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,7 +57,8 @@ jobs: 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/${{matrix.torch_version}}/index.html + pip install openmim + mim install 'mmcv<=2.0.0rc1' python -c 'import mmcv; print(mmcv.__version__)' - name: Install unittest dependencies run: | @@ -131,7 +132,8 @@ jobs: - name: Install mmseg dependencies run: | python -V - python -m pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu101/${{matrix.torch_version}}/index.html + python -m pip install -U openmim + mim install mmcv-full python -m pip install -r requirements.txt python -c 'import mmcv; print(mmcv.__version__)' - name: Build and install @@ -199,7 +201,8 @@ jobs: - name: Install mmseg dependencies run: | python -V - python -m pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu102/${{matrix.torch_version}}/index.html + python -m pip install openmim + mim install mmcv-full python -m pip install -r requirements.txt python -c 'import mmcv; print(mmcv.__version__)' - name: Build and install @@ -264,7 +267,8 @@ jobs: - name: Install mmseg dependencies run: | python -V - python -m pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu116/${{matrix.torch_version}}/index.html + python -m pip install openmim + mim install mmcv-full python -m pip install -r requirements.txt python -c 'import mmcv; print(mmcv.__version__)' - name: Build and install @@ -301,7 +305,8 @@ jobs: run: pip install torch==1.8.2+${{ matrix.platform }} torchvision==0.9.2+${{ matrix.platform }} -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html - name: Install MMCV run: | - pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cpu/torch1.8/index.html --only-binary mmcv-full + pip install -U openmim + mim isnall mmcv-full - name: Install unittest dependencies run: pip install -r requirements/tests.txt -r requirements/optional.txt - name: Build and install From d215860694e7d05e82351197489ae74085d91e06 Mon Sep 17 00:00:00 2001 From: MeowZheng Date: Sat, 31 Dec 2022 15:18:27 +0800 Subject: [PATCH 05/14] fix mmcv install --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 10ceb62f17..a8c1e64276 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -58,7 +58,7 @@ jobs: - name: Install MMCV run: | pip install openmim - mim install 'mmcv<=2.0.0rc1' + mim install 'mmcv<2.0.0rc0' python -c 'import mmcv; print(mmcv.__version__)' - name: Install unittest dependencies run: | From 9afe5643150e4b76fb0056cc5ebf5071854a964c Mon Sep 17 00:00:00 2001 From: MeowZheng Date: Sat, 31 Dec 2022 15:23:02 +0800 Subject: [PATCH 06/14] fix mmcv cpu install --- .github/workflows/build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a8c1e64276..b700cf957d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,8 +57,7 @@ jobs: 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 openmim - mim install 'mmcv<2.0.0rc0' + pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cpu/${{matrix.torch_version}}/index.html python -c 'import mmcv; print(mmcv.__version__)' - name: Install unittest dependencies run: | From e2906e3a6b9cee6a2913247818cd357043edcb7a Mon Sep 17 00:00:00 2001 From: MeowZheng Date: Sat, 31 Dec 2022 15:32:08 +0800 Subject: [PATCH 07/14] typo --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b700cf957d..08b530c451 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -192,6 +192,8 @@ jobs: apt-get update && apt-get install -y libgl1-mesa-glx ffmpeg libsm6 libxext6 git ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 apt-get clean rm -rf /var/lib/apt/lists/* + export LC_ALL=C.UTF-8 + export LANG=C.UTF-8 - name: Install Pillow run: python -m pip install Pillow==6.2.2 if: ${{matrix.torchvision < 0.5}} From f1fd8f1ce0c74a2fd9f85ec08b5aacaf0f4ee8c3 Mon Sep 17 00:00:00 2001 From: MeowZheng Date: Sat, 31 Dec 2022 15:36:27 +0800 Subject: [PATCH 08/14] typo --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 08b530c451..f471ed6c9e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -307,7 +307,7 @@ jobs: - name: Install MMCV run: | pip install -U openmim - mim isnall mmcv-full + mim install mmcv-full - name: Install unittest dependencies run: pip install -r requirements/tests.txt -r requirements/optional.txt - name: Build and install From fcd380bd5d71553c14f36aa10466c8d0bfea9309 Mon Sep 17 00:00:00 2001 From: MeowZheng Date: Sat, 31 Dec 2022 15:44:30 +0800 Subject: [PATCH 09/14] fix --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f471ed6c9e..914e643ab8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -189,11 +189,11 @@ jobs: apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub - name: Install system dependencies run: | + export LC_ALL=C.UTF-8 + export LANG=C.UTF-8 apt-get update && apt-get install -y libgl1-mesa-glx ffmpeg libsm6 libxext6 git ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 apt-get clean rm -rf /var/lib/apt/lists/* - export LC_ALL=C.UTF-8 - export LANG=C.UTF-8 - name: Install Pillow run: python -m pip install Pillow==6.2.2 if: ${{matrix.torchvision < 0.5}} From 4d3884f9868ddffe63c6dc991ec6fb625c9df1a8 Mon Sep 17 00:00:00 2001 From: MeowZheng Date: Sat, 31 Dec 2022 15:58:45 +0800 Subject: [PATCH 10/14] add env --- .github/workflows/build.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 914e643ab8..398a55800d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -164,10 +164,12 @@ jobs: fail_ci_if_error: false build_cuda102: + env: + LC_ALL: C.UTF-8 + LANG: C.UTF-8 runs-on: ubuntu-18.04 container: image: pytorch/pytorch:1.9.0-cuda10.2-cudnn7-devel - strategy: matrix: python-version: [3.6, 3.7, 3.8, 3.9] @@ -176,7 +178,6 @@ jobs: - torch: 1.9.0+cu102 torch_version: torch1.9 torchvision: 0.10.0+cu102 - steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} @@ -189,8 +190,6 @@ jobs: apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub - name: Install system dependencies run: | - export LC_ALL=C.UTF-8 - export LANG=C.UTF-8 apt-get update && apt-get install -y libgl1-mesa-glx ffmpeg libsm6 libxext6 git ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 apt-get clean rm -rf /var/lib/apt/lists/* From 5d646a1bd02a02c84736f1a3fdf77dbb3a19e448 Mon Sep 17 00:00:00 2001 From: MeowZheng Date: Sat, 31 Dec 2022 16:09:07 +0800 Subject: [PATCH 11/14] fix timm test --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 398a55800d..a2b01abaa9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -147,13 +147,13 @@ jobs: coverage xml coverage report -m # timm from v0.6.11 requires torch>=1.7 - if: ${{matrix.torch >= '1.7.0'}} + if: ${{matrix.torch != '1.5.1' || matrix.torch != '1.6.0'}} - name: Skip timm unittests and generate coverage report run: | coverage run --branch --source mmseg -m pytest tests/ --ignore tests/test_models/test_backbones/test_timm_backbone.py coverage xml coverage report -m - if: ${{matrix.torch < '1.7.0'}} + if: ${{matrix.torch == '1.5.1' || matrix.torch == '1.6.0'}} - name: Upload coverage to Codecov uses: codecov/codecov-action@v1.0.10 with: @@ -313,7 +313,7 @@ jobs: run: pip install -e . - name: Run unittests run: | - python -m pip install 'timm<0.6.11' + python -m pip install timm coverage run --branch --source mmseg -m pytest tests/ - name: Generate coverage report run: | From bb7f4d52f2c58f379ec407450bbb8fd0202f1dae Mon Sep 17 00:00:00 2001 From: MeowZheng Date: Sat, 31 Dec 2022 16:12:29 +0800 Subject: [PATCH 12/14] fix if --- .github/workflows/build.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a2b01abaa9..29a6113c92 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -71,13 +71,13 @@ jobs: coverage xml coverage report -m # timm from v0.6.11 requires torch>=1.7 - if: ${{matrix.torch >= '1.7.0'}} + if: ${{matrix.torch != '1.5.1' || matrix.torch != '1.6.0'}} - name: Skip timm unittests and generate coverage report run: | coverage run --branch --source mmseg -m pytest tests/ --ignore tests/test_models/test_backbones/test_timm_backbone.py coverage xml coverage report -m - if: ${{matrix.torch < '1.7.0'}} + if: ${{matrix.torch == '1.5.1' || matrix.torch == '1.6.0'}} build_cuda101: runs-on: ubuntu-18.04 @@ -123,9 +123,6 @@ jobs: apt-get update && apt-get install -y libgl1-mesa-glx ffmpeg libsm6 libxext6 git ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 python${{matrix.python-version}}-dev apt-get clean rm -rf /var/lib/apt/lists/* - - name: Install Pillow - run: python -m pip install Pillow==6.2.2 - if: ${{matrix.torchvision < 0.5}} - name: Install PyTorch run: python -m pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html - name: Install mmseg dependencies @@ -193,9 +190,6 @@ jobs: apt-get update && apt-get install -y libgl1-mesa-glx ffmpeg libsm6 libxext6 git ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 apt-get clean rm -rf /var/lib/apt/lists/* - - name: Install Pillow - run: python -m pip install Pillow==6.2.2 - if: ${{matrix.torchvision < 0.5}} - name: Install PyTorch run: python -m pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html - name: Install mmseg dependencies @@ -259,9 +253,6 @@ jobs: run: python -m pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html - name: Install system dependencies run: apt-get update && apt-get install -y ffmpeg libturbojpeg ninja-build - - name: Install Pillow - run: python -m pip install Pillow==6.2.2 - if: ${{matrix.torchvision < 0.5}} - name: Install PyTorch run: python -m pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html - name: Install mmseg dependencies From 9154c1700b2763ba857a3c981ae46fe143a7ef80 Mon Sep 17 00:00:00 2001 From: MeowZheng Date: Sat, 31 Dec 2022 16:29:28 +0800 Subject: [PATCH 13/14] fix cu101 --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 29a6113c92..aaf977a627 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -144,13 +144,13 @@ jobs: coverage xml coverage report -m # timm from v0.6.11 requires torch>=1.7 - if: ${{matrix.torch != '1.5.1' || matrix.torch != '1.6.0'}} + if: ${{matrix.torch != '1.5.1+cu101' || matrix.torch != '1.6.0+cu101'}} - name: Skip timm unittests and generate coverage report run: | coverage run --branch --source mmseg -m pytest tests/ --ignore tests/test_models/test_backbones/test_timm_backbone.py coverage xml coverage report -m - if: ${{matrix.torch == '1.5.1' || matrix.torch == '1.6.0'}} + if: ${{matrix.torch == '1.5.1+cu101' || matrix.torch == '1.6.0+cu101'}} - name: Upload coverage to Codecov uses: codecov/codecov-action@v1.0.10 with: From 93bf509419eb88fa71456bcd2c17de82d9b30639 Mon Sep 17 00:00:00 2001 From: MeowZheng Date: Sat, 31 Dec 2022 16:35:20 +0800 Subject: [PATCH 14/14] fix if --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index aaf977a627..2ab59cd3f3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -71,7 +71,7 @@ jobs: coverage xml coverage report -m # timm from v0.6.11 requires torch>=1.7 - if: ${{matrix.torch != '1.5.1' || matrix.torch != '1.6.0'}} + if: ${{matrix.torch != '1.5.1' && matrix.torch != '1.6.0'}} - name: Skip timm unittests and generate coverage report run: | coverage run --branch --source mmseg -m pytest tests/ --ignore tests/test_models/test_backbones/test_timm_backbone.py @@ -144,7 +144,7 @@ jobs: coverage xml coverage report -m # timm from v0.6.11 requires torch>=1.7 - if: ${{matrix.torch != '1.5.1+cu101' || matrix.torch != '1.6.0+cu101'}} + if: ${{matrix.torch != '1.5.1+cu101' && matrix.torch != '1.6.0+cu101'}} - name: Skip timm unittests and generate coverage report run: | coverage run --branch --source mmseg -m pytest tests/ --ignore tests/test_models/test_backbones/test_timm_backbone.py