-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import importlib | ||
from copy import deepcopy | ||
from os import path as osp | ||
|
||
from hordelib.nodes.facerestore_cf.basicsr.utils import get_root_logger, scandir | ||
from hordelib.nodes.facerestore_cf.basicsr.utils.registry import MODEL_REGISTRY | ||
|
||
__all__ = ["build_model"] | ||
|
||
# automatically scan and import model modules for registry | ||
# scan all the files under the 'models' folder and collect files ending with | ||
# '_model.py' | ||
model_folder = osp.dirname(osp.abspath(__file__)) | ||
model_filenames = [osp.splitext(osp.basename(v))[0] for v in scandir(model_folder) if v.endswith("_model.py")] | ||
# import all the model modules | ||
_model_modules = [importlib.import_module(f"basicsr.models.{file_name}") for file_name in model_filenames] | ||
|
||
|
||
def build_model(opt): | ||
"""Build model from options. | ||
Args: | ||
opt (dict): Configuration. It must constain: | ||
model_type (str): Model type. | ||
""" | ||
opt = deepcopy(opt) | ||
model = MODEL_REGISTRY.get(opt["model_type"])(opt) | ||
logger = get_root_logger() | ||
logger.info(f"Model [{model.__class__.__name__}] is created.") | ||
return model |
Binary file added
BIN
+1.31 KB
hordelib/nodes/facerestore_cf/basicsr/models/__pycache__/__init__.cpython-310.pyc
Binary file not shown.