Fabrice-TIERCELIN
commited on
Commit
•
4fe413f
1
Parent(s):
320e40a
Information
Browse files- gradio_demo.py +34 -20
gradio_demo.py
CHANGED
@@ -129,6 +129,7 @@ def stage2_process(
|
|
129 |
s_stage1,
|
130 |
s_stage2,
|
131 |
s_cfg,
|
|
|
132 |
seed,
|
133 |
s_churn,
|
134 |
s_noise,
|
@@ -142,6 +143,7 @@ def stage2_process(
|
|
142 |
spt_linear_s_stage2,
|
143 |
model_select
|
144 |
):
|
|
|
145 |
print('Start stage2_process')
|
146 |
if torch.cuda.device_count() == 0:
|
147 |
gr.Warning('Set this space to GPU config to make it work.')
|
@@ -200,8 +202,17 @@ def stage2_process(
|
|
200 |
Image.fromarray(input_image).save(f'./history/{event_id[:5]}/{event_id[5:]}/LQ.png')
|
201 |
for i, result in enumerate(results):
|
202 |
Image.fromarray(result).save(f'./history/{event_id[:5]}/{event_id[5:]}/HQ_{i}.png')
|
|
|
203 |
print('End stage2_process')
|
204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
|
206 |
def load_and_reset(param_setting):
|
207 |
print('Start load_and_reset')
|
@@ -285,17 +296,18 @@ with gr.Blocks(title="SUPIR") as interface:
|
|
285 |
""")
|
286 |
gr.HTML(title_html)
|
287 |
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
|
|
299 |
|
300 |
with gr.Accordion("Pre-denoising (optional)", open=False):
|
301 |
gamma_correction = gr.Slider(label="Gamma Correction", minimum=0.1, maximum=2.0, value=1.0, step=0.1)
|
@@ -352,17 +364,18 @@ with gr.Blocks(title="SUPIR") as interface:
|
|
352 |
with gr.Group():
|
353 |
param_setting = gr.Radio(["Quality", "Fidelity"], interactive=True, label="Presetting", value="Quality")
|
354 |
restart_button = gr.Button(value="Apply presetting")
|
355 |
-
|
356 |
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
|
|
|
|
|
|
362 |
|
363 |
with gr.Accordion("Feedback", open=True, visible=False):
|
364 |
-
fb_score = gr.Slider(label="Feedback Score", minimum=1, maximum=5, value=3, step=1,
|
365 |
-
interactive=True)
|
366 |
fb_text = gr.Textbox(label="Feedback Text", value="", placeholder='Please enter your feedback here.')
|
367 |
submit_button = gr.Button(value="Submit Feedback")
|
368 |
with gr.Row():
|
@@ -412,6 +425,7 @@ with gr.Blocks(title="SUPIR") as interface:
|
|
412 |
s_stage1,
|
413 |
s_stage2,
|
414 |
s_cfg,
|
|
|
415 |
seed,
|
416 |
s_churn,
|
417 |
s_noise,
|
|
|
129 |
s_stage1,
|
130 |
s_stage2,
|
131 |
s_cfg,
|
132 |
+
randomize_seed,
|
133 |
seed,
|
134 |
s_churn,
|
135 |
s_noise,
|
|
|
143 |
spt_linear_s_stage2,
|
144 |
model_select
|
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.')
|
|
|
202 |
Image.fromarray(input_image).save(f'./history/{event_id[:5]}/{event_id[5:]}/LQ.png')
|
203 |
for i, result in enumerate(results):
|
204 |
Image.fromarray(result).save(f'./history/{event_id[:5]}/{event_id[5:]}/HQ_{i}.png')
|
205 |
+
|
206 |
print('End stage2_process')
|
207 |
+
end = time.time()
|
208 |
+
secondes = int(end - start)
|
209 |
+
minutes = secondes // 60
|
210 |
+
secondes = secondes - (minutes * 60)
|
211 |
+
hours = minutes // 60
|
212 |
+
minutes = minutes - (hours * 60)
|
213 |
+
information = ("Restart the process to get another result. " if randomize_seed else "") + "The image(s) has(ve) been generated in " + ((str(hours) + " h, ") if hours != 0 else "") + ((str(minutes) + " min, ") if hours != 0 or minutes != 0 else "") + str(secondes) + " sec."
|
214 |
+
|
215 |
+
return [input_image] + results, [input_image] + results, gr.update(value = information, visible = True), event_id
|
216 |
|
217 |
def load_and_reset(param_setting):
|
218 |
print('Start load_and_reset')
|
|
|
296 |
""")
|
297 |
gr.HTML(title_html)
|
298 |
|
299 |
+
with gr.Group():
|
300 |
+
input_image = gr.Image(label="Input", show_label=True, type="numpy", height=600, elem_id="image-input")
|
301 |
+
prompt = gr.Textbox(label="Image description for LlaVa", value="", placeholder="A person, walking, in a town, Summer, photorealistic", lines=3, visible=False)
|
302 |
+
upscale = gr.Radio([1, 2, 3, 4, 5, 6, 7, 8], label="Upscale factor", info="Resolution x1 to x8", value=2, interactive=True)
|
303 |
+
a_prompt = gr.Textbox(label="Image description",
|
304 |
+
info="Help the AI to understand what the image represents",
|
305 |
+
value='Cinematic, High Contrast, highly detailed, taken using a Canon EOS R '
|
306 |
+
'camera, hyper detailed photo - realistic maximum detail, 32k, Color '
|
307 |
+
'Grading, ultra HD, extreme meticulous detailing, skin pore detailing, '
|
308 |
+
'hyper sharpness, perfect without deformations.',
|
309 |
+
lines=3)
|
310 |
+
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.")
|
311 |
|
312 |
with gr.Accordion("Pre-denoising (optional)", open=False):
|
313 |
gamma_correction = gr.Slider(label="Gamma Correction", minimum=0.1, maximum=2.0, value=1.0, step=0.1)
|
|
|
364 |
with gr.Group():
|
365 |
param_setting = gr.Radio(["Quality", "Fidelity"], interactive=True, label="Presetting", value="Quality")
|
366 |
restart_button = gr.Button(value="Apply presetting")
|
|
|
367 |
|
368 |
+
with gr.Group():
|
369 |
+
llave_button = gr.Button(value="Generate description by LlaVa (disabled)", visible=False)
|
370 |
+
|
371 |
+
diffusion_button = gr.Button(value="🚀 Upscale/Restore", variant = "primary", elem_id="process_button")
|
372 |
+
|
373 |
+
restore_information = gr.HTML(value="Restart the process to get another result.", visible=False)
|
374 |
+
result_slider = ImageSlider(label='Output', show_label=True, elem_id="slider1")
|
375 |
+
result_gallery = gr.Gallery(label='Output', show_label=True, elem_id="gallery1")
|
376 |
|
377 |
with gr.Accordion("Feedback", open=True, visible=False):
|
378 |
+
fb_score = gr.Slider(label="Feedback Score", minimum=1, maximum=5, value=3, step=1, interactive=True)
|
|
|
379 |
fb_text = gr.Textbox(label="Feedback Text", value="", placeholder='Please enter your feedback here.')
|
380 |
submit_button = gr.Button(value="Submit Feedback")
|
381 |
with gr.Row():
|
|
|
425 |
s_stage1,
|
426 |
s_stage2,
|
427 |
s_cfg,
|
428 |
+
randomize_seed,
|
429 |
seed,
|
430 |
s_churn,
|
431 |
s_noise,
|