Ahsen Khaliq commited on
Commit
504b262
1 Parent(s): 634f264

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -108,8 +108,7 @@ class FaceEnhancement(object):
108
  use_sr = False
109
  use_cuda = False
110
  sr_model = 'rrdb_realesrnet_psnr'
111
- indir = "."
112
- outdir = "."
113
 
114
 
115
  faceenhancer = FaceEnhancement(size=size, model=model, use_sr=use_sr, sr_model=sr_model, channel_multiplier=channel_multiplier, narrow=narrow, key=key, device='cuda' if args.use_cuda else 'cpu')
@@ -118,13 +117,11 @@ class FaceEnhancement(object):
118
 
119
 
120
 
121
- def inference(img):
122
  im = cv2.imread(file, cv2.IMREAD_COLOR)
123
  img, orig_faces, enhanced_faces = faceenhancer.process(im)
124
 
125
  return enhanced_faces[0]
126
- os.system("python face_enhancement.py --model GPEN-BFR-512 --size 512 --channel_multiplier 2 --narrow 1 --use_sr --indir examples/imgs --outdir examples/outs-BFR2")
127
- return "examples/outs-BFR2/"
128
 
129
  title = "GFP-GAN"
130
  description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
@@ -132,7 +129,7 @@ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.040
132
  gr.Interface(
133
  inference,
134
  [gr.inputs.Image(type="filepath", label="Input")],
135
- gr.outputs.Image(type="pil", label="Output"),
136
  title=title,
137
  description=description,
138
  article=article,
 
108
  use_sr = False
109
  use_cuda = False
110
  sr_model = 'rrdb_realesrnet_psnr'
111
+
 
112
 
113
 
114
  faceenhancer = FaceEnhancement(size=size, model=model, use_sr=use_sr, sr_model=sr_model, channel_multiplier=channel_multiplier, narrow=narrow, key=key, device='cuda' if args.use_cuda else 'cpu')
 
117
 
118
 
119
 
120
+ def inference(file):
121
  im = cv2.imread(file, cv2.IMREAD_COLOR)
122
  img, orig_faces, enhanced_faces = faceenhancer.process(im)
123
 
124
  return enhanced_faces[0]
 
 
125
 
126
  title = "GFP-GAN"
127
  description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
 
129
  gr.Interface(
130
  inference,
131
  [gr.inputs.Image(type="filepath", label="Input")],
132
+ gr.outputs.Image(type="numpy", label="Output"),
133
  title=title,
134
  description=description,
135
  article=article,