@@ -112,9 +112,9 @@ def assign_to_checkpoint(
112112 continue
113113
114114 # Global renaming happens here
115- new_path = new_path .replace ("middle_block.0" , "mid .resnets.0" )
116- new_path = new_path .replace ("middle_block.1" , "mid .attentions.0" )
117- new_path = new_path .replace ("middle_block.2" , "mid .resnets.1" )
115+ new_path = new_path .replace ("middle_block.0" , "mid_block .resnets.0" )
116+ new_path = new_path .replace ("middle_block.1" , "mid_block .attentions.0" )
117+ new_path = new_path .replace ("middle_block.2" , "mid_block .resnets.1" )
118118
119119 if additional_replacements is not None :
120120 for replacement in additional_replacements :
@@ -175,15 +175,16 @@ def convert_ldm_checkpoint(checkpoint, config):
175175 attentions = [key for key in input_blocks [i ] if f"input_blocks.{ i } .1" in key ]
176176
177177 if f"input_blocks.{ i } .0.op.weight" in checkpoint :
178- new_checkpoint [f"downsample_blocks .{ block_id } .downsamplers.0.conv.weight" ] = checkpoint [
178+ new_checkpoint [f"down_blocks .{ block_id } .downsamplers.0.conv.weight" ] = checkpoint [
179179 f"input_blocks.{ i } .0.op.weight"
180180 ]
181- new_checkpoint [f"downsample_blocks .{ block_id } .downsamplers.0.conv.bias" ] = checkpoint [
181+ new_checkpoint [f"down_blocks .{ block_id } .downsamplers.0.conv.bias" ] = checkpoint [
182182 f"input_blocks.{ i } .0.op.bias"
183183 ]
184+ continue
184185
185186 paths = renew_resnet_paths (resnets )
186- meta_path = {"old" : f"input_blocks.{ i } .0" , "new" : f"downsample_blocks .{ block_id } .resnets.{ layer_in_block_id } " }
187+ meta_path = {"old" : f"input_blocks.{ i } .0" , "new" : f"down_blocks .{ block_id } .resnets.{ layer_in_block_id } " }
187188 resnet_op = {"old" : "resnets.2.op" , "new" : "downsamplers.0.op" }
188189 assign_to_checkpoint (
189190 paths , new_checkpoint , checkpoint , additional_replacements = [meta_path , resnet_op ], config = config
@@ -193,18 +194,18 @@ def convert_ldm_checkpoint(checkpoint, config):
193194 paths = renew_attention_paths (attentions )
194195 meta_path = {
195196 "old" : f"input_blocks.{ i } .1" ,
196- "new" : f"downsample_blocks .{ block_id } .attentions.{ layer_in_block_id } " ,
197+ "new" : f"down_blocks .{ block_id } .attentions.{ layer_in_block_id } " ,
197198 }
198199 to_split = {
199200 f"input_blocks.{ i } .1.qkv.bias" : {
200- "key" : f"downsample_blocks .{ block_id } .attentions.{ layer_in_block_id } .key.bias" ,
201- "query" : f"downsample_blocks .{ block_id } .attentions.{ layer_in_block_id } .query.bias" ,
202- "value" : f"downsample_blocks .{ block_id } .attentions.{ layer_in_block_id } .value.bias" ,
201+ "key" : f"down_blocks .{ block_id } .attentions.{ layer_in_block_id } .key.bias" ,
202+ "query" : f"down_blocks .{ block_id } .attentions.{ layer_in_block_id } .query.bias" ,
203+ "value" : f"down_blocks .{ block_id } .attentions.{ layer_in_block_id } .value.bias" ,
203204 },
204205 f"input_blocks.{ i } .1.qkv.weight" : {
205- "key" : f"downsample_blocks .{ block_id } .attentions.{ layer_in_block_id } .key.weight" ,
206- "query" : f"downsample_blocks .{ block_id } .attentions.{ layer_in_block_id } .query.weight" ,
207- "value" : f"downsample_blocks .{ block_id } .attentions.{ layer_in_block_id } .value.weight" ,
206+ "key" : f"down_blocks .{ block_id } .attentions.{ layer_in_block_id } .key.weight" ,
207+ "query" : f"down_blocks .{ block_id } .attentions.{ layer_in_block_id } .query.weight" ,
208+ "value" : f"down_blocks .{ block_id } .attentions.{ layer_in_block_id } .value.weight" ,
208209 },
209210 }
210211 assign_to_checkpoint (
0 commit comments