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

Function load_model_hook

diffusers/examples/controlnet/train_controlnet_sd3.py:1031–1041  ·  view source on GitHub ↗
(models, input_dir)

Source from the content-addressed store, hash-verified

1029 i -= 1
1030
1031 def load_model_hook(models, input_dir):
1032 while len(models) > 0:
1033 # pop models so that they are not loaded again
1034 model = models.pop()
1035
1036 # load diffusers style into model
1037 load_model = SD3ControlNetModel.from_pretrained(input_dir, subfolder="controlnet")
1038 model.register_to_config(**load_model.config)
1039
1040 model.load_state_dict(load_model.state_dict())
1041 del load_model
1042
1043 accelerator.register_save_state_pre_hook(save_model_hook)
1044 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