MCPcopy Create free account
hub / github.com/JunlinHan/DCLGAN / find_model_using_name

Function find_model_using_name

models/__init__.py:25–45  ·  view source on GitHub ↗

Import the module "models/[model_name]_model.py". In the file, the class called DatasetNameModel() will be instantiated. It has to be a subclass of BaseModel, and it is case-insensitive.

(model_name)

Source from the content-addressed store, hash-verified

23
24
25def find_model_using_name(model_name):
26 """Import the module "models/[model_name]_model.py".
27
28 In the file, the class called DatasetNameModel() will
29 be instantiated. It has to be a subclass of BaseModel,
30 and it is case-insensitive.
31 """
32 model_filename = "models." + model_name + "_model"
33 modellib = importlib.import_module(model_filename)
34 model = None
35 target_model_name = model_name.replace('_', '') + 'model'
36 for name, cls in modellib.__dict__.items():
37 if name.lower() == target_model_name.lower() \
38 and issubclass(cls, BaseModel):
39 model = cls
40
41 if model is None:
42 print("In %s.py, there should be a subclass of BaseModel with class name that matches %s in lowercase." % (model_filename, target_model_name))
43 exit(0)
44
45 return model
46
47
48def get_option_setter(model_name):

Callers 2

get_option_setterFunction · 0.85
create_modelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected