Spaces:
Runtime error
Runtime error
Update app.py
Browse files4 unmodified lines56789104 unmodified linesimport torchimport uvicornimport os# Import the CodeFormer model processing functionfrom codeformer_model import enhance_image # Make sure this function is defined4 unmodified lines567891011121314151617181920212223242526272829303132333435363738394041424344454647484 unmodified linesimport torchimport uvicornimport osimport syssys.path.append('CodeFormer')import osimport cv2import torchimport torch.nn.functional as Fimport gradio as grfrom torchvision.transforms.functional import normalizefrom basicsr.utils import imwrite, img2tensor, tensor2imgfrom basicsr.utils.download_util import load_file_from_urlfrom facelib.utils.face_restoration_helper import FaceRestoreHelperfrom basicsr.archs.rrdbnet_arch import RRDBNetfrom basicsr.utils.realesrgan_utils import RealESRGANerfrom facelib.utils.misc import is_grayfrom basicsr.utils.registry import ARCH_REGISTRYos.system("pip freeze")pretrain_model_url = {'codeformer': 'https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/codeformer.pth','detection': 'https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/detection_Resnet50_Final.pth','parsing': 'https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/parsing_parsenet.pth','realesrgan': 'https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/RealESRGAN_x2plus.pth'}# download weightsif not os.path.exists('CodeFormer/weights/CodeFormer/codeformer.pth'):load_file_from_url(url=pretrain_model_url['codeformer'], model_dir='CodeFormer/weights/CodeFormer', progress=True, file_name=None)if not os.path.exists('CodeFormer/weights/facelib/detection_Resnet50_Final.pth'):load_file_from_url(url=pretrain_model_url['detection'], model_dir='CodeFormer/weights/facelib', progress=True, file_name=None)if not os.path.exists('CodeFormer/weights/facelib/parsing_parsenet.pth'):load_file_from_url(url=pretrain_model_url['parsing'], model_dir='CodeFormer/weights/facelib', progress=True, file_name=None)if not os.path.exists('CodeFormer/weights/realesrgan/RealESRGAN_x2plus.pth'):load_file_from_url(url=pretrain_model_url['realesrgan'], model_dir='CodeFormer/weights/realesrgan', progress=True, file_name=None)# Import the CodeFormer model processing functionfrom codeformer_model import enhance_image # Make sure this function is defined
app.py+38