MCPcopy Create free account
hub / github.com/tdrussell/diffusion-pipe / load_diffusion_model

Method load_diffusion_model

models/base.py:556–581  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

554 self.dequantize(module, diffusion_model_dtype)
555
556 def load_diffusion_model(self):
557 dtype = self.model_config['dtype']
558 model_options = {}
559 model_options['dtype'] = dtype
560 model_patcher = comfy.sd.load_diffusion_model(self.model_config['diffusion_model'], model_options=model_options, disable_dynamic=True)
561
562 for adapter_path in self.model_config.get('merge_adapters', []):
563 if is_main_process():
564 print(f'Merging adapter {adapter_path}')
565 sd = comfy.utils.load_torch_file(adapter_path, safe_load=True)
566 model_patcher, _ = comfy.sd.load_lora_for_models(model_patcher, None, sd, 1.0, 0.0)
567 del sd
568
569 model_patcher.set_model_compute_dtype(dtype)
570 with torch.no_grad():
571 model_patcher.patch_model()
572 self.diffusion_model = model_patcher.model.diffusion_model
573 self.model_patcher = model_patcher
574
575 diffusion_model_dtype = self.model_config.get('diffusion_model_dtype', dtype)
576 self.dequantize(self.diffusion_model, diffusion_model_dtype)
577
578 self.diffusion_model.train()
579 for name, p in self.diffusion_model.named_parameters():
580 p.original_name = name
581 p.requires_grad_(True)
582
583 def get_vae(self):
584 return self.vae

Callers

nothing calls this directly

Calls 4

dequantizeMethod · 0.95
is_main_processFunction · 0.90
getMethod · 0.80
load_diffusion_modelMethod · 0.45

Tested by

no test coverage detected