Charbel Malo
commited on
Update face_enhancer.py
Browse files- face_enhancer.py +3 -3
face_enhancer.py
CHANGED
@@ -45,15 +45,15 @@ def get_available_enhancer_names():
|
|
45 |
|
46 |
|
47 |
@spaces.GPU(enable_queue=True)
|
48 |
-
def load_face_enhancer_model(name='GFPGAN', device='cuda' if torch.cuda.is_available() else 'cpu'):
|
49 |
assert name in get_available_enhancer_names() + cv2_interpolations, f"Face enhancer {name} unavailable."
|
50 |
if name in supported_enhancers.keys():
|
51 |
model_path, model_runner = supported_enhancers.get(name)
|
52 |
model_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), model_path)
|
53 |
if name == 'CodeFormer':
|
54 |
-
model = CodeFormerEnhancer(model_path=model_path, device=device)
|
55 |
elif name == 'GFPGAN':
|
56 |
-
model = gfpgan.GFPGANer(model_path=model_path, upscale=1, device=device)
|
57 |
elif name == 'REAL-ESRGAN 2x':
|
58 |
model = RealESRGAN(device, scale=2)
|
59 |
model.load_weights(model_path, download=False)
|
|
|
45 |
|
46 |
|
47 |
@spaces.GPU(enable_queue=True)
|
48 |
+
def load_face_enhancer_model(name='GFPGAN', device=torch.device('cuda' if torch.cuda.is_available() else 'cpu')):
|
49 |
assert name in get_available_enhancer_names() + cv2_interpolations, f"Face enhancer {name} unavailable."
|
50 |
if name in supported_enhancers.keys():
|
51 |
model_path, model_runner = supported_enhancers.get(name)
|
52 |
model_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), model_path)
|
53 |
if name == 'CodeFormer':
|
54 |
+
model = CodeFormerEnhancer(model_path=model_path, device=torch.device('cuda' if torch.cuda.is_available() else 'cpu'))
|
55 |
elif name == 'GFPGAN':
|
56 |
+
model = gfpgan.GFPGANer(model_path=model_path, upscale=1, device=torch.device('cuda' if torch.cuda.is_available() else 'cpu'))
|
57 |
elif name == 'REAL-ESRGAN 2x':
|
58 |
model = RealESRGAN(device, scale=2)
|
59 |
model.load_weights(model_path, download=False)
|