leonelhs commited on
Commit
1b008ec
·
verified ·
1 Parent(s): 93b3c32

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -15
app.py CHANGED
@@ -1,14 +1,14 @@
1
  from glob import glob
2
 
3
  import gradio as gr
4
- from gradio_client import Client
5
 
6
  from utils import make_flatten_background
7
 
8
  REPO_ID = "leonelhs/faceshine"
9
 
10
  clients = {
11
- "GFPGAN": "leonelhs/GFPGAN",
12
  "ZeroScratches": "leonelhs/ZeroScratches",
13
  "Deoldify": "leonelhs/deoldify",
14
  "EnhanceLight": "leonelhs/Zero-DCE",
@@ -26,27 +26,23 @@ def load_client(space):
26
 
27
 
28
  def gfpgan_face(image, version, scale):
29
- return clients["GFPGAN"].predict(image, version, scale, fn_index=0)[0]
30
-
31
 
32
  def zero_scratches(image):
33
- return clients["ZeroScratches"].predict(image, api_name="/predict")
34
-
35
 
36
  def colorize_photo(image):
37
- return clients["Deoldify"].predict(image, api_name="/predict")
38
-
39
 
40
  def enhance_light(image):
41
- return clients["EnhanceLight"].predict(image, api_name="/predict")
42
 
43
 
44
  def zero_background(image, new_bgr=None):
45
- # Fixme: cant find predict function by name
46
- # return clients["ZeroBackground"].predict(image, new_bgr, fn_index=0)[1]
47
- # return clients["ZeroBackground"].predict(image, fn_index=0)
48
- img, mask = clients["ZeroBackground"].predict(image, "U2NET Human Seg", False, fn_index=9)
49
- return make_flatten_background(img, mask)
50
 
51
 
52
  def parse_face(image):
@@ -136,5 +132,5 @@ with gr.Blocks(title="Face Shine") as app:
136
  with gr.Row():
137
  gr.HTML(footer)
138
 
139
- app.queue()
140
  app.launch(share=False, debug=True, show_error=True)
 
 
1
  from glob import glob
2
 
3
  import gradio as gr
4
+ from gradio_client import Client, handle_file
5
 
6
  from utils import make_flatten_background
7
 
8
  REPO_ID = "leonelhs/faceshine"
9
 
10
  clients = {
11
+ "GFPGAN": "leonelhs/realesrgan_x2plus",
12
  "ZeroScratches": "leonelhs/ZeroScratches",
13
  "Deoldify": "leonelhs/deoldify",
14
  "EnhanceLight": "leonelhs/Zero-DCE",
 
26
 
27
 
28
  def gfpgan_face(image, version, scale):
29
+ return clients["GFPGAN"].predict(img=handle_file(image), api_name="/predict")
 
30
 
31
  def zero_scratches(image):
32
+ return clients["ZeroScratches"].predict(img=handle_file(image), api_name="/predict")
 
33
 
34
  def colorize_photo(image):
35
+ return clients["Deoldify"].predict(image=handle_file(image), api_name="/predict")
 
36
 
37
  def enhance_light(image):
38
+ return clients["EnhanceLight"].predict(image=handle_file(image), api_name="/predict")
39
 
40
 
41
  def zero_background(image, new_bgr=None):
42
+ img_cut, mask = clients["ZeroBackground"].predict(
43
+ image=handle_file(image), session="U2NET Human Seg", smoot=False, api_name="/predict")
44
+ return make_flatten_background(image, img_cut, mask)
45
+
 
46
 
47
 
48
  def parse_face(image):
 
132
  with gr.Row():
133
  gr.HTML(footer)
134
 
 
135
  app.launch(share=False, debug=True, show_error=True)
136
+ app.queue()