Skip to content

Commit

Permalink
Fix setting scaling factor in VAE config (#6779)
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
DN6 committed Jan 31, 2024
1 parent 97ee616 commit d7dc0ff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/diffusers/loaders/single_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ def build_sub_model_components(
return unet_components

if component_name == "vae":
scaling_factor = kwargs.get("scaling_factor", None)
vae_components = create_diffusers_vae_model_from_ldm(
pipeline_class_name, original_config, checkpoint, image_size
pipeline_class_name, original_config, checkpoint, image_size, scaling_factor
)
return vae_components

Expand Down
3 changes: 2 additions & 1 deletion src/diffusers/loaders/single_file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,11 +513,12 @@ def create_controlnet_diffusers_config(original_config, image_size: int):
return controlnet_config


def create_vae_diffusers_config(original_config, image_size, scaling_factor=0.18125):
def create_vae_diffusers_config(original_config, image_size, scaling_factor=None):
"""
Creates a config for the diffusers based on the config of the LDM model.
"""
vae_params = original_config["model"]["params"]["first_stage_config"]["params"]["ddconfig"]
scaling_factor = scaling_factor or original_config["model"]["params"]["scale_factor"]

This comment has been minimized.

Copy link
@patrickvonplaten

patrickvonplaten Feb 12, 2024

Contributor

I'm not sure that we can assume that a scaling_factor exists in the config, see: #6428 (comment)


block_out_channels = [vae_params["ch"] * mult for mult in vae_params["ch_mult"]]
down_block_types = ["DownEncoderBlock2D"] * len(block_out_channels)
Expand Down

0 comments on commit d7dc0ff

Please sign in to comment.