victorisgeek commited on
Commit
de0bb6c
1 Parent(s): 0854b12

Update face_enhancer.py

Browse files
Files changed (1) hide show
  1. face_enhancer.py +3 -27
face_enhancer.py CHANGED
@@ -10,22 +10,12 @@ def gfpgan_runner(img, model):
10
  _, imgs, _ = model.enhance(img, paste_back=True, has_aligned=True)
11
  return imgs[0]
12
 
 
13
  def realesrgan_runner(img, model):
14
  img = model.predict(img)
15
  return img
16
 
17
- def realhatgan_runner(img, model):
18
- img = model.predict(img)
19
- return img
20
-
21
- def restoreformer_runner(img, model):
22
- img = model.predict(img)
23
- return img
24
 
25
- def ultrasharp_runner(img, model):
26
- img = model.predict(img)
27
- return img
28
-
29
  def codeformer_runner(img, model):
30
  img = model.enhance(img)
31
  return img
@@ -34,9 +24,6 @@ def codeformer_runner(img, model):
34
  supported_enhancers = {
35
  "CodeFormer": ("./assets/pretrained_models/codeformer.onnx", codeformer_runner),
36
  "GFPGAN": ("./assets/pretrained_models/GFPGANv1.4.pth", gfpgan_runner),
37
- "REAL_HATGAN x4": ("./assets/pretrained_models/real_hatgan_x4.onnx", realhatgan_runner),
38
- "ULTRA_SHARP x4": ("./assets/pretrained_models/ultra_sharp_x4.onnx", ultrasharp_runner),
39
- "RESTOREFORMER PLUS PLUS": ("./assets/pretrained_models/restoreformer_plus_plus.onnx", restoreformer_runner),
40
  "REAL-ESRGAN 2x": ("./assets/pretrained_models/RealESRGAN_x2.pth", realesrgan_runner),
41
  "REAL-ESRGAN 4x": ("./assets/pretrained_models/RealESRGAN_x4.pth", realesrgan_runner),
42
  "REAL-ESRGAN 8x": ("./assets/pretrained_models/RealESRGAN_x8.pth", realesrgan_runner)
@@ -62,23 +49,12 @@ def load_face_enhancer_model(name='GFPGAN', device="cpu"):
62
  model = CodeFormerEnhancer(model_path=model_path, device=device)
63
  elif name == 'GFPGAN':
64
  model = gfpgan.GFPGANer(model_path=model_path, upscale=1, device=device)
65
- elif name =='RESTOREFORMER PLUS PLUS':
66
- model = RestoreFormer(device, scale=1)
67
- model.load_weights(model_path, download=False)
68
- elif name == 'REAL-ESRGAN 4x':
69
- model = RealESRGAN(device, scale=4)
70
- model.load_weights(model_path, download=False)
71
  elif name == 'REAL-ESRGAN 2x':
72
  model = RealESRGAN(device, scale=2)
73
  model.load_weights(model_path, download=False)
74
- elif name == 'REAL_HATGAN x4':
75
- model = RealHatGAN(device, scale=4)
76
- elif name == 'ULTRA_SHARP x4':
77
- model = UltraShap(device, scale=4)
78
- model.load_weights(model_path, download=False)
79
  elif name == 'REAL-ESRGAN 4x':
80
- model = RealHatGAN(device, scale=4)
81
- model.load_weights(model_path, download=False)
82
  elif name == 'REAL-ESRGAN 8x':
83
  model = RealESRGAN(device, scale=8)
84
  model.load_weights(model_path, download=False)
 
10
  _, imgs, _ = model.enhance(img, paste_back=True, has_aligned=True)
11
  return imgs[0]
12
 
13
+
14
  def realesrgan_runner(img, model):
15
  img = model.predict(img)
16
  return img
17
 
 
 
 
 
 
 
 
18
 
 
 
 
 
19
  def codeformer_runner(img, model):
20
  img = model.enhance(img)
21
  return img
 
24
  supported_enhancers = {
25
  "CodeFormer": ("./assets/pretrained_models/codeformer.onnx", codeformer_runner),
26
  "GFPGAN": ("./assets/pretrained_models/GFPGANv1.4.pth", gfpgan_runner),
 
 
 
27
  "REAL-ESRGAN 2x": ("./assets/pretrained_models/RealESRGAN_x2.pth", realesrgan_runner),
28
  "REAL-ESRGAN 4x": ("./assets/pretrained_models/RealESRGAN_x4.pth", realesrgan_runner),
29
  "REAL-ESRGAN 8x": ("./assets/pretrained_models/RealESRGAN_x8.pth", realesrgan_runner)
 
49
  model = CodeFormerEnhancer(model_path=model_path, device=device)
50
  elif name == 'GFPGAN':
51
  model = gfpgan.GFPGANer(model_path=model_path, upscale=1, device=device)
 
 
 
 
 
 
52
  elif name == 'REAL-ESRGAN 2x':
53
  model = RealESRGAN(device, scale=2)
54
  model.load_weights(model_path, download=False)
 
 
 
 
 
55
  elif name == 'REAL-ESRGAN 4x':
56
+ model = RealESRGAN(device, scale=4)
57
+ model.load_weights(model_path, download=False)
58
  elif name == 'REAL-ESRGAN 8x':
59
  model = RealESRGAN(device, scale=8)
60
  model.load_weights(model_path, download=False)