MCPcopy Create free account
hub / github.com/00why00/JoDiffusion / load_model_hook

Function load_model_hook

train_ae.py:413–426  ·  view source on GitHub ↗
(models, input_dir)

Source from the content-addressed store, hash-verified

411 weights.pop()
412
413 def load_model_hook(models, input_dir):
414 for _ in range(len(models)):
415 # pop models so that they are not loaded again
416 model = models.pop()
417
418 # load diffusers style into model
419 if isinstance(model, VAEClass):
420 load_model = VAEClass.from_pretrained(input_dir, subfolder="vae")
421 else:
422 raise ValueError(f"Unknown model type {model}")
423
424 model.register_to_config(**load_model.config) # noqa
425 model.load_state_dict(load_model.state_dict())
426 del load_model
427
428 accelerator.register_save_state_pre_hook(save_model_hook)
429 accelerator.register_load_state_pre_hook(load_model_hook)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected