Fabrice-TIERCELIN commited on
Commit
c3bd45b
·
verified ·
1 Parent(s): 66209b8

Link, prompt, time & stat

Browse files
Files changed (1) hide show
  1. app.py +21 -21
app.py CHANGED
@@ -70,7 +70,7 @@ def reset():
70
  None,
71
  None,
72
  "Cinematic, High Contrast, highly detailed, taken using a Canon EOS R camera, hyper detailed photo - realistic maximum detail, 32k, Color Grading, ultra HD, extreme meticulous detailing, skin pore detailing, hyper sharpness, perfect without deformations.",
73
- "painting, oil painting, illustration, drawing, art, sketch, anime, cartoon, CG Style, 3D render, unreal engine, blurring, aliasing, bokeh, ugly, dirty, messy, worst quality, low quality, frames, watermark, signature, jpeg artifacts, deformed, lowres, over-smooth",
74
  1,
75
  1024,
76
  1,
@@ -377,25 +377,25 @@ def restore_on_gpu(
377
 
378
  torch.cuda.set_device(SUPIR_device)
379
 
380
- input_image = upscale_image(input_image, upscale, unit_resolution=32, min_size=min_size)
381
- LQ = np.array(input_image) / 255.0
382
- LQ = np.power(LQ, gamma_correction)
383
- LQ *= 255.0
384
- LQ = LQ.round().clip(0, 255).astype(np.uint8)
385
- LQ = LQ / 255 * 2 - 1
386
- LQ = torch.tensor(LQ, dtype=torch.float32).permute(2, 0, 1).unsqueeze(0).to(SUPIR_device)[:, :3, :, :]
387
- captions = ['']
388
-
389
  with torch.no_grad():
 
 
 
 
 
 
 
 
 
390
  samples = model.batchify_sample(LQ, captions, num_steps=edm_steps, restoration_scale=s_stage1, s_churn=s_churn,
391
  s_noise=s_noise, cfg_scale=s_cfg, control_scale=s_stage2, seed=seed,
392
  num_samples=num_samples, p_p=a_prompt, n_p=n_prompt, color_fix_type=color_fix_type,
393
  use_linear_CFG=linear_CFG, use_linear_control_scale=linear_s_stage2,
394
  cfg_scale_start=spt_linear_CFG, control_scale_start=spt_linear_s_stage2)
395
 
396
- x_samples = (einops.rearrange(samples, 'b c h w -> b h w c') * 127.5 + 127.5).cpu().numpy().round().clip(
397
- 0, 255).astype(np.uint8)
398
- results = [x_samples[i] for i in range(num_samples)]
399
  torch.cuda.empty_cache()
400
 
401
  # All the results have the same size
@@ -426,7 +426,7 @@ def restore_on_gpu(
426
  print("edm_steps: " + str(edm_steps))
427
  print("num_samples: " + str(num_samples))
428
  print("downscale: " + str(downscale))
429
- print("Estimated minutes: " + f'{(((result_width * result_height**(1/1.5)) * input_width * input_height * (edm_steps**(1/2)) * (num_samples**(1/2.5)))**(1/2.5)) / 30000:,}')
430
  except Exception as e:
431
  print('Exception of Estimation')
432
 
@@ -492,7 +492,7 @@ title_html = """
492
  SUPIR is for beauty and illustration only.
493
  Most of the processes only last few minutes.
494
  The process will be aborted if it lasts more than 10 min.
495
- If you want to upscale AI-generated images, be noticed that <i>Stable Diffusion 3 Medium</i> spaces can directly generate 1536x1536 images.
496
  Due to Gradio issues, the generated image is slightly less satured than the original.
497
  Please leave a <a href="https://huggingface.co/spaces/Fabrice-TIERCELIN/SUPIR/discussions/new">message in discussion</a> if you encounter issues.
498
  You can also use <a href="https://huggingface.co/spaces/gokaygokay/AuraSR">AuraSR</a> to upscale x4.
@@ -532,7 +532,7 @@ with gr.Blocks() as interface:
532
  prompt = gr.Textbox(label="Image description", info="Help the AI understand what the image represents; describe as much as possible, especially the details we can't see on the original image; you can write in any language", value="", placeholder="A 33 years old man, walking, in the street, Santiago, morning, Summer, photorealistic", lines=3)
533
  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.")
534
  upscale = gr.Radio([["x1", 1], ["x2", 2], ["x3", 3], ["x4", 4], ["x5", 5], ["x6", 6], ["x7", 7], ["x8", 8], ["x9", 9], ["x10", 10]], label="Upscale factor", info="Resolution x1 to x10", value=2, interactive=True)
535
- 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 (discouraged)", 8], ["9 min (discouraged)", 9], ["10 min (discouraged)", 10]], label="GPU allocation time", info="lower=May abort run, higher=Quota penalty for next runs", value=6, interactive=True)
536
  output_format = gr.Radio([["As input", "input"], ["*.png", "png"], ["*.webp", "webp"], ["*.jpeg", "jpeg"], ["*.gif", "gif"], ["*.bmp", "bmp"]], label="Image format for result", info="File extention", value="input", interactive=True)
537
 
538
  with gr.Accordion("Pre-denoising (optional)", open=False):
@@ -552,7 +552,7 @@ with gr.Blocks() as interface:
552
  n_prompt = gr.Textbox(label="Negative image description",
553
  info="Disambiguate by listing what the image does NOT represent",
554
  value='painting, oil painting, illustration, drawing, art, sketch, anime, '
555
- 'cartoon, CG Style, 3D render, unreal engine, blurring, aliasing, bokeh, ugly, dirty, messy, '
556
  'worst quality, low quality, frames, watermark, signature, jpeg artifacts, '
557
  'deformed, lowres, over-smooth',
558
  lines=3)
@@ -611,7 +611,7 @@ with gr.Blocks() as interface:
611
  None,
612
  "Group of people, walking, happy, in the street, photorealistic, 8k, extremely detailled",
613
  "Cinematic, High Contrast, highly detailed, taken using a Canon EOS R camera, hyper detailed photo - realistic maximum detail, 32k, Color Grading, ultra HD, extreme meticulous detailing, skin pore detailing, hyper sharpness, perfect without deformations.",
614
- "painting, oil painting, illustration, drawing, art, sketch, anime, cartoon, CG Style, 3D render, unreal engine, blurring, aliasing, bokeh, ugly, dirty, messy, worst quality, low quality, frames, watermark, signature, jpeg artifacts, deformed, lowres, over-smooth",
615
  2,
616
  1024,
617
  1,
@@ -642,7 +642,7 @@ with gr.Blocks() as interface:
642
  None,
643
  "La cabeza de un gato atigrado, en una casa, fotorrealista, 8k, extremadamente detallada",
644
  "Cinematic, High Contrast, highly detailed, taken using a Canon EOS R camera, hyper detailed photo - realistic maximum detail, 32k, Color Grading, ultra HD, extreme meticulous detailing, skin pore detailing, hyper sharpness, perfect without deformations.",
645
- "painting, oil painting, illustration, drawing, art, sketch, anime, cartoon, CG Style, 3D render, unreal engine, blurring, aliasing, bokeh, ugly, dirty, messy, worst quality, low quality, frames, watermark, signature, jpeg artifacts, deformed, lowres, over-smooth",
646
  1,
647
  1024,
648
  1,
@@ -673,7 +673,7 @@ with gr.Blocks() as interface:
673
  None,
674
  "A red apple",
675
  "Cinematic, High Contrast, highly detailed, taken using a Canon EOS R camera, hyper detailed photo - realistic maximum detail, 32k, Color Grading, ultra HD, extreme meticulous detailing, skin pore detailing, hyper sharpness, perfect without deformations.",
676
- "painting, oil painting, illustration, drawing, art, sketch, anime, cartoon, CG Style, 3D render, unreal engine, blurring, aliasing, bokeh, ugly, dirty, messy, worst quality, low quality, frames, watermark, signature, jpeg artifacts, deformed, lowres, over-smooth",
677
  1,
678
  1024,
679
  1,
@@ -704,7 +704,7 @@ with gr.Blocks() as interface:
704
  None,
705
  "A red marble",
706
  "Cinematic, High Contrast, highly detailed, taken using a Canon EOS R camera, hyper detailed photo - realistic maximum detail, 32k, Color Grading, ultra HD, extreme meticulous detailing, skin pore detailing, hyper sharpness, perfect without deformations.",
707
- "painting, oil painting, illustration, drawing, art, sketch, anime, cartoon, CG Style, 3D render, unreal engine, blurring, aliasing, bokeh, ugly, dirty, messy, worst quality, low quality, frames, watermark, signature, jpeg artifacts, deformed, lowres, over-smooth",
708
  1,
709
  1024,
710
  1,
 
70
  None,
71
  None,
72
  "Cinematic, High Contrast, highly detailed, taken using a Canon EOS R camera, hyper detailed photo - realistic maximum detail, 32k, Color Grading, ultra HD, extreme meticulous detailing, skin pore detailing, hyper sharpness, perfect without deformations.",
73
+ "painting, oil painting, illustration, drawing, art, sketch, anime, cartoon, CG Style, 3D render, unreal engine, blurring, aliasing, unsharp, weird textures, ugly, dirty, messy, worst quality, low quality, frames, watermark, signature, jpeg artifacts, deformed, lowres, over-smooth",
74
  1,
75
  1024,
76
  1,
 
377
 
378
  torch.cuda.set_device(SUPIR_device)
379
 
 
 
 
 
 
 
 
 
 
380
  with torch.no_grad():
381
+ input_image = upscale_image(input_image, upscale, unit_resolution=32, min_size=min_size)
382
+ LQ = np.array(input_image) / 255.0
383
+ LQ = np.power(LQ, gamma_correction)
384
+ LQ *= 255.0
385
+ LQ = LQ.round().clip(0, 255).astype(np.uint8)
386
+ LQ = LQ / 255 * 2 - 1
387
+ LQ = torch.tensor(LQ, dtype=torch.float32).permute(2, 0, 1).unsqueeze(0).to(SUPIR_device)[:, :3, :, :]
388
+ captions = ['']
389
+
390
  samples = model.batchify_sample(LQ, captions, num_steps=edm_steps, restoration_scale=s_stage1, s_churn=s_churn,
391
  s_noise=s_noise, cfg_scale=s_cfg, control_scale=s_stage2, seed=seed,
392
  num_samples=num_samples, p_p=a_prompt, n_p=n_prompt, color_fix_type=color_fix_type,
393
  use_linear_CFG=linear_CFG, use_linear_control_scale=linear_s_stage2,
394
  cfg_scale_start=spt_linear_CFG, control_scale_start=spt_linear_s_stage2)
395
 
396
+ x_samples = (einops.rearrange(samples, 'b c h w -> b h w c') * 127.5 + 127.5).cpu().numpy().round().clip(
397
+ 0, 255).astype(np.uint8)
398
+ results = [x_samples[i] for i in range(num_samples)]
399
  torch.cuda.empty_cache()
400
 
401
  # All the results have the same size
 
426
  print("edm_steps: " + str(edm_steps))
427
  print("num_samples: " + str(num_samples))
428
  print("downscale: " + str(downscale))
429
+ print("Estimated minutes: " + f'{(((result_width * result_height**(1/1.5)) * input_width * input_height * (edm_steps**(1/2)) * (num_samples**(1/2.5)))**(1/2.5)) / 25000:,}')
430
  except Exception as e:
431
  print('Exception of Estimation')
432
 
 
492
  SUPIR is for beauty and illustration only.
493
  Most of the processes only last few minutes.
494
  The process will be aborted if it lasts more than 10 min.
495
+ If you want to upscale AI-generated images, be noticed that <i>PixArt Sigma</i> space can directly generate 5984x5984 images.
496
  Due to Gradio issues, the generated image is slightly less satured than the original.
497
  Please leave a <a href="https://huggingface.co/spaces/Fabrice-TIERCELIN/SUPIR/discussions/new">message in discussion</a> if you encounter issues.
498
  You can also use <a href="https://huggingface.co/spaces/gokaygokay/AuraSR">AuraSR</a> to upscale x4.
 
532
  prompt = gr.Textbox(label="Image description", info="Help the AI understand what the image represents; describe as much as possible, especially the details we can't see on the original image; you can write in any language", value="", placeholder="A 33 years old man, walking, in the street, Santiago, morning, Summer, photorealistic", lines=3)
533
  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.")
534
  upscale = gr.Radio([["x1", 1], ["x2", 2], ["x3", 3], ["x4", 4], ["x5", 5], ["x6", 6], ["x7", 7], ["x8", 8], ["x9", 9], ["x10", 10]], label="Upscale factor", info="Resolution x1 to x10", value=2, interactive=True)
535
+ 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 (discouraged)", 8], ["9 min (discouraged)", 9], ["10 min (discouraged)", 10]], label="GPU allocation time", info="lower=May abort run, higher=Quota penalty for next runs", value=7, interactive=True)
536
  output_format = gr.Radio([["As input", "input"], ["*.png", "png"], ["*.webp", "webp"], ["*.jpeg", "jpeg"], ["*.gif", "gif"], ["*.bmp", "bmp"]], label="Image format for result", info="File extention", value="input", interactive=True)
537
 
538
  with gr.Accordion("Pre-denoising (optional)", open=False):
 
552
  n_prompt = gr.Textbox(label="Negative image description",
553
  info="Disambiguate by listing what the image does NOT represent",
554
  value='painting, oil painting, illustration, drawing, art, sketch, anime, '
555
+ 'cartoon, CG Style, 3D render, unreal engine, blurring, aliasing, unsharp, weird textures, ugly, dirty, messy, '
556
  'worst quality, low quality, frames, watermark, signature, jpeg artifacts, '
557
  'deformed, lowres, over-smooth',
558
  lines=3)
 
611
  None,
612
  "Group of people, walking, happy, in the street, photorealistic, 8k, extremely detailled",
613
  "Cinematic, High Contrast, highly detailed, taken using a Canon EOS R camera, hyper detailed photo - realistic maximum detail, 32k, Color Grading, ultra HD, extreme meticulous detailing, skin pore detailing, hyper sharpness, perfect without deformations.",
614
+ "painting, oil painting, illustration, drawing, art, sketch, anime, cartoon, CG Style, 3D render, unreal engine, blurring, aliasing, unsharp, weird textures, ugly, dirty, messy, worst quality, low quality, frames, watermark, signature, jpeg artifacts, deformed, lowres, over-smooth",
615
  2,
616
  1024,
617
  1,
 
642
  None,
643
  "La cabeza de un gato atigrado, en una casa, fotorrealista, 8k, extremadamente detallada",
644
  "Cinematic, High Contrast, highly detailed, taken using a Canon EOS R camera, hyper detailed photo - realistic maximum detail, 32k, Color Grading, ultra HD, extreme meticulous detailing, skin pore detailing, hyper sharpness, perfect without deformations.",
645
+ "painting, oil painting, illustration, drawing, art, sketch, anime, cartoon, CG Style, 3D render, unreal engine, blurring, aliasing, unsharp, weird textures, ugly, dirty, messy, worst quality, low quality, frames, watermark, signature, jpeg artifacts, deformed, lowres, over-smooth",
646
  1,
647
  1024,
648
  1,
 
673
  None,
674
  "A red apple",
675
  "Cinematic, High Contrast, highly detailed, taken using a Canon EOS R camera, hyper detailed photo - realistic maximum detail, 32k, Color Grading, ultra HD, extreme meticulous detailing, skin pore detailing, hyper sharpness, perfect without deformations.",
676
+ "painting, oil painting, illustration, drawing, art, sketch, anime, cartoon, CG Style, 3D render, unreal engine, blurring, aliasing, unsharp, weird textures, ugly, dirty, messy, worst quality, low quality, frames, watermark, signature, jpeg artifacts, deformed, lowres, over-smooth",
677
  1,
678
  1024,
679
  1,
 
704
  None,
705
  "A red marble",
706
  "Cinematic, High Contrast, highly detailed, taken using a Canon EOS R camera, hyper detailed photo - realistic maximum detail, 32k, Color Grading, ultra HD, extreme meticulous detailing, skin pore detailing, hyper sharpness, perfect without deformations.",
707
+ "painting, oil painting, illustration, drawing, art, sketch, anime, cartoon, CG Style, 3D render, unreal engine, blurring, aliasing, unsharp, weird textures, ugly, dirty, messy, worst quality, low quality, frames, watermark, signature, jpeg artifacts, deformed, lowres, over-smooth",
708
  1,
709
  1024,
710
  1,