Fabrice-TIERCELIN
commited on
Commit
•
7e93de4
1
Parent(s):
a14ce71
Make allocation work
Browse files- gradio_demo.py +51 -5
gradio_demo.py
CHANGED
@@ -147,6 +147,8 @@ def stage2_process(
|
|
147 |
output_format,
|
148 |
allocation
|
149 |
):
|
|
|
|
|
150 |
if allocation == 1:
|
151 |
return restore_in_1min(
|
152 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
@@ -188,6 +190,7 @@ def stage2_process(
|
|
188 |
def restore_in_1min(
|
189 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
190 |
):
|
|
|
191 |
return restore(
|
192 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
193 |
)
|
@@ -196,6 +199,7 @@ def restore_in_1min(
|
|
196 |
def restore_in_2min(
|
197 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
198 |
):
|
|
|
199 |
return restore(
|
200 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
201 |
)
|
@@ -204,6 +208,7 @@ def restore_in_2min(
|
|
204 |
def restore_in_3min(
|
205 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
206 |
):
|
|
|
207 |
return restore(
|
208 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
209 |
)
|
@@ -212,6 +217,7 @@ def restore_in_3min(
|
|
212 |
def restore_in_4min(
|
213 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
214 |
):
|
|
|
215 |
return restore(
|
216 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
217 |
)
|
@@ -220,6 +226,7 @@ def restore_in_4min(
|
|
220 |
def restore_in_5min(
|
221 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
222 |
):
|
|
|
223 |
return restore(
|
224 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
225 |
)
|
@@ -228,6 +235,7 @@ def restore_in_5min(
|
|
228 |
def restore_in_6min(
|
229 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
230 |
):
|
|
|
231 |
return restore(
|
232 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
233 |
)
|
@@ -236,6 +244,7 @@ def restore_in_6min(
|
|
236 |
def restore_in_7min(
|
237 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
238 |
):
|
|
|
239 |
return restore(
|
240 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
241 |
)
|
@@ -244,6 +253,7 @@ def restore_in_7min(
|
|
244 |
def restore_in_8min(
|
245 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
246 |
):
|
|
|
247 |
return restore(
|
248 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
249 |
)
|
@@ -252,6 +262,7 @@ def restore_in_8min(
|
|
252 |
def restore_in_9min(
|
253 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
254 |
):
|
|
|
255 |
return restore(
|
256 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
257 |
)
|
@@ -287,9 +298,36 @@ def restore(
|
|
287 |
):
|
288 |
start = time.time()
|
289 |
print('stage2_process ==>>')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
if torch.cuda.device_count() == 0:
|
291 |
gr.Warning('Set this space to GPU config to make it work.')
|
292 |
-
return None, None, None
|
293 |
if output_format == "input":
|
294 |
if noisy_image is None:
|
295 |
output_format = "png"
|
@@ -412,6 +450,11 @@ def load_and_reset(param_setting):
|
|
412 |
return edm_steps, s_cfg, s_stage2, s_stage1, s_churn, s_noise, a_prompt, n_prompt, color_fix_type, linear_CFG, \
|
413 |
linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select
|
414 |
|
|
|
|
|
|
|
|
|
|
|
415 |
|
416 |
def submit_feedback(event_id, fb_score, fb_text):
|
417 |
if args.log_history:
|
@@ -433,7 +476,7 @@ title_html = """
|
|
433 |
|
434 |
<p>This is an online demo of SUPIR, a practicing model scaling for photo-realistic image restoration.
|
435 |
It is still a research project under tested and is not yet a stable commercial product.
|
436 |
-
|
437 |
The aim of SUPIR is the beauty and the illustration.
|
438 |
Most of the processes only last few minutes.
|
439 |
This demo can handle huge images but the process will be aborted if it lasts more than 9 min.
|
@@ -456,7 +499,7 @@ with gr.Blocks(title="SUPIR") as interface:
|
|
456 |
if torch.cuda.device_count() == 0:
|
457 |
with gr.Row():
|
458 |
gr.HTML("""
|
459 |
-
<p style="background-color: red;"><big><big><big><b>⚠️To use SUPIR, <a href="https://huggingface.co/spaces/Fabrice-TIERCELIN/SUPIR?duplicate=true">
|
460 |
|
461 |
You can't use SUPIR directly here because this space runs on a CPU, which is not enough for SUPIR. This is a template space. Please provide feedback if you have issues.
|
462 |
</big></big></big></p>
|
@@ -508,6 +551,7 @@ with gr.Blocks(title="SUPIR") as interface:
|
|
508 |
with gr.Column():
|
509 |
color_fix_type = gr.Radio(["None", "AdaIn", "Wavelet"], label="Color-Fix Type", info="AdaIn=Improve following a style, Wavelet=For JPEG artifacts", value="Wavelet",
|
510 |
interactive=True)
|
|
|
511 |
s_cfg = gr.Slider(label="Text Guidance Scale", info="lower=follow the image, higher=follow the prompt", minimum=1.0, maximum=15.0,
|
512 |
value=default_setting.s_cfg_Quality if torch.cuda.device_count() > 0 else 1.0, step=0.1)
|
513 |
s_stage2 = gr.Slider(label="Restoring Guidance Strength", minimum=0., maximum=1., value=1., step=0.05)
|
@@ -529,7 +573,6 @@ with gr.Blocks(title="SUPIR") as interface:
|
|
529 |
with gr.Column():
|
530 |
ae_dtype = gr.Radio(['fp32', 'bf16'], label="Auto-Encoder Data Type", value="bf16",
|
531 |
interactive=True)
|
532 |
-
allocation = gr.Radio([["1 min", 1], ["2 min", 2], ["3 min", 3], ["4 min", 4], ["5 min", 5], ["6 min", 6], ["7 min", 7], ["8 min", 8], ["9 min", 9]], label="GPU allocation time", info="lower=May abort run, higher=Time penalty for next runs", value=6, interactive=True)
|
533 |
randomize_seed = gr.Checkbox(label = "\U0001F3B2 Randomize seed", value = True, info = "If checked, result is always different")
|
534 |
seed = gr.Slider(label="Seed", minimum=0, maximum=2147483647, step=1, randomize=True)
|
535 |
with gr.Group():
|
@@ -715,7 +758,8 @@ with gr.Blocks(title="SUPIR") as interface:
|
|
715 |
spt_linear_CFG,
|
716 |
spt_linear_s_stage2,
|
717 |
model_select,
|
718 |
-
output_format
|
|
|
719 |
], outputs = [
|
720 |
result_slider,
|
721 |
result_gallery,
|
@@ -723,6 +767,8 @@ with gr.Blocks(title="SUPIR") as interface:
|
|
723 |
event_id
|
724 |
])
|
725 |
|
|
|
|
|
726 |
restart_button.click(fn = load_and_reset, inputs = [
|
727 |
param_setting
|
728 |
], outputs = [
|
|
|
147 |
output_format,
|
148 |
allocation
|
149 |
):
|
150 |
+
print('allocation')
|
151 |
+
print(allocation)
|
152 |
if allocation == 1:
|
153 |
return restore_in_1min(
|
154 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
|
|
190 |
def restore_in_1min(
|
191 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
192 |
):
|
193 |
+
print('1 min')
|
194 |
return restore(
|
195 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
196 |
)
|
|
|
199 |
def restore_in_2min(
|
200 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
201 |
):
|
202 |
+
print('2 min')
|
203 |
return restore(
|
204 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
205 |
)
|
|
|
208 |
def restore_in_3min(
|
209 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
210 |
):
|
211 |
+
print('3 min')
|
212 |
return restore(
|
213 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
214 |
)
|
|
|
217 |
def restore_in_4min(
|
218 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
219 |
):
|
220 |
+
print('4 min')
|
221 |
return restore(
|
222 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
223 |
)
|
|
|
226 |
def restore_in_5min(
|
227 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
228 |
):
|
229 |
+
print('5 min')
|
230 |
return restore(
|
231 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
232 |
)
|
|
|
235 |
def restore_in_6min(
|
236 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
237 |
):
|
238 |
+
print('6 min')
|
239 |
return restore(
|
240 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
241 |
)
|
|
|
244 |
def restore_in_7min(
|
245 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
246 |
):
|
247 |
+
print('7 min')
|
248 |
return restore(
|
249 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
250 |
)
|
|
|
253 |
def restore_in_8min(
|
254 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
255 |
):
|
256 |
+
print('8 min')
|
257 |
return restore(
|
258 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
259 |
)
|
|
|
262 |
def restore_in_9min(
|
263 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
264 |
):
|
265 |
+
print('9 min')
|
266 |
return restore(
|
267 |
noisy_image, denoise_image, prompt, a_prompt, n_prompt, num_samples, min_size, downscale, upscale, edm_steps, s_stage1, s_stage2, s_cfg, randomize_seed, seed, s_churn, s_noise, color_fix_type, diff_dtype, ae_dtype, gamma_correction, linear_CFG, linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select, output_format
|
268 |
)
|
|
|
298 |
):
|
299 |
start = time.time()
|
300 |
print('stage2_process ==>>')
|
301 |
+
print(noisy_image)
|
302 |
+
print(denoise_image)
|
303 |
+
print(prompt)
|
304 |
+
print(a_prompt)
|
305 |
+
print(n_prompt)
|
306 |
+
print(num_samples)
|
307 |
+
print(min_size)
|
308 |
+
print(downscale)
|
309 |
+
print(upscale)
|
310 |
+
print(edm_steps)
|
311 |
+
print(s_stage1)
|
312 |
+
print(s_stage2)
|
313 |
+
print(s_cfg)
|
314 |
+
print(randomize_seed)
|
315 |
+
print(seed)
|
316 |
+
print(s_churn)
|
317 |
+
print(s_noise)
|
318 |
+
print(color_fix_type)
|
319 |
+
print(diff_dtype)
|
320 |
+
print(ae_dtype)
|
321 |
+
print(gamma_correction)
|
322 |
+
print(linear_CFG)
|
323 |
+
print(linear_s_stage2)
|
324 |
+
print(spt_linear_CFG)
|
325 |
+
print(spt_linear_s_stage2)
|
326 |
+
print(model_select)
|
327 |
+
print(output_format)
|
328 |
if torch.cuda.device_count() == 0:
|
329 |
gr.Warning('Set this space to GPU config to make it work.')
|
330 |
+
return None, None, None, None
|
331 |
if output_format == "input":
|
332 |
if noisy_image is None:
|
333 |
output_format = "png"
|
|
|
450 |
return edm_steps, s_cfg, s_stage2, s_stage1, s_churn, s_noise, a_prompt, n_prompt, color_fix_type, linear_CFG, \
|
451 |
linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select
|
452 |
|
453 |
+
def on_select_result(result_gallery, evt: gr.SelectData):
|
454 |
+
print('on_select_result')
|
455 |
+
print(result_gallery[0])
|
456 |
+
print(result_gallery[evt.index])
|
457 |
+
return [result_gallery[0][0], result_gallery[evt.index][0]]
|
458 |
|
459 |
def submit_feedback(event_id, fb_score, fb_text):
|
460 |
if args.log_history:
|
|
|
476 |
|
477 |
<p>This is an online demo of SUPIR, a practicing model scaling for photo-realistic image restoration.
|
478 |
It is still a research project under tested and is not yet a stable commercial product.
|
479 |
+
The content added by SUPIR is imagination, not real-world information.
|
480 |
The aim of SUPIR is the beauty and the illustration.
|
481 |
Most of the processes only last few minutes.
|
482 |
This demo can handle huge images but the process will be aborted if it lasts more than 9 min.
|
|
|
499 |
if torch.cuda.device_count() == 0:
|
500 |
with gr.Row():
|
501 |
gr.HTML("""
|
502 |
+
<p style="background-color: red;"><big><big><big><b>⚠️To use SUPIR, <a href="https://huggingface.co/spaces/Fabrice-TIERCELIN/SUPIR?duplicate=true">duplicate this space</a> and set a GPU with 30 GB VRAM.</b>
|
503 |
|
504 |
You can't use SUPIR directly here because this space runs on a CPU, which is not enough for SUPIR. This is a template space. Please provide feedback if you have issues.
|
505 |
</big></big></big></p>
|
|
|
551 |
with gr.Column():
|
552 |
color_fix_type = gr.Radio(["None", "AdaIn", "Wavelet"], label="Color-Fix Type", info="AdaIn=Improve following a style, Wavelet=For JPEG artifacts", value="Wavelet",
|
553 |
interactive=True)
|
554 |
+
allocation = gr.Radio([["1 min", 1], ["2 min", 2], ["3 min", 3], ["4 min", 4], ["5 min", 5], ["6 min", 6], ["7 min", 7], ["8 min", 8], ["9 min", 9]], label="GPU allocation time", info="lower=May abort run, higher=Time penalty for next runs", value=6, interactive=True)
|
555 |
s_cfg = gr.Slider(label="Text Guidance Scale", info="lower=follow the image, higher=follow the prompt", minimum=1.0, maximum=15.0,
|
556 |
value=default_setting.s_cfg_Quality if torch.cuda.device_count() > 0 else 1.0, step=0.1)
|
557 |
s_stage2 = gr.Slider(label="Restoring Guidance Strength", minimum=0., maximum=1., value=1., step=0.05)
|
|
|
573 |
with gr.Column():
|
574 |
ae_dtype = gr.Radio(['fp32', 'bf16'], label="Auto-Encoder Data Type", value="bf16",
|
575 |
interactive=True)
|
|
|
576 |
randomize_seed = gr.Checkbox(label = "\U0001F3B2 Randomize seed", value = True, info = "If checked, result is always different")
|
577 |
seed = gr.Slider(label="Seed", minimum=0, maximum=2147483647, step=1, randomize=True)
|
578 |
with gr.Group():
|
|
|
758 |
spt_linear_CFG,
|
759 |
spt_linear_s_stage2,
|
760 |
model_select,
|
761 |
+
output_format,
|
762 |
+
allocation
|
763 |
], outputs = [
|
764 |
result_slider,
|
765 |
result_gallery,
|
|
|
767 |
event_id
|
768 |
])
|
769 |
|
770 |
+
result_gallery.select(on_select_result, result_gallery, result_slider)
|
771 |
+
|
772 |
restart_button.click(fn = load_and_reset, inputs = [
|
773 |
param_setting
|
774 |
], outputs = [
|