Created
January 7, 2023 16:20
-
-
Save Narsil/489e444647d5e9de7a534e61976bbc46 to your computer and use it in GitHub Desktop.
This file contains 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 characters
from safetensors import safe_open | |
import torch | |
from huggingface_hub import hf_hub_download | |
filenames = [ | |
"safety_checker/model.safetensors", | |
"safety_checker/pytorch_model.bin", | |
"vae/diffusion_pytorch_model.safetensors", | |
"vae/diffusion_pytorch_model.bin", | |
"unet/diffusion_pytorch_model.safetensors", | |
"unet/diffusion_pytorch_model.bin", | |
"text_encoder/model.safetensors", | |
"text_encoder/pytorch_model.bin", | |
] | |
for (sfilename, pfilename) in zip(filenames[::2], filenames[1::2]): | |
sfilename = hf_hub_download( | |
"runwayml/stable-diffusion-v1-5", | |
filename=sfilename, | |
revision="refs/pr/61", | |
) | |
pfilename = hf_hub_download( | |
"runwayml/stable-diffusion-v1-5", | |
filename=pfilename, | |
revision="refs/pr/61", | |
) | |
with safe_open(sfilename, framework="pt") as f: | |
pweights = torch.load(pfilename) | |
for (k, v) in pweights.items(): | |
torch.testing.assert_close(v, f.get_tensor(k)) | |
print(f"{sfilename} is OK ") | |
~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment