MCPcopy Create free account
hub / github.com/KohakuBlueleaf/LyCORIS / pack_bundle

Function pack_bundle

tools/batch_bundle_convert.py:32–48  ·  view source on GitHub ↗
(lora, emb_dict, verbose=False)

Source from the content-addressed store, hash-verified

30
31
32def pack_bundle(lora, emb_dict, verbose=False):
33 for emb, emb_sd in emb_dict.items():
34 for key, value in emb_sd.items():
35 if isinstance(value, dict):
36 for subkey, subvalue in value.items():
37 lora[f"bundle_emb.{emb}.{key}.{subkey}"] = subvalue
38 elif isinstance(value, torch.Tensor):
39 lora[f"bundle_emb.{emb}.{key}"] = value
40 if verbose:
41 print("The following content has been added to lora")
42 for key, value in lora.items():
43 if key.startswith("bundle_emb"):
44 if isinstance(value, torch.Tensor):
45 print(f" {key}: tensor of shape {value.shape}")
46 else:
47 print(f" {key}: {value}")
48 return lora
49
50
51def unpack_bundle(lora, verbose, step="", emb_format=".pt"):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected