From 73b27ab35080703dbec03d7b625a2d9848eaca5f Mon Sep 17 00:00:00 2001 From: nkchocoai Date: Sun, 18 Feb 2024 14:43:47 +0900 Subject: [PATCH] Add Hashes --- py/capture.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/py/capture.py b/py/capture.py index 4956950..16306be 100644 --- a/py/capture.py +++ b/py/capture.py @@ -1,3 +1,5 @@ +import json + from . import hook from .defs.captures import CAPTURE_FIELD_LIST from .defs.meta import MetaField @@ -81,6 +83,10 @@ class Capture: update_pnginfo_dict(MetaField.MODEL_NAME, "Model") update_pnginfo_dict(MetaField.MODEL_HASH, "Model hash") + hashes_for_civitai = cls.get_hashes_for_civitai(inputs) + if len(hashes_for_civitai) > 0: + pnginfo_dict["Hashes"] = json.dumps(hashes_for_civitai) + return pnginfo_dict @classmethod @@ -99,3 +105,12 @@ class Capture: s_list.append(f"{k}: {s}") return result + ", ".join(s_list) + + @classmethod + def get_hashes_for_civitai(cls, inputs): + resource_hashes = {} + x = inputs.get(MetaField.MODEL_HASH, []) + if len(x) > 0: + resource_hashes["model"] = x[0][1] + + return resource_hashes