From 778505347c4a06238e48b9260119a48cc7464fb4 Mon Sep 17 00:00:00 2001 From: Bryce Date: Sat, 21 Sep 2024 13:21:58 -0700 Subject: [PATCH] fix: update sd15 weight links Fixes #488. See also https://huggingface.co/posts/dn6/357701279407928 --- .github/workflows/ci.yaml | 8 ++++---- imaginairy/config.py | 2 +- imaginairy/weight_management/execution_trace.py | 8 +++++--- imaginairy/weight_management/generate_weight_info.py | 6 +++--- scripts/controlnet_convert.py | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1c9d66b9..9b245993 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -132,7 +132,7 @@ jobs: fail-fast: false matrix: python-version: ["3.10", "3.11"] - os: ["ubuntu-latest", "windows-latest", "macos-latest"] + os: ["ubuntu-latest", "windows-latest", "m2-16gb"] steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4.5.0 @@ -150,7 +150,7 @@ jobs: uv pip install --system ${{ needs.build-wheel.outputs.wheel_name }} - name: Generate an image run: | - imagine fruit --steps 3 --size 512 --seed 1 + imagine fruit --steps 3 --size 128 --seed 1 - uses: actions/upload-artifact@v3 with: name: images @@ -163,7 +163,7 @@ jobs: fail-fast: false matrix: python-version: [ "3.10", "3.11" ] - os: [ "ubuntu-latest", "windows-latest", "macos-latest" ] + os: [ "ubuntu-latest", "windows-latest", "m2-16gb" ] steps: - uses: actions/checkout@v3 - uses: conda-incubator/setup-miniconda@v3 @@ -188,7 +188,7 @@ jobs: shell: bash -l {0} run: | conda activate test-env - imagine fruit --steps 3 --size 512 --seed 1 + imagine fruit --steps 3 --size 128 --seed 1 - uses: actions/upload-artifact@v3 with: name: images diff --git a/imaginairy/config.py b/imaginairy/config.py index 9cce76ac..7e49f450 100644 --- a/imaginairy/config.py +++ b/imaginairy/config.py @@ -131,7 +131,7 @@ def __post_init__(self): aliases=MODEL_ARCHITECTURE_LOOKUP["sd15"].aliases, architecture=MODEL_ARCHITECTURE_LOOKUP["sd15"], defaults={"negative_prompt": DEFAULT_NEGATIVE_PROMPT}, - weights_location="https://huggingface.co/runwayml/stable-diffusion-v1-5/tree/1d0c4ebf6ff58a5caecab40fa1406526bca4b5b9/", + weights_location="https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5/tree/f03de327dd89b501a01da37fc5240cf4fdba85a1/", ), ModelWeightsConfig( name="Stable Diffusion 1.5 - Inpainting", diff --git a/imaginairy/weight_management/execution_trace.py b/imaginairy/weight_management/execution_trace.py index 95589dcd..cd9b6a9d 100644 --- a/imaginairy/weight_management/execution_trace.py +++ b/imaginairy/weight_management/execution_trace.py @@ -98,14 +98,15 @@ def trace_sd15_diffusers_execution_order(device=None): image_size = 256 img_in = torch.randn(1, 3, image_size, image_size).to(device) vae = AutoencoderKL.from_pretrained( - pretrained_model_name_or_path="runwayml/stable-diffusion-v1-5", subfolder="vae" + pretrained_model_name_or_path="stable-diffusion-v1-5/stable-diffusion-v1-5", + subfolder="vae", ).to(device) vae_execution_order = trace_execution_order(vae, (img_in,)) # text encoder model text_encoder = CLIPTextModelWithProjection.from_pretrained( - pretrained_model_name_or_path="runwayml/stable-diffusion-v1-5", + pretrained_model_name_or_path="stable-diffusion-v1-5/stable-diffusion-v1-5", subfolder="text_encoder", ).to(device) tokens = torch.Tensor( @@ -200,7 +201,8 @@ def trace_sd15_diffusers_execution_order(device=None): text_embedding = torch.randn(1, 77, 768).to(device) timestep = torch.tensor(data=[0]).to(device) unet = UNet2DConditionModel.from_pretrained( - pretrained_model_name_or_path="runwayml/stable-diffusion-v1-5", subfolder="unet" + pretrained_model_name_or_path="stable-diffusion-v1-5/stable-diffusion-v1-5", + subfolder="unet", ).to(device) unet_execution_order = trace_execution_order( unet, (latent_in, timestep, text_embedding) diff --git a/imaginairy/weight_management/generate_weight_info.py b/imaginairy/weight_management/generate_weight_info.py index 22d92769..b5ea5256 100644 --- a/imaginairy/weight_management/generate_weight_info.py +++ b/imaginairy/weight_management/generate_weight_info.py @@ -56,21 +56,21 @@ def save_diffusers_patterns(): model_name=utils.MODEL_NAMES.SD15, component_name=utils.COMPONENT_NAMES.VAE, format_name=utils.FORMAT_NAMES.DIFFUSERS, - weights_url="https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/vae/diffusion_pytorch_model.fp16.safetensors", + weights_url="https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5/resolve/main/vae/diffusion_pytorch_model.fp16.safetensors", ) save_weight_info( model_name=utils.MODEL_NAMES.SD15, component_name=utils.COMPONENT_NAMES.UNET, format_name=utils.FORMAT_NAMES.DIFFUSERS, - weights_url="https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/unet/diffusion_pytorch_model.fp16.safetensors", + weights_url="https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5/resolve/main/unet/diffusion_pytorch_model.fp16.safetensors", ) save_weight_info( model_name=utils.MODEL_NAMES.SD15, component_name=utils.COMPONENT_NAMES.TEXT_ENCODER, format_name=utils.FORMAT_NAMES.DIFFUSERS, - weights_url="https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/text_encoder/model.fp16.safetensors", + weights_url="https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5/resolve/main/text_encoder/model.fp16.safetensors", ) diff --git a/scripts/controlnet_convert.py b/scripts/controlnet_convert.py index e8692c6a..fbfcc1a8 100644 --- a/scripts/controlnet_convert.py +++ b/scripts/controlnet_convert.py @@ -6,7 +6,7 @@ from imaginairy.utils.downloads import get_cached_url_path from imaginairy.utils.paths import PKG_ROOT -sd15_url = "https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/889b629140e71758e1e0006e355c331a5744b4bf/v1-5-pruned-emaonly.ckpt" +sd15_url = "https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5/resolve/f03de327dd89b501a01da37fc5240cf4fdba85a1/v1-5-pruned-emaonly.ckpt" def main():