Spaces:
Configuration error
Configuration error
fix: different safetensors
Browse files4 unmodified lines567891011121314154 unmodified lines2021222324252654 unmodified lines818283844 unmodified linesfrom net.CIDNet import CIDNetimport torchvision.transforms as transformsimport torch.nn.functional as Fimport osimport imquality.brisque as brisquefrom loss.niqe_utils import *import spacesimport huggingface_hubeval_net = CIDNet().cuda()eval_net.trans.gated = True4 unmodified linesif model_path is None:return input_img,"Please choose a model weights."torch.set_grad_enabled(False)eval_net.from_pretrained("Fediory/HVI-CIDNet-"+model_path)# eval_net.load_state_dict(torch.load(os.path.join(directory,model_path), map_location=lambda storage, loc: storage))eval_net.eval()54 unmodified linesallow_flagging="never")interface.launch(share=True)4 unmodified lines56789101112131415161718192021222324252627282930314 unmodified lines3637383940414254 unmodified lines9798991004 unmodified linesfrom net.CIDNet import CIDNetimport torchvision.transforms as transformsimport torch.nn.functional as Fimport safetensors.torch as sfimport imquality.brisque as brisquefrom loss.niqe_utils import *import spacesfrom huggingface_hub import hf_hub_downloadimport jsondef from_pretrained(cls, pretrained_model_name_or_path: str):model_id = str(pretrained_model_name_or_path)config_file = hf_hub_download(repo_id=model_id, filename="config.json", repo_type="model")config = Noneif config_file is not None:with open(config_file, "r", encoding="utf-8") as f:config = json.load(f)model_file = hf_hub_download(repo_id=model_id, filename="model.safetensors", repo_type="model")# instance = sf.load_model(cls, model_file, strict=False)state_dict = sf.load_file(model_file)cls.load_state_dict(state_dict, strict=False)eval_net = CIDNet().cuda()eval_net.trans.gated = True4 unmodified linesif model_path is None:return input_img,"Please choose a model weights."torch.set_grad_enabled(False)from_pretrained(eval_net,"Fediory/HVI-CIDNet-"+model_path)# eval_net.load_state_dict(torch.load(os.path.join(directory,model_path), map_location=lambda storage, loc: storage))eval_net.eval()54 unmodified linesallow_flagging="never")interface.launch(share=False)
app.py+20-4