Skip to content

[Feature Request] Incorporate HiDiffusion (monofy-org) #11

@iwr-redmond

Description

@iwr-redmond

HiDiffusion allows for higher-resolution image-generation in SD15 and SDXL.

The original package is broken (the maintainer chamber-of-commerced it) but has been updated by John Street in this PR to fix the erroneous code.

This branch seems suitable to be incorporated into stablepy as another extension. It could then be called upon by adding the apply_hidiffusion and remove_hidiffusion activations in model.py at around about L1826 in a manner similar to the existing FreeU code.

if HiDiffusion and self.class_name != FLUX:
    logger.info("HiDiffusion active")
    apply_hidiffusion(pipe)
    self.HiDiffusion = True
elif self.HiDiffusion:
    remove_hidiffusion(pipe)
    self.HiDiffusion = False
fi

Note that if an SD15 model does not have a built-in (baked) VAE, it would be highly advantageous to discover this and apply the default SD15 VAE. There is code in the diffusers conversion pipeline (lines 636-643) to detect baked VAEs, and so I suggest trialing the following process for SD15/SDXL to replace your Default VAE SDXL code in model.py lines 602-622:

  1. Probe the single file model for the VAE key per the Diffusers code:

vae_key = "first_stage_model." if any(k.startswith("first_stage_model.") for k in keys) else ""

Detecting a VAE in diffusers format can be done using path (per this gist):

vae_path = osp.join(args.model_path, "vae", "diffusion_pytorch_model.safetensors")

  1. If there is a bakedVAE, load this (SD15 + SDXL)
  2. If SDXL & no bakedVAE, load the vae-fp16-fix
  3. If SD15 & HiDiffusion & no bakedVAE, load the SD15 default VAE (stabilityai/sd-vae-ft-mse-original)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions