Spaces:
Running
on
Zero
Running
on
Zero
Fabrice-TIERCELIN
commited on
Commit
•
ba43c72
1
Parent(s):
3dd58cf
10 min (may fail)
Browse files- gradio_demo.py +27 -55
gradio_demo.py
CHANGED
@@ -179,82 +179,54 @@ def stage2_process(
|
|
179 |
return restore_in_9min(
|
180 |
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, allocation
|
181 |
)
|
|
|
|
|
|
|
|
|
182 |
else:
|
183 |
return restore_in_6min(
|
184 |
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, allocation
|
185 |
)
|
186 |
|
187 |
@spaces.GPU(duration=60)
|
188 |
-
def restore_in_1min(
|
189 |
-
|
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, allocation
|
193 |
-
)
|
194 |
|
195 |
@spaces.GPU(duration=120)
|
196 |
-
def restore_in_2min(
|
197 |
-
|
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, allocation
|
201 |
-
)
|
202 |
|
203 |
@spaces.GPU(duration=180)
|
204 |
-
def restore_in_3min(
|
205 |
-
|
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, allocation
|
209 |
-
)
|
210 |
|
211 |
@spaces.GPU(duration=240)
|
212 |
-
def restore_in_4min(
|
213 |
-
|
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, allocation
|
217 |
-
)
|
218 |
|
219 |
@spaces.GPU(duration=300)
|
220 |
-
def restore_in_5min(
|
221 |
-
|
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, allocation
|
225 |
-
)
|
226 |
|
227 |
@spaces.GPU(duration=360)
|
228 |
-
def restore_in_6min(
|
229 |
-
|
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, allocation
|
233 |
-
)
|
234 |
|
235 |
@spaces.GPU(duration=420)
|
236 |
-
def restore_in_7min(
|
237 |
-
|
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, allocation
|
241 |
-
)
|
242 |
|
243 |
@spaces.GPU(duration=480)
|
244 |
-
def restore_in_8min(
|
245 |
-
*args, **kwargs
|
246 |
-
):
|
247 |
-
return restore(
|
248 |
-
*args, **kwargs
|
249 |
-
)
|
250 |
|
251 |
@spaces.GPU(duration=540)
|
252 |
-
def restore_in_9min(
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
)
|
258 |
|
259 |
def restore(
|
260 |
noisy_image,
|
@@ -527,7 +499,7 @@ with gr.Blocks(title="SUPIR") as interface:
|
|
527 |
prompt = gr.Textbox(label="Image description", info="Help the AI understand what the image represents; describe as much as possible; I advise you to write in English as other languages may not be handled", value="", placeholder="A person, walking, in a town, Summer, photorealistic", lines=3)
|
528 |
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.")
|
529 |
upscale = gr.Radio([["x1", 1], ["x2", 2], ["x3", 3], ["x4", 4], ["x5", 5], ["x6", 6], ["x7", 7], ["x8", 8]], label="Upscale factor", info="Resolution x1 to x8", value=2, interactive=True)
|
530 |
-
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)
|
531 |
output_format = gr.Radio([["*.png", "png"], ["*.webp", "webp"], ["*.jpeg", "jpeg"], ["*.gif", "gif"], ["*.bmp", "bmp"]], label="Image format for result", info="File extention", value="png", interactive=True)
|
532 |
|
533 |
with gr.Accordion("Pre-denoising (optional)", open=False):
|
|
|
179 |
return restore_in_9min(
|
180 |
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, allocation
|
181 |
)
|
182 |
+
if allocation == 10:
|
183 |
+
return restore_in_10min(
|
184 |
+
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, allocation
|
185 |
+
)
|
186 |
else:
|
187 |
return restore_in_6min(
|
188 |
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, allocation
|
189 |
)
|
190 |
|
191 |
@spaces.GPU(duration=60)
|
192 |
+
def restore_in_1min(*args, **kwargs):
|
193 |
+
return restore(*args, **kwargs)
|
|
|
|
|
|
|
|
|
194 |
|
195 |
@spaces.GPU(duration=120)
|
196 |
+
def restore_in_2min(*args, **kwargs):
|
197 |
+
return restore(*args, **kwargs)
|
|
|
|
|
|
|
|
|
198 |
|
199 |
@spaces.GPU(duration=180)
|
200 |
+
def restore_in_3min(*args, **kwargs):
|
201 |
+
return restore(*args, **kwargs)
|
|
|
|
|
|
|
|
|
202 |
|
203 |
@spaces.GPU(duration=240)
|
204 |
+
def restore_in_4min(*args, **kwargs):
|
205 |
+
return restore(*args, **kwargs)
|
|
|
|
|
|
|
|
|
206 |
|
207 |
@spaces.GPU(duration=300)
|
208 |
+
def restore_in_5min(*args, **kwargs):
|
209 |
+
return restore(*args, **kwargs)
|
|
|
|
|
|
|
|
|
210 |
|
211 |
@spaces.GPU(duration=360)
|
212 |
+
def restore_in_6min(*args, **kwargs):
|
213 |
+
return restore(*args, **kwargs)
|
|
|
|
|
|
|
|
|
214 |
|
215 |
@spaces.GPU(duration=420)
|
216 |
+
def restore_in_7min(*args, **kwargs):
|
217 |
+
return restore(*args, **kwargs)
|
|
|
|
|
|
|
|
|
218 |
|
219 |
@spaces.GPU(duration=480)
|
220 |
+
def restore_in_8min(*args, **kwargs):
|
221 |
+
return restore(*args, **kwargs)
|
|
|
|
|
|
|
|
|
222 |
|
223 |
@spaces.GPU(duration=540)
|
224 |
+
def restore_in_9min(*args, **kwargs):
|
225 |
+
return restore(*args, **kwargs)
|
226 |
+
|
227 |
+
@spaces.GPU(duration=599)
|
228 |
+
def restore_in_10min(*args, **kwargs):
|
229 |
+
return restore(*args, **kwargs)
|
230 |
|
231 |
def restore(
|
232 |
noisy_image,
|
|
|
499 |
prompt = gr.Textbox(label="Image description", info="Help the AI understand what the image represents; describe as much as possible; I advise you to write in English as other languages may not be handled", value="", placeholder="A person, walking, in a town, Summer, photorealistic", lines=3)
|
500 |
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.")
|
501 |
upscale = gr.Radio([["x1", 1], ["x2", 2], ["x3", 3], ["x4", 4], ["x5", 5], ["x6", 6], ["x7", 7], ["x8", 8]], label="Upscale factor", info="Resolution x1 to x8", value=2, interactive=True)
|
502 |
+
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], ["10 min (may fail)", 10]], label="GPU allocation time", info="lower=May abort run, higher=Time penalty for next runs", value=6, interactive=True)
|
503 |
output_format = gr.Radio([["*.png", "png"], ["*.webp", "webp"], ["*.jpeg", "jpeg"], ["*.gif", "gif"], ["*.bmp", "bmp"]], label="Image format for result", info="File extention", value="png", interactive=True)
|
504 |
|
505 |
with gr.Accordion("Pre-denoising (optional)", open=False):
|