adjust settings
Browse files- .gitignore +1 -0
- README.md +1 -1
- app.py +61 -24
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
.idea/
|
README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
---
|
2 |
title: Faceshine
|
3 |
-
emoji:
|
4 |
colorFrom: indigo
|
5 |
colorTo: yellow
|
6 |
sdk: gradio
|
|
|
1 |
---
|
2 |
title: Faceshine
|
3 |
+
emoji: π
|
4 |
colorFrom: indigo
|
5 |
colorTo: yellow
|
6 |
sdk: gradio
|
app.py
CHANGED
@@ -2,17 +2,24 @@ import gradio as gr
|
|
2 |
from gradio_client import Client
|
3 |
|
4 |
clientGFPGAN = Client("leonelhs/GFPGAN")
|
|
|
5 |
clientZeroScratches = Client("leonelhs/ZeroScratches")
|
6 |
clientDeoldify = Client("leonelhs/deoldify")
|
7 |
clientEnhanceLight = Client("leonelhs/Zero-DCE")
|
8 |
clientZeroBackground = Client("leonelhs/ZeroBackground")
|
9 |
clientFaceParser = Client("leonelhs/faceparser")
|
10 |
|
|
|
11 |
|
12 |
-
|
|
|
13 |
return clientGFPGAN.predict(image, "v1.4", "2", api_name="/predict")[1]
|
14 |
|
15 |
|
|
|
|
|
|
|
|
|
16 |
def zero_scratches(image):
|
17 |
return clientZeroScratches.predict(image, api_name="/predict")
|
18 |
|
@@ -25,7 +32,7 @@ def enhance_light(image):
|
|
25 |
return clientEnhanceLight.predict(image, api_name="/predict")
|
26 |
|
27 |
|
28 |
-
def zero_background(image, new_bgr):
|
29 |
return clientZeroBackground.predict(image, new_bgr, api_name="/predict")
|
30 |
|
31 |
|
@@ -50,17 +57,19 @@ footer = r"""
|
|
50 |
"""
|
51 |
|
52 |
with gr.Blocks() as app:
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
54 |
with gr.Row():
|
55 |
with gr.Column(scale=1):
|
56 |
btn_hires = gr.Button(value="Enhance resolution")
|
57 |
btn_eraser = gr.Button(value="Erase scratches")
|
58 |
btn_color = gr.Button(value="Colorize photo")
|
59 |
btn_light = gr.Button(value="Enhance light")
|
60 |
-
|
61 |
-
btn_clear = gr.Button(value="Clear background")
|
62 |
-
# chk_newbgr = gr.Checkbox(label="Change background")
|
63 |
-
img_newbgr = gr.Image(label="Choose file for new background", type="filepath")
|
64 |
|
65 |
with gr.Column(scale=4):
|
66 |
with gr.Row():
|
@@ -69,28 +78,56 @@ with gr.Blocks() as app:
|
|
69 |
|
70 |
with gr.Row():
|
71 |
btn_swap = gr.Button(value="Swap images")
|
72 |
-
btn_reset = gr.Button("Clear")
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
|
|
|
|
|
|
81 |
|
82 |
with gr.Tab("Settings"):
|
83 |
-
with gr.Accordion("
|
84 |
-
gr.
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
gr.Button("Save settings")
|
92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
with gr.Row():
|
94 |
gr.HTML(footer)
|
95 |
|
96 |
-
app.launch()
|
|
|
2 |
from gradio_client import Client
|
3 |
|
4 |
clientGFPGAN = Client("leonelhs/GFPGAN")
|
5 |
+
clientSuperface = Client("leonelhs/superface")
|
6 |
clientZeroScratches = Client("leonelhs/ZeroScratches")
|
7 |
clientDeoldify = Client("leonelhs/deoldify")
|
8 |
clientEnhanceLight = Client("leonelhs/Zero-DCE")
|
9 |
clientZeroBackground = Client("leonelhs/ZeroBackground")
|
10 |
clientFaceParser = Client("leonelhs/faceparser")
|
11 |
|
12 |
+
context = dict()
|
13 |
|
14 |
+
|
15 |
+
def gfpgan_face(image):
|
16 |
return clientGFPGAN.predict(image, "v1.4", "2", api_name="/predict")[1]
|
17 |
|
18 |
|
19 |
+
def enhance_face(image, upsampler, face_enhancer, scale):
|
20 |
+
return clientSuperface.predict(image, upsampler, face_enhancer, scale, api_name="/predict")
|
21 |
+
|
22 |
+
|
23 |
def zero_scratches(image):
|
24 |
return clientZeroScratches.predict(image, api_name="/predict")
|
25 |
|
|
|
32 |
return clientEnhanceLight.predict(image, api_name="/predict")
|
33 |
|
34 |
|
35 |
+
def zero_background(image, new_bgr=None):
|
36 |
return clientZeroBackground.predict(image, new_bgr, api_name="/predict")
|
37 |
|
38 |
|
|
|
57 |
"""
|
58 |
|
59 |
with gr.Blocks() as app:
|
60 |
+
gr.Request()
|
61 |
+
|
62 |
+
with gr.Row():
|
63 |
+
gr.HTML("<center><h1>Face Shine</h1></center>")
|
64 |
+
|
65 |
+
with gr.Tab("Photo restorer"):
|
66 |
with gr.Row():
|
67 |
with gr.Column(scale=1):
|
68 |
btn_hires = gr.Button(value="Enhance resolution")
|
69 |
btn_eraser = gr.Button(value="Erase scratches")
|
70 |
btn_color = gr.Button(value="Colorize photo")
|
71 |
btn_light = gr.Button(value="Enhance light")
|
72 |
+
btn_reset = gr.Button(value="Clear", variant="primary")
|
|
|
|
|
|
|
73 |
|
74 |
with gr.Column(scale=4):
|
75 |
with gr.Row():
|
|
|
78 |
|
79 |
with gr.Row():
|
80 |
btn_swap = gr.Button(value="Swap images")
|
|
|
81 |
|
82 |
+
with gr.Tab("Background") as tab_background:
|
83 |
+
with gr.Row():
|
84 |
+
with gr.Column(scale=1):
|
85 |
+
btn_clear = gr.Button(value="Clear background")
|
86 |
+
with gr.Accordion("New background", open=True):
|
87 |
+
btn_newbgr = gr.Button(value="Change background")
|
88 |
+
img_newbgr = gr.Image(label="Choose file for new background", type="filepath")
|
89 |
+
with gr.Column(scale=4):
|
90 |
+
with gr.Row():
|
91 |
+
img_input_bgr = gr.Image(label="Input", type="filepath")
|
92 |
+
img_output_bgr = gr.Image(label="Result", type="filepath", interactive=False)
|
93 |
|
94 |
with gr.Tab("Settings"):
|
95 |
+
with gr.Accordion("Image restoration settings", open=False):
|
96 |
+
restorer = gr.Dropdown([
|
97 |
+
'RealESRGAN_x2plus',
|
98 |
+
'RealESRGAN_x4plus',
|
99 |
+
'RealESRNet_x4plus',
|
100 |
+
'AI-Forever_x2plus',
|
101 |
+
'AI-Forever_x4plus',
|
102 |
+
'RealESRGAN_x4plus_anime_6B',
|
103 |
+
'realesr-animevideov3',
|
104 |
+
'realesr-general-x4v3'],
|
105 |
+
type="value", value='RealESRGAN_x4plus', label='General restoration algorithm', info="version")
|
106 |
+
enhancer = gr.Dropdown([
|
107 |
+
'No additional face process',
|
108 |
+
'GFPGANv1.2',
|
109 |
+
'GFPGANv1.3',
|
110 |
+
'GFPGANv1.4',
|
111 |
+
'RestoreFormer'],
|
112 |
+
type="value", value='No additional face process', label='Special face restoration algorithm',
|
113 |
+
info="version")
|
114 |
+
rescale = gr.Dropdown(["1", "2", "3", "4"], type="value", value="4", label="Rescaling factor")
|
115 |
+
with gr.Accordion("Logs info", open=False):
|
116 |
+
text_logger = gr.Textbox(label="login", lines=5, show_label=False)
|
117 |
gr.Button("Save settings")
|
118 |
|
119 |
+
btn_hires.click(enhance_face, inputs=[img_input, restorer, enhancer, rescale],
|
120 |
+
outputs=[img_output, text_logger])
|
121 |
+
btn_eraser.click(zero_scratches, inputs=[img_input], outputs=[img_output])
|
122 |
+
btn_color.click(colorize_photo, inputs=[img_input], outputs=[img_output])
|
123 |
+
btn_light.click(enhance_light, inputs=[img_input], outputs=[img_output])
|
124 |
+
btn_clear.click(zero_background, inputs=[img_input_bgr], outputs=[img_output_bgr])
|
125 |
+
btn_newbgr.click(zero_background, inputs=[img_input_bgr, img_newbgr], outputs=[img_output_bgr])
|
126 |
+
btn_swap.click(mirror, inputs=[img_output], outputs=[img_input])
|
127 |
+
btn_reset.click(lambda: None, None, img_input, queue=False)
|
128 |
+
tab_background.select(mirror, inputs=[img_input], outputs=[img_input_bgr])
|
129 |
+
|
130 |
with gr.Row():
|
131 |
gr.HTML(footer)
|
132 |
|
133 |
+
app.launch(debug=True, enable_queue=True)
|