Spaces:
Sleeping
Sleeping
File size: 777 Bytes
c42fe7e |
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 26 27 28 29 30 31 32 33 34 35 36 |
import importlib
import os
import sys
from pathlib import Path
import yaml
hparams = {}
def set_hparams(config_path=None):
global hparams
if config_path:
with open(config_path, "r") as f:
hparams = yaml.safe_load(f)
root_dir = Path(__file__).parent.parent.resolve()
os.environ['PYTHONPATH'] = str(root_dir)
sys.path.insert(0, str(root_dir))
from utils.hparams import set_hparams, hparams
set_hparams()
def binarize():
binarizer_cls = hparams["binarizer_cls"]
pkg = ".".join(binarizer_cls.split(".")[:-1])
cls_name = binarizer_cls.split(".")[-1]
binarizer_cls = getattr(importlib.import_module(pkg), cls_name)
print("| Binarizer: ", binarizer_cls)
binarizer_cls().process()
if __name__ == '__main__':
binarize()
|