Spaces:
Running on Zero

gokaygokay commited on
Commit
ed4c73f
·
verified ·
1 Parent(s): 81564ac

Calibrate Detail workload limits from live GPU timing and preserve palette alpha

Browse files
Files changed (1) hide show
  1. pipeline.py +3 -2
pipeline.py CHANGED
@@ -58,7 +58,7 @@ def work_estimate(target, mode, passes, overlap, variations, steps, batch_size):
58
  # first pass; subsequent passes use the newer, one-step Restore checkpoint.
59
  single = (h * w / (1024 * 1024)) * .9
60
  per_pass = single + tiles * .025 * (4 / int(batch_size)) ** .35
61
- first = single + tiles * int(steps) * .055 * (4 / int(batch_size)) ** .35 if mode == 'Detail' else per_pass
62
  seconds = 12 + int(variations) * (first + max(0, int(passes) - 1) * per_pass)
63
  return tiles, seconds
64
 
@@ -124,7 +124,8 @@ def run_pipeline(models, image, mode='Restore', size='2×', seed=42, restoration
124
  start = time.perf_counter()
125
  reference = image.convert('RGB').resize(target, Image.Resampling.BICUBIC)
126
  source = np.array(reference, dtype=np.float32)
127
- alpha = image.getchannel('A').resize(target, Image.Resampling.LANCZOS) if image.mode == 'RGBA' else None
 
128
  pw, ph = padded_size(*target)
129
  folder = output_directory()
130
  reference_path = folder / 'before.png'
 
58
  # first pass; subsequent passes use the newer, one-step Restore checkpoint.
59
  single = (h * w / (1024 * 1024)) * .9
60
  per_pass = single + tiles * .025 * (4 / int(batch_size)) ** .35
61
+ first = single + tiles * int(steps) * .12 * (4 / int(batch_size)) ** .35 if mode == 'Detail' else per_pass
62
  seconds = 12 + int(variations) * (first + max(0, int(passes) - 1) * per_pass)
63
  return tiles, seconds
64
 
 
124
  start = time.perf_counter()
125
  reference = image.convert('RGB').resize(target, Image.Resampling.BICUBIC)
126
  source = np.array(reference, dtype=np.float32)
127
+ has_alpha = 'A' in image.getbands() or 'transparency' in image.info
128
+ alpha = image.convert('RGBA').getchannel('A').resize(target, Image.Resampling.LANCZOS) if has_alpha else None
129
  pw, ph = padded_size(*target)
130
  folder = output_directory()
131
  reference_path = folder / 'before.png'