MCPcopy
hub / github.com/thygate/stable-diffusion-webui-depthmap-script / load_ckpt

Function load_ckpt

lib/net_tools.py:27–43  ·  view source on GitHub ↗

Load checkpoint.

(args, depth_model, shift_model, focal_model)

Source from the content-addressed store, hash-verified

25 raise
26
27def load_ckpt(args, depth_model, shift_model, focal_model):
28 """
29 Load checkpoint.
30 """
31 if os.path.isfile(args.load_ckpt):
32 print("loading checkpoint %s" % args.load_ckpt)
33 checkpoint = torch.load(args.load_ckpt)
34 if shift_model is not None:
35 shift_model.load_state_dict(strip_prefix_if_present(checkpoint['shift_model'], 'module.'),
36 strict=True)
37 if focal_model is not None:
38 focal_model.load_state_dict(strip_prefix_if_present(checkpoint['focal_model'], 'module.'),
39 strict=True)
40 depth_model.load_state_dict(strip_prefix_if_present(checkpoint['depth_model'], "module."),
41 strict=True)
42 del checkpoint
43 torch.cuda.empty_cache()
44
45
46def strip_prefix_if_present(state_dict, prefix):

Callers

nothing calls this directly

Calls 2

strip_prefix_if_presentFunction · 0.85
loadMethod · 0.80

Tested by

no test coverage detected