| import psutil |
| from pathlib import Path |
| import os |
| from utils import utils |
| from utils.utils import Singleton,read_yaml_file |
|
|
| |
| class FileConfig(metaclass=Singleton): |
| def __init__(self): |
| |
| cur_path = Path(os.path.abspath(__file__)) |
| base_dir = cur_path.parent |
| self.model_config_path = base_dir / "model.yaml" |
| self.model_file = read_yaml_file(self.model_config_path.as_posix()) |
| |
| |
| |
| self.model_path = base_dir / "resnet101-5d3b4d8f.pth" |
|
|
| class BaseUI(object): |
| def __init__(self): |
| cur_path = Path(os.path.abspath(__file__)) |
| cur_dir = cur_path.parent |
| self.file_init() |
| self.model_init() |
| def file_init(self): |
| |
| file_config_singleton = FileConfig() |
| self.mdoel_config_path = file_config_singleton.model_config_path |
| self.model_file = file_config_singleton.model_file |
| self.model_path = file_config_singleton.model_path |
| def model_init(self): |
| self.mdoel_name = self.model_file['model_name'] |
| self.contrast_path = ('.' + str(self.model_file['contrast_path'])) |
| self.transforms_Resize = [int(item) for item in self.model_file['transform']['Resize']] |
| self.transforms_Normalize_mean = [float(item) for item in self.model_file['transform']['Normalize']['mean']] |
| self.transforms_Normalize_std = [float(item) for item in self.model_file['transform']['Normalize']['std']] |
| self.transforms_centercrop_isExist = bool(self.model_file['transform']['centercrop']['isExist']) |
| if self.transforms_centercrop_isExist: |
| self.transforms_centercrop_value = int(self.model_file['transform']['centercrop']['value']) |
| baseui = BaseUI() |