Spaces:
Paused
Paused
Commit
•
a1cd2f5
1
Parent(s):
f9c8d7c
Update app.py
Browse files
app.py
CHANGED
@@ -12,11 +12,15 @@ from realesrgan.archs.srvgg_arch import SRVGGNetCompact
|
|
12 |
|
13 |
last_file = None
|
14 |
img_mode = "RGBA"
|
|
|
15 |
|
16 |
-
|
17 |
-
def realesrgan(img, model_name, denoise_strength, face_enhance, outscale):
|
18 |
"""Real-ESRGAN function to restore (and upscale) images.
|
19 |
"""
|
|
|
|
|
|
|
|
|
20 |
if not img:
|
21 |
return
|
22 |
|
@@ -176,7 +180,11 @@ def main():
|
|
176 |
gr.Markdown(
|
177 |
"""This Space is a fork of "Real-ESRGAN-Demo", so if you want to use it please refer to [havas79/Real-ESRGAN_Demo](https://huggingface.co/spaces/havas79/Real-ESRGAN_Demo), thank you!"""
|
178 |
)
|
179 |
-
|
|
|
|
|
|
|
|
|
180 |
with gr.Accordion("Options/Parameters"):
|
181 |
with gr.Row():
|
182 |
model_name = gr.Dropdown(label="Real-ESRGAN inference model to be used",
|
@@ -201,7 +209,7 @@ def main():
|
|
201 |
# Event listeners:
|
202 |
input_image.change(fn=image_properties, inputs=input_image, outputs=input_image_properties)
|
203 |
restore_btn.click(fn=realesrgan,
|
204 |
-
inputs=[input_image, model_name, denoise_strength, face_enhance, outscale],
|
205 |
outputs=output_image,
|
206 |
api_name="upscale")
|
207 |
|
|
|
12 |
|
13 |
last_file = None
|
14 |
img_mode = "RGBA"
|
15 |
+
SECRET_TOKEN = os.getenv('SECRET_TOKEN', 'default_secret')
|
16 |
|
17 |
+
def realesrgan(secret_token, img, model_name, denoise_strength, face_enhance, outscale):
|
|
|
18 |
"""Real-ESRGAN function to restore (and upscale) images.
|
19 |
"""
|
20 |
+
if secret_token != SECRET_TOKEN:
|
21 |
+
raise gr.Error(
|
22 |
+
f'Invalid secret token. Please fork the original space if you want to use it for yourself.')
|
23 |
+
|
24 |
if not img:
|
25 |
return
|
26 |
|
|
|
180 |
gr.Markdown(
|
181 |
"""This Space is a fork of "Real-ESRGAN-Demo", so if you want to use it please refer to [havas79/Real-ESRGAN_Demo](https://huggingface.co/spaces/havas79/Real-ESRGAN_Demo), thank you!"""
|
182 |
)
|
183 |
+
secret_token = gr.Text(
|
184 |
+
label='Secret Token',
|
185 |
+
max_lines=1,
|
186 |
+
placeholder='Enter your secret token',
|
187 |
+
)
|
188 |
with gr.Accordion("Options/Parameters"):
|
189 |
with gr.Row():
|
190 |
model_name = gr.Dropdown(label="Real-ESRGAN inference model to be used",
|
|
|
209 |
# Event listeners:
|
210 |
input_image.change(fn=image_properties, inputs=input_image, outputs=input_image_properties)
|
211 |
restore_btn.click(fn=realesrgan,
|
212 |
+
inputs=[secret_token, input_image, model_name, denoise_strength, face_enhance, outscale],
|
213 |
outputs=output_image,
|
214 |
api_name="upscale")
|
215 |
|