We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c4bd1c7 commit 1348463Copy full SHA for 1348463
src/diffusers/utils/state_dict_utils.py
@@ -355,11 +355,9 @@ def _load_sft_state_dict_metadata(model_file: str):
355
356
from ..loaders.lora_base import LORA_ADAPTER_METADATA_KEY
357
358
- metadata = None
359
with safetensors.torch.safe_open(model_file, framework="pt", device="cpu") as f:
360
- metadata = f.metadata()
361
- if metadata is not None:
362
- metadata_keys = list(metadata.keys())
363
- if not (len(metadata_keys) == 1 and metadata_keys[0] == "format"):
364
- metadata = json.loads(metadata[LORA_ADAPTER_METADATA_KEY])
365
- return metadata
+ metadata = f.metadata() or {}
+
+ metadata.pop("format", None)
+ raw = metadata.get(LORA_ADAPTER_METADATA_KEY)
+ return json.loads(raw) if raw else None
0 commit comments