Creates a config for the diffusers based on the config of the LDM model.
(original_config, image_size: int)
| 282 | |
| 283 | |
| 284 | def create_vae_diffusers_config(original_config, image_size: int): |
| 285 | """ |
| 286 | Creates a config for the diffusers based on the config of the LDM model. |
| 287 | """ |
| 288 | vae_params = original_config.model.params.first_stage_config.params.ddconfig |
| 289 | _ = original_config.model.params.first_stage_config.params.embed_dim |
| 290 | |
| 291 | block_out_channels = [vae_params.ch * mult for mult in vae_params.ch_mult] |
| 292 | down_block_types = ["DownEncoderBlock2D"] * len(block_out_channels) |
| 293 | up_block_types = ["UpDecoderBlock2D"] * len(block_out_channels) |
| 294 | |
| 295 | config = { |
| 296 | "sample_size": image_size, |
| 297 | "in_channels": vae_params.in_channels, |
| 298 | "out_channels": vae_params.out_ch, |
| 299 | "down_block_types": tuple(down_block_types), |
| 300 | "up_block_types": tuple(up_block_types), |
| 301 | "block_out_channels": tuple(block_out_channels), |
| 302 | "latent_channels": vae_params.z_channels, |
| 303 | "layers_per_block": vae_params.num_res_blocks, |
| 304 | } |
| 305 | return config |
| 306 | |
| 307 | |
| 308 | def create_diffusers_schedular(original_config): |
nothing calls this directly
no outgoing calls
no test coverage detected