adamelliotfields commited on
Commit
fe94951
1 Parent(s): 6b66635

GPU duration refinements

Browse files
Files changed (2) hide show
  1. DOCS.md +1 -1
  2. lib/inference.py +13 -5
DOCS.md CHANGED
@@ -41,4 +41,4 @@ Each model checkpoint has a different aesthetic:
41
 
42
  ### Refiner
43
 
44
- Use the [ensemble of expert denoisers](https://research.nvidia.com/labs/dir/eDiff-I/) technique, where the first 80% of timesteps are denoised by the base model and the remaining 80% by the [refiner](https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0). Enabled by default. Not available with image-to-image pipelines.
 
41
 
42
  ### Refiner
43
 
44
+ Use the [ensemble of expert denoisers](https://research.nvidia.com/labs/dir/eDiff-I/) technique, where the first 80% of timesteps are denoised by the base model and the remaining 80% by the [refiner](https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0). Not available with image-to-image pipelines.
lib/inference.py CHANGED
@@ -74,19 +74,27 @@ def apply_style(prompt, style_id, negative=False):
74
  return prompt
75
 
76
 
 
77
  def gpu_duration(**kwargs):
78
- base = 20
79
- duration = 20
 
 
80
  scale = kwargs.get("scale", 1)
81
  num_images = kwargs.get("num_images", 1)
82
  use_refiner = kwargs.get("use_refiner", False)
 
83
  if use_refiner:
84
- base += 10
 
 
 
 
85
  if scale == 2:
86
  duration += 5
87
- elif scale == 4:
88
  duration += 10
89
- return base + (duration * num_images)
90
 
91
 
92
  @spaces.GPU(duration=gpu_duration)
 
74
  return prompt
75
 
76
 
77
+ # max 60s per image
78
  def gpu_duration(**kwargs):
79
+ loading = 15
80
+ duration = 15
81
+ width = kwargs.get("width", 1024)
82
+ height = kwargs.get("height", 1024)
83
  scale = kwargs.get("scale", 1)
84
  num_images = kwargs.get("num_images", 1)
85
  use_refiner = kwargs.get("use_refiner", False)
86
+ size = width * height
87
  if use_refiner:
88
+ loading += 10
89
+ if size > 1_100_000:
90
+ duration += 5
91
+ if size > 1_600_000:
92
+ duration += 5
93
  if scale == 2:
94
  duration += 5
95
+ if scale == 4:
96
  duration += 10
97
+ return loading + (duration * num_images)
98
 
99
 
100
  @spaces.GPU(duration=gpu_duration)