Creates a config for the diffusers based on the config of the LDM model.
(original_config)
| 244 | |
| 245 | |
| 246 | def create_vae_diffusers_config(original_config): |
| 247 | """ |
| 248 | Creates a config for the diffusers based on the config of the LDM model. |
| 249 | """ |
| 250 | vae_params = original_config.model.params.first_stage_config.params.ddconfig |
| 251 | _ = original_config.model.params.first_stage_config.params.embed_dim |
| 252 | |
| 253 | block_out_channels = [vae_params.ch * mult for mult in vae_params.ch_mult] |
| 254 | down_block_types = ["DownEncoderBlock2D"] * len(block_out_channels) |
| 255 | up_block_types = ["UpDecoderBlock2D"] * len(block_out_channels) |
| 256 | |
| 257 | config = dict( |
| 258 | sample_size=vae_params.resolution, |
| 259 | in_channels=vae_params.in_channels, |
| 260 | out_channels=vae_params.out_ch, |
| 261 | down_block_types=tuple(down_block_types), |
| 262 | up_block_types=tuple(up_block_types), |
| 263 | block_out_channels=tuple(block_out_channels), |
| 264 | latent_channels=vae_params.z_channels, |
| 265 | layers_per_block=vae_params.num_res_blocks, |
| 266 | ) |
| 267 | return config |
| 268 | |
| 269 | |
| 270 | def create_diffusers_schedular(original_config): |