Spaces:
Sleeping
Sleeping
Add gr.Request parameter to analyze_slide signature
Browse files- src/mosaic/analysis.py +35 -11
src/mosaic/analysis.py
CHANGED
|
@@ -462,16 +462,40 @@ def analyze_slide(
|
|
| 462 |
)
|
| 463 |
logger.info("Slide mask drawn")
|
| 464 |
|
| 465 |
-
# Step 2-6: Run inference pipeline with
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 476 |
|
| 477 |
return slide_mask, aeon_results, paladin_results
|
|
|
|
| 462 |
)
|
| 463 |
logger.info("Slide mask drawn")
|
| 464 |
|
| 465 |
+
# Step 2-6: Run inference pipeline with GPU
|
| 466 |
+
# Check if user is PRO for longer GPU duration
|
| 467 |
+
is_pro = False
|
| 468 |
+
if request is not None:
|
| 469 |
+
try:
|
| 470 |
+
# Check if user has logged in (PRO users are more likely to be logged in)
|
| 471 |
+
is_pro = request.username is not None and request.username != ""
|
| 472 |
+
logger.info(f"User: {request.username or 'anonymous'} | PRO: {is_pro}")
|
| 473 |
+
except:
|
| 474 |
+
pass
|
| 475 |
+
|
| 476 |
+
if is_pro:
|
| 477 |
+
logger.info("Using 300s GPU allocation (logged-in user)")
|
| 478 |
+
aeon_results, paladin_results = _run_inference_pipeline_pro(
|
| 479 |
+
coords,
|
| 480 |
+
slide_path,
|
| 481 |
+
attrs,
|
| 482 |
+
site_type,
|
| 483 |
+
cancer_subtype,
|
| 484 |
+
cancer_subtype_name_map,
|
| 485 |
+
num_workers,
|
| 486 |
+
progress,
|
| 487 |
+
)
|
| 488 |
+
else:
|
| 489 |
+
logger.info("Using 60s GPU allocation (anonymous user)")
|
| 490 |
+
aeon_results, paladin_results = _run_inference_pipeline_free(
|
| 491 |
+
coords,
|
| 492 |
+
slide_path,
|
| 493 |
+
attrs,
|
| 494 |
+
site_type,
|
| 495 |
+
cancer_subtype,
|
| 496 |
+
cancer_subtype_name_map,
|
| 497 |
+
num_workers,
|
| 498 |
+
progress,
|
| 499 |
+
)
|
| 500 |
|
| 501 |
return slide_mask, aeon_results, paladin_results
|