Update README.md
Browse files
README.md
CHANGED
|
@@ -17,7 +17,7 @@ datasets:
|
|
| 17 |
- OpenNeuro
|
| 18 |
base_model:
|
| 19 |
- google/medgemma-1.5-4b-it
|
| 20 |
-
- google/medsiglip-
|
| 21 |
---
|
| 22 |
|
| 23 |
# 🧠 BrainGemma3D — Brain Report Automation via Inflated Vision Transformers in 3D
|
|
@@ -76,7 +76,6 @@ pip install torch torchvision transformers nibabel scikit-image lime
|
|
| 76 |
```python
|
| 77 |
from huggingface_hub import snapshot_download
|
| 78 |
|
| 79 |
-
|
| 80 |
# 1. Download the repository containing our custom architecture from Hugging Face
|
| 81 |
repo_id = "praiselab-picuslab/BrainGemma3D"
|
| 82 |
print(f"Downloading repository: {repo_id}...")
|
|
@@ -98,7 +97,6 @@ from medgemma3d_architecture import MedGemma3D, load_nifti_volume, CANONICAL_PRO
|
|
| 98 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 99 |
print(f"Hardware accelerator selected: {device}")
|
| 100 |
|
| 101 |
-
|
| 102 |
# 2. Instantiate the base architecture (3D-inflated MedSigLIP + MedGemma)
|
| 103 |
model = MedGemma3D(
|
| 104 |
vision_model_dir=f"{local_dir}/vision_model",
|
|
@@ -110,7 +108,6 @@ model = MedGemma3D(
|
|
| 110 |
device_map={"": 0} if device == "cuda" else None,
|
| 111 |
)
|
| 112 |
|
| 113 |
-
|
| 114 |
# 3. Load projector
|
| 115 |
proj_path = os.path.join(local_dir, "projector_vis_scale.pt")
|
| 116 |
print(f"Loading custom projector weights from: {proj_path}...")
|
|
@@ -132,7 +129,6 @@ if ckpt.get("vis_scale") is not None:
|
|
| 132 |
model.eval()
|
| 133 |
print("✅ BrainGemma3D is fully loaded and ready for inference!")
|
| 134 |
|
| 135 |
-
|
| 136 |
# 4. Load MRI scan
|
| 137 |
volume = load_nifti_volume(
|
| 138 |
"path/to/brain_flair.nii.gz",
|
|
@@ -256,6 +252,13 @@ weights, wvol = run_interpretability(
|
|
| 256 |
- `lime_top_supervoxels_grid.png` — Most influential supervoxels
|
| 257 |
- `lime_weights.json` — Supervoxel importance scores
|
| 258 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
---
|
| 260 |
|
| 261 |
## ⚙️ Model Details
|
|
|
|
| 17 |
- OpenNeuro
|
| 18 |
base_model:
|
| 19 |
- google/medgemma-1.5-4b-it
|
| 20 |
+
- google/medsiglip-448
|
| 21 |
---
|
| 22 |
|
| 23 |
# 🧠 BrainGemma3D — Brain Report Automation via Inflated Vision Transformers in 3D
|
|
|
|
| 76 |
```python
|
| 77 |
from huggingface_hub import snapshot_download
|
| 78 |
|
|
|
|
| 79 |
# 1. Download the repository containing our custom architecture from Hugging Face
|
| 80 |
repo_id = "praiselab-picuslab/BrainGemma3D"
|
| 81 |
print(f"Downloading repository: {repo_id}...")
|
|
|
|
| 97 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 98 |
print(f"Hardware accelerator selected: {device}")
|
| 99 |
|
|
|
|
| 100 |
# 2. Instantiate the base architecture (3D-inflated MedSigLIP + MedGemma)
|
| 101 |
model = MedGemma3D(
|
| 102 |
vision_model_dir=f"{local_dir}/vision_model",
|
|
|
|
| 108 |
device_map={"": 0} if device == "cuda" else None,
|
| 109 |
)
|
| 110 |
|
|
|
|
| 111 |
# 3. Load projector
|
| 112 |
proj_path = os.path.join(local_dir, "projector_vis_scale.pt")
|
| 113 |
print(f"Loading custom projector weights from: {proj_path}...")
|
|
|
|
| 129 |
model.eval()
|
| 130 |
print("✅ BrainGemma3D is fully loaded and ready for inference!")
|
| 131 |
|
|
|
|
| 132 |
# 4. Load MRI scan
|
| 133 |
volume = load_nifti_volume(
|
| 134 |
"path/to/brain_flair.nii.gz",
|
|
|
|
| 252 |
- `lime_top_supervoxels_grid.png` — Most influential supervoxels
|
| 253 |
- `lime_weights.json` — Supervoxel importance scores
|
| 254 |
|
| 255 |
+
### Expected Output Example
|
| 256 |
+
|
| 257 |
+
<div align="left">
|
| 258 |
+
<img src="https://cdn-uploads.huggingface.co/production/uploads/662a12d70951c58269b066fb/UkQwmZRwkn-rlNlFBNVkH.png" alt="LIME Interpretability" width="50%">
|
| 259 |
+
<p><i>Figure 3: LIME attribution maps for BraTS training sample 072. Red regions show supervoxels that positively contribute to pathology predictions. The model correctly focuses on tumor-affected areas in the left parietal and frontal lobes.</i></p>
|
| 260 |
+
</div>
|
| 261 |
+
|
| 262 |
---
|
| 263 |
|
| 264 |
## ⚙️ Model Details
|