Same format as input image
Browse files- gradio_demo.py +10 -5
gradio_demo.py
CHANGED
|
@@ -79,7 +79,7 @@ def check(input_image):
|
|
| 79 |
def reset_feedback():
|
| 80 |
return 3, ''
|
| 81 |
|
| 82 |
-
@spaces.GPU(duration=
|
| 83 |
def stage1_process(input_image, gamma_correction):
|
| 84 |
print('stage1_process ==>>')
|
| 85 |
if torch.cuda.device_count() == 0:
|
|
@@ -101,7 +101,7 @@ def stage1_process(input_image, gamma_correction):
|
|
| 101 |
print('<<== stage1_process')
|
| 102 |
return LQ, gr.update(visible = True)
|
| 103 |
|
| 104 |
-
@spaces.GPU(duration=
|
| 105 |
def llave_process(input_image, temperature, top_p, qs=None):
|
| 106 |
print('llave_process ==>>')
|
| 107 |
if torch.cuda.device_count() == 0:
|
|
@@ -117,7 +117,7 @@ def llave_process(input_image, temperature, top_p, qs=None):
|
|
| 117 |
print('<<== llave_process')
|
| 118 |
return captions[0]
|
| 119 |
|
| 120 |
-
@spaces.GPU(duration=
|
| 121 |
def stage2_process(
|
| 122 |
noisy_image,
|
| 123 |
denoise_image,
|
|
@@ -152,6 +152,11 @@ def stage2_process(
|
|
| 152 |
if torch.cuda.device_count() == 0:
|
| 153 |
gr.Warning('Set this space to GPU config to make it work.')
|
| 154 |
return None, None, None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
input_image = noisy_image if denoise_image is None else denoise_image
|
| 156 |
if 1 < downscale:
|
| 157 |
input_height, input_width, input_channel = np.array(input_image).shape
|
|
@@ -292,7 +297,7 @@ title_html = """
|
|
| 292 |
LlaVa is not integrated in this demo. The content added by SUPIR is imagination, not real-world information.
|
| 293 |
The aim of SUPIR is the beauty and the illustration.
|
| 294 |
Most of the processes only last few minutes.
|
| 295 |
-
This demo can handle huge images but the process will be aborted if it lasts more than
|
| 296 |
|
| 297 |
<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>
|
| 298 |
"""
|
|
@@ -336,7 +341,7 @@ with gr.Blocks(title="SUPIR") as interface:
|
|
| 336 |
'hyper sharpness, perfect without deformations.',
|
| 337 |
lines=3)
|
| 338 |
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.")
|
| 339 |
-
output_format = gr.Radio([["*.png", "png"], ["*.webp", "webp"], ["*.jpeg", "jpeg"], ["*.gif", "gif"], ["*.bmp", "bmp"]], label="Image format for result", info="File extention", value="
|
| 340 |
|
| 341 |
with gr.Accordion("Pre-denoising (optional)", open=False):
|
| 342 |
gamma_correction = gr.Slider(label="Gamma Correction", info = "lower=lighter, higher=darker", minimum=0.1, maximum=2.0, value=1.0, step=0.1)
|
|
|
|
| 79 |
def reset_feedback():
|
| 80 |
return 3, ''
|
| 81 |
|
| 82 |
+
@spaces.GPU(duration=540)
|
| 83 |
def stage1_process(input_image, gamma_correction):
|
| 84 |
print('stage1_process ==>>')
|
| 85 |
if torch.cuda.device_count() == 0:
|
|
|
|
| 101 |
print('<<== stage1_process')
|
| 102 |
return LQ, gr.update(visible = True)
|
| 103 |
|
| 104 |
+
@spaces.GPU(duration=540)
|
| 105 |
def llave_process(input_image, temperature, top_p, qs=None):
|
| 106 |
print('llave_process ==>>')
|
| 107 |
if torch.cuda.device_count() == 0:
|
|
|
|
| 117 |
print('<<== llave_process')
|
| 118 |
return captions[0]
|
| 119 |
|
| 120 |
+
@spaces.GPU(duration=540)
|
| 121 |
def stage2_process(
|
| 122 |
noisy_image,
|
| 123 |
denoise_image,
|
|
|
|
| 152 |
if torch.cuda.device_count() == 0:
|
| 153 |
gr.Warning('Set this space to GPU config to make it work.')
|
| 154 |
return None, None, None
|
| 155 |
+
if output_format == "input":
|
| 156 |
+
if noisy_image is None:
|
| 157 |
+
output_format = "png"
|
| 158 |
+
else:
|
| 159 |
+
output_format = noisy_image.format
|
| 160 |
input_image = noisy_image if denoise_image is None else denoise_image
|
| 161 |
if 1 < downscale:
|
| 162 |
input_height, input_width, input_channel = np.array(input_image).shape
|
|
|
|
| 297 |
LlaVa is not integrated in this demo. The content added by SUPIR is imagination, not real-world information.
|
| 298 |
The aim of SUPIR is the beauty and the illustration.
|
| 299 |
Most of the processes only last few minutes.
|
| 300 |
+
This demo can handle huge images but the process will be aborted if it lasts more than 9 min.
|
| 301 |
|
| 302 |
<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>
|
| 303 |
"""
|
|
|
|
| 341 |
'hyper sharpness, perfect without deformations.',
|
| 342 |
lines=3)
|
| 343 |
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.")
|
| 344 |
+
output_format = gr.Radio([["As original image", "input"], ["*.png", "png"], ["*.webp", "webp"], ["*.jpeg", "jpeg"], ["*.gif", "gif"], ["*.bmp", "bmp"]], label="Image format for result", info="File extention", value="input", interactive=True)
|
| 345 |
|
| 346 |
with gr.Accordion("Pre-denoising (optional)", open=False):
|
| 347 |
gamma_correction = gr.Slider(label="Gamma Correction", info = "lower=lighter, higher=darker", minimum=0.1, maximum=2.0, value=1.0, step=0.1)
|