ali-ghamdan commited on
Commit
baf9660
·
1 Parent(s): ccb6b49

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -3
app.py CHANGED
@@ -13,15 +13,28 @@ os.system('wget https://github.com/TencentARC/GFPGAN/releases/download/v0.2.0/GF
13
  os.system('wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth')
14
 
15
 
16
- def interface(image: Image, model: str = "GFPGANv1.3.pth"):
17
  if model == "":
18
  model = "GFPGANv1.3.pth"
19
  if model != "GFPGANv1.pth" and model != "GFPGANCleanv1-NoCE-C2.pth" and model != "GFPGANv1.3.pth":
20
  model = "GFPGANv1.3.pth"
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  restorer = GFPGANer(
22
  model_path=model,
23
  arch="original" if model == "GFPGANv1.pth" else "clean",
24
- bg_upsampler=None,
25
  channel_multiplier=1 if model == "GFPGANv1.pth" else 2,
26
  upscale=2)
27
  img = np.array(image).copy()
@@ -43,7 +56,8 @@ gr.Interface(
43
  ],
44
  label="model",
45
  default="GFPGANv1.3.pth",
46
- type="value")
 
47
  ],
48
  [gr.components.Image(label="Enhanced Image")],
49
  ).launch()
 
13
  os.system('wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth')
14
 
15
 
16
+ def interface(image: Image, model: str = "GFPGANv1.3.pth", useRealesrgan=False):
17
  if model == "":
18
  model = "GFPGANv1.3.pth"
19
  if model != "GFPGANv1.pth" and model != "GFPGANCleanv1-NoCE-C2.pth" and model != "GFPGANv1.3.pth":
20
  model = "GFPGANv1.3.pth"
21
+ if useRealesrgan == True:
22
+ from basicsr.archs.rrdbnet_arch import RRDBNet
23
+ from realesrgan import RealESRGANer
24
+ BGupscaler = RealESRGANer(
25
+ scale=2,
26
+ model_path='https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.1/RealESRGAN_x2plus.pth',
27
+ model=RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32, scale=2),
28
+ tile=0,
29
+ tile_pad=10,
30
+ pre_pad=0
31
+ )
32
+ else:
33
+ BGupscaler = None
34
  restorer = GFPGANer(
35
  model_path=model,
36
  arch="original" if model == "GFPGANv1.pth" else "clean",
37
+ bg_upsampler=BGupscaler,
38
  channel_multiplier=1 if model == "GFPGANv1.pth" else 2,
39
  upscale=2)
40
  img = np.array(image).copy()
 
56
  ],
57
  label="model",
58
  default="GFPGANv1.3.pth",
59
+ type="value"),
60
+ gr.Checkbox(label="realesrgan?"),
61
  ],
62
  [gr.components.Image(label="Enhanced Image")],
63
  ).launch()