Spaces:
Paused
Paused
victorli
commited on
Commit
·
46fe537
1
Parent(s):
16278b5
updates
Browse files- medrax/utils/utils.py +1 -18
medrax/utils/utils.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import os
|
| 2 |
import json
|
| 3 |
import numpy as np
|
| 4 |
-
from typing import Dict, List,
|
| 5 |
|
| 6 |
|
| 7 |
def preprocess_medical_image(
|
|
@@ -70,23 +70,6 @@ def preprocess_medical_image(
|
|
| 70 |
return image
|
| 71 |
|
| 72 |
|
| 73 |
-
def normalize_medical_image_for_torchxrayvision(image: np.ndarray) -> np.ndarray:
|
| 74 |
-
"""
|
| 75 |
-
Normalize medical images specifically for TorchXRayVision models.
|
| 76 |
-
|
| 77 |
-
This function is a convenience wrapper around preprocess_medical_image
|
| 78 |
-
that normalizes images to the -1024 to 1024 range expected by TorchXRayVision models.
|
| 79 |
-
This range corresponds to the Hounsfield Unit scale adapted for X-ray images.
|
| 80 |
-
|
| 81 |
-
Args:
|
| 82 |
-
image (np.ndarray): Input image array (2D or 3D)
|
| 83 |
-
|
| 84 |
-
Returns:
|
| 85 |
-
np.ndarray: Normalized image in -1024 to 1024 range
|
| 86 |
-
"""
|
| 87 |
-
return preprocess_medical_image(image, target_range=(-1024.0, 1024.0))
|
| 88 |
-
|
| 89 |
-
|
| 90 |
def load_prompts_from_file(file_path: str) -> Dict[str, str]:
|
| 91 |
"""
|
| 92 |
Load multiple prompts from a file.
|
|
|
|
| 1 |
import os
|
| 2 |
import json
|
| 3 |
import numpy as np
|
| 4 |
+
from typing import Dict, List, Tuple
|
| 5 |
|
| 6 |
|
| 7 |
def preprocess_medical_image(
|
|
|
|
| 70 |
return image
|
| 71 |
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
def load_prompts_from_file(file_path: str) -> Dict[str, str]:
|
| 74 |
"""
|
| 75 |
Load multiple prompts from a file.
|