import os import torch import random import numpy as np from SR_Inference.inference_hat import HAT from SR_Inference.inference_gfpgan import GFPGAN from SR_Inference.inference_realesr import RealEsr from SR_Inference.inference_srresnet import SRResNet from SR_Inference.inference_codeformer import CodeFormer def seed_everything(seed=42): random.seed(seed) os.environ["PYTHONHASHSEED"] = str(seed) np.random.seed(seed) torch.manual_seed(seed) torch.cuda.manual_seed(seed) torch.backends.cudnn.benchmark = True torch.backends.cudnn.deterministic = True def get_sr_method(self, sr_configs): sr_method_class = globals().get(self.sr_method_name) if sr_method_class is not None: return sr_method_class(**sr_configs["params"]) else: raise Exception( f"No such SR method called '{self.sr_method_name}' implemented!" )