diff options
author | AUTOMATIC <16777216c@gmail.com> | 2022-09-12 20:47:46 +0300 |
---|---|---|
committer | AUTOMATIC <16777216c@gmail.com> | 2022-09-12 20:47:46 +0300 |
commit | 3de44fc580681f785065565fbe63f46c5a872d43 (patch) | |
tree | a986f34beb19cd399c076df98b287e2e526227a4 /webui.py | |
parent | 35a4649c9e0a54272bbaae7b2489d529bf3154d1 (diff) |
Include the model name (or the SHA256 of the file) in the metadata #271
Diffstat (limited to 'webui.py')
-rw-r--r-- | webui.py | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -35,7 +35,7 @@ realesrgan.setup_realesrgan() def load_model_from_config(config, ckpt, verbose=False):
- print(f"Loading model from {ckpt}")
+ print(f"Loading model [{shared.sd_model_hash}] from {ckpt}")
pl_sd = torch.load(ckpt, map_location="cpu")
if "global_step" in pl_sd:
print(f"Global Step: {pl_sd['global_step']}")
@@ -89,6 +89,14 @@ try: except Exception:
pass
+with open(cmd_opts.ckpt, "rb") as file:
+ import hashlib
+ m = hashlib.sha256()
+
+ file.seek(0x100000)
+ m.update(file.read(0x10000))
+ shared.sd_model_hash = m.hexdigest()[0:8]
+
sd_config = OmegaConf.load(cmd_opts.config)
shared.sd_model = load_model_from_config(sd_config, cmd_opts.ckpt)
shared.sd_model = (shared.sd_model if cmd_opts.no_half else shared.sd_model.half())
|