MCPcopy Create free account
hub / github.com/TencentARC/BrushNet / load_model_hook

Function load_model_hook

examples/controlnet/train_controlnet.py:838–848  ·  view source on GitHub ↗
(models, input_dir)

Source from the content-addressed store, hash-verified

836 i -= 1
837
838 def load_model_hook(models, input_dir):
839 while len(models) > 0:
840 # pop models so that they are not loaded again
841 model = models.pop()
842
843 # load diffusers style into model
844 load_model = ControlNetModel.from_pretrained(input_dir, subfolder="controlnet")
845 model.register_to_config(**load_model.config)
846
847 model.load_state_dict(load_model.state_dict())
848 del load_model
849
850 accelerator.register_save_state_pre_hook(save_model_hook)
851 accelerator.register_load_state_pre_hook(load_model_hook)

Callers

nothing calls this directly

Calls 5

register_to_configMethod · 0.80
load_state_dictMethod · 0.80
popMethod · 0.45
from_pretrainedMethod · 0.45
state_dictMethod · 0.45

Tested by

no test coverage detected