File size: 795 Bytes
fc5ed00
 
 
 
 
35916c5
fc5ed00
 
 
 
 
35916c5
fc5ed00
 
 
 
 
 
 
 
 
35916c5
fc5ed00
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from importlib import import_module

import torch
from loguru import logger

from df_local.config import DfParams, config


class ModelParams(DfParams):
    def __init__(self):
        self.__model = config("MODEL", default="deepfilternet", section="train")
        self.__params = getattr(import_module("df_local." + self.__model), "ModelParams")()

    def __getattr__(self, attr: str):
        return getattr(self.__params, attr)


def init_model(*args, **kwargs):
    """Initialize the model specified in the config."""
    model = config("MODEL", default="deepfilternet", section="train")
    logger.info(f"Initializing model `{model}`")
    model = getattr(import_module("df_local." + model), "init_model")(*args, **kwargs)
    model.to(memory_format=torch.channels_last)
    return model