From c1873ddffde7be866db4fad59daa81087e78c758 Mon Sep 17 00:00:00 2001 From: rangoliu Date: Mon, 13 Nov 2023 20:48:33 +0800 Subject: [PATCH] [Fix] Update diffusers to v0.23.0 (#2069) * update diffusers to 23.0 * fix github workflow * fix * fix * downgrade on windows * fix test_base_edit_model.py * fix irse50 link * fix model path * fix * downgrade to torch2.0.1 * fix * fix path error * windows error * avoid interactive --- .github/workflows/pr_stage_test.yml | 22 +++++++++---------- mmagic/models/editors/arcface/id_loss.py | 2 +- requirements/runtime.txt | 2 +- tests/test_models/test_archs/test_wrapper.py | 9 +++++--- .../test_base_models/test_base_edit_model.py | 1 - 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/.github/workflows/pr_stage_test.yml b/.github/workflows/pr_stage_test.yml index d7a6bfc929..daeae03b8b 100644 --- a/.github/workflows/pr_stage_test.yml +++ b/.github/workflows/pr_stage_test.yml @@ -23,10 +23,10 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - python-version: [3.7] + python-version: [3.8] include: - - torch: 1.8.1 - torchvision: 0.9.1 + - torch: 2.0.1 + torchvision: 0.15.2 steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} @@ -66,13 +66,13 @@ jobs: # if: ${{ failure() }} # uses: mxschmitt/action-tmate@v3 - build_cu102: + build_cu118: runs-on: ubuntu-22.04 container: - image: pytorch/pytorch:1.8.1-cuda10.2-cudnn7-devel + image: pytorch/pytorch:2.1.0-cuda11.8-cudnn8-devel strategy: matrix: - python-version: [3.7] + python-version: [3.8] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} @@ -88,9 +88,9 @@ jobs: - name: Install system dependencies run: | apt-get update - apt-get install -y ffmpeg libsm6 libxext6 git ninja-build libglib2.0-0 libxrender-dev + DEBIAN_FRONTEND=noninteractive apt-get install -y ffmpeg libsm6 libxext6 git ninja-build libglib2.0-0 libxrender-dev - name: Install PyTorch - run: pip install torch==1.8.1+cpu torchvision==0.9.1+cpu -f https://download.pytorch.org/whl/torch_stable.html + run: pip install torch==2.0.1+cpu torchvision==0.15.2+cpu -f https://download.pytorch.org/whl/torch_stable.html - name: Install mmagic dependencies run: | pip install git+https://github.com/open-mmlab/mmengine.git@main @@ -108,8 +108,8 @@ jobs: runs-on: windows-2022 strategy: matrix: - python-version: [3.7] - platform: [cpu, cu111] + python-version: [3.8] + platform: [cpu, cu118] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} @@ -121,7 +121,7 @@ jobs: - 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 + run: python -m pip install torch==2.0.1+${{matrix.platform}} torchvision==0.15.2+${{matrix.platform}} -f https://download.pytorch.org/whl/torch_stable.html - name: Install mmagic dependencies run: | python -m pip install git+https://github.com/open-mmlab/mmengine.git@main diff --git a/mmagic/models/editors/arcface/id_loss.py b/mmagic/models/editors/arcface/id_loss.py index 0294f1831d..bec05dd053 100644 --- a/mmagic/models/editors/arcface/id_loss.py +++ b/mmagic/models/editors/arcface/id_loss.py @@ -16,7 +16,7 @@ class IDLossModel(nn.Module): Defaults to None. """ # ir se50 weight download link - _ir_se50_url = 'https://gg0ltg.by.files.1drv.com/y4m3fNNszG03z9n8JQ7EhdtQKW8tQVQMFBisPVRgoXi_UfP8pKSSqv8RJNmHy2JampcPmEazo_Mx6NTFSqBpZmhPniROm9uNoghnzaavvYpxkCfiNmDH9YyIF3g-0nwt6bsjk2X80JDdL5z88OAblSDmB-kuQkWSWvA9BM3Xt8DHMCY8lO4HOQCZ5YWUtFyPAVwEyzTGDM-JRA5EJoN2bF1cg' # noqa + _ir_se50_url = 'https://download.openxlab.org.cn/models/rangoliu/Arcface-IR-SE50/weight/Arcface-IR-SE50' # noqa def __init__(self, ir_se50_weights=None): super(IDLossModel, self).__init__() diff --git a/requirements/runtime.txt b/requirements/runtime.txt index 4debb18102..7d3c05f843 100644 --- a/requirements/runtime.txt +++ b/requirements/runtime.txt @@ -2,7 +2,7 @@ av av==8.0.3; python_version < '3.7' click # required by mmagic/utils/io_utils.py controlnet_aux -diffusers>=0.12.0 +diffusers>=0.23.0 einops face-alignment<=1.3.4 facexlib diff --git a/tests/test_models/test_archs/test_wrapper.py b/tests/test_models/test_archs/test_wrapper.py index c1b2ae8f70..53681c7ed1 100644 --- a/tests/test_models/test_archs/test_wrapper.py +++ b/tests/test_models/test_archs/test_wrapper.py @@ -1,6 +1,7 @@ # Copyright (c) OpenMMLab. All rights reserved. import os import os.path as osp +import platform import shutil from unittest import TestCase from unittest.mock import MagicMock @@ -12,7 +13,7 @@ from mmagic.registry import MODELS from mmagic.utils import register_all_modules -test_dir = osp.join(osp.dirname(__file__), '../../..', 'tests') +test_dir = osp.join(osp.dirname(__file__), '..', '..', '..', 'tests') config_path = osp.join(test_dir, 'configs', 'diffuser_wrapper_cfg') model_path = osp.join(test_dir, 'configs', 'tmp_weight') ckpt_path = osp.join(test_dir, 'configs', 'ckpt') @@ -40,6 +41,7 @@ def test_build(self): self.assertIn(f'From Config: {config_path}', model_str) # 2. test save as diffuser + os.makedirs(model_path, exist_ok=True) if digit_version(TORCH_VERSION) < digit_version('2.0.1'): model.save_pretrained(model_path, safe_serialization=False) else: @@ -71,8 +73,9 @@ def test_build(self): model.init_weights() # delete saved model to save space - shutil.rmtree(model_path) - shutil.rmtree(ckpt_path) + if 'win' not in platform.system().lower(): + shutil.rmtree(model_path) + shutil.rmtree(ckpt_path) # 4. test loading without repo_id model = MODELS.build( diff --git a/tests/test_models/test_base_models/test_base_edit_model.py b/tests/test_models/test_base_models/test_base_edit_model.py index 7b85a49fab..f7c3c09d24 100644 --- a/tests/test_models/test_base_models/test_base_edit_model.py +++ b/tests/test_models/test_base_models/test_base_edit_model.py @@ -50,7 +50,6 @@ def test_base_edit_model(): # train log_vars = model.train_step(data, optim_wrapper) - assert model.generator.layer.weight.grad is not None assert isinstance(log_vars['loss'], torch.Tensor) save_loss = log_vars['loss'] log_vars = model.train_step(data, optim_wrapper)