Xintao commited on
Commit
082c35d
1 Parent(s): e836c0d
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -3,7 +3,6 @@ import os
3
  import cv2
4
  import gradio as gr
5
  import torch
6
- from PIL import Image
7
 
8
  from realesrgan_utils import RealESRGANer
9
  from srvgg_arch import SRVGGNetCompact
@@ -35,7 +34,8 @@ netscale = 4
35
  model_path = os.path.join('weights', 'realesr-general-x4v3.pth')
36
 
37
  # restorer
38
- upsampler = RealESRGANer(scale=netscale, model_path=model_path, model=model, tile=0, tile_pad=10, pre_pad=0, half=False)
 
39
 
40
  # Use GFPGAN for face enhancement
41
  from gfpgan_utils import GFPGANer
@@ -60,7 +60,7 @@ def inference(img):
60
  else:
61
  extension = 'png'
62
 
63
- return Image.fromarray(output)
64
 
65
 
66
  title = "GFP-GAN"
@@ -68,7 +68,7 @@ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoratio
68
  article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</a> | <a href='https://github.com/TencentARC/GFPGAN' target='_blank'>Github Repo</a></p><center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_GFPGAN' alt='visitor badge'></center>"
69
  gr.Interface(
70
  inference, [gr.inputs.Image(type="filepath", label="Input")],
71
- gr.outputs.Image(type="pil", label="Output"),
72
  title=title,
73
  description=description,
74
  article=article,
 
3
  import cv2
4
  import gradio as gr
5
  import torch
 
6
 
7
  from realesrgan_utils import RealESRGANer
8
  from srvgg_arch import SRVGGNetCompact
 
34
  model_path = os.path.join('weights', 'realesr-general-x4v3.pth')
35
 
36
  # restorer
37
+ half = True if torch.cuda.is_available() else False
38
+ upsampler = RealESRGANer(scale=netscale, model_path=model_path, model=model, tile=0, tile_pad=10, pre_pad=0, half=half)
39
 
40
  # Use GFPGAN for face enhancement
41
  from gfpgan_utils import GFPGANer
 
60
  else:
61
  extension = 'png'
62
 
63
+ return output
64
 
65
 
66
  title = "GFP-GAN"
 
68
  article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</a> | <a href='https://github.com/TencentARC/GFPGAN' target='_blank'>Github Repo</a></p><center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_GFPGAN' alt='visitor badge'></center>"
69
  gr.Interface(
70
  inference, [gr.inputs.Image(type="filepath", label="Input")],
71
+ gr.outputs.Image(type="numpy", label="Output (The whole image)"),
72
  title=title,
73
  description=description,
74
  article=article,