Last active
December 26, 2023 07:15
-
-
Save ProGamerGov/70061a08e3a2da6e9ed83e145ea24a70 to your computer and use it in GitHub Desktop.
Revisions
-
ProGamerGov revised this gist
Oct 23, 2022 . No changes.There are no files selected for viewing
-
ProGamerGov revised this gist
Oct 23, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ model_file_path = "v1-5-pruned-emaonly.ckpt" # Name to use for new model file new_model_name = "v1-5-pruned-emaonly_ema_vae.ckpt" # Load files vae_model = torch.load(vae_file_path, map_location="cpu") -
ProGamerGov created this gist
Oct 23, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ # Script by https://github.com/ProGamerGov import copy import torch # Path to model and VAE files that you want to merge vae_file_path = "vae-ft-mse-840000-ema-pruned.ckpt" model_file_path = "v1-5-pruned-emaonly.ckpt" # Name to use for new model file new_model_name = "v1-5-pruned-emaonly_mse_vae.ckpt" # Load files vae_model = torch.load(vae_file_path, map_location="cpu") full_model = torch.load(model_file_path, map_location="cpu") # Replace VAE in model file with new VAE vae_dict = {k: v for k, v in vae_model["state_dict"].items() if k[0:4] not in ["loss", "mode"]} for k, _ in vae_dict.items(): key_name = "first_stage_model." + k full_model['state_dict'][key_name] = copy.deepcopy(vae_model["state_dict"][k]) # Save model with new VAE torch.save(full_model, new_model_name)