Added support to load model config from Metadata. (#399)

* Implement GGUF metadata extraction function

Added function to extract metadata from GGUF files.

* Updated the GGUF model loading and patching classes to include metadata handling.

* Clean up return logic for extra metadata

This should be more future proof in case we need to return other attributes in the future. Possible breaking change for anyone using `gguf_sd_loader` directly either way, though.

---------

Co-authored-by: City <125218114+city96@users.noreply.github.com>
This commit is contained in:
Vantage with AI
2026-01-11 19:30:59 +01:00
committed by GitHub
co-authored by City
parent 795e45156e
commit 58625e1cb6
2 changed files with 32 additions and 8 deletions
+3 -2
View File
@@ -165,9 +165,9 @@ class UnetLoaderGGUF:
# init model
unet_path = folder_paths.get_full_path("unet", unet_name)
sd = gguf_sd_loader(unet_path)
sd, extra = gguf_sd_loader(unet_path)
model = comfy.sd.load_diffusion_model_state_dict(
sd, model_options={"custom_operations": ops}
sd, model_options={"custom_operations": ops}, metadata=extra.get("metadata", {})
)
if model is None:
logging.error("ERROR UNSUPPORTED UNET {}".format(unet_path))
@@ -319,3 +319,4 @@ NODE_CLASS_MAPPINGS = {
"QuadrupleCLIPLoaderGGUF": QuadrupleCLIPLoaderGGUF,
"UnetLoaderGGUFAdvanced": UnetLoaderGGUFAdvanced,
}