Skip to content

Commit

Permalink
[Fix] Update diffusers to v0.23.0 (open-mmlab#2069)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
liuwenran authored Nov 13, 2023
1 parent ef68f11 commit c1873dd
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/pr_stage_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand All @@ -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
Expand All @@ -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 }}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mmagic/models/editors/arcface/id_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__()
Expand Down
2 changes: 1 addition & 1 deletion requirements/runtime.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions tests/test_models/test_archs/test_wrapper.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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')
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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(
Expand Down
1 change: 0 additions & 1 deletion tests/test_models/test_base_models/test_base_edit_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c1873dd

Please sign in to comment.