remove useless function
Browse files
app.py
CHANGED
|
@@ -89,26 +89,41 @@ DATASET_OPTIONS: Dict[str, Dict[str, Any]] = {
|
|
| 89 |
}
|
| 90 |
|
| 91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
# ---------------------------------------------------------------------------
|
| 93 |
# Utility helpers
|
| 94 |
# ---------------------------------------------------------------------------
|
| 95 |
|
| 96 |
|
| 97 |
-
def resolve_token() -> Optional[str]:
|
| 98 |
-
"""Return the Hugging Face token if configured."""
|
| 99 |
-
|
| 100 |
-
return os.environ.get("HF_TOKEN")
|
| 101 |
-
|
| 102 |
-
|
| 103 |
@lru_cache(maxsize=1)
|
| 104 |
def load_processor() -> AutoImageProcessor:
|
| 105 |
-
token =
|
| 106 |
return AutoImageProcessor.from_pretrained(HF_REPO_ID, trust_remote_code=True, token=token)
|
| 107 |
|
| 108 |
|
| 109 |
@lru_cache(maxsize=len(HEAD_OPTIONS))
|
| 110 |
def load_model(head: str) -> AutoModelForImageClassification:
|
| 111 |
-
token =
|
| 112 |
model = AutoModelForImageClassification.from_pretrained(
|
| 113 |
HF_REPO_ID,
|
| 114 |
trust_remote_code=True,
|
|
@@ -121,7 +136,7 @@ def load_model(head: str) -> AutoModelForImageClassification:
|
|
| 121 |
|
| 122 |
@lru_cache(maxsize=len(DATASET_OPTIONS))
|
| 123 |
def load_curia_dataset(subset: str) -> Any:
|
| 124 |
-
token =
|
| 125 |
ds = load_dataset(
|
| 126 |
HF_DATASET_ID,
|
| 127 |
subset,
|
|
|
|
| 89 |
}
|
| 90 |
|
| 91 |
|
| 92 |
+
# Default CT windowing for each dataset
|
| 93 |
+
# Format: {"window_level": center, "window_width": width} or None for MRI
|
| 94 |
+
# CT values are in Hounsfield Units (HU)
|
| 95 |
+
DEFAULT_WINDOWINGS: Dict[str, Optional[Dict[str, int]]] = {
|
| 96 |
+
"anatomy-ct": {"window_level": 40, "window_width": 400},
|
| 97 |
+
"anatomy-ct-hard": {"window_level": 40, "window_width": 400},
|
| 98 |
+
"anatomy-mri": None,
|
| 99 |
+
"atlas-stroke": None,
|
| 100 |
+
"covidx-ct": {"window_level": -600, "window_width": 1500},
|
| 101 |
+
"deep-lesion-site": {"window_level": 40, "window_width": 400},
|
| 102 |
+
"emidec-classification-mask": None,
|
| 103 |
+
"ich": {"window_level": 40, "window_width": 80},
|
| 104 |
+
"ixi": None,
|
| 105 |
+
"kits": {"window_level": 40, "window_width": 400},
|
| 106 |
+
"kneeMRI": None,
|
| 107 |
+
"luna16": {"window_level": -600, "window_width": 1500},
|
| 108 |
+
"luna16-3D": {"window_level": -600, "window_width": 1500},
|
| 109 |
+
"oasis": None,
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
|
| 113 |
# ---------------------------------------------------------------------------
|
| 114 |
# Utility helpers
|
| 115 |
# ---------------------------------------------------------------------------
|
| 116 |
|
| 117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
@lru_cache(maxsize=1)
|
| 119 |
def load_processor() -> AutoImageProcessor:
|
| 120 |
+
token = os.environ.get("HF_TOKEN")
|
| 121 |
return AutoImageProcessor.from_pretrained(HF_REPO_ID, trust_remote_code=True, token=token)
|
| 122 |
|
| 123 |
|
| 124 |
@lru_cache(maxsize=len(HEAD_OPTIONS))
|
| 125 |
def load_model(head: str) -> AutoModelForImageClassification:
|
| 126 |
+
token = os.environ.get("HF_TOKEN")
|
| 127 |
model = AutoModelForImageClassification.from_pretrained(
|
| 128 |
HF_REPO_ID,
|
| 129 |
trust_remote_code=True,
|
|
|
|
| 136 |
|
| 137 |
@lru_cache(maxsize=len(DATASET_OPTIONS))
|
| 138 |
def load_curia_dataset(subset: str) -> Any:
|
| 139 |
+
token = os.environ.get("HF_TOKEN")
|
| 140 |
ds = load_dataset(
|
| 141 |
HF_DATASET_ID,
|
| 142 |
subset,
|