mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-08-08 13:19:54 +00:00
Include the model name (or the SHA256 of the file) in the metadata #271
This commit is contained in:
10
webui.py
10
webui.py
@@ -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())
|
||||
|
Reference in New Issue
Block a user