MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / load_model_hook

Function load_model_hook

diffusers/examples/controlnet/train_controlnet.py:842–852  ·  view source on GitHub ↗
(models, input_dir)

Source from the content-addressed store, hash-verified

840 i -= 1
841
842 def load_model_hook(models, input_dir):
843 while len(models) > 0:
844 # pop models so that they are not loaded again
845 model = models.pop()
846
847 # load diffusers style into model
848 load_model = ControlNetModel.from_pretrained(input_dir, subfolder="controlnet")
849 model.register_to_config(**load_model.config)
850
851 model.load_state_dict(load_model.state_dict())
852 del load_model
853
854 accelerator.register_save_state_pre_hook(save_model_hook)
855 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