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

Function get_trainer

dzoedepth/trainers/builder.py:28–48  ·  view source on GitHub ↗

Builds and returns a trainer based on the config. Args: config (dict): the config dict (typically constructed using utils.config.get_config) config.trainer (str): the name of the trainer to use. The module named "{config.trainer}_trainer" must exist in trainers root module

(config)

Source from the content-addressed store, hash-verified

26
27
28def get_trainer(config):
29 """Builds and returns a trainer based on the config.
30
31 Args:
32 config (dict): the config dict (typically constructed using utils.config.get_config)
33 config.trainer (str): the name of the trainer to use. The module named "{config.trainer}_trainer" must exist in trainers root module
34
35 Raises:
36 ValueError: If the specified trainer does not exist under trainers/ folder
37
38 Returns:
39 Trainer (inherited from zoedepth.trainers.BaseTrainer): The Trainer object
40 """
41 assert "trainer" in config and config.trainer is not None and config.trainer != '', "Trainer not specified. Config: {0}".format(
42 config)
43 try:
44 Trainer = getattr(import_module(
45 f"zoedepth.trainers.{config.trainer}_trainer"), 'Trainer')
46 except ModuleNotFoundError as e:
47 raise ValueError(f"Trainer {config.trainer}_trainer not found.") from e
48 return Trainer

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected