Spaces:
Running on Zero
Running on Zero
Request only the GPU time actually needed, for better queue priority
Browse files
app.py
CHANGED
|
@@ -134,10 +134,17 @@ def _restore(arr, device):
|
|
| 134 |
|
| 135 |
|
| 136 |
def _duration(image):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
if image is None:
|
| 138 |
-
return
|
| 139 |
-
n = _tile_count(*image
|
| 140 |
-
return int(min(180,
|
| 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)
|