Fabrice-TIERCELIN
commited on
Commit
•
5b111e7
1
Parent(s):
96c7fb7
Hide LlaVa
Browse files- gradio_demo.py +7 -8
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
|
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(input_image, prompt, a_prompt, n_prompt, num_samples, upscale, edm_steps, s_stage1, s_stage2,
|
121 |
s_cfg, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction,
|
122 |
linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select):
|
@@ -240,10 +240,9 @@ else:
|
|
240 |
title_md = """
|
241 |
<h1><center>SUPIR Image Upscaler</center></h1>
|
242 |
|
243 |
-
<p>SUPIR is a practicing model scaling for photo-realistic image restoration. It is still a research project under tested and is not yet a stable commercial product.
|
244 |
|
245 |
<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></p>
|
246 |
-
<p style="background-color: blue;">LLaVa is disabled.</p>
|
247 |
"""
|
248 |
|
249 |
|
@@ -276,13 +275,13 @@ with gr.Blocks(title="SUPIR") as interface:
|
|
276 |
with gr.Accordion("Pre-denoising options", open=False):
|
277 |
gamma_correction = gr.Slider(label="Gamma Correction", minimum=0.1, maximum=2.0, value=1.0, step=0.1)
|
278 |
|
279 |
-
with gr.Accordion("LLaVA options", open=False):
|
280 |
temperature = gr.Slider(label="Temperature", info = "lower=Always similar, higher=More creative", minimum=0., maximum=1.0, value=0.2, step=0.1)
|
281 |
top_p = gr.Slider(label="Top P", info = "Percent of tokens shortlisted", minimum=0., maximum=1.0, value=0.7, step=0.1)
|
282 |
qs = gr.Textbox(label="Question", info="Ask LLaVa what description you want", value="Describe the image and its style in a very detailed manner. The image is a realistic photography, not an art painting.", lines=3)
|
283 |
|
284 |
with gr.Accordion("Restoring options", open=False):
|
285 |
-
num_samples = gr.Slider(label="Num Samples", info="Number of generated results; I discourage to increase because the process is limited to
|
286 |
, value=1, step=1)
|
287 |
upscale = gr.Slider(label="Upscale factor", info="Resolution x1, x2, x3, x4, x5, x6, x7 or x8", minimum=1, maximum=8, value=1, step=1)
|
288 |
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)
|
@@ -340,7 +339,7 @@ with gr.Blocks(title="SUPIR") as interface:
|
|
340 |
with gr.Row():
|
341 |
with gr.Column():
|
342 |
denoise_button = gr.Button(value="Pre-denoise")
|
343 |
-
with gr.Column():
|
344 |
llave_button = gr.Button(value="Generate description by LlaVa (disabled)")
|
345 |
with gr.Column():
|
346 |
diffusion_button = gr.Button(value="🚀 Restore", variant = "primary")
|
|
|
78 |
def reset_feedback():
|
79 |
return 3, ''
|
80 |
|
81 |
+
@spaces.GPU(duration=240)
|
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
|
102 |
|
103 |
+
@spaces.GPU(duration=240)
|
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=240)
|
120 |
def stage2_process(input_image, prompt, a_prompt, n_prompt, num_samples, upscale, edm_steps, s_stage1, s_stage2,
|
121 |
s_cfg, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction,
|
122 |
linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select):
|
|
|
240 |
title_md = """
|
241 |
<h1><center>SUPIR Image Upscaler</center></h1>
|
242 |
|
243 |
+
<p>SUPIR is a practicing model scaling for photo-realistic image restoration. It is still a research project under tested and is not yet a stable commercial product. LLaVa is not available in this demo. If you want to auto-generate the description of your image, use another <a href="https://huggingface.co/spaces/MaziyarPanahi/llava-llama-3-8b">LLaVa space</a>.
|
244 |
|
245 |
<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></p>
|
|
|
246 |
"""
|
247 |
|
248 |
|
|
|
275 |
with gr.Accordion("Pre-denoising options", open=False):
|
276 |
gamma_correction = gr.Slider(label="Gamma Correction", minimum=0.1, maximum=2.0, value=1.0, step=0.1)
|
277 |
|
278 |
+
with gr.Accordion("LLaVA options", open=False, visible=False):
|
279 |
temperature = gr.Slider(label="Temperature", info = "lower=Always similar, higher=More creative", minimum=0., maximum=1.0, value=0.2, step=0.1)
|
280 |
top_p = gr.Slider(label="Top P", info = "Percent of tokens shortlisted", minimum=0., maximum=1.0, value=0.7, step=0.1)
|
281 |
qs = gr.Textbox(label="Question", info="Ask LLaVa what description you want", value="Describe the image and its style in a very detailed manner. The image is a realistic photography, not an art painting.", lines=3)
|
282 |
|
283 |
with gr.Accordion("Restoring options", open=False):
|
284 |
+
num_samples = gr.Slider(label="Num Samples", info="Number of generated results; I discourage to increase because the process is limited to 4 min", minimum=1, maximum=4 if not args.use_image_slider else 1
|
285 |
, value=1, step=1)
|
286 |
upscale = gr.Slider(label="Upscale factor", info="Resolution x1, x2, x3, x4, x5, x6, x7 or x8", minimum=1, maximum=8, value=1, step=1)
|
287 |
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)
|
|
|
339 |
with gr.Row():
|
340 |
with gr.Column():
|
341 |
denoise_button = gr.Button(value="Pre-denoise")
|
342 |
+
with gr.Column(visible=False):
|
343 |
llave_button = gr.Button(value="Generate description by LlaVa (disabled)")
|
344 |
with gr.Column():
|
345 |
diffusion_button = gr.Button(value="🚀 Restore", variant = "primary")
|