MCPcopy Create free account
hub / github.com/thygate/stable-diffusion-webui-depthmap-script / get_func

Function get_func

lib/net_tools.py:7–25  ·  view source on GitHub ↗

Helper to return a function object by name. func_name must identify a function in this module or the path to a function relative to the base 'modeling' module.

(func_name)

Source from the content-addressed store, hash-verified

5
6
7def get_func(func_name):
8 """Helper to return a function object by name. func_name must identify a
9 function in this module or the path to a function relative to the base
10 'modeling' module.
11 """
12 if func_name == '':
13 return None
14 try:
15 parts = func_name.split('.')
16 # Refers to a function in this module
17 if len(parts) == 1:
18 return globals()[parts[0]]
19 # Otherwise, assume we're referencing a module under modeling
20 module_name = 'lib.' + '.'.join(parts[:-1])
21 module = importlib.import_module(module_name)
22 return getattr(module, parts[-1])
23 except Exception:
24 print('Failed to f1ind function: %s', func_name)
25 raise
26
27def load_ckpt(args, depth_model, shift_model, focal_model):
28 """

Callers 1

__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected