(args)
| 13 | |
| 14 | |
| 15 | def main(args): |
| 16 | all_state_dict = torch.load(args.orig_ckpt_path) |
| 17 | state_dict = all_state_dict.pop("state_dict") |
| 18 | converted_state_dict = {} |
| 19 | |
| 20 | # Patch embeddings. |
| 21 | converted_state_dict["pos_embed.proj.weight"] = state_dict.pop("x_embedder.proj.weight") |
| 22 | converted_state_dict["pos_embed.proj.bias"] = state_dict.pop("x_embedder.proj.bias") |
| 23 | |
| 24 | # Caption projection. |
| 25 | converted_state_dict["caption_projection.linear_1.weight"] = state_dict.pop("y_embedder.y_proj.fc1.weight") |
| 26 | converted_state_dict["caption_projection.linear_1.bias"] = state_dict.pop("y_embedder.y_proj.fc1.bias") |
| 27 | converted_state_dict["caption_projection.linear_2.weight"] = state_dict.pop("y_embedder.y_proj.fc2.weight") |
| 28 | converted_state_dict["caption_projection.linear_2.bias"] = state_dict.pop("y_embedder.y_proj.fc2.bias") |
| 29 | |
| 30 | # AdaLN-single LN |
| 31 | converted_state_dict["adaln_single.emb.timestep_embedder.linear_1.weight"] = state_dict.pop( |
| 32 | "t_embedder.mlp.0.weight" |
| 33 | ) |
| 34 | converted_state_dict["adaln_single.emb.timestep_embedder.linear_1.bias"] = state_dict.pop("t_embedder.mlp.0.bias") |
| 35 | converted_state_dict["adaln_single.emb.timestep_embedder.linear_2.weight"] = state_dict.pop( |
| 36 | "t_embedder.mlp.2.weight" |
| 37 | ) |
| 38 | converted_state_dict["adaln_single.emb.timestep_embedder.linear_2.bias"] = state_dict.pop("t_embedder.mlp.2.bias") |
| 39 | |
| 40 | if args.micro_condition: |
| 41 | # Resolution. |
| 42 | converted_state_dict["adaln_single.emb.resolution_embedder.linear_1.weight"] = state_dict.pop( |
| 43 | "csize_embedder.mlp.0.weight" |
| 44 | ) |
| 45 | converted_state_dict["adaln_single.emb.resolution_embedder.linear_1.bias"] = state_dict.pop( |
| 46 | "csize_embedder.mlp.0.bias" |
| 47 | ) |
| 48 | converted_state_dict["adaln_single.emb.resolution_embedder.linear_2.weight"] = state_dict.pop( |
| 49 | "csize_embedder.mlp.2.weight" |
| 50 | ) |
| 51 | converted_state_dict["adaln_single.emb.resolution_embedder.linear_2.bias"] = state_dict.pop( |
| 52 | "csize_embedder.mlp.2.bias" |
| 53 | ) |
| 54 | # Aspect ratio. |
| 55 | converted_state_dict["adaln_single.emb.aspect_ratio_embedder.linear_1.weight"] = state_dict.pop( |
| 56 | "ar_embedder.mlp.0.weight" |
| 57 | ) |
| 58 | converted_state_dict["adaln_single.emb.aspect_ratio_embedder.linear_1.bias"] = state_dict.pop( |
| 59 | "ar_embedder.mlp.0.bias" |
| 60 | ) |
| 61 | converted_state_dict["adaln_single.emb.aspect_ratio_embedder.linear_2.weight"] = state_dict.pop( |
| 62 | "ar_embedder.mlp.2.weight" |
| 63 | ) |
| 64 | converted_state_dict["adaln_single.emb.aspect_ratio_embedder.linear_2.bias"] = state_dict.pop( |
| 65 | "ar_embedder.mlp.2.bias" |
| 66 | ) |
| 67 | # Shared norm. |
| 68 | converted_state_dict["adaln_single.linear.weight"] = state_dict.pop("t_block.1.weight") |
| 69 | converted_state_dict["adaln_single.linear.bias"] = state_dict.pop("t_block.1.bias") |
| 70 | |
| 71 | for depth in range(28): |
| 72 | # Transformer blocks. |
no test coverage detected
searching dependent graphs…