Spaces:
Running on Zero
Running on Zero
Right-size ZeroGPU duration requests (dynamic where workload-dependent)
Browse files- gradio_app.py +6 -2
gradio_app.py
CHANGED
|
@@ -149,7 +149,9 @@ def show_mask_img(input_image: Image) -> Image:
|
|
| 149 |
new_img = img_numpy[..., :3] * alpha[:, :, None] + chkb * (1 - alpha[:, :, None])
|
| 150 |
return Image.fromarray(new_img.astype(np.uint8), mode="RGB")
|
| 151 |
|
| 152 |
-
|
|
|
|
|
|
|
| 153 |
def run_button(
|
| 154 |
run_btn,
|
| 155 |
input_image,
|
|
@@ -243,7 +245,9 @@ def update_foreground_ratio(img_proc, fr):
|
|
| 243 |
)
|
| 244 |
|
| 245 |
|
| 246 |
-
|
|
|
|
|
|
|
| 247 |
def image_to_glb(input_image, foreground_ratio, remesh_option, vertex_count, texture_size):
|
| 248 |
# One-call API pipeline for headless callers (Upsampler free tool): background
|
| 249 |
# removal + foreground resize + mesh generation, all in a single GPU allocation.
|
|
|
|
| 149 |
new_img = img_numpy[..., :3] * alpha[:, :, None] + chkb * (1 - alpha[:, :, None])
|
| 150 |
return Image.fromarray(new_img.astype(np.uint8), mode="RGB")
|
| 151 |
|
| 152 |
+
# Mesh generation alone runs in ~5-10s; the 60s default request was rejecting
|
| 153 |
+
# anonymous visitors whose remaining ZeroGPU quota was below the request.
|
| 154 |
+
@spaces.GPU(duration=20)
|
| 155 |
def run_button(
|
| 156 |
run_btn,
|
| 157 |
input_image,
|
|
|
|
| 245 |
)
|
| 246 |
|
| 247 |
|
| 248 |
+
# Full pipeline (bg removal + mesh + texture bake) measured ~12s end to end;
|
| 249 |
+
# 30s keeps 2.5x headroom without tripping visitors' quota check.
|
| 250 |
+
@spaces.GPU(duration=30)
|
| 251 |
def image_to_glb(input_image, foreground_ratio, remesh_option, vertex_count, texture_size):
|
| 252 |
# One-call API pipeline for headless callers (Upsampler free tool): background
|
| 253 |
# removal + foreground resize + mesh generation, all in a single GPU allocation.
|