Spaces:
Running on Zero

Shafi99 commited on
Commit
c6b261d
·
verified ·
1 Parent(s): 4668ada

Request only the GPU time actually needed, for better queue priority

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -134,10 +134,17 @@ def _restore(arr, device):
134
 
135
 
136
  def _duration(image):
 
 
 
 
 
 
 
137
  if image is None:
138
- return 30
139
- n = _tile_count(*image.size)
140
- return int(min(180, 25 + n * 0.5))
141
 
142
 
143
  @spaces.GPU(duration=_duration)
 
134
 
135
 
136
  def _duration(image):
137
+ """Ask for as little GPU time as is safe.
138
+
139
+ Quota is charged per visitor and a shorter request also earns better queue
140
+ priority, so this tracks the measured cost rather than padding it: about
141
+ 0.15 s per 512 px tile once the model is resident, plus a fixed allowance for
142
+ getting it there.
143
+ """
144
  if image is None:
145
+ return 25
146
+ n = _tile_count(*getattr(image, "size", (512, 512)))
147
+ return int(min(180, 20 + n * 0.4))
148
 
149
 
150
  @spaces.GPU(duration=_duration)