Fabrice-TIERCELIN commited on
Commit
56f2c0e
1 Parent(s): 8479e8d

Only load useful files

Browse files
Files changed (1) hide show
  1. gradio_demo.py +13 -16
gradio_demo.py CHANGED
@@ -16,11 +16,9 @@ import time
16
  import spaces
17
  from huggingface_hub import hf_hub_download
18
 
19
- hf_hub_download(repo_id="laion/CLIP-ViT-bigG-14-laion2B-39B-b160k", filename="open_clip_pytorch_model.bin", local_dir="laion_CLIP-ViT-bigG-14-laion2B-39B-b160k")
20
  hf_hub_download(repo_id="camenduru/SUPIR", filename="sd_xl_base_1.0_0.9vae.safetensors", local_dir="yushan777_SUPIR")
21
  hf_hub_download(repo_id="camenduru/SUPIR", filename="SUPIR-v0F.ckpt", local_dir="yushan777_SUPIR")
22
  hf_hub_download(repo_id="camenduru/SUPIR", filename="SUPIR-v0Q.ckpt", local_dir="yushan777_SUPIR")
23
- hf_hub_download(repo_id="RunDiffusion/Juggernaut-XL-Lightning", filename="Juggernaut_RunDiffusionPhoto2_Lightning_4Steps.safetensors", local_dir="RunDiffusion_Juggernaut-XL-Lightning")
24
 
25
  parser = argparse.ArgumentParser()
26
  parser.add_argument("--opt", type=str, default='options/SUPIR_v0.yaml')
@@ -73,20 +71,19 @@ def stage1_process(input_image, gamma_correction):
73
  gr.Warning('Set this space to GPU config to make it work.')
74
  return None
75
  torch.cuda.set_device(SUPIR_device)
76
- #LQ = HWC3(input_image)
77
- #LQ = fix_resize(LQ, 512)
78
- ## stage1
79
- #LQ = np.array(LQ) / 255 * 2 - 1
80
- #LQ = torch.tensor(LQ, dtype=torch.float32).permute(2, 0, 1).unsqueeze(0).to(SUPIR_device)[:, :3, :, :]
81
- #LQ = model.batchify_denoise(LQ, is_stage1=True)
82
- #LQ = (LQ[0].permute(1, 2, 0) * 127.5 + 127.5).cpu().numpy().round().clip(0, 255).astype(np.uint8)
83
- ## gamma correction
84
- #LQ = LQ / 255.0
85
- #LQ = np.power(LQ, gamma_correction)
86
- #LQ *= 255.0
87
- #LQ = LQ.round().clip(0, 255).astype(np.uint8)
88
- #return LQ
89
- return None
90
 
91
  @spaces.GPU(duration=120)
92
  def llave_process(input_image, temperature, top_p, qs=None):
 
16
  import spaces
17
  from huggingface_hub import hf_hub_download
18
 
 
19
  hf_hub_download(repo_id="camenduru/SUPIR", filename="sd_xl_base_1.0_0.9vae.safetensors", local_dir="yushan777_SUPIR")
20
  hf_hub_download(repo_id="camenduru/SUPIR", filename="SUPIR-v0F.ckpt", local_dir="yushan777_SUPIR")
21
  hf_hub_download(repo_id="camenduru/SUPIR", filename="SUPIR-v0Q.ckpt", local_dir="yushan777_SUPIR")
 
22
 
23
  parser = argparse.ArgumentParser()
24
  parser.add_argument("--opt", type=str, default='options/SUPIR_v0.yaml')
 
71
  gr.Warning('Set this space to GPU config to make it work.')
72
  return None
73
  torch.cuda.set_device(SUPIR_device)
74
+ LQ = HWC3(input_image)
75
+ LQ = fix_resize(LQ, 512)
76
+ # stage1
77
+ LQ = np.array(LQ) / 255 * 2 - 1
78
+ LQ = torch.tensor(LQ, dtype=torch.float32).permute(2, 0, 1).unsqueeze(0).to(SUPIR_device)[:, :3, :, :]
79
+ LQ = model.batchify_denoise(LQ, is_stage1=True)
80
+ LQ = (LQ[0].permute(1, 2, 0) * 127.5 + 127.5).cpu().numpy().round().clip(0, 255).astype(np.uint8)
81
+ # gamma correction
82
+ LQ = LQ / 255.0
83
+ LQ = np.power(LQ, gamma_correction)
84
+ LQ *= 255.0
85
+ LQ = LQ.round().clip(0, 255).astype(np.uint8)
86
+ return LQ
 
87
 
88
  @spaces.GPU(duration=120)
89
  def llave_process(input_image, temperature, top_p, qs=None):