Spaces:
Sleeping
Sleeping
Add dynamic GPU duration: 60s for anonymous, 300s for logged-in users
Browse files- Split pipeline into _free (60s) and _pro (300s) versions
- Both call same _impl function for code reuse
- analyze_slide now accepts gr.Request parameter
- Logged-in users get 300s (can process 10k+ tiles)
- Anonymous users get 60s (limited to ~2000 tiles)
- Log user status for debugging
This allows both free and PRO users to use the Space
- src/mosaic/analysis.py +36 -1
src/mosaic/analysis.py
CHANGED
|
@@ -254,8 +254,43 @@ def _run_paladin_inference(features, aeon_results, site_type, num_workers):
|
|
| 254 |
return paladin_results
|
| 255 |
|
| 256 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
@spaces.GPU(duration=300)
|
| 258 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
coords,
|
| 260 |
slide_path,
|
| 261 |
attrs,
|
|
|
|
| 254 |
return paladin_results
|
| 255 |
|
| 256 |
|
| 257 |
+
@spaces.GPU(duration=60)
|
| 258 |
+
def _run_inference_pipeline_free(
|
| 259 |
+
coords,
|
| 260 |
+
slide_path,
|
| 261 |
+
attrs,
|
| 262 |
+
site_type,
|
| 263 |
+
cancer_subtype,
|
| 264 |
+
cancer_subtype_name_map,
|
| 265 |
+
num_workers,
|
| 266 |
+
progress,
|
| 267 |
+
):
|
| 268 |
+
"""Run inference pipeline with 60s GPU limit (for free users)."""
|
| 269 |
+
return _run_inference_pipeline_impl(
|
| 270 |
+
coords, slide_path, attrs, site_type, cancer_subtype,
|
| 271 |
+
cancer_subtype_name_map, num_workers, progress
|
| 272 |
+
)
|
| 273 |
+
|
| 274 |
+
|
| 275 |
@spaces.GPU(duration=300)
|
| 276 |
+
def _run_inference_pipeline_pro(
|
| 277 |
+
coords,
|
| 278 |
+
slide_path,
|
| 279 |
+
attrs,
|
| 280 |
+
site_type,
|
| 281 |
+
cancer_subtype,
|
| 282 |
+
cancer_subtype_name_map,
|
| 283 |
+
num_workers,
|
| 284 |
+
progress,
|
| 285 |
+
):
|
| 286 |
+
"""Run inference pipeline with 300s GPU limit (for PRO users)."""
|
| 287 |
+
return _run_inference_pipeline_impl(
|
| 288 |
+
coords, slide_path, attrs, site_type, cancer_subtype,
|
| 289 |
+
cancer_subtype_name_map, num_workers, progress
|
| 290 |
+
)
|
| 291 |
+
|
| 292 |
+
|
| 293 |
+
def _run_inference_pipeline_impl(
|
| 294 |
coords,
|
| 295 |
slide_path,
|
| 296 |
attrs,
|