owiedotch commited on
Commit
9fd6710
1 Parent(s): 2c22ca3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -9,6 +9,7 @@ import subprocess
9
  from tqdm import tqdm
10
  import requests
11
  import spaces
 
12
 
13
  def download_file(url, filename):
14
  response = requests.get(url, stream=True)
@@ -60,7 +61,7 @@ model.to("cuda")
60
 
61
  @spaces.GPU
62
  @torch.no_grad()
63
- def process(image, steps, t_max, t_min, color_fix_type):
64
  image = Image.open(image).convert("RGB")
65
  image = image.resize((256, 256), Image.LANCZOS)
66
  image = np.array(image)
@@ -69,7 +70,7 @@ def process(image, steps, t_max, t_min, color_fix_type):
69
  control = torch.tensor(np.stack([image]) / 255.0, dtype=torch.float32, device=model.device).clamp_(0, 1)
70
  control = einops.rearrange(control, "n h w c -> n c h w").contiguous()
71
 
72
- model.control_scales = [1.0] * 13
73
 
74
  height, width = control.size(-2), control.size(-1)
75
  shape = (1, 4, height // 8, width // 8)
@@ -89,13 +90,14 @@ def process(image, steps, t_max, t_min, color_fix_type):
89
  interface = gr.Interface(
90
  fn=process,
91
  inputs=[
92
- gr.Image(type="filepath"),
93
- gr.Slider(minimum=1, maximum=100, step=1, value=45),
94
- gr.Slider(minimum=0, maximum=1, step=0.0001, value=0.6667),
95
- gr.Slider(minimum=0, maximum=1, step=0.0001, value=0.3333),
96
- gr.Dropdown(choices=["adain", "wavelet", "none"], value="adain"),
 
97
  ],
98
- outputs=gr.Image(type="pil"),
99
  title="CCSR: Continuous Contrastive Super-Resolution",
100
  )
101
 
 
9
  from tqdm import tqdm
10
  import requests
11
  import spaces
12
+ import einops # Import einops to fix the NameError
13
 
14
  def download_file(url, filename):
15
  response = requests.get(url, stream=True)
 
61
 
62
  @spaces.GPU
63
  @torch.no_grad()
64
+ def process(image, steps, t_max, t_min, color_fix_type, scale):
65
  image = Image.open(image).convert("RGB")
66
  image = image.resize((256, 256), Image.LANCZOS)
67
  image = np.array(image)
 
70
  control = torch.tensor(np.stack([image]) / 255.0, dtype=torch.float32, device=model.device).clamp_(0, 1)
71
  control = einops.rearrange(control, "n h w c -> n c h w").contiguous()
72
 
73
+ model.control_scales = [scale] * 13 # Use the scale parameter
74
 
75
  height, width = control.size(-2), control.size(-1)
76
  shape = (1, 4, height // 8, width // 8)
 
90
  interface = gr.Interface(
91
  fn=process,
92
  inputs=[
93
+ gr.Image(type="filepath", label="Input Image"),
94
+ gr.Slider(minimum=1, maximum=100, step=1, value=45, label="Steps"),
95
+ gr.Slider(minimum=0, maximum=1, step=0.0001, value=0.6667, label="T Max"),
96
+ gr.Slider(minimum=0, maximum=1, step=0.0001, value=0.3333, label="T Min"),
97
+ gr.Dropdown(choices=["adain", "wavelet", "none"], value="adain", label="Color Fix Type"),
98
+ gr.Slider(minimum=0, maximum=2, step=0.01, value=1.0, label="Scale"),
99
  ],
100
+ outputs=gr.Image(type="pil", label="Output Image"),
101
  title="CCSR: Continuous Contrastive Super-Resolution",
102
  )
103