cdancette commited on
Commit
1925b95
·
1 Parent(s): b49f319

disable upload when requiring mask

Browse files
Files changed (1) hide show
  1. app.py +27 -2
app.py CHANGED
@@ -54,10 +54,21 @@ HEAD_OPTIONS: List[Tuple[str, str]] = [
54
  ("luna16-3D", "LUNA16 3D"),
55
  ("neural_foraminal_narrowing", "Neural Foraminal Narrowing"),
56
  ("oasis", "OASIS"),
57
- ("spinal_canal_stenosis", "Spinal Canal Stenosis"),
58
- ("subarticular_stenosis", "Subarticular Stenosis"),
59
  ]
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
62
  DATASET_OPTIONS: Dict[str, Dict[str, Any]] = {
63
  "anatomy-ct": {"label": "Anatomy CT (test)", "head": "anatomy-ct"},
@@ -328,6 +339,16 @@ def update_dataset_from_head(head: str) -> Dict[str, Any]:
328
  return gr.update()
329
 
330
 
 
 
 
 
 
 
 
 
 
 
331
  def load_dataset_metadata(subset: str) -> Tuple[Dict[str, Any], str]:
332
  try:
333
  dataset = load_curia_dataset(subset)
@@ -524,6 +545,10 @@ def build_demo() -> gr.Blocks:
524
  fn=update_dataset_from_head,
525
  inputs=[head_dropdown],
526
  outputs=[dataset_dropdown],
 
 
 
 
527
  )
528
 
529
  dataset_dropdown.change(
 
54
  ("luna16-3D", "LUNA16 3D"),
55
  ("neural_foraminal_narrowing", "Neural Foraminal Narrowing"),
56
  ("oasis", "OASIS"),
 
 
57
  ]
58
 
59
+ # Heads that require masks - custom image upload will be disabled for these
60
+ HEADS_REQUIRING_MASK: set[str] = {
61
+ "anatomy-ct",
62
+ "anatomy-mri",
63
+ "deep-lesion-site",
64
+ "emidec-classification-mask",
65
+ "kits",
66
+ "kneeMRI",
67
+ "luna16-3D",
68
+ "spinal_canal_stenosis",
69
+ "subarticular_stenosis",
70
+ }
71
+
72
 
73
  DATASET_OPTIONS: Dict[str, Dict[str, Any]] = {
74
  "anatomy-ct": {"label": "Anatomy CT (test)", "head": "anatomy-ct"},
 
339
  return gr.update()
340
 
341
 
342
+ def update_upload_component_state(head: str) -> Dict[str, Any]:
343
+ """Disable upload component for heads that require masks."""
344
+ if head in HEADS_REQUIRING_MASK:
345
+ return gr.update(
346
+ interactive=False,
347
+ info="Custom image upload is disabled for this task because it requires a mask from the dataset.",
348
+ )
349
+ return gr.update(interactive=True, info=None)
350
+
351
+
352
  def load_dataset_metadata(subset: str) -> Tuple[Dict[str, Any], str]:
353
  try:
354
  dataset = load_curia_dataset(subset)
 
545
  fn=update_dataset_from_head,
546
  inputs=[head_dropdown],
547
  outputs=[dataset_dropdown],
548
+ ).then(
549
+ fn=update_upload_component_state,
550
+ inputs=[head_dropdown],
551
+ outputs=[upload_component],
552
  )
553
 
554
  dataset_dropdown.change(