Spaces:
Paused
Paused
Fabrice-TIERCELIN
commited on
Commit
•
427d179
1
Parent(s):
57363eb
Resolution
Browse files- gradio_demo.py +25 -7
gradio_demo.py
CHANGED
@@ -78,7 +78,7 @@ def check(input_image):
|
|
78 |
def reset_feedback():
|
79 |
return 3, ''
|
80 |
|
81 |
-
@spaces.GPU(duration=
|
82 |
def stage1_process(input_image, gamma_correction):
|
83 |
print('Start stage1_process')
|
84 |
if torch.cuda.device_count() == 0:
|
@@ -100,7 +100,7 @@ def stage1_process(input_image, gamma_correction):
|
|
100 |
print('End stage1_process')
|
101 |
return LQ, gr.update(visible = True)
|
102 |
|
103 |
-
@spaces.GPU(duration=
|
104 |
def llave_process(input_image, temperature, top_p, qs=None):
|
105 |
print('Start llave_process')
|
106 |
if torch.cuda.device_count() == 0:
|
@@ -116,7 +116,7 @@ def llave_process(input_image, temperature, top_p, qs=None):
|
|
116 |
print('End llave_process')
|
117 |
return captions[0]
|
118 |
|
119 |
-
@spaces.GPU(duration=
|
120 |
def stage2_process(
|
121 |
noisy_image,
|
122 |
denoise_image,
|
@@ -145,6 +145,7 @@ def stage2_process(
|
|
145 |
):
|
146 |
start = time.time()
|
147 |
print('Start stage2_process')
|
|
|
148 |
if torch.cuda.device_count() == 0:
|
149 |
gr.Warning('Set this space to GPU config to make it work.')
|
150 |
return None, None, None
|
@@ -213,7 +214,14 @@ def stage2_process(
|
|
213 |
secondes = secondes - (minutes * 60)
|
214 |
hours = minutes // 60
|
215 |
minutes = minutes - (hours * 60)
|
216 |
-
information = ("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
|
218 |
return [noisy_image] + results, [noisy_image] + results, gr.update(value = information, visible = True), event_id
|
219 |
|
@@ -271,13 +279,22 @@ title_html = """
|
|
271 |
<big><center>Upscale your images up to x8 freely, without account, without watermark and download it</center></big>
|
272 |
<br/>
|
273 |
|
274 |
-
<p>
|
|
|
|
|
|
|
|
|
|
|
275 |
|
276 |
<p><center><a href="https://arxiv.org/abs/2401.13627">Paper</a>   <a href="http://supir.xpixel.group/">Project Page</a>   <a href="https://github.com/Fanghua-Yu/SUPIR/blob/master/assets/DemoGuide.png">How to play</a>   <a href="https://huggingface.co/blog/MonsterMMORPG/supir-sota-image-upscale-better-than-magnific-ai">Local Install Guide</a></center></p>
|
277 |
"""
|
278 |
|
279 |
|
280 |
claim_md = """
|
|
|
|
|
|
|
|
|
281 |
## **Terms of use**
|
282 |
|
283 |
By using this service, users are required to agree to the following terms: The service is a research preview intended for non-commercial use only. It only provides limited safety measures and may generate offensive content. It must not be used for any illegal, harmful, violent, racist, or sexual purposes. The service may collect user dialogue data for future research. Please submit a feedback to us if you get any inappropriate answer! We will collect those to keep improving our models. For an optimal experience, please use desktop computers for this demo, as mobile devices may compromise its quality.
|
@@ -309,7 +326,8 @@ with gr.Blocks(title="SUPIR") as interface:
|
|
309 |
'Grading, ultra HD, extreme meticulous detailing, skin pore detailing, '
|
310 |
'hyper sharpness, perfect without deformations.',
|
311 |
lines=3)
|
312 |
-
|
|
|
313 |
|
314 |
with gr.Accordion("Pre-denoising (optional)", open=False):
|
315 |
gamma_correction = gr.Slider(label="Gamma Correction", minimum=0.1, maximum=2.0, value=1.0, step=0.1)
|
@@ -331,7 +349,7 @@ with gr.Blocks(title="SUPIR") as interface:
|
|
331 |
'deformed, lowres, over-smooth',
|
332 |
lines=3)
|
333 |
edm_steps = gr.Slider(label="Steps", info="lower=faster, higher=more details", minimum=1, maximum=200, value=default_setting.edm_steps if torch.cuda.device_count() > 0 else 1, step=1)
|
334 |
-
num_samples = gr.Slider(label="Num Samples", info="Number of generated results
|
335 |
, value=1, step=1)
|
336 |
with gr.Row():
|
337 |
with gr.Column():
|
|
|
78 |
def reset_feedback():
|
79 |
return 3, ''
|
80 |
|
81 |
+
@spaces.GPU(duration=3600)
|
82 |
def stage1_process(input_image, gamma_correction):
|
83 |
print('Start stage1_process')
|
84 |
if torch.cuda.device_count() == 0:
|
|
|
100 |
print('End stage1_process')
|
101 |
return LQ, gr.update(visible = True)
|
102 |
|
103 |
+
@spaces.GPU(duration=3600)
|
104 |
def llave_process(input_image, temperature, top_p, qs=None):
|
105 |
print('Start llave_process')
|
106 |
if torch.cuda.device_count() == 0:
|
|
|
116 |
print('End llave_process')
|
117 |
return captions[0]
|
118 |
|
119 |
+
@spaces.GPU(duration=3600)
|
120 |
def stage2_process(
|
121 |
noisy_image,
|
122 |
denoise_image,
|
|
|
145 |
):
|
146 |
start = time.time()
|
147 |
print('Start stage2_process')
|
148 |
+
print(a_prompt)
|
149 |
if torch.cuda.device_count() == 0:
|
150 |
gr.Warning('Set this space to GPU config to make it work.')
|
151 |
return None, None, None
|
|
|
214 |
secondes = secondes - (minutes * 60)
|
215 |
hours = minutes // 60
|
216 |
minutes = minutes - (hours * 60)
|
217 |
+
information = ("Start the process again if you want a different result. " if randomize_seed else "") + \
|
218 |
+
"The new image resolution is " + str(result_width) + \
|
219 |
+
" pixels large and " + str(result_height) + \
|
220 |
+
" pixels high, so a resolution of " + f'{result_width * result_height:,}' + " pixels. " + \
|
221 |
+
"The image(s) has(ve) been generated in " + \
|
222 |
+
((str(hours) + " h, ") if hours != 0 else "") + \
|
223 |
+
((str(minutes) + " min, ") if hours != 0 or minutes != 0 else "") + \
|
224 |
+
str(secondes) + " sec."
|
225 |
|
226 |
return [noisy_image] + results, [noisy_image] + results, gr.update(value = information, visible = True), event_id
|
227 |
|
|
|
279 |
<big><center>Upscale your images up to x8 freely, without account, without watermark and download it</center></big>
|
280 |
<br/>
|
281 |
|
282 |
+
<p>This is an online demo of SUPIR, a practicing model scaling for photo-realistic image restoration.
|
283 |
+
It is still a research project under tested and is not yet a stable commercial product.
|
284 |
+
LlaVa is not integrated in this demo. The content added by SUPIR is imagination, not real-world information.
|
285 |
+
The aim of SUPIR is the beauty and the illustration.
|
286 |
+
Most of the processes only last few minutes.
|
287 |
+
This demo can handle huge images but the process will be aborted if it lasts more than an hour.
|
288 |
|
289 |
<p><center><a href="https://arxiv.org/abs/2401.13627">Paper</a>   <a href="http://supir.xpixel.group/">Project Page</a>   <a href="https://github.com/Fanghua-Yu/SUPIR/blob/master/assets/DemoGuide.png">How to play</a>   <a href="https://huggingface.co/blog/MonsterMMORPG/supir-sota-image-upscale-better-than-magnific-ai">Local Install Guide</a></center></p>
|
290 |
"""
|
291 |
|
292 |
|
293 |
claim_md = """
|
294 |
+
## **Piracy**
|
295 |
+
|
296 |
+
The images are not stored but the logs are saved during a month.
|
297 |
+
|
298 |
## **Terms of use**
|
299 |
|
300 |
By using this service, users are required to agree to the following terms: The service is a research preview intended for non-commercial use only. It only provides limited safety measures and may generate offensive content. It must not be used for any illegal, harmful, violent, racist, or sexual purposes. The service may collect user dialogue data for future research. Please submit a feedback to us if you get any inappropriate answer! We will collect those to keep improving our models. For an optimal experience, please use desktop computers for this demo, as mobile devices may compromise its quality.
|
|
|
326 |
'Grading, ultra HD, extreme meticulous detailing, skin pore detailing, '
|
327 |
'hyper sharpness, perfect without deformations.',
|
328 |
lines=3)
|
329 |
+
with gr.Group():
|
330 |
+
a_prompt_hint = gr.HTML("You can use a <a href='"'https://huggingface.co/spaces/MaziyarPanahi/llava-llama-3-8b'"'>LlaVa space</a> to auto-generate the description of your image.")
|
331 |
|
332 |
with gr.Accordion("Pre-denoising (optional)", open=False):
|
333 |
gamma_correction = gr.Slider(label="Gamma Correction", minimum=0.1, maximum=2.0, value=1.0, step=0.1)
|
|
|
349 |
'deformed, lowres, over-smooth',
|
350 |
lines=3)
|
351 |
edm_steps = gr.Slider(label="Steps", info="lower=faster, higher=more details", minimum=1, maximum=200, value=default_setting.edm_steps if torch.cuda.device_count() > 0 else 1, step=1)
|
352 |
+
num_samples = gr.Slider(label="Num Samples", info="Number of generated results", minimum=1, maximum=4 if not args.use_image_slider else 1
|
353 |
, value=1, step=1)
|
354 |
with gr.Row():
|
355 |
with gr.Column():
|