MCPcopy Index your code
hub / github.com/NVIDIA/Stable-Diffusion-WebUI-TensorRT / apply_lora

Function apply_lora

exporter.py:28–48  ·  view source on GitHub ↗
(model: torch.nn.Module, lora_path: str, inputs: Tuple[torch.Tensor])

Source from the content-addressed store, hash-verified

26
27
28def apply_lora(model: torch.nn.Module, lora_path: str, inputs: Tuple[torch.Tensor]) -> torch.nn.Module:
29 try:
30 import sys
31
32 sys.path.append("extensions-builtin/Lora")
33 import importlib
34
35 networks = importlib.import_module("networks")
36 network = importlib.import_module("network")
37 lora_net = importlib.import_module("extra_networks_lora")
38 except Exception as e:
39 error(e)
40 error("LoRA not found. Please install LoRA extension first from ...")
41 model.forward(*inputs)
42 lora_name = os.path.splitext(os.path.basename(lora_path))[0]
43 networks.load_networks(
44 [lora_name], [1.0], [1.0], [None]
45 )
46
47 model.forward(*inputs)
48 return model
49
50
51def get_refit_weights(

Callers 1

export_loraFunction · 0.85

Calls 1

forwardMethod · 0.80

Tested by

no test coverage detected