MCPcopy Create free account
hub / github.com/PaddlePaddle/Research / get_func

Function get_func

CV/SemSegPaddle/src/models/model_builder.py:69–92  ·  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

67
68
69def get_func(func_name):
70 """Helper to return a function object by name. func_name must identify a
71 function in this module or the path to a function relative to the base
72 'modeling' module.
73 """
74 print("func_name: ", func_name)
75 if func_name == '':
76 return None
77 try:
78 parts = func_name.split('.')
79 # Refers to a function in this module
80 if len(parts) == 1:
81 return globals()[parts[0]]
82 # Otherwise, assume we're referencing a module under modeling
83 module_name = 'src.models.' + '.'.join(parts[:-1])
84 print("module_name: ", module_name)
85 # method 1
86 #from src.models.modeling import pspnet
87 # method 2
88 module = importlib.import_module(module_name)
89 return getattr(module, parts[-1])
90 except Exception:
91 print('Failed to find function: {}'.format(func_name))
92 return module
93
94
95def softmax(logit):

Callers 1

build_modelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected