From 3de44fc580681f785065565fbe63f46c5a872d43 Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Mon, 12 Sep 2022 20:47:46 +0300 Subject: Include the model name (or the SHA256 of the file) in the metadata #271 --- webui.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'webui.py') diff --git a/webui.py b/webui.py index 953e6620..add72123 100644 --- a/webui.py +++ b/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()) -- cgit v1.2.1