MCPcopy
hub / github.com/OpenBMB/VoxCPM / load_lora

Method load_lora

src/voxcpm/core.py:317–335  ·  view source on GitHub ↗

Load LoRA weights from a checkpoint file. Args: lora_weights_path: Path to LoRA weights (.pth file or directory containing lora_weights.ckpt). Returns: tuple: (loaded_keys, skipped_keys) - lists of loaded and skipped parameter names.

(self, lora_weights_path: str)

Source from the content-addressed store, hash-verified

315 # LoRA Interface (delegated to VoxCPMModel)
316 # ------------------------------------------------------------------ #
317 def load_lora(self, lora_weights_path: str) -> tuple:
318 """Load LoRA weights from a checkpoint file.
319
320 Args:
321 lora_weights_path: Path to LoRA weights (.pth file or directory
322 containing lora_weights.ckpt).
323
324 Returns:
325 tuple: (loaded_keys, skipped_keys) - lists of loaded and skipped parameter names.
326
327 Raises:
328 RuntimeError: If model was not initialized with LoRA config.
329 """
330 if self.tts_model.lora_config is None:
331 raise RuntimeError(
332 "Cannot load LoRA weights: model was not initialized with LoRA config. "
333 "Please reinitialize with lora_config or lora_weights_path parameter."
334 )
335 return self.tts_model.load_lora_weights(lora_weights_path)
336
337 def unload_lora(self):
338 """Unload LoRA by resetting all LoRA weights to initial state (effectively disabling LoRA)."""

Callers 2

run_inferenceFunction · 0.80
mainFunction · 0.80

Calls 1

load_lora_weightsMethod · 0.45

Tested by 1

mainFunction · 0.64