Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
{}
|
| 3 |
+
---
|
| 4 |
+
---
|
| 5 |
+
license: other
|
| 6 |
+
library_name: pytorch
|
| 7 |
+
tags:
|
| 8 |
+
- medical-imaging
|
| 9 |
+
- brain-mri
|
| 10 |
+
- tumor-classification
|
| 11 |
+
- binary-classification
|
| 12 |
+
- pytorch
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# Brain Tumor Binary Classifier
|
| 16 |
+
|
| 17 |
+
PyTorch checkpoint artifacts for the MultiAgentMedClassifier binary brain tumor
|
| 18 |
+
MRI task. The repository contains a VGG16 CNN classifier checkpoint and,
|
| 19 |
+
optionally, a BiomedCLIP linear-probe checkpoint for classifying brain MRI
|
| 20 |
+
images as normal or tumor.
|
| 21 |
+
|
| 22 |
+
These are checkpoint files for the accompanying project loaders, not standalone
|
| 23 |
+
Transformers models.
|
| 24 |
+
|
| 25 |
+
## Model Description
|
| 26 |
+
|
| 27 |
+
- Task: binary brain tumor MRI classification
|
| 28 |
+
- CNN architecture: VGG16
|
| 29 |
+
- Vision-language backbone for probe: `microsoft/BiomedCLIP-PubMedBERT_256-vit_base_patch16_224`
|
| 30 |
+
- Framework: PyTorch
|
| 31 |
+
|
| 32 |
+
## Classes
|
| 33 |
+
|
| 34 |
+
- `normal`
|
| 35 |
+
- `tumor`
|
| 36 |
+
|
| 37 |
+
The project-level BiomedCLIP labels are:
|
| 38 |
+
|
| 39 |
+
- `normal brain MRI`
|
| 40 |
+
- `brain tumor MRI`
|
| 41 |
+
|
| 42 |
+
## Files
|
| 43 |
+
|
| 44 |
+
- `binary_tumor/cnn/vgg16_MRI_tumor_binary_norm_final.pt`: VGG16 CNN checkpoint for binary brain tumor MRI classification.
|
| 45 |
+
- `binary_tumor/biomedclip/linear_probe_BiomedCLIP_MRI_tumor_binary_norm_best.pt`: BiomedCLIP linear-probe checkpoint for binary brain tumor MRI classification.
|
| 46 |
+
|
| 47 |
+
## Dataset
|
| 48 |
+
|
| 49 |
+
Trained/evaluated for the binary tumor task using brain MRI tumor/normal data.
|
| 50 |
+
The local evaluation script supports the Br35H binary layout:
|
| 51 |
+
|
| 52 |
+
- `data/Br35H/yes`: brain tumor MRI
|
| 53 |
+
- `data/Br35H/no`: normal brain MRI
|
| 54 |
+
|
| 55 |
+
Update this section if you publish a model trained on a different dataset split
|
| 56 |
+
or source.
|
| 57 |
+
|
| 58 |
+
## Training Details
|
| 59 |
+
|
| 60 |
+
- Input size: 224 x 224 RGB
|
| 61 |
+
- Normalization: ImageNet mean/std
|
| 62 |
+
- CNN checkpoint: VGG16 fine-tuned for the `binary_tumor` task
|
| 63 |
+
- BiomedCLIP probe: linear/MLP probe over frozen BiomedCLIP image features
|
| 64 |
+
|
| 65 |
+
## Metrics
|
| 66 |
+
|
| 67 |
+
Evaluation is intended for the `binary_tumor` task on brain MRI tumor/normal
|
| 68 |
+
datasets such as the Br35H binary layout described above. Recompute metrics on
|
| 69 |
+
your held-out test set before using this model in a new domain or workflow.
|
| 70 |
+
|
| 71 |
+
## Inference Example
|
| 72 |
+
|
| 73 |
+
Download the checkpoint from Hugging Face and point the local project config at
|
| 74 |
+
it:
|
| 75 |
+
|
| 76 |
+
```python
|
| 77 |
+
from huggingface_hub import hf_hub_download
|
| 78 |
+
|
| 79 |
+
from agents.cnn_tool import CNNClassifier
|
| 80 |
+
from config import DEFAULT_CONFIG
|
| 81 |
+
|
| 82 |
+
checkpoint_path = hf_hub_download(
|
| 83 |
+
repo_id="tamara-kostova/multiagentmed-binary-tumor",
|
| 84 |
+
filename="binary_tumor/cnn/vgg16_MRI_tumor_binary_norm_final.pt",
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
DEFAULT_CONFIG.model.cnn_checkpoints["binary_tumor"] = checkpoint_path
|
| 88 |
+
|
| 89 |
+
classifier = CNNClassifier(DEFAULT_CONFIG.model, DEFAULT_CONFIG.preprocess)
|
| 90 |
+
result = classifier.classify("path/to/brain_mri.png", task="binary_tumor")
|
| 91 |
+
print(result)
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
For the BiomedCLIP probe:
|
| 95 |
+
|
| 96 |
+
```python
|
| 97 |
+
from huggingface_hub import hf_hub_download
|
| 98 |
+
|
| 99 |
+
from agents.biomedclip_tool import BiomedCLIPTool
|
| 100 |
+
from config import DEFAULT_CONFIG
|
| 101 |
+
|
| 102 |
+
probe_path = hf_hub_download(
|
| 103 |
+
repo_id="tamara-kostova/multiagentmed-binary-tumor",
|
| 104 |
+
filename=(
|
| 105 |
+
"binary_tumor/biomedclip/"
|
| 106 |
+
"linear_probe_BiomedCLIP_MRI_tumor_binary_norm_best.pt"
|
| 107 |
+
),
|
| 108 |
+
)
|
| 109 |
+
|
| 110 |
+
DEFAULT_CONFIG.model.biomedclip_probe_checkpoints["binary_tumor"] = probe_path
|
| 111 |
+
|
| 112 |
+
tool = BiomedCLIPTool(DEFAULT_CONFIG.model, DEFAULT_CONFIG.preprocess)
|
| 113 |
+
result = tool.classify("path/to/brain_mri.png", task="binary_tumor")
|
| 114 |
+
print(result)
|
| 115 |
+
```
|
| 116 |
+
|
| 117 |
+
## Intended Use
|
| 118 |
+
|
| 119 |
+
This model is intended for research and experimentation in automated
|
| 120 |
+
neuroimaging pipelines. It may be useful for prototype triage, benchmarking,
|
| 121 |
+
and comparison against other image classifiers.
|
| 122 |
+
|
| 123 |
+
It is not a medical device and should not be used as the sole basis for
|
| 124 |
+
diagnosis, treatment decisions, or patient management.
|
| 125 |
+
|
| 126 |
+
## Loading In This Repository
|
| 127 |
+
|
| 128 |
+
Use these files with this repository's local loaders:
|
| 129 |
+
|
| 130 |
+
- CNN: `config.ModelConfig.cnn_checkpoints["binary_tumor"]`
|
| 131 |
+
- BiomedCLIP probe: `config.ModelConfig.biomedclip_probe_checkpoints["binary_tumor"]`
|
| 132 |
+
|